akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cmath> 
using namespace std;
 
 
int main()
{	int n = 0;
 	long long sum = 0;
 	cin>>n;
    vector<long long> A;
    vector<long long> B;
 for(int i = 0;i<=n;i++){
  int a = 0;
   cin>>a;
   A.push_back(a);
 }
 for(int i = 0;i<n;i++){
  int a = 0;
   cin>>a;
   B.push_back(a);
 }

   
  long long nokori = 0;
 for(int i = 0;i<n;i++){
long long hiku = min(A[i],nokori);
   sum += min(A[i],nokori+B[i]);
   nokori = max(B[i] - (A[i] - hiku), (long long)0);
}
 sum += min(A[n],nokori);
 
 cout<<sum;
}

Measured memory_bytes: 2548
n, x = map(int, input().split())

a = [1]
p = [1]
so_num = 1
for i in range(1, 51):
    a.append(a[i-1] * 2 + 3)
    p.append(p[i-1] * 2 + 1)

#print(a)
#print(p)

ans = 0
lv = n
tmp =x
while lv >= 0:
    z = (a[lv]-1)//2
    #print('lv,tmp,z,ans: ',lv, tmp, z, ans)
    if lv == 0:
        if tmp >= 1:
            ans += 1
        break
    if tmp > z:
        ans += p[lv - 1] + 1
        tmp = tmp - z - 1
        lv -= 1
    elif tmp == z:
        ans += p[lv - 1]
        break
    else:
        tmp -= 1
        lv -= 1
        # ans 何もしない
    
print(ans)

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int f = s.size();
	rep(i,f){
		s[i] = (s[i] - 'A' + n)%26 + 'A';
	}
	cout << s << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void push(int a[],char c,int *top)
{
	switch(c)
	{
		case '+':a[*top-1]=a[*top-1]+a[*top];break;
		case '-':a[*top-1]=a[*top-1]-a[*top];break;
		case '*':a[*top-1]=a[*top-1]*a[*top];break;
	}	
	*top=*top-1;
}

int main(int argc, char *argv[])
{
	char a[1000],num[1000];
	int b[100];
	int i,top=-1,j=0;//j????¬???¬??¢?????°??? 
	while(scanf("%s",a)!=EOF)
	{
	for(i=0;i<strlen(a);i++)
	{
		if(strlen(a)!=1&&a[i]=='-')//?´???° 
		{
			num[j]='-';
			j++;
		}		
		else if(a[i]>='0'&&a[i]<='9')//?????????????????????????????\?????¨?????\
		{
			num[j]=a[i];
			j++;
			if(i+1==strlen(a))
			{
				top++;
				num[j]='\0';
				b[top]=atoi(num);
				j=0;
			}
		}
	 	else if(a[i]!=' ')
		{
			push(b,a[i],&top);//??°?????°??????????¬?????????¶ 
		}
		
	}
	}
	printf("%d\n",b[top]);
}

Measured memory_bytes: 1864
input_texts = input()
text_list = input_texts.split(" ")
text_s = text_list[0]
text_t = text_list[1]

input_counts = input()
count_list = input_counts.split(" ")
count_s = int(count_list[0])
count_t = int(count_list[1])

pull_text = input()

if pull_text == text_s:
    count_s -= 1
else:
    count_t -= 1
