akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

#define REP(i,n) for(int i=0;i<(n);i++)

const int MAXN = 500 + 10;
int a[MAXN][MAXN];
int b[MAXN][MAXN];
int ans[MAXN][MAXN];

void init() {
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	memset(ans, 0, sizeof(ans));
}
int main() {
	int n, m, q;
	scanf("%d %d %d", &n, &m, &q);
	init();
	for (int i = 0; i < m; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		a[l][r]++;
	}

	for (int j = 1; j <= n; j++) {
		b[j][j] = a[j][j];
		for (int i = j - 1; i >= 1; i--) {
			b[i][j] = b[i + 1][j] + a[i][j];
		}
	}

	for (int i = 1; i <= n; i++) {
		ans[i][i] = a[i][i];
		for (int j = i + 1; j <= n; j++) {
			ans[i][j] = ans[i][j - 1] + b[i][j];
		}
	}
	while (q--) {
		int li, ri;
		scanf("%d %d", &li, &ri);
		printf("%d\n", ans[li][ri]);
	}
	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main(){
	int numero,AC=0,WA=0,TLE=0,RE=0;
	string palabra;
	cin>>numero;
	for(int i=0;i<numero;i++){
		cin>>palabra;
		if(palabra=="AC"){
			AC++;
		}
		else if(palabra=="WA"){
			WA++;
		}
		else if(palabra=="TLE"){
			TLE++;
		}
		else if(palabra=="RE"){
			RE++;
		}
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"

#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}

#define SHOW(x) std::cout << #x << " = " << x << std::endl;

inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    int bal = 0;
    int minbal = 0;
    for(char c : s)
    {
        bal += c == '('? 1 : -1;
        minbal = min(minbal, bal);
    }
    for(;minbal < 0; ++minbal)
        cout << '(', ++bal;
    cout << s;
    for(; bal > 0; --bal)
        cout << ')';
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int n; cin>>n;
  set<ll> s;
  rep(i,0,n){
    int si;cin>>si;
    s.insert(si);
  }
  int q; cin>>q;
  ll t[q];
  rep(i,0,q) cin>>t[i];

  ll c=0;
  for(auto si: s){
    //cout<<si<<" ";
  }

  rep(i,0,q){
    //cout<<t[i]<<endl;
    if(s.count(t[i])) c++;
  }

  cout<<c<<endl;
}




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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

double r;

int main(){
	cin >> r;
	printf("%.12f\n", r * 2 * M_PI);
}


Measured memory_bytes: 3800
let a, v = Scanf.sscanf (read_line()) "%d %d" (fun a v -> a,v)
let b, w = Scanf.sscanf (read_line()) "%d %d" (fun b w -> b,w)
let t = read_int()
let diff = abs @@ a - b
let _ = (if diff + (w * t) - (v * t) <= 0 then "YES" else "NO") |> print_endline

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    int n;
    cin >> n;
    //vector<vector<int>> x(n, vector<int>(15));
    vector<vector<int>> x(n, vector<int>(0));
    vector<vector<int>> y(n, vector<int>(0));
    vector<int> a(n);

    int temp;

    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        for (int l = 0; l < a.at(i); l++)
        {
            //cin >> x.at(i).at(l);
            cin >> temp;
            x.at(i).push_back(temp);
            cin >> temp;
            y.at(i).push_back(temp);
        }
    }

    vector<int> tr_fa(n);
    bool ch;
    int ans = 0;
    int sum;

    for (int i = 0; i < (1 << n); i++)
    {
        sum = 0;
        for (int l = 0; l < n; l++)
        {
            if (i & (1 << l))
            {
                tr_fa.at(l) = 1;
                sum++;
            }
            else
            {
                tr_fa.at(l) = 0;
            }
        }

        ch = true;

        for (int l = 0; l < n; l++)
        {
            if (ch == false)
            {
                break;
            }
            if (tr_fa.at(l))
            {
                for (int m = 0; m < x.at(l).size(); m++)
                {
                    if (tr_fa.at(x.at(l).at(m) - 1) != y.at(l).at(m))
                    {
                        // cout << "l:" << l << " m:" << m << endl;
                        ch = false;
                        break;
                    }
                }
            }
            /*
            else
            {
                for (int m = 0; m < x.at(l).size(); m++)
                {
                    if (tr_fa.at(x.at(l).at(m) - 1) == y.at(l).at(m))
                    {
                        cout << "l:" << l << " m:" << m << endl;
                        ch = false;
                        break;
                    }
                }
            }
            */
        }

        if (ch)
        {
            if (ans < sum)
            {
                ans = sum;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    int ans=0;
    int V[N];
    int C[N];
    for (int i=0;i<N;i++) cin >> V[i];
    for (int i=0;i<N;i++) cin >> C[i];

    for (int i=0;i<N;i++){
        ans += max(0,(V[i]-C[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
x = [[0,0,0]]*N
for i in range(N):
	x[i] = list(map(int,input().split()))
#print(x)

#dp = [[0,0,0]]*N this caused error!!! dp[i] and dp[j] have the same memory!!!!
dp = [[0,0,0] for i in range(N)]
#dp[i][j] means the happiness of day i, when Taro do activity j.
dp[0] = x[0]

for i in range(1,N):
	for j in range(3):
		for k in range(3):
			#print(i,j,k,dp)
			if j != k:
				dp[i][j] = max(dp[i][j],dp[i-1][k]+x[i][j])
#print(dp)
print(max(dp[N-1]))

Measured memory_bytes: 71000
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll n,m;
       cin>>n>>m;
       string s, t;
       cin>>s>>t;
       ll tn=n, tm=m;
       ll g = __gcd(m,n);
       tn /= g, tm /= g;
       rep(i,0,g)
       {
              if(s[i*tn]!=t[i*tm]) { cout<<-1; exit(0); }
       }
       cout<<n*m/g;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A[101010];
int cnt[101010];

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

	int ret = 0;
	for (int i = 1; i <= 100000; ++i) if (cnt[i]) ++ret;
	if (ret % 2 == 0) --ret;
	printf("%d\n", ret);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>                                                               
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

long gcd(long A, long B)                                                        {
  while (A % B != 0) {
    long C = A % B;
    A = B;
    B = C;
  }
  return B;
}

long skip(const vector<long>& x)
{
  if (x.size() == 2) return x[1] - x[0];
  long A = x[1] - x[0];
  for (size_t n = 2; n < x.size(); ++n) {
    long B = x[n] - x[n - 1];
    A = gcd(A, B);
  }
  return A;
}

int main()
{
  long N, X;
  cin >> N >> X;
  vector<long> x(N + 1);
  x[0] = X;
  for (long n = 1; n <= N; ++n) cin >> x[n];
  sort(x.begin(), x.end());
  cout << skip(x) << endl; 
  return 0;
} 


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

int main(){
  int n;
  while(cin>>n,n){
    int a=2;
    int tmp=n;
    vector<int> ans;
    ans.push_back(1);
    while((int)sqrt(n)>=a && n!=1){
      if(n%a==0){
	ans.push_back(a);
	if(a!=n/a)
	  ans.push_back(n/a);
      }
      a++;
    }
    int b=0;
    for(int i=0;i<ans.size();i++){
      if(ans[i]==tmp)continue;
      b+=ans[i];
    }
    if(tmp==b && tmp != 1){
      cout << "perfect number" << endl;
    }else if(tmp > b){
      cout << "deficient number" << endl;
    }else{
      cout << "abundant number" << endl;
    }
  }
  return 0;
}

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


int arr[100007][3];
int dp[100007][3];
int f(int n, int s, int size){
    if(n==size) return 0;
    int &ans = dp[n][s];
    if(ans!=-1) return ans;
    
    ans = 0;
    ans = max(f(n+1, (s+1)%3,size), f(n+1, (s+2)%3,size));
    ans = ans + arr[n][s];
    
    return ans;
}

int main(){
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i][0];
        cin>>arr[i][1];
        cin>>arr[i][2];
    }
    cout<<max(f(0,0,n),max(f(0,1,n),f(0,2,n)));
}

Measured memory_bytes: 8832
//NOTE: this is not my own program. I'm helping a student of mine to debug his program.

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

int main(){
	double a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<double> sug;
	set<double> wat;

	for( int i = 0; 100*i*a < f; ++i ){
		for( int j = 0; 100*j*b+100*i*a < f; ++j ){
			//cout << 100*i*a+100*j*b << endl;
			wat.insert(100*i*a+100*j*b);
		}
	}

	for( int i = 0; i*c < f; ++i ){
		for( int j = 0; i*c+j*d < f; ++j ){
			sug.insert(i*c+j*d);
		}
	}

	double restw = 0;
	int maxi = -1, sugM = -1;
	//cout << endl;
	for( set<double>::iterator it = wat.begin(); it != wat.end(); ++it ){
		auto search = sug.upper_bound(min(((*it)*e)/100, f-(*it)));
		if( search != sug.begin() )
			--search;
		else
			continue;
		//cout << *it << " " <<  *search << endl;
		if( search != sug.end() && *it != 0 && restw < (100*(*search))/(*search+*it) && *it + *search <= f ){
			restw = (100*(*search))/(*search+*it) ;
			maxi =  *it + *search;
			sugM = *search;
		}
	}
	//cout << endl;
	if( maxi == -1) cout << min(100*a, 100*b) << " " << 0 << endl;
	else
		cout << maxi << " " << sugM << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&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: 580
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include<iomanip>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;



int main(){
  long double l;
  cin >> l;
  cout << fixed << setprecision(10) << l*l*l/27 << endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

data=[0]*n
s=set()
sum_wa=0

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]+=1
        else:
            sum_wa+=data[p]
            s.add(p)

print(len(s),sum_wa)

Measured memory_bytes: 18040
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int maxt = 0;
  int maxi = 1;
  for (int i = 1; i <= n; i++) {
    int t = 0;
    for (int j = i; j % 2 == 0; j /= 2) {
      t++;
    }
    if (maxt < t) {
      maxt = t;
      maxi = i;
    }
  }
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 5*(int)1e5 + 10;
// make sure N size is correctttt!!!!!!!!!

int n;

int which[2][2], ma[2][2];

int32_t main(){_

   cin>>n;
   vector<int> v;
   v.resize(n);

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

   map<int, int> freq[2];

   for (int i = 0; i < n; i++)
   {
      freq[i%2][v[i]]++;
   }

   for (int i = 0; i < 2; ++i)
   {
      for(auto it: freq[i]){
         if(it.S > ma[i][0]){
            swap(ma[i][1], ma[i][0]);
            swap(which[i][1], which[i][0]);
            ma[i][0] = it.S;
            which[i][0] = it.F;
         }
         else if(it.S > ma[i][1]){
            ma[i][1] = it.S;
            which[i][1] = it.F;
         }
      }
   }

   int ans = inf;

   for (int i = 0; i < 2; ++i)
   {
      int first = which[0][i];
      for (int j = 0; j < 2; ++j)
      {
         int second = which[1][j];
         if(first == second)continue;
         int curr = 0;
         for (int i = 0; i < n; ++i)
         {
            if(i % 2 == 0){
               curr += (v[i] != first);
            }
            else{
               curr += (v[i] != second);
            }
         }
         smin(ans, curr);
      }
   }

   cout<<ans;
   //make sure N size is correct!!!!!!!!!
   return 0;
}

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

using namespace std;

const int INF=1000000000;

int N,M;
int coins[101];
int dp[100001];
int summ[1<<11];

int main(){
    while(cin>>N>>M&&(N|M)){
        for(int i=0;i<N;i++)cin>>coins[i];
        for(int i=0;i<(1<<N);i++){
            summ[i]=0;
            for(int j=0;j<N;j++)if((i>>j)&1)summ[i]+=coins[j];
        }
        for(int i=0;i<=M;i++){
            int res=INF;
            if(i==0)res=0;
            else{
                for(int j=1;j<(1<<N);j++){
                    if(i-summ[j]>=0)res=min(res,dp[i-summ[j]]+1);
                }
            }
            dp[i]=res;
        }
        cout<<dp[M]<<endl;
    }

    return 0;
}

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

int main() {
  int n,ans = 1;
  string s;
  cin >> n >> s;
  rep(i,1,n){
    if(s[i] != s[i-1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


ll Count(ll x){
    vector<ll> B,SB;
    for(ll a:A){
        if(a>=x) B.push_back(1);
        else B.push_back(-1);
    }
    SB.assign(N+1,0LL);
    for (int i = 0; i < N; i++) SB[i+1] = SB[i]+B[i];
    ll mm = *min_element(SB.begin(),SB.end());
    for(auto &s:SB) s+=1-mm;
    // ll MM = *max_element(SB.begin(),SB.end());
    BinaryIndexedTree< ll > bit(N+10);
    ll K = 0LL;
    for (int i = 0; i <= N; i++)
    {
        K += bit.sum(SB[i]);
        bit.add(SB[i],1);
    }
    return K;
}


int solve(){
    ll ok = 0, ng = 1e9+1;
    ll M = N*(N+1)/2;
    while(ng-ok>1){
        ll mid = (ok+ng)/2;
        if(Count(mid)>=(M+1)/2) ok=mid;
        else ng = mid;
        DBG(mid)
    }
    cout << ok << endl;
    return 0;
}   

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

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

int main(){
  int N,Y;cin>>N>>Y;
  int ansx=-1;
  int ansy=-1;
  int ansz=-1;
  
  rep(x,N+1){
    rep(y,N+1){
      int z=N-x-y;
      if(0<=z &&z<=N){
      int total=10000*x + 5000*y + 1000*z;
      if(total==Y){
        ansx=x;
        ansy=y;
        ansz=z;
      }
      }
    }
  }
  
  cout<<ansx<<" "<<ansy<<" "<<ansz<<" "<<endl;
}

Measured memory_bytes: 3612
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
XY = [sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(N)]


ans = 0.0
for x, y in XY:
    if y == 'BTC':
        ans += float(x) * 380000.0
    else:
        ans += float(x)
print(ans)


Measured memory_bytes: 13660
#include<stdio.h>

int n,k;
int T[100000];

int check(int p,int T[])
{
	int i=0,j;
	for(j=0;j<k;j++)
	{
		int s=0;
		while(s+T[i]<=p)
		{
			s+=T[i];
			i++;
			if(i==n)
			{
				return n;
			}
		}
	}
	return i;
}

int solve(int T[])
{
	int left=0,right=100000*10000,mid;
	
	while(right-left>1)
	{
		mid=(left+right)/2;
		int v=check(mid,T);
		if(v>=n)
		{
			right=mid;
		}
		else
		{
			left=mid;
		}
	}
	
	return right;
}

int main(void)
{
	int i;
	
	scanf("%d %d",&n,&k);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
	}
	
	int x=solve(T);
	
	printf("%d\n",x);
	
	return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int antenas[] = new int[6];

		for (int i = 0; i < 6; i++) {
			antenas[i] = Integer.parseInt(sc.nextLine());
		}

		sc.close();

		boolean isConnect = true;

		for(int i = 0; i < 4; i++) {
			for(int j = 1; j < 5; j++) {
				if(antenas[j] - antenas[i] > antenas[5]) {
					isConnect = false;
				}
			}
		}

		if(isConnect) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}


	}

}

Measured memory_bytes: 21716
def right_num(m,u):
    cube = [
        {2:3,3:5,4:2,5:4},
        {1:4,3:1,4:6,6:3},
        {1:2,2:6,5:1,6:5},
        {1:5,2:1,5:6,6:2},
        {1:3,3:6,4:1,6:4},
        {2:4,3:2,4:5,5:3},
    ]
    return cube[m][u]

d=input().split()
for i in range(int(input())):
    num = input().split()

    p = d.index(num[0])
    s = int(d.index(num[1])) + 1

    print("{}".format(d[(right_num(p, s)-1)]))




Measured memory_bytes: 5604
#include<stdio.h>
#include<string.h>
int main(){
  int i;
  char weather[10];
  char wt_list[3][10] = {"Sunny","Cloudy","Rainy"};
  scanf("%s",weather);
  for(i=0;i<3;i++){
  	if(strcmp(weather,wt_list[i]) == 0){
  	  printf("%s",wt_list[(i+1)%3]);
  	}
  }
}

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

int main(){
	int w;
	int n;
	int a, b;

	cin >> w >> n;
	
	int number[30];
	for(int i = 0; i < w; i++){
		number[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		swap(number[a-1], number[b-1]);
	}
	
	for(int i = 0; i < w; i++){
		cout << number[i] << endl;
	}

	return(0);
}

Measured memory_bytes: 1240
/*
 * main.c
 *
 *  Created on: 2019/05/11
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t;
uint64_t a[10000] = {0};

int sort_inc_u(const void *a, const void *b)
{
    unsigned long long int da = *(unsigned long long int*)a;
    unsigned long long int db = *(unsigned long long int*)b;
    int val = 0;
    if(da > db) {
        val = 1;
    } else if (da == db) {
        val = 0;
    } else {
        val = -1;
    }

    return val;
}

int main()
{
    uint64_t N = 0, i = 0, j = 0, ans = 0;
    int J = 0;
    scanf("%llu", &N);
    for(i = 1; (i*i) <= N; i++) { // 2乗して元の数を超えない値で検索
        if(N%i == 0) { // 約数
        	a[j] = i;
        	j++;
            if(i != N/i) { // 平方数以外の場合
            	a[j] = N/i;
            	j++;
            }
        }
    }
    //printf("j = %d\n",j);
    J = j;
    qsort(a, j, sizeof(uint64_t), sort_inc_u); // 昇順に並べる
    for(i = 0; i < J; i++) {
    	if(a[i] != 1) { // 1は除外
        	j = a[i] - 1;
            if(N%j == N/j) { // 商とあまりが同じ
            	ans += j;
                //printf("m=%llu N/m=%llu Nmodm=%llu\n", j , N/j, N%j);
            }
    	}
    }
    printf("%llu\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n,A;
       cin>>n>>A;
       cout<<n*n-A;
    } 
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n, m, ans = 0;
int main() {
    cin >> n >> m;
    if(n == 1 && m == 1) {
        cout << 1 << endl; return 0;
    }
    if(n == 1 || m == 1) {
        cout << max(n, m) - 2 << endl; return 0;
    }
    ans = (n - 2) * (m - 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

int main()
{	
	char k;
	scanf("%c",&k);
	if(k >= 'a' && k <= 'z') printf("a");
	else printf("A"); 
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>

using namespace std;

int main(){
    typedef pair<int,int> P;
    int N;
    cin>>N;
    vector<vector<P>> to(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(P(b,i));
        to[b].push_back(P(a,i));
    }
    vector<int> c(N);
    for(int i=0;i<N;i++) cin>>c[i];
    sort(c.rbegin(),c.rend());
    queue<int> que;
    bool d[10000]={false};
    vector<int> hen(N-1,0);
    vector<int> ans(N,0);
    que.push(0);
    ans[0]=c[0];
    int j=0;
    int sum=0;
    while(!que.empty()){
        int p=que.front();que.pop();
        for(int i=0;i<to[p].size();i++){
            int v=to[p][i].first;
            int id=to[p][i].second;
            if(d[v]) continue;
            d[v]=true;
            que.push(v);
            if(hen[id]==0){
                hen[id]=c[j+1];
                ans[v]=c[j+1];
                sum+=c[j+1];
                j++;
            }
        }
    }
    cout<<sum<<endl;
    for(int i=0;i<N;i++) cout<<ans[i]<<" ";
}

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

    return divisors


n, m = map(int, input().split())

ans = 0
for i in make_divisors(m):
    if i <= m / n:
        ans = max(ans, i)

print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, m, a, b = 0, c;
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			m = Integer.valueOf(reader.readLine());
			
			int map[][] = new int[n][n];
			boolean visit[] = new boolean[n];
			for(int i = 0;i < n; i++) Arrays.fill(map[i], 1 << 29);
			for(int i = 0; i < m; i++){
				string = reader.readLine();
				a = Integer.valueOf(string.split(",")[0]);
				b = Integer.valueOf(string.split(",")[1]);
				c = (Integer.valueOf(string.split(",")[2]) - 100) / 100;
				map[a][b] = map[b][a] = c;
			}
			c = 0;
			visit[0] = true;
			for(int x = 0; x < n - 1; x++){
				m = 1 << 29;
				for(int i = 0; i < n; i++){
					if(map[0][i] < m && !visit[i]){
						m = map[0][i];
						b = i;
					}
				}
				visit[b] = true;
				c += map[0][b];
				for(int i = 0; i < n; i++){
					map[0][i] = Math.min(map[0][i], map[b][i]);
				};
			}
			System.out.println(c);
		}
		reader.close();
	}
}

Measured memory_bytes: 35068
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    string c;
    cin >> c;
    c[5] = ' ';
    c[13] = ' ';
    cout << c <<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class GoodDst{
	static void Main(string[] args){
		string[] ND = Console.ReadLine().Split(' ');
		int N = int.Parse(ND[0]);
		int D = int.Parse(ND[1]);
		int[][] X = new int[N][];
		for(int i = 0;i < N;i++){
			X[i] = new int[D];
			string[] strXi = Console.ReadLine().Split(' ');
			for(int j = 0;j < D;j++){
				X[i][j] = int.Parse(strXi[j]);
			}
		}
		int Ans = 0;
		for(int i = 0;i < N - 1;i++){
			for(int j = i + 1;j < N;j++){
				if(isSqnum(Norm(X[i],X[j],D)))Ans++;
			}
		}
		Console.WriteLine(Ans);
	}
	static int Norm(int[] X1,int[] X2,int D){
		int Norm = 0;
		for(int i = 0;i < D;i++){
			Norm += (X1[i] - X2[i]) * (X1[i] - X2[i]);
		}
		return Norm;
	}

	static bool isSqnum(int x){
		double Sqrt = Math.Sqrt((double)x);
		return ((double)x == (Math.Round(Sqrt) * Math.Round(Sqrt)));
	}
}

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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            //SolveA(args);
            //SolveB(args);
            SolveC(args);
            //SolveD(args);
        }
        
        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            if(n %  2 == 0)
            {
                Console.WriteLine(n);
            }
            else
            {
                Console.WriteLine(n * 2);
            }
        }
        static void SolveB(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            long[] a = new long[n];
            string[] szArr = Console.ReadLine().Split(' ');

            long max = long.MinValue;
            long min = long.MaxValue;

            for (int i=0;i<szArr.Length;++i)
            {
                long tmp  = long.Parse(szArr[i]);
                a[i] = tmp;
                max = Math.Max(tmp, max);
                min = Math.Min(tmp, min);
            }

            long val = Math.Abs(max - min);
            Console.WriteLine(val);
        }
        static void SolveC(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            long[] a = new long[n];
            string[] szArr = Console.ReadLine().Split(' ');
            for (int i = 0; i < szArr.Length; ++i)
            {
                long tmp = long.Parse(szArr[i]);
                a[i] = tmp - (i + 1);

            }


            long[] a2 = a.OrderByDescending(p => p).ToArray();
            long b_candidate = 0;
            long b_candidate2 = 0;

            if (n % 2 == 1)
            {
                long idx = (n - 1) / 2;
                b_candidate = a2[idx];
            }
            else
            {
                long k = (n-1) / 2;
                b_candidate = a2[k];
                b_candidate2 = a[k + 1];
            }
            var sad_list = new List<long>();
            sad_list.Add(SadValue(a, b_candidate));
            sad_list.Add(SadValue(a, b_candidate2));

            long sad = sad_list.Min();
            Console.WriteLine(sad);

        }
        private static double Average(long[] a)
        {
            // オーバーフローしそう

            double ave = 0.0;
            long total = 0;
            for(int i=0;i<a.Length;++i)
            {
                ave += (a[i] - ave) / (total + 1);
                total++;
            }
            return ave;
        }
        private static long SadValue(long[] a, long b)
        {
            long val = 0;
            for(int i=0;i<a.Length;++i)
            {
                val += Math.Abs(a[i] - b);
            }
            return val;
        }
    }

}


Measured memory_bytes: 40476
#include <math.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;

int main()
{
vector<int> alphabet(26);
string s;
while(cin >> s)
{
for(int i=0;i<s.size();i++)
{
if(isupper(s.at(i)))alphabet.at(s.at(i)-'A')++;
else if(islower(s.at(i)))alphabet.at(s.at(i)-'a')++;
else continue;
}
}
for(int i=0;i<26;i++)
{
char c=i+'a';
cout << c << " : " << alphabet.at(i) << endl;
}
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

using namespace std;

int main() {
    long long L,R;
    cin >> L >> R;
    bool a[2020] = {false};
    for(long long i=L;i<=min(R,L+2019);i++){
        a[i%2019]=true;
    }
    if(a[0] || (a[3]&&a[673])) cout << 0 << endl;
    else{
        int minV = 2020;
        repi(i,1,2019){
            if(a[i%2019]){
                repi(j,i+1,2019){
                    if(a[j%2019]){
                        int value = (i%2019)*(j%2019)%2019;
                        if(value<minV) minV=value;
                    }
                }
            }
        }
        cout << minV << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
   int n;
   cin >> n;
   vector<ll> a(n+1),b(n);
   rep(i,n+1) cin >> a.at(i);
   rep(i,n) cin >> b.at(i);
   ll ans=0;
   rep(i,n){
     if (b.at(i)>a.at(i)){
       ans+=a.at(i);
       b.at(i)-=a.at(i);
       if (b.at(i)>=a.at(i+1)) {
         ans+=a.at(i+1);
         a.at(i+1)=0;
       }
       else {
         ans+=b.at(i);
         a.at(i+1)-=b.at(i);
       }
     }
     else{
       ans+=b.at(i);
     }
   }
   cout << ans << endl;
  }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++){
        if ( i == n - 1)
            cout << a.at(i) << endl;
        else
            cout << a.at(i) << " ";
    }
}



Measured memory_bytes: 3096
#include<iostream>
#include<set>
using namespace std;
set <int> s;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        if(s.find(x)!=s.end())
            s.erase(x);
        else
            s.insert(x);
    }
    cout<<s.size()<<endl;
    return 0;
 } 


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

//階乗
ll factorial(ll num){ll sum = 1; for(ll i=1;i<=num;i++) sum*=i; return sum;}
//素数判定
bool isPrime(ll num){if(num<2){return false;}else if(num==2){return true;}else if(num%2==0){return false;} double sqrtNum=sqrt(num);for(int i=3;i<=sqrtNum;i+=2){if(num%i==0)return false;}return true;}

int main(){
  ll n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  
  ll satisfaction = 0;
  rep(i,n) satisfaction += b[a[i]-1]; //単純満足度
  rep(i,n-1) if(a[i] +1 == a[i+1]) satisfaction += c[a[i]-1]; //掛け合わせ満足度
  
  cout << satisfaction << endl;
}

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

typedef long long lint;
typedef long double louble;
template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return b<a?a:b;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 407 , __ = 100007;

int n,m,tar[__][2]={0},faint[__]={0};
bitset<_> got[_]={0};

int main()
{
	n=ty(),m=ty();
	for(int i=1;i<=m;i++)tar[i][0]=ty(),tar[i][1]=ty();
	for(int i=1;i<=n;i++)
	{
		got[i][i]=1;
		for(int j=m;j>=1;j--)
		{
			if(got[i][tar[j][0]] && got[i][tar[j][1]]){faint[i]=1;break;}
			else if(got[i][tar[j][0]] || got[i][tar[j][1]])
				got[i][tar[j][0]]=got[i][tar[j][1]]=1;
		}
	}

	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(!faint[i] && !faint[j] && !(got[i]&got[j]).any())ans++;

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll wa(ll x){
  return x*(1+x)/2;
}


signed main(){
	int n; cin>>n;
  cout<<(n-1)/2<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll INF=(ll)1e18;

int main(void) {
  int a,b,q;
  cin >> a >> b >> q;

  vector<ll>s(a+2),t(b+2),x(q+1);
  for (int i = 1; i <= a; i++) {
    cin >> s[i];
  }
  for (int i = 1; i <= b; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= q; i++) {
    cin >> x[i];
  }

  s[0]=t[0]=-INF;
  s[a+1]=t[b+1]=INF;

  for (int i = 1; i <= q; i++) {
    auto s2 = lower_bound(s.begin(), s.end(), x[i]);
    auto s1 = s2-1;
    auto t2 = lower_bound(t.begin(), t.end(), x[i]);
    auto t1 = t2-1;
 
    ll res = INF;
    for (auto j = s1; j <= s2; j++) {
      for (auto k = t1; k <= t2; k++) {
	res =min(res,abs(x[i]-*j)+abs(*j-*k));
	res =min(res,abs(x[i]-*k)+abs(*j-*k));
      }
    }

    cout << res << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()




int main(void){
	int N, K;
    cin >> N >> K;
    vector<int> h;
    rep(i,N){
        int a;
        cin >> a;
        h.push_back(a);
    }

    sort(rall(h));

    int ans = 0;
    rep(i,N){
        if(h[i]>=K){
            ans++;
        }else{
            cout << ans << endl;
            break;
        }
        if(i == N-1){
            cout << ans << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a+b) cout<<min(k, a)<<"\n";
    else cout<<a-(k-a-b)<<"\n";
    return 0;
}

Measured memory_bytes: 3652
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms_map=(-1)x($n+1);
	my$m=0;
	my@lms;
	for(1..$n-1){
		if(!$ls[$_-1]&&$ls[$_]){
			$lms_map[$_]=$m++;
			push@lms,$_;
		}
	}
	@sa=$induce->(@lms);
	if($m>0){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


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

int main() {
    double t,x;
    cin >> t >> x;
    cout << fixed << setprecision(10);
    cout << t/x << endl;
}


Measured memory_bytes: 256
import * as fs from 'fs'

const getInput = (): string => {
  return (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
}

export const solveAbc070b = () => {
  const input = getInput()

  const [A, B, C, D] = input.trim().split(' ').map(Number)

  const min = Math.max(A, C)
  const max = Math.min(B, D)
  console.log(Math.max(max - min, 0))
}
solveAbc070b()


Measured memory_bytes: 7372
let c = 1_000_000_007
let n, m = Scanf.scanf "%d %d" (fun n m -> n, m)

let f = fun _ -> Scanf.scanf " %d" (fun i -> i)
let x = Array.init n f
let y = Array.init m f

let f n x =
  let rec g i t s =
    if i = -1 then s
    else
      let t = (t + x.(i + 1)) mod c in
      g (i - 1) t ((s + t - (n - 1 - i) * x.(i)) mod c)
  in g (n - 2) 0 0

let () =
  let sx = f n x in
  let sy = f m y in
  Printf.printf "%d\n" (sx * sy mod c)


Measured memory_bytes: 7532
n,k = map(int,input().split())
mod = 10**9+7
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
from collections import deque
stack = deque([(0,k)])
seen = [True]*n
seen[0] = False

ans = 1

while stack:
    u,t = stack.popleft()
    ans = (ans*t)%mod
    if u==0: l = k-1
    else: l = k-2
    for v in g[u]:
        if seen[v]:
            seen[v] =False
            stack.append((v,l))
            l -=1
print(ans)

Measured memory_bytes: 91172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,k,a,b,ans=1;
	vector<int>v;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a==1)b=i;
	}
	n-=k;
	while(n!=0)
	{
		if(n-(k-1)>0)
		{
			n-=k-1;
			ans++;
		}
		else
		{
			n=0;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        		int n = sc.nextInt();
        		int x = sc.nextInt();
        		if(n==0 && x==0) break;
        		int c = 0;
        		for(int i=1; i<n-1; i++) {
        			for(int j=i+1; j<n; j++) {
        				for(int k=j+1; k<n+1; k++) {
        					if(i+j+k == x) c++;
        				}
        			}
        		}
        		System.out.println(c);
        }
    }
}


Measured memory_bytes: 26520