akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<string.h>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
#define GREATER cout<<"GREATER"<<endl
#define LESS cout<<"LESS"<<endl
#define EQUAL cout<<"EQUAL"<<endl
typedef long long ll;
using namespace std;

int main() {
	int N; cin >> N;
	ll ans = 1;
	for (int i = 1; i <= N; ++i) {
  	ans = (ans * i) % (1000000007);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	double x, y, z, r;
} Coord;

typedef struct {
	int parent, rank;
} Node;

typedef struct {
	int from, to;
	double weight;
} Edge;

Coord coord[ 100 ];
Node node[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	if ( at > bt )
		return 1;
	return 0;
}

int find( int x ) {
	if ( node[ x ].parent == x )
		return x;
	else
		return node[ x ].parent = find( node[ x ].parent );
}

int main( void ) {
	int i, j;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int cnt;
		double sum;

		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( sqrt( ( coord[ i ].x - coord[ j ].x ) * ( coord[ i ].x - coord[ j ].x ) + ( coord[ i ].y - coord[ j ].y ) * ( coord[ i ].y - coord[ j ].y ) + ( coord[ i ].z - coord[ j ].z ) * ( coord[ i ].z - coord[ j ].z ) ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}
		qsort( edge, cnt, sizeof(Edge), &compare );

		for ( i = 0; i < n; i++ ) {
			node[ i ].parent = i;
			node[ i ].rank = 0;
		}

		sum = 0.0;
		for ( i = 0; n && i < cnt; i++ ) {
			int set1 = find( edge[ i ].from ), set2 = find( edge[ i ].to );

			if ( set1 != set2 ) {
				if ( node[ set1 ].rank < node[ set2 ].rank )
					node[ set1 ].parent = set2;
				else {
					node[ set2 ].parent = set1;
					if ( node[ set1 ].rank == node[ set2 ].rank )
						node[ set1 ].rank++;
				}

				sum += edge[ i ].weight;
				n--;
			}
		}

		printf( "%.3f\n", sum );
	}

	return 0;
}

Measured memory_bytes: 868
#include<iostream>
#include<stdio.h>

int main()
{
	int h, w;
	int i, j;
	std::cin >> h;
	std::cin >> w;
	while (h != 0 || w != 0){
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				std::cout << "#";
			}
			std::cout << "\n";
		}
		std::cout << "\n";
		std::cin >> h;
		std::cin >> w;
	}
	return 0;
}

Measured memory_bytes: 1120
/*挿入ソートを実装したプログラム*/
#include <stdio.h>

#define ARY_MAX 100       /*入力の数列の最大の長さ*/

int main()
{
  int i, j, n, v, ary[ARY_MAX];

  scanf("%d", &n);

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

      if( i == n-1 )
	break;
    }

  /*挿入ソートを用いて昇順にソート*/
  for( i = 1; i<n; i++ )
    {
      /*各ステップでの途中結果を表示*/
      for( j = 0; j<n; j++ )
	{
	  printf("%d", ary[j]);
	  if( j != n-1 )
	    printf(" ");
	}
      printf("\n");

      v = ary[i];
      j = i-1;

      while( j>=0 && ary[j]>v )
	{
	  ary[j+1] = ary[j];
	  j--;
	}
      ary[j+1] = v;

    }

  for( j = 0; j<n; j++ )
    {
      printf("%d", ary[j]);

      if( j != n-1 )
	printf(" ");
    }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2144
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int par[M];
int fnd(int x)
{
    if(x==par[x])return x;
    return par[x]=fnd(par[x]);
}
void tie(int x,int y)
{
    int fx=fnd(x);
    int fy=fnd(y);
    if(fx==fy)return ;
    par[fy]=fx;
}
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,n)par[i]=i;
    f(i,1,m)
    {
        int u,v,w;
        cin>>u>>v>>w;
        tie(u,v);
    }
    set<int>s;
    f(i,1,n)
    {
        s.insert(fnd(i));
    }
    cout<<s.size()<<endl;
    return 0;

}





