output = str(count_s) + " " + str(count_t)
print(output)

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;


    int H, W;

    void calc()
    {
        H = cin.nextInt();
        W = cin.nextInt();

        string[] s = new string[H];
        for (int i = 0; i < H; i++)
        {
            s[i] = cin.next();
        }

        int[] vy = { 1, 0, -1, 0 };
        int[] vx = { 0, 1, 0, -1 };
        int fy = 0;
        int fx = 0;

        int[,] dist = new int[H, W];
        int MAX = 99999;
        int white = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                dist[i, j] = MAX;
                if (s[i][j] == '.') white++;
            }
        }

        Queue<Tuple<int, int>> q = new Queue<Tuple<int, int>>();
        dist[fy, fx] = 0;
        q.Enqueue(Tuple.Create(fy, fx));
        while (q.Count > 0)
        {
            var now = q.Dequeue();
            int y = now.Item1;
            int x = now.Item2;
            for (int k = 0; k < vy.Length; k++)
            {
                int ny = y + vy[k];
                int nx = x + vx[k];
                if (!inside(ny, nx)) continue;
                if (dist[ny, nx] != MAX) continue;
                if (s[ny][nx] == '#') continue;

                dist[ny, nx] = dist[y, x] + 1;

                q.Enqueue(Tuple.Create(ny, nx));
            }
        }

        int ans = white - dist[H - 1, W - 1] - 1;

        if (dist[H - 1, W - 1] == MAX) ans = -1;

        Console.WriteLine(ans);
    }

    bool inside(int y, int x)
    {
        return y >= 0 && x >= 0 && y < H && x < W;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define N 101
#define M 51
using namespace std;
int n,m,l;
double p[N],t[N],d[N];
vector<double> A[N],B[N];

double mem[M][M];
double nCr(int n, int r){
  if(mem[n][r]!=0)return mem[n][r];
  if(r==0||n==r)return 1;
  double a=1;
  for(int i=0;i<r;i++) a*=(n-i)/(i+1.0);
  return mem[n][r]=a;
}

double DP(){
  double dp[N][M]={};
  for(int i=0;i<=m;i++)dp[0][i]=A[0][m-i]*B[0][i]*nCr(m,i);
  
  for(int i=1;i<n;i++)
    for(int j=0;j<=m;j++)
      for(int k=0;k<=m;k++)
	if(d[0]+j*t[0]<d[i]+k*t[i]) 
	  dp[i][j]+=dp[i-1][j]*A[i][m-k]*B[i][k]*nCr(m,k);

  double res=0;
  for(int i=0;i<=m;i++)res+=dp[n-1][i];
  return res;
}

int main(){
  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    cin>>p[i]>>t[i]>>d[i];
    p[i]/=100;
    d[i]=l/d[i];
    
    A[i].resize(m+1),B[i].resize(m+1);
    A[i][0]=B[i][0]=1;
    for(int j=1;j<=m;j++){
      A[i][j]=A[i][j-1]*(1-p[i]);
      B[i][j]=B[i][j-1]*p[i];
    }
  }
  
  for(int i=0;i<n;i++){
      printf("%.10f\n",DP());
      swap(p[0],p[i+1]);
      swap(t[0],t[i+1]);
      swap(d[0],d[i+1]);    
      swap(A[0],A[i+1]);    
      swap(B[0],B[i+1]);    
  }
  return 0;
}

Measured memory_bytes: 3392
object Main {
  def main(args:Array[String]):Unit = {
    for (line <- scala.io.Source.stdin.getLines() if line != "0 0") {
      val Array(h, w) = line.split(" ").map(_.toInt)
      println("#" * w)
      for (i <- 1 to h-2) {
        println("#" + "." * (w-2) + "#")
      }
      println("#" * w + "\n")
    }
  }
}

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

int main() {
    ll n;
    cin >> n;
    int ans = 0;
    if(n < 10) cout << n << endl;
    else{
        n++;
        string tmp = to_string(n);
        while(n > 10) n /= 10;
        if(n != 10) ans += n-1;
        rep(i, tmp.size()-1) ans += 9;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
i64 a, b, c;

int main() {
  cin >> a >> b >> c;
  if (c - a - b <= 0) {
    cout << "No\n";
  } else {
    cout << ((c - a - b) * (c - a - b) > 4 * a * b ? "Yes" : "No") << '\n';
  }
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int a, b;
    
    scanf("%d", &a);
    scanf("%d", &b);
    
    if(a > b)
        printf("a > b\n");
    else if(a < b)
        printf("a < b\n");
    else
        printf("a == b\n");
        
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
    //文字列を1文字ずつsort
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, tmp;
	int flag = 1;

	scanf("%d %d %d", &a, &b, &c);

	while (flag) {
		flag = 0;
		if (a > b) {
			tmp = a;
			a = b;
			b = tmp;
			flag = 1;
		}

		if (b > c) {
			tmp = b;
			b = c;
			c = tmp;
			flag = 1;
		}
	}

	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
const int N=2000005,mo=1000000007;
long long fac[N],inv[N];
int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}
void Pre(int n){
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i>=1;i--) inv[i-1]=inv[i]*i%mo;
}
long long C(int n,int m){
	return fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
	int a,b,s,t,ans=0;
	scanf("%d%d%d%d",&s,&t);
    a=(int)((2*t-s)/3);
    b=(int)((2*s-t)/3);
	if((2*t-s)%3!=0 or (2*s-t)%3!=0 or a<0 or b<0){
	    printf("%d\n",0);
	}else{
    	Pre(a+b+2);
    	ans=C(a+b,a)%mo;
    	printf("%d\n",ans);    
	}
}


Measured memory_bytes: 14464
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    string a;
    cin>>a;
    int t=a.length();
    int b[t];
    int sum=0;
    int inte=0;
    for(int i=0;i<t;i++)
    {
        b[i]=a[i]-'0';
    }
    for(int i=0;i<t;i++)
    {
        sum+=b[i];
    }
    for(int i=0;i<t;i++)
    {
        inte+=(b[i])*pow(10,(t-i-1));
    }
    if(t==3)
    {
        inte+=1;
    }
    if(inte%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
        if(inte%sum!=0)
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	cin >> n;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for (i = 0; i < n - 1; i++) {
		if (a[i] % 2) {
			if (a[i + 1]) {
				ans++;
				a[i]--;
				a[i + 1]--;
			}
		}
		ans += a[i] / 2;
	}
	ans += a[n - 1] / 2;
	cout << ans << endl;
}

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


int main()
{
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // string s,t;
    // cin>>s>>t;
    ll h,w;
    cin>>h>>w;
    string s;
   vector<string>v;
   for(int i=0;i<h;i++)
   {
   	  cin>>s;
   	  v.push_back(s);
   }
     ll a[h][w];
     memset(a,0,sizeof(a));
   for(int i=0;i<w;i++)
   {
   	   if(v[0][i]=='.')
   	   	a[0][i]=1;
   	   else
   	   	break;
   }
   for(int i=0;i<h;i++)
   {
   	  if(v[i][0]=='.')
   	  	a[i][0]=1;
   	  else
   	  	break;
   }
   for(int i=1;i<h;i++)
   {
   	 for(int j=1;j<w;j++)
   	 {
   	 	 if(v[i][j]=='.')
   	 	  {
   	 	  	a[i][j]+=(a[i-1][j]+a[i][j-1]);
   	 	  	a[i][j]%=1000000007;
   	 	  }
   	 }
   }
   // for(int i=0;i<h;i++)
   // {
   // 	 for(int j=0;j<w;j++)
   // 	 {
   // 	 	cout<<a[i][j]<<" ";
   // 	 }
   // 	 cout<<endl;
   // }
   cout<<a[h-1][w-1]<<endl;

  
	return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 998244353

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  init_fact(n);
  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll res = nCr(n - 1, n - 1 - i);
    res = (res * m) % MOD;
    res = (res * mod_pow(m - 1, n - 1 - i)) % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6396
#include <stdio.h>
typedef struct{
    char class[16];
    int before;
    int after;
}data;
typedef struct{
    int all_enter;
    int all_money;
}output;
int main(){
    data pro;
    output Out;
    int i;
    for(i=0;i<9;i++){
        scanf("%s %d %d",pro.class,&pro.before,&pro.after);
        Out.all_enter = pro.before + pro.after;
        pro.before = pro.before * 200;
        Out.all_money = pro.after * 300 + pro.before;
        printf("%s %d %d\n",pro.class,Out.all_enter,Out.all_money);
    }
    return (0);
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const ll INF=1e+15;
ll upper_bound(ll a[],ll b,ll c,ll k){//k<=a[x]を満たす最小のa[x]を返す
  ll lb=b,ub=c;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(k<=a[mid]) ub=mid;
    else lb=mid;
  }
  if(ub!=c){
    return a[ub];
  }
  else{
    return INF;
  }
}
ll lower_bound(ll a[],ll b,ll c,ll k){//a[x]<=kを満たす最大のa[x]を返す
  ll lb=b,ub=c;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(a[mid]<=k) lb=mid;
    else ub=mid;
  }
  if(lb!=-1){
    return a[lb];
  }
  else{
    return -INF;
  }
}
int A,B,Q;
ll s[100010],t[100010],x[100010];
int main(){
  cin>>A>>B>>Q;
  rep(i,A)cin>>s[i];
  rep(i,B)cin>>t[i];
  rep(i,Q)cin>>x[i];
  rep(i,Q){
    ll su=upper_bound(s,-1,A,x[i]);
    ll sl=lower_bound(s,-1,A,x[i]);
    ll tu=upper_bound(t,-1,B,x[i]);
    ll tl=lower_bound(t,-1,B,x[i]);
    ll res1=min((x[i]-min(sl,tl)),(max(su,tu)-x[i]));
    ll res2=min(x[i]-2*sl+tu,x[i]-2*tl+su);
    ll res3=min(2*su-x[i]-tl,2*tu-x[i]-sl);
    ll res=min(res1,min(res2,res3));
    prin(res);
  }


    
    
  return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>

#define N 100
#define A 100

int main(){

  int i, j, n, a[A], b = 0, temp1, temp2, count = 0;

  scanf("%d", &n);

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

  b = 1;
  while(b == 1){
    b = 0;
    for(j = n - 1; j > 0; j--){
      if(a[j] < a[j - 1]){
	temp1 = a[j - 1];
	temp2 = a[j];
	a[j - 1] = temp2;
	a[j] = temp1;
	b = 1;
	count++;
      }
    }
  }

  for(i = 0; i < n; i++){
    
    if(i == n - 1){
      printf("%d", a[i]);
      continue;
    }
    
    printf("%d ", a[i]);
      
   
  }
  printf("\n%d\n", count);

  return 0;
}
      
	
    



Measured memory_bytes: 2104
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for (; n--; )
	{
		string a, b;
		cin >> a >> b;

		string c;

		int add = 0;
		int len = max(a.length(), b.length());
		for (int i = 0; i < len; i++)
		{
			int a0 = 0, b0 = 0;
			int ai = a.length() - i - 1;
			if (ai >= 0)
			{
				a0 = atoi(a.substr(ai, 1).c_str());
			}
			int bi = b.length() - i - 1;
			if (bi >= 0)
			{
				b0 = atoi(b.substr(bi, 1).c_str());
			}
			
			int c0 = a0 + b0 + add;
			add = (c0 >= 10) ? 1 : 0;

			c += to_string(c0).back();
		}
		if (add == 1)
		{
			c += to_string(1);
		}
		reverse(c.begin(), c.end());

		cout << (c.length() > 80 ? "overflow" : c) << endl;
	}
}


Measured memory_bytes: 3260
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e8;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
	fast
	ll n;
	cin >> n;
	vl a(n), b(n);
	loop(i, n)	cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));
	if (n & 1)
	{
		cout << b[n / 2] - a[n / 2] + 1 << END;;
	}
	else
	{
		ll ans = 0;
		// cout << ans << " " << n << END;
		ll A = a[n / 2] + a[n / 2 - 1];
		ll B = b[n / 2] + b[n / 2 - 1];
		ans += B - A + 1;
		cout << ans << END;
	}




	return 0;
}

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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