Measured memory_bytes: 8996
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string s;
	int n;
	cin >> n;
	cin >> s;
	vector<int> a(n);
	rep(i, n) {
		if (s[i] == 'R') a[i] = 0;
		if (s[i] == 'G') a[i] = 1;
		if (s[i] == 'B') a[i] = 2;
	}
	vector<ll> cnt(3);
	rep(i, n) cnt[a[i]]++;
	long long total = cnt[0] * cnt[1] * cnt[2];
	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			int k = 2 * j - i;
			if (k < n) {
				if (s[i] == s[j]) continue;
				if (s[i] == s[k]) continue;
				if (s[k] == s[j]) continue;
				total--;
			}
		}
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
R, G, B, N = list(map(int, input().split()))

pat = 0
for r in range(N//R+1):
    rest = N - R*r
    for b in range(rest//B+1):
        if (rest-B*b) % G == 0:
            pat += 1
print(pat)


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  char ch; cin>>ch;
  ch++;
  cout<<ch<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int n;
    scanf("%d", &n);
    int p[n];
    for (int i=0; i < n; i++) scanf("%d", &p[i]);

    int max = p[0];
    for (int i=1; i < n; i++){
        if (max < p[i]){
            max = p[i];
        }
    }

    int sum = 0;
    for (int i=0; i < n; i++){
        sum += p[i];
    }

    sum -= max/2;

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

    return 0;
} 



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d,x,a,ans; cin>>n>>d>>x;
  ans=n;
  for(int i=0; i<n; i++){
    cin>>a; x+=d/a;
    if(d%a) x++;
  }
  cout<<x;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n,t=0;
	string s1, s2, s3;
	cin >> n;
	cin >> s1 >> s2 >> s3;
	rep(i, n) {
		if (s1[i] == s2[i] && s1[i] == s3[i]) {

		}
		else if (s1[i] != s2[i] && s1[i] != s3[i] && s2[i] != s3[i]) {
			t += 2;
		}
		else {
			t += 1;
		}
	}
	cout << t << endl;
}



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


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

  int n;
  cin >> n;
  int a[n];
  pair<ll,int> p[n];
  rep(i,n){
    cin >> a[i];
    p[i]=mp(a[i],i);
  }
  sort(p,p+n);
  reverse(p,p+n);

  ll ans[n];
  rep(i,n) ans[i]=0;
  int ind=n;
  rep(i,n){
    ind=min(ind, p[i].second);
    if(i==n-1) ans[ind]+=(i+1)*(p[i].first-0);
    else ans[ind]+=(i+1)*(p[i].first-p[i+1].first);
    //    cout << ans[ind] << endl;
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
  
  return 0;
    

}


Measured memory_bytes: 3840
import re

bra_re = re.compile(r'\[([-+\w?]+)\]')
let_re = re.compile(r'[-+]*[\w?]')

def rep(m):
    s = m.group(0)
    if s[-1] == '?': return 'A'
    d = 0
    d += s.count('+')
    d -= s.count('-')
    d %= 26
    d += ord(s[-1])
    if d < ord('A'): d += 26
    if d > ord('Z'): d -= 26
    return chr(d)

def dec(m):
    s = m.group(1)
    return let_re.sub(rep, s)[::-1]

def decipher(s):
    m = bra_re.search(s)
    while m is not None:
        s = bra_re.sub(dec, s)
        m = bra_re.search(s)

    s = let_re.sub(rep, s)
    print(s)