vector <pair <int, int>> G[Max];

int col[Max];
int vist[Max];

void dfs(int u, int c) {
	col[u] = c;
	vist[u] = 1;
	for(auto v : G[u]) {
		if(vist[v.first]) {
			continue;
		}
		if(v.second & 1) {
			dfs(v.first, !c);
		}
		else {
			dfs(v.first, c);
		}
	}
}

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	int n, u, v, w;
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		scanf("%d %d %d", &u, &v, &w);
		G[u].push_back({v, w});
		G[v].push_back({u, w});
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++) {
		printf("%d\n", col[i]);
	}
	return 0;
}

Measured memory_bytes: 56704
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N, K;
    cin >> N >> K;
    
    string S;
    cin >> S;
    
    int score = 0;
    for(int i = 0; i < N-1; i++){
        if(S[i] == S[i+1]) score++;
    }
    
    cout << min(N-1, score + 2 * K) << endl;
}


Measured memory_bytes: 512
input_line = list(map(int,input().split()))

W = input_line[0]
H = input_line[1]
x = input_line[2]
y = input_line[3]
r = input_line[4]
flag = True

if x-r < 0 or x+r > W:
    flag = False
if y-r < 0 or y + r > H:
    flag = False
if flag:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();		//店の個数

		//そのお店が開催しているか 0 or 1
		int[][] f = new int[n][10];
		for(int i=0; i<n; i++){{
			for(int j=0; j<10; j++){
				f[i][j] = sc.nextInt();

			}
		}
		}

		//そのお店の開催時期との被りの個数によって異なる利益
		int[][] p = new int[n][11];
		for(int i=0; i<n; i++){
			for(int j=0; j<11; j++){
				p[i][j] = sc.nextInt();
			}
		}

		int[][] joi = new int[1023][10];
		String strrr;
		for(int i=0; i<1023; i++){
			for(int j=0; j<10; j++){
				strrr = Integer.toBinaryString(i+1);
				for(; strrr.length()<10;){
					strrr = "0"+strrr;
				}
				joi[i][j] = strrr.charAt(j) - '0';
			}
		}
		int[][] c = new int[1023][n];
		int[] y = new int[1023];
		for(int i=0; i<1023; i++){
			for(int j=0; j<10; j++){
				if(joi[i][j]==1){
					for(int g=0; g<n; g++){
						if(f[g][j]==1){
							c[i][g]++;
						}
					}
				}
			}
			for(int j=0; j<n; j++){
				y[i] += p[j][ c[i][j] ];
			}
		}

		int w = y[0];
		for(int i=1; i<1023; i++){
			if(w<y[i]){
				w=y[i];
			}
		}
		System.out.println(w);


	}

}


Measured memory_bytes: 29636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define mod 998244353
using namespace std;                       
typedef long long ll;
int main(){
	 int n,m;
	   cin>>n>>m;
	     cout<<n*m<<endl; 
	 }

Measured memory_bytes: 3608
#include<stdio.h>

int senkei();

int main(){
  int i = 0;
  int count2;
  int setdata[10000 + 1];
  int change;
  int key;
  int sum = 0;

  scanf("%d",&count2);

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

  scanf("%d",&change);

  for(i = 0;i < change;i++){
    scanf("%d",&key);

    if(senkei(setdata,count2,key)){
      sum++;
    }
  }
  printf("%d",sum);
  printf("\n");
  return 0;
}


int senkei(int data[],int count,int key){
  int i = 0;
  
  data[count] = key;

  while(data[i] != key){
    i++;
  }
  return i != count;
}



Measured memory_bytes: 2088
from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = list(map(int,input().split()))
    a = Counter(A)
    Q = int(input())
    BC = [list(map(int,input().split())) for _ in range(Q)]
    ans = sum(A)

    for b,c in BC:
        tmp = a[b]
        a[b] = 0
        ans -= b * tmp
        a[c] += tmp
        ans += c * tmp
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39568
import bisect
from collections import defaultdict

S=list(input().strip())
T=list(input().strip())
L=len(S)

if not set(T)<=set(S):
  print(-1)
  exit()

d=defaultdict(list)
for i,s in enumerate(S):
  d[s].append(i)
start=-1
ans=0
for i in T:
  p=bisect.bisect_right(d[i],start)
  le=len(d[i])
  if p==le:
    ans+=(L-start-1)+(d[i][0]+1)
    start=d[i][0]    
  else:
    ans+=d[i][p]-start
    start=d[i][p]
print(ans)

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;

public class MainClass{
	public static void Main(string[] args){
		var line = Console.ReadLine ().Split(' ');
		var x = int.Parse(line[0]);
		var y = int.Parse(line [1]);
		var list1 = new int[]{1,3,5,7,8,10,12};
		var list2 = new int[]{4,6,9,11};
		var list3 = new int[]{ 2 };
		var flag1 = list1.Contains (x) && list1.Contains (y);
		var flag2 = list2.Contains (x) && list2.Contains (y);
		var flag3 = list3.Contains (x) && list3.Contains (y);
		if (flag1 || flag2 || flag3) {
			Console.WriteLine ("Yes");
		} else {
			Console.WriteLine("No");
		}

	}
}

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

using namespace std;

long long k, a, b;

int main()
{
    cin >> k >> a >> b;
    k -= a;
    if (a > b)
        return cout << k+a+1, 0;
    long long cnt = (k+1)/2;
    if (k%2)
        cout << max(cnt*b-(cnt-1)*a, k+a+1);
    else
        cout << max(cnt*b-(cnt-1)*a, k+a)+1;
    return 0;
}


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

	
int main()
{
	int n,sum,sum1;
	int a[100005];
   cin >> n;
   for(int i=1;i<=n;i++)
   {
	   cin >> a[i];
   }
   int dp[100005]={0};
   dp[2]=abs(a[2]-a[1]);
   //dp[2]=abs(a[2]-a[0]);
   sum=0;
   sum1=0;
   for(int i=3;i<=n;i++)
   {
	   sum=(abs(a[i]-a[i-2])+dp[i-2]);
	   sum1=(abs(a[i]-a[i-1])+dp[i-1]);
	   
	   dp[i]=min(sum1,sum); 
   }
   cout << dp[n];
}
			


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