while True:
    s = input()
    if s == '.': break
    decipher(s)



Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    long long int m,n,i,j,k,sum=0,l,r;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i*i>1e4) break;
        for(j=1;j<=n;j++)
        {
            if(j*j>1e4) break;
            for(k=1;k<=n;k++)
            {
                if(k*k>1e4) break;
                m=i*i+j*j+k*k+i*j+i*k+j*k;
                if(m>1e4) break;
                num[m]++;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<num[i]<<endl;
    }
    return 0;
}





Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    string s; cin>>s;
    ll x[s.size()];
    for(ll i=0; i<s.size(); i++)
        x[i] = 1;
    for(ll i=1; i<s.size(); i++){
        if(s[i] == s[i-1]){
            x[i] += x[i-1];
            x[i-1] = 0;
        }
    }
    ll indexR;
    for(ll i=0; i<s.size(); i++){
        if(x[i] && s[i]=='R')
            indexR = i;
        else if(x[i] && s[i]=='L'){
            ll tmp = x[indexR]+x[i];
            x[i] = 0;
            if(tmp%2 == 0){
                x[indexR] = tmp/2;
                x[indexR+1] = tmp/2;
            }
            else{
                if(x[indexR]&1){
                    x[indexR] = tmp/2 + 1;
                    x[indexR+1] = tmp/2;
                }
                else{
                    x[indexR] = tmp/2;
                    x[indexR+1] = tmp/2 + 1;
                }
            }
        }
    }
    for(ll i=0; i<s.size(); i++)
        cout << x[i] << " ";
    cout << endl;
}


Measured memory_bytes: 1408
def calculate(arr):
    N = len(arr)
    index = N - 1

    result = [0]*N
    result2 = []

    while index >= 0:

        if N // (index+1) > 1:
            v1 = calculate2(N // (index+1),index,result)

            if arr[index] % 2 == 0:
                if v1 % 2 == 0:
                    pass
                else:
                    result[index] = 1
                    result2.append(index + 1)
            else:
                if v1 % 2 == 0:
                    result[index] = 1
                    result2.append(index + 1)
                else:
                    pass

        else:
            if arr[index] == 0:
                result[index] = 0
            else:
                result[index] = 1
                result2.append(index + 1)

        index = index - 1

    return result,result2


def calculate2(len, base, arr):
    result = 0
    for i in range(2, len+1):
        result += arr[(base + 1) * i - 1]
    return result


N = int(input())
S = input().split(" ")
arr = [int(s) for s in S]

result, result2 = calculate(arr)

print(sum(result))
if len(result2) > 0:
    print(" ".join([str(s) for s in result2]))




Measured memory_bytes: 21664
#include <iostream>
#include <string>

using namespace std;
int main() {
	string code = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int result = 0;
	for (int i = 0; i < 16; i++) {
		if (code.at(i) != s.at(i)) result++;
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())
s = 0
g = K

def d(h):
    return X + (h - (K-h))*D

if d(s) >= 0:
    ans = d(s)
elif d(g) <= 0:
    ans = abs(d(g))
else:
    half = (s + g)//2
    while s < half:
        if d(half) < 0:
            s = half
        else:
            g = half
        half = (s + g)//2

    ans = min(abs(d(s)) , abs(d(g)) )
print(ans)

Measured memory_bytes: 8984
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
  b=[0]*(n+1)
  for j in range(n):
    b[max(0,j-a[j])]+=1
    b[min(n,j+a[j]+1)]-=1
  for j in range(n):
    b[j+1]+=b[j]
  a=b[:-1]
  if a==[n]*n:exit(print(*a))
print(*a)


Measured memory_bytes: 169116
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
string s,t;
cin>>s>>t;
bool ans=false;

for(int i=1; i<=s.size(); i++)
{
    if(s==t)
    {
        ans=true; break;
    }
    s=s.back()+s.substr(0, s.size()-1);
}
if(ans)
{
    cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// int INF = 1000000007;
		int n = sc.nextInt();

		Vec[][] vec = new Vec[50][50];
		Vec[] ary = new Vec[50];

		//int[][] ary = new int[INF][INF];
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			// 50個保存
			ary[i] = new Vec();
			ary[i].x = x;
			ary[i].y = y;
		}

		HashMap<Integer, HashMap<Integer, Integer>> map = new HashMap<>();
		int max = 0;
		int maxx = 0;
		int maxy = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if(i == j) continue;
				int x = ary[i].x - ary[j].x;
				int y = ary[i].y - ary[j].y;

				map.putIfAbsent(x, new HashMap<>());
				map.get(x).putIfAbsent(y, 0);

				int num = map.get(x).get(y) + 1;
				// System.out.println(num);

				if (num > max) {
					max = num;
					maxx = x;
					maxy = y;
				}

				map.get(x).put(y, num);

				// System.out.println(map);
				vec[i][j] = new Vec(x, y);
			}
		}