int main(){
    string s;
    int m,h;
    cin >> s;
    while(s != "-"){
        cin >> m;
        for(int i=0; i<m;i++){
            cin >> h;
            s =  s.substr(h,s.size()-h) + s.substr(0,h);
        }
        cout << s << endl;
        cin >> s;
    }
    return 0;
}


Measured memory_bytes: 3176
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int n;
    cin >> n;
    int p[10], q[10];
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }

    vector<int> v(n);
    iota(v.begin(), v.end(), 1);

    int j = 0;
    int np;
    int nq;
    do {
        j++;
        bool ep = 1;
        bool eq = 1;
        for (int i = 0; i < n; i++) {
            if (p[i] != v[i]) ep = 0;
            if (q[i] != v[i]) eq = 0;
        }
        if (ep) np = j;
        if (eq) nq = j;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(np - nq) << endl;

    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Restaurant
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  int x = n * 800;
  int y = (n / 15) * 200;
  printf("%d\n", x - y);
  return 0;
}


Measured memory_bytes: 256
import math
k = int(input())+1

sum = 0
for a in range(1,k):
    for b in range(a,k):
        for c in range(b,k):
            tmp = math.gcd(math.gcd(a,b),c)

            if a != b and b != c and a != c:
                tmp *= 2
            if a!=b or b!=c:
                tmp *= 3
            sum += tmp

print(sum)

Measured memory_bytes: 9192
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;

void main() {
	auto A = readln.chomp.to!int, B = readln.chomp.to!int, C = readln.chomp.to!int, X = readln.chomp.to!int;
	int count;
	foreach(i; 0..A+1) {
		foreach(j; 0..B+1) {
			foreach(k; 0..C+1) {
				if(500*i + 100*j + 50*k == X) count++;
			}
		}
	}
	count.writeln;
}


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

int main() {
  int N,A,B;
  cin >>N;
  if(N==1){
    cout <<"Hello World" <<endl;
    return 0;
  }
  else{
    cin >>A >>B;
    cout <<A+B <<endl;
    return 0;
  }
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>X(N); 
	vector<int>Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
	}
	vector<int>copyX = X;
	vector<int>copyY = Y;
	sort(copyX.begin(),copyX.end());
	sort(copyY.begin(),copyY.end());
	long long ans = (long long)4 * 1e18;
	for (int i = 0;i<N;++i) {
		for (int j = i + 1;j<N;++j) {
			for (int l = 0;l<N;++l) {
				for (int m = l + 1; m < N; ++m) {
					int count = 0;
					for (int n = 0;n<N;++n) {
						if ((X[n]>=copyX[i])&&(X[n]<=copyX[j])&&(Y[n]>=copyY[l])&&(Y[n]<=copyY[m])) {
							count++;
						}
					}
					//cout << copyX[i] <<"_"<<copyX[j] <<"_"<<copyY[l]<<"_"<<copyY[m]<<endl;
					//cout << count <<endl;
					if (count >= K) {
						ans = min(ans, (long long)(copyX[j] - copyX[i])*(long long)(copyY[m] - copyY[l]));
					}
				}
			}
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (!h && !w) break;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,r;
    cin>>n>>r;
    if(n>=10)
    {
        n=10;
    }
    int ans=r+(100*(10-n));
    cout<<ans;
    return 0;
}







Measured memory_bytes: 256
package main

import "fmt"

func nextperm(p []int) bool {
	i := len(p) - 1
	for i > 0 && p[i-1] > p[i] {
		i--
	}
	if i == 0 {
		return false
	}
	i--
	j := len(p) - 1
	for p[j] < p[i] {
		j--
	}
	p[i], p[j] = p[j], p[i]
	i, j = i+1, len(p)-1
	for i < j {
		p[i], p[j] = p[j], p[i]
		i, j = i+1, j-1
	}
	return true
}

var graph [][]int

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	// グラフ入力
	graph = make([][]int, N)
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}
	// 頂点の順列を作成 (0-indexed, 頂点0からスタート)
	v := make([]int, 0)
	for i := 1; i < N; i++ {
		v = append(v, i)
	}

    ans := 0
	for {
		if isGoodPath(v) { // この頂点の順列vで全ての頂点を辿れるか？
			ans++
		}
		if !nextperm(v) {
			break
		}
	}
	fmt.Println(ans)
}

func isGoodPath(v []int) bool {
	current := 0                  // 現在いる頂点(0-indexedで0からスタート)
	for i := 0; i < len(v); i++ { // 頂点の順列
		next := v[i] // 次に訪れるべき頂点
		ok := false  // 現在いる頂点からnextに行けるか？
		for j := 0; j < len(graph[current]); j++ {
			if graph[current][j] == next {
				ok = true
			}
		}
		if !ok {
			return false
		}
		current = next
	}
	return true
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [tuple(map(int, input().split())) for _ in range(M)]

As.sort()
BCs.sort(reverse=True, key=lambda x: x[1])

i = 0
for B, C in BCs:
    num = min(N-i, B)
    for j in range(i, i+num):
        if As[j] >= C:
            break
        As[j] = C
    else:
        i += B
        if i >= N:
            break
        continue
    break
#print('As:', As)

print(sum(As))


Measured memory_bytes: 22184
def myAnswer(N:int,B:list) -> None:
   ans = []
   for n,b in enumerate(B):
      if(n + 1 < b):
         print(-1)
         return
   
   while len(B) > 0:
      tmp = 0
      for n,b in enumerate(B):
         if(n + 1 == b):
            tmp = n
      ans.append(B[tmp])
      B.pop(tmp)
   for a in ans[::-1]:
      print(a)
   
def modelAnswer():
   return
def main():
   N = int(input())
   B = list(map(int,input().split()))
   myAnswer(N,B)
if __name__ == '__main__':
   main()

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

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

using ll = long long;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

void dfs(const graph &g,int s,int from,vector<int> &d){
  for(auto nx:g[s]){
    if(nx==from) continue;
    d[nx]=d[s]+1;
    dfs(g,nx,s,d);
  }
}

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  A--;
  B--;
  vector<vector<int>> g(N);
  for(int i = 0; i < N-1; i++) {
    int x,y;
    cin>>x>>y;
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);
  }
  vector<int> dA(N,0),dB(N,0);
  dfs(g,A,-1,dA);
  dfs(g,B,-1,dB);
  int t = dA[B];
  int ans = 0;
  for(int i = 0; i < N; i++){
    int cnt = 0;
    if(dA[i]+t==dB[i]){
      if(t%2==0) cnt = dB[i]-1;
      if(t%2==1) cnt = dB[i]-1;
    }
    else{
      if(dA[i]>dB[i])continue;
      if(dA[i]==dB[i]) cnt = t/2;
      else {
        if(t%2==0) cnt = dB[i]-1;
        else cnt = dB[i]-1;
      }
    }
    chmax(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12928
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	
	int n;
	cin >> n;
	vector<int>x(n);
	rep(i, n) cin >> x[i];
	sort(x.begin(), x.end());
	int res = INF;
	for(int i = 1; i <= x[n - 1]; ++i){
		int tmp = 0;
		rep(j, n) {
			tmp += pow((x[j] - i), 2);
		}
		res = min(res, tmp);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    m, n1, n2 = map(int, input().split())
    if m == 0:
        break
    p = [int(input()) for _ in range(m)]
    p.sort(reverse = True)
    g = [p[i] - p[i - 1] for i in range(n1, n2 + 1)]
    print(n2 - g[::-1].index(min(g)))


Measured memory_bytes: 5624
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,N,Z,W,ans;
int a[2005];
int main() {
	cin >> N;
	
	cout << (N/3);
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var A = new int[200001];
        int N = cin.nextint;
        int K = cin.nextint;
        var D = cin.scanint;
        for (int i = 0; i < N; i++)
        {
            A[D[i]]++;
        }
        Array.Sort(A);
        Array.Reverse(A);
        //WriteLine(string.Join(" ", A));
        long ans = 0;
        for (int i = K; i < N; i++)
        {
            ans += A[i];
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 33500
#include <stdio.h>
#include <algorithm>

void Vacation(int& days, int pointsMatrix[][3])
{
    for (int row = days-2; row >= 0; row--)
    {
        for (int col = 2; col >= 0; col--)
        {
            if (col == 2) pointsMatrix[row][col] += std::max(pointsMatrix[row+1][col-1], pointsMatrix[row+1][col-2]);
            else if (col == 1) pointsMatrix[row][col] += std::max(pointsMatrix[row+1][col-1], pointsMatrix[row+1][col+1]);
            else if (col == 0) pointsMatrix[row][col] += std::max(pointsMatrix[row+1][col+1], pointsMatrix[row+1][col+2]);
        }
    }

    printf("%d\n", std::max(std::max(pointsMatrix[0][0], pointsMatrix[0][1]), pointsMatrix[0][2]));
}

int main()
{
    int days;

    scanf("%d", &days);

    // There are always 3 activities possible per day...
    int pointsMatrix[days][3];

    for (int i = 0; i < days; i++)
    {
        for (int j = 0; j < 3; j++) scanf("%d", &pointsMatrix[i][j]);
    }

    Vacation(days, pointsMatrix);

    return 0;
}

Measured memory_bytes: 1280
words = lambda t : list(map(t, input().split()))
a,b = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

import math
def num_prime_factors(n):
    cnt = 0
    m = int(math.sqrt(n)) + 1
    for num in range(2,m):
        if n % num == 0:
            cnt += 1
            while n % num == 0:
                n //= num
    if not n == 1:
        cnt += 1
    return cnt

g = gcd(a,b)
cnt = num_prime_factors(g)
print(cnt+1)


Measured memory_bytes: 38512
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
inline int ppc(int x){return __builtin_popcount(x);}
const int N=21;
int n;
bool a[N+1][N+1];
int dp[1<<N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>a[i][j];
	dp[0]=1;
	for(int i=1;i<1<<n;i++){
		int x=ppc(i);
		for(int j=1;j<=n;j++)if(i&1<<j-1&&a[x][j])(dp[i]+=dp[i^1<<j-1])%=mod;
	}
	cout<<dp[(1<<n)-1];
	return 0;
}
/*1
3
0 1 1
1 0 1
1 1 1
*/
/*2
4
0 1 0 0
0 0 0 1
1 0 0 0
0 0 1 0
*/
/*3
1
0
*/
/*4
21
0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1
1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0
0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1
0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0
1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0
0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1
0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0
0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1
0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1
0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1
0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0
0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1
0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1
1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1
0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1
1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1
0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1
0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0
1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0
1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0
*/

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int H, A; cin >> H >> A;
	cout << (H + A - 1) / A << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()

length = 0
ans = 0

for i in range(len(s)):
	#print(i)
	if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
		length = length + 1
		ans = max ( ans , length )
	else:
		length = 0

print(ans)

	


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define INF 2000000000



int main() {
    string S[4] = { "maerd","remaerd","esare","resare" };
    string T;
    cin >> T;
    reverse(T.begin(), T.end());
    bool can = true;
    for(int i=0;i<T.size();) {
        bool dflag = false;
        for (int j = 0; j < 4; j++) {
            string d = S[j];
            if (T.substr(i, d.size()) == d) {
                dflag = true;
                i += d.size();
            }
        }
        if (!dflag) {
            can = false;
            break;
        }
    }
    if (can)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long

using namespace std;

int N;
int C[200010];
int cnt = 0;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        char c;
        cin >> c;
        if(c == 'W') C[i] = 0;
        else 
        {
            C[i] = 1;
            cnt++;
        }
    }

    int mem1 = 0, mem2 = 0;
    for(int i = 0; i < N; i++)
    {
        if(C[i] == 0 && i < cnt)mem1++;
        if(C[i] == 1 && cnt <= i)mem2++;
    }

    cout << min(mem1, mem2) << endl;
    
    return 0;
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define mm 1000000007
#define ll long long
using namespace std;
bool valid(int x,int y,int n1,int n2){
  if(x>0&& y> 0&&x<=n1&&y<=n2)
  return true;

  return false;
}
string helper(vector<vector<int>>dp,string a,string b,int x,int y){
  string ans;
     while(x>0&&y>0){
       if(a[x-1]==b[y-1]){
         ans=a[x-1]+ans;
         x--;
         y--;
       }else if(dp[x-1][y]>dp[x][y-1])
       x--;
       else
       y--;
     }
  return ans;
}
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
  int n1=s.size();
  int n2 = t.size();
vector<vector<int>>dp(n1+1,vector<int>(n2+1,0));
  loop(i,1,n1+1){
    loop(j,1,n2+1){
      if(s[i-1]==t[j-1])
      dp[i][j]=1+dp[i-1][j-1];
      else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
    }
     string r=helper(dp,s,t,n1,n2);
     cout<<r;
}


Measured memory_bytes: 70912