//
//		System.out.println(max);
//		System.out.println(maxx);
//		System.out.println(maxy);

		System.out.println(n - max);



	}

	public static class Vec {
		public int x;
		public int y;

		public Vec() {
			this.x = 0;

			this.y = 0;

		}
		public Vec(int x, int y) {
			this.x = x;

			this.y = y;

		}

		@Override
		public String toString() {
			return "Vec [x=" + x + ", y=" + y + "]";
		}

	}

}


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

char S[200009];

int main() {
    int N, A, B, C, D; scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
    scanf(" %s", S+1);
    for(int i=A; i<D; i++) {
        if(S[i] == '#' && S[i+1] == '#') return !printf("No");
    }
    if(C < D) puts("Yes");
    else {
        for(int i=B-1; i<D; i++) {
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') return !printf("Yes");
        }
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<vector>

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> ai;
    map<long long, long long> map1;
    for(long long i = 1; i <= n; i++) map1[i] = 0;
    for(long long i = 0; i < n; i++){
        long long input;
        cin >> input;
        ai.push_back(input);
        map1[input]++;
    }
    map<long long, long long> map2;
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        long long num = map1[i];
        num = num * (num - 1) / 2;
        map2[i] = num;
        sum += num;
    }
    for(long long k = 0; k < n; k++){
        long long num = map1[ai[k]] - 1;
        num = num * (num - 1) / 2;
        long long ans = sum;
        ans += num - map2[ai[k]];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 29168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int a,b;
    double t;
    cin >> a >> b >> t;
    t += 0.5;
    int cnt = 0;
    int sec = 0;
    while(sec+a < t){
        cnt += b;
        sec += a;
    }
    cout << cnt << endl;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	int k;
	cin >>s >>k;
	
	set<string> st;
	int n=sz(s);
	rep(i, n){
		rep2(j, 1, n-i+1){
		 string cr = s.substr(i,j);
		 if(sz(st)> k && cr >= *next(st.begin(),k)) break;
		 st.insert(cr);
		}
		while(sz(st)> k+1) st.erase(next(st.begin(),k+1));
	}
	//for(auto x :st) cout<<x <<" "; puts("");
	
	cout << *next(st.begin(), k-1) <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import sys
sys.setrecursionlimit(10**8)
class BIT():
    def __init__(self,number):
        self.n=number
        self.list=[0]*(number+1)
        
    def add(self,i,x):#ith added x  1indexed
        while i<=self.n:
            self.list[i]+=x
            i+=i&-i
            
    def search(self,i):#1-i sum
        s=0
        while i>0:
            s+=self.list[i]
            i-=i&-i
        return s
    
    def suma(self,i,j):#i,i+1,..j sum
        return self.search(j)-self.search(i-1)

N,K=map(int,input().split())
A=[int(input()) for i in range(N)]
B=list(accumulate([0]+A))
for i in range(N+1):
    B[i]-=K*i
C=sorted((B[i],i) for i in range(N+1))
D=[-1]*(N+1)
D[C[0][1]]=0
s=C[0][0]
t=0
for i in range(1,N+1):
    if s<C[i][0]:
        s=C[i][0]
        t+=1
        D[C[i][1]]=t
    else:
        D[C[i][1]]=t
tree=BIT(t+1)
ans=0
for i in range(N+1):
    ans+=tree.search(D[i]+1)
    tree.add(D[i]+1,1)
print(ans)

Measured memory_bytes: 81956
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
signed main() {
    int n;
    cin >> n;
    vector<int> a(n+1,0);
    rep(i,n) cin >> a[i];
    int now = 0;
    int nex = 1;
    int ca = 1000;
    int cr = 0;
    int last = 0;
    bool f = false;
    while(now<n) {
        //cout << now << endl;
        if(a[now]<a[nex]){
            cr = ca / a[now];
            ca = ca - cr*a[now];
            ca = ca + cr*a[nex];
            cr = 0;
        }
        now++;
        nex++;
    }
    cout << ca << endl;
    
  return 0;
}



Measured memory_bytes: 3624
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = nextIntArray(sc, N);

		sc.close();

		int[] left = new int[N];
		int[] right = new int[N];

		left[0] = A[0];
		for (int i = 1; i < N; i++) {
			left[i] = Math.max(left[i - 1], A[i]);
		}

		right[N - 1] = A[N - 1];
		for (int i = N - 2; i >= 0; i--) {
			right[i] = Math.max(right[i + 1], A[i]);
		}

		StringBuilder sb = new StringBuilder();

		sb.append(right[1]);
		sb.append("\n");
		for (int i = 1; i < N - 1; i++) {
			int l = left[i - 1];
			int r = right[i + 1];

			sb.append(Math.max(l, r));
			sb.append("\n");
		}
		sb.append(left[N - 2]);
		sb.append("\n");

		out.print(sb.toString());

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 74144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3616
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

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

int main()
{
	int k,x;

	cin >> k >> x;

	if(k*500 >= x)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    A.push_back(k + A[0]);
    
    int ma = 0;
    for (int i = 0; i < n; i++)
        ma = max(ma, A[i + 1] - A[i]);

    cout << k - ma << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int M, T, P, R;

struct Team{
	int id, ac, timecost;
	int wa[11];
	Team(int i){
		id = i;
		ac = 0; timecost = 0;
		for(int i = 0; i < 11; i++) wa[i] = 0;
	}
};

bool compare(const Team &a, const Team &b){
	if(a.ac != b.ac) return a.ac > b.ac;
	else if(a.timecost != b.timecost) return a.timecost < b.timecost;
	else return a.id > b.id;
}

int main(){
	while(cin >> M >> T >> P >> R && M != 0){
		vector<Team> teams;
		for(int i = 0; i < T; i++){
			Team t(i);
			teams.push_back(t);
		}

		for(int i = 0; i < R; i++){
			int m, t, p, j;
			cin >> m >> t >> p >>j;
			if(j == 0){
				teams[t-1].ac++;
				teams[t-1].timecost += m + teams[t-1].wa[p] * 20;
			}else{
				teams[t-1].wa[p]++;
			}
		}

		sort(teams.begin(), teams.end(), compare);

		int p_ac = -1, p_tc = -1;
		for(int i = 0; i < T; i++){
			if (i>0) {
				if(teams[i-1].ac== teams[i].ac && teams[i-1].timecost == teams[i].timecost) cout << "=";
				else cout << ",";	
			}
			cout << teams[i].id+1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	while(cin >> n , n){
		int ans = 0;
		vector<int> data(n);
		rep(i,n) cin >> data[i];
		rep(i,n){
			rep(j,n-1){
				if(data[j] > data[j+1]){
					swap(data[j],data[j+1]);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
N,M,RR = map(int,input().split(" "))
R = list(map(lambda x:int(x)-1,input().split(" ")))
G = [[] for i in range(N)]
sq = [[(x==y)-1 for x in range(RR)] for y in range(RR)]
for i in range(M):
    a,b,c = map(int,input().split(" "))
    a -= 1
    b -= 1
    G[a].append((b,c))
    G[b].append((a,c))

for i in range(RR):
    E = [-1 for x in range(N)]
    F = [0 for x in range(N)]
    E[R[i]] = 0
    F[R[i]] = 1
    q = R[i]
    c = 1
    while c != N:
        for a,b in G[q]:
            if F[a]:
                continue
            if E[a] == -1:
                E[a] = E[q] + b
            else:
                E[a] = min(E[a],E[q] + b)
        a = [x for x in range(N) if not(F[x]) and E[x] != -1]
        q = min(a,key=lambda x:E[x])
        F[q] = 1
        c += 1
    for j in range(RR):
        sq[i][j] = E[R[j]]

q = [[[],0,0]]
s = []
while len(q):
    a,b,c = q.pop()
    if b == RR:
        s.append(c)
        continue
    for i in range(RR):
        if i in a:
            continue
        if b == 0:
            q.append([a+[i],b+1,0])
        else:
            q.append([a+[i],b+1,c+sq[a[-1]][i]])

print(min(s))

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

#define N 100005
char a[N];

int main() {
  scanf("%s", a);
  int n = (int) strlen(a);
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (a[i] == a[i - 1]) {
      a[i] = '1' - a[i] + '0';
      ans++;
    }
    if (a[i] == a[i + 1]) {
      a[i + 1] = '1' - a[i + 1] + '0';
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
--import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO



getVUIL :: IO (VU.Vector Int)
getVUIL = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readI :: BSC8.ByteString -> Int
readI = fst . fromJust . BSC8.readInt
readIL :: BSC8.ByteString -> [Int]
readIL = map readI . BSC8.words
getI :: IO Int
getI = readI <$> BSC8.getLine
getIL :: IO [Int]
getIL = readIL <$> BSC8.getLine

getNIS :: Int -> IO [(Int, BSC8.ByteString)]
getNIS 0 = return []
getNIS n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getNIS (n - 1))
    return ((readI aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show (mod a modNum)

mFromInt :: Int -> Mint
mFromInt a = M (mod a modNum)

main :: IO ()
main = do
    [aA, aB, aX] <- getIL
    let ret = (div aB aX) - (div (aA - 1) aX)
    print ret




Measured memory_bytes: 508
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String input1 = sc.nextLine();
		String input2 = sc.nextLine();
		int cnt = 0;
		for(int i = 0 ; i<3; i++){
			if(input1.charAt(i)==input2.charAt(i))cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>
 
#define pi 2 * acos(0.00)
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define nll '\0'
#define mx 1000007
#define bdyptb return 0;
#define testcase ll t,tt; cin>>tt; for(t=1;t<=tt;t++)
   
 
 
using namespace std;
 
int main()
{
    fastio;  
	int a,b;
  cin>>a>>b;
  cout<<a*b<<nl;
 
    
 
 
 
    bdyptb;
}

Measured memory_bytes: 3652
//ProblemD.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

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

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemD.cpp

#define MAXN 100010



struct Node
{
	int father;
	vector<int> sons;
};
static Node a[MAXN + 1];
static int n, k;

static int rst;
static int dfs(int i) {
	int height = 0;
	for (auto &son : a[i].sons) {
		int hson = dfs(son);
		if (height < hson + 1)
			height = hson + 1;
	}

	if (i != 1 && a[i].father != 1 && height == k - 1) {
		++rst;
		return -1;
	}
	else
		return height;
}


int main(int argc, char* argv[])
{
	OPENOJIO;

	ip >> n >> k;
	for (int i = 1; i <= n; ++i) {
		ip >> a[i].father;
	}

	rst = 0;
	if (a[1].father != 1) {
		rst++;
	}
	a[1].father = 0;

	for (int i = 2; i <= n; ++i) {
		a[a[i].father].sons.push_back(i);
	}

	dfs(1);

	op << rst << endl;

	return 0;
}
/***************************************************************/


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

const int MaxN(100003);
int fa[MaxN], n, K, ans;
vector<int> G[MaxN];

int dfs(int u)
{
	int d = 0;
	for(auto v : G[u])
		d = max(d, dfs(v));
	if(d == K - 1)
		ans += (fa[u] != 1), d = -1;
	return d + 1;
}

int main()
{
	scanf("%d%d", &n, &K);
	for(int i = 1; i <= n; i++)
		scanf("%d", &fa[i]);
	ans = (fa[1] != 1), fa[1] = 1;
	for(int i = 2; i <= n; i++)
		G[fa[i]].push_back(i);
	dfs(1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10752
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

int bins(int lo, int hi, int k)
{
	while((lo+1)<hi)
	{
		int mid=(lo+hi)/2;
		if(((mid*(mid+1))/2)<=k)
		{
			lo=mid;
		}
		else
		{
			hi=mid-1;
		}
	}
	int mid=hi;
	while(mid>=0)
	{
		if(((mid*(mid+1))/2)<=k){
			return mid;
		}
		--mid;
	}
	return 0;
}
signed main()
{
	speed
	int n,k,s;cin>>n>>k>>s;
	if(s==0)
	{
		int num=bins(0,n,k);
		int rem=k-((num*(num+1))/2);
		for(int i=0;i<num;++i){cout<<0<<" ";}
		for(int i=num;i<n;++i){
			if((rem)&&((i%2)!=(num%2)))
			{
				cout<<0<<" ";
			}
			else
			{
				cout<<1<<" ";
			}
		}
		return 0;
	}
	for(int i=0;i<k;++i){cout<<s<<' ';}
	int nex=s+1;
	if(nex==1000000001){nex-=2;}
	for(int i=k;i<n;++i){cout<<nex<<" ";}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    for(ll i = sqrt(n); i >= 1; i--)
    {
        if(n % i == 0)
        {
            cout << n/i -1 + i-1 << endl;
            return 0;
        }
    }
    cout << n-1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
	string str;
	getline(cin,str);
	for(int i=0;i<str.size();i++){
		if('a'<=str[i]&&str[i]<='z')
			str[i]-=32;
	}

	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 1172
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
// #include<vector>
// #include<stdio.h>
// #include <cmath>
// #include <cstdlib>
// #include <cassert>
// #include <algorithm>
// #include <set>
// #include <deque>
// #include <numeric>
// #include<tuple>
// #include <utility>
#include <map>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}
 
int main(){
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int sum1 = h1*60 + m1;
	int sum2 = h2*60 + m2;
	cout << (sum2 - k ) - sum1 << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<map>


#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  long long a;
  long long b;
  long long m;

  cin >> a >> b >> m;
  // // map<string, long long> words;
  vector<long long> res(a);
  vector<long long> mis(b);

  long long r_min = -1;
  for(long long i=0; i<a; ++i){
    cin >> res[i];
    if (r_min > res[i] || r_min == -1) r_min = res[i];
  }
  long long m_min = -1;
  for(long long i=0; i<b; ++i){
    cin >> mis[i];
    if (m_min > mis[i] || m_min == -1) m_min = mis[i];
  }
  map<vector<long long>, long long> cs;
  long long min = r_min + r_min;
  // cout << min << endl;
  for(long long i=0; i<m; ++i){
    long long r_i;
    long long m_i;
    long long d;
    cin >> r_i >> m_i >> d;
    long long p = res[r_i-1] + mis[m_i-1] - d;
    // cout << "p: " << p << res[r_i] << mis[m_i] << endl;
    if (min > p) min = p;
  }
  
  cout << min << endl;
  return 0;  
}

Measured memory_bytes: 1792
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_pair(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  int cnt=0;
  rep(i, 1, n+1){
    int j = n-i;
    if (i<j) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  vector<string> ans(n);
  int A = 0;
  int B = 0;
  rep(i, n) {
    if(s.at(i) == 'a'){
      if(A + B < a + b) {
        ans[i] = "Yes";
        A++;
      }
      else ans[i] = "No";
    }  
    if(s.at(i) == 'b'){
      if(A + B < a + b && B < b) {
        ans[i] = "Yes";
        B++;
      }
      else ans[i] = "No";
    }
    if(s.at(i) == 'c') ans[i] = "No";
  }
  rep(i,n) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 6616
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int k;
  cin>>k;
  
  if(k%2==1) cout<<(k+1)/2*(k/2)<<endl;
  else cout<<k/2*(k/2)<<endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n, d, k, b, a[105], ans;
int main(){
	scanf("%d%d", &n, &k);
	for(int i=1; i<=k; i++){
		scanf("%d", &d);
		for(int j=1; j<=d; j++){
			scanf("%d", &b);
			a[b]++;
		}
	}
	for(int i=1; i<=n; i++){
		if(!a[i]) ans++;
	}
	printf("%d", ans);
	return 0;
}

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

//factorial
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
///////////////////////////////////////////
int n,x[123],A=1000000;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i];
    sort(x,x+n);
    
    for(int i=x[0];i<=x[n-1];i++){
        int a=0;
        for(int j=0;j<n;j++){
            a+=(i-x[j])*(i-x[j]);
        }
        if(A>a)A=a;
        
    }
    cout<<A<<endl;
}



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


int main(int argc, char* argv[])
{
    int n,m,k;
    scanf("%d%d%d", &n, &m, &k);

    int i,j;
    for(i=0; i<=n; i++) {
        for(j=0; j<=m; j++) {
            int tmp=i*j+(n-i)*(m-j);
            if(k==tmp) {
                printf("Yes\n"); return 0;
            }
        }
    }
    printf("No\n");


    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int a, b, c, tmp;
	scanf("%d %d %d", &a,&b,&c);
	tmp = a;
	a = b;
	b = tmp;
	tmp = a;
	a = c;
	c = tmp;
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

string T;

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

    cin >> T;

    for (int i = 0; i < T.length(); i++)
        if (T[i] == '?') T[i] = 'D';
    cout << T; return 0;
/*
    int cnt = 0;
    if (T[T.length()] == 'D') cnt++;

    for (int i = 0; i < T.length() - 1; i++) {
        if (T[i] == 'P' && T[i+1] == 'D') cnt++;
        if (T[i] == 'D') cnt++;
    }
    */

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,n,res=0;
  cin>>r>>g>>b>>n;
  for(int i=0;r*i<=n;++i){
    for(int j=0;g*j<=n;++j){
      if(n<r*i+g*j)break;
      if((n-r*i-g*j)%b==0)res++;
    }
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t W, H, w, h, x, y;
  scanf("%jd %jd %jd %jd %jd %jd", &W, &H, &w, &h, &x, &y);

  intmax_t xr = std::min(W/2, x+w/2);
  intmax_t xl = std::max(-W/2, x-w/2);
  intmax_t yr = std::min(H/2, y+h/2);
  intmax_t yl = std::max(-H/2, y-h/2);

  double xx = 0.5 * (xr+xl);
  double yy = 0.5 * (yr+yl);
  printf("%.12f\n", yy/xx);
}



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

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int f;
  string s ;
  vi v(10,0);
  while(cin >> s){
    f = 0;
    v.resize(10) ;
    rep(i,10){
      v[i] = s[i] - '0' ;
    }
    while(v.size() != 1){
      rep(i,v.size()-1){
        v[i] = (v[i] + v[i+1]) % 10 ;
      }
      v.erase(v.end()-1) ;
    }
    cout << v[0] << endl;
  }
  return 0;
}

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

int main() {
    int n;cin>>n;
    int a[n];
    int c[n+1]{};
    ll ans=0;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        ans+=c[a[i]];
        c[a[i]]++;
    }
    for (int i=0;i<n;i++)
        cout<<ans-c[a[i]]+1<<endl;
    return 0;
}

Measured memory_bytes: 4096