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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
    ll n,k;
    cin >> n >> k;
    vll pref(n+2);
    pref[0]=0;
    for(int i=0;i<=n;i++){
    	if(i) pref[i+1] = pref[i] + i;
    	else pref[i+1] = i;
    }
    ll ans=0;
    for(int i=k;i<=n+1;i++){
    	ll mx = pref[n+1] - pref[n+1-i] ;  // 0 1 2 3 
   		ll mn = pref[i];
   		ans = (ans + mx-mn+1)%MOD;	
    }
    cout << ans;
  }
  

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<62);

using namespace std;

bool prime(ll k){
	for(ll i = 2; i * i <= k; i++){
		if( k % i == 0) return 0;
	}
	return 1;
}

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a, b; cin >> a>> b;

	set<ll> s1, s2;
	for(ll i = 1; i * i <= a; i++){
		if(a % i == 0){
			s1.insert(i);
			s1.insert(a/i);
		}
	}
	for(ll i = 1; i * i <= b; i++){
		if(b % i == 0){
			s2.insert(i);
			s2.insert(b/i);
		}
	}
	vi v;
	for(auto k : s1){
		if(s2.find(k) != s2.end()){
			v.pb(k);
		}
	}
	ll ans = 0;
	f(i, sz(v)){
		// DBG(v[i]);
		if(prime(v[i])) ans++;
	}

	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    set<ll>A;
    for(ll i=0;i<n;i++){
        ll a;cin>>a;
        A.insert(a);
    }
    ll m;cin>>m;
    set<ll>B;
    for(ll i=0;i<m;i++){
        ll b;cin>>b;
        B.insert(b);
    }
    set<ll>c;
    set_union(all(A),all(B),inserter(c,c.begin()));
    for(auto it=c.begin();it!=c.end();it++){
        cout<<*it<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 40736
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    int x,y;
    cin>>x>>y;

    if (y%2==0 and 2*x<=y and y<=4*x){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }













}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int exp(int a, int b)
{
    if (b == 0)
    {
        return 1;
    }
    return a * exp(a, b - 1);
}

int main()
{
    int K;
    vector<int> A(3);
    rep(0, i, 3)
    {
        cin >> A[i];
    }
    cin >> K;
    sort(all(A));
    cout << A[0] + A[1] + A[2] * exp(2, K) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n, i; cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    long long n,x;cin >> n >> x;
    vector<long long> a;
    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        long long c;
        cin >> c;
        if(c > x){
            cnt += ((-1)*(x - c));
            c += (x - c);   
        }
        //cout << c << " ";
        //cout <<cnt << endl;
        a.push_back(c);
    }
//cout << endl;

    for(long long i = 0; i < n - 1; i++){
        if(a[i] + a[i+1] > x){
            long long l = (a[i+1] + a[i]) - x;
            a[i+1] -= l;
            cnt+= l;
        }
    }

    if((a[0] + a[1]) > x){
        long long l = (a[0] + a[1]) - x;
        a[0] -= l;
        cnt+= l;
    }

    // for(long long i = 0; i < n; i ++){
    //     cout << a[i] << " ";
    // }

    cout << cnt << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    for(int i = 1; i < S.size(); i++) {
        if(S[i-1] == 'A' && S[i] == 'A') {
            cout << "NO" << endl;
            return 0;
        }
    }
    int index = 0;
    if(S[index] == 'A') index++;
    if(S.size() == index || S[index] != 'K') {
        cout << "NO" << endl;
        return 0;
    }
    index++;
    if(S.size() == index || S[index] != 'I') {
        cout << "NO" << endl;
        return 0;
    }
    index++;
    if(S.size() == index || S[index] != 'H') {
        cout << "NO" << endl;
        return 0;
    }
    index++;
    if(index < S.size() && S[index] == 'A') index++;
    if(S.size() == index || S[index] != 'B') {
        cout << "NO" << endl;
        return 0;
    }
    index++;
    if(index < S.size() && S[index] == 'A') index++;
    if(S.size() == index || S[index] != 'R') {
        cout << "NO" << endl;
        return 0;
    }
    index++;
    if(index < S.size() && S[index] == 'A') index++;
    if(index != S.size()) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;
// const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// struct edge {int to, cost;};
// vector<edge> graph[MAX];
// bool visited[MAX];
// int dist[MAX];

int main() {
    // input
    string s;
    cin >> s;
    // solve
    vector<int> sa = suffix_array(s);
    ll ans  = 1LL * s.size() * (s.size()+1) / 2;
    for (auto x : lcp_array(s, sa)) {
        ans -= x;
    }
    cout << ans << endl;
}

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

int main() {
    int h,w,ans=1,ty;
    cin>>h>>w;
    vector<string>grid(h);
    rep(i,h)cin>>grid[i];
    rep(i,h)rep(j,w)if(grid[i][j]=='#'){
        ty=1;
        if(i>0&&grid[i-1][j]=='#')ty=0;
        else if(i<h-1&&grid[i+1][j]=='#')ty=0;
        else if(j>0&&grid[i][j-1]=='#')ty=0;
        else if(j<w-1&&grid[i][j+1]=='#')ty=0;
        
        if(ty)ans=0;
    }
    if(ans)cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 1e6 + 11;
LL x;
LL f[N];
LL gao(LL a) {
	//cout << a << endl;
	if (a == 1)return 1;
	if (a < N && f[a])return f[a];
	if (a >= N) {
		return 1 + 2ll * gao(a / 2);
	} else {
		return (f[a] = 1 + 2ll * gao(a / 2));
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin >> x;
	cout << gao(x) << endl;
	return 0;
}


Measured memory_bytes: 4352
#include <cstdio>

int main(){
	while(1){
		int n;
		if(scanf("%d",&n) == EOF){
			return 0;
		}
		printf("3C");
		n = n % 39;
		if(n == 0){
			printf("39\n");
		}
		else if (n < 10){
			printf("0%d\n",n);
		}
		else{
			printf("%d\n",n);
		}
	}
	return 0;
}



Measured memory_bytes: 2692
S=input()
if S=="SUN":
  print('7')
elif S=="MON":
  print('6')
elif S=="TUE":
  print('5')
elif S=="WED":
  print('4')
elif S=="THU":
  print('3')
elif S=="FRI":
  print('2')
else:
  print('1')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll f(ll n) {
  if (n == 1) return 1;
  return 1 + 2*f(n/2);
}

int main () {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}

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

static const int MAX = 500;
double p[MAX + 1];
double q[MAX + 1];
double w[MAX + 2][MAX + 2];
double e[MAX + 2][MAX + 2];
double r[MAX + 1][MAX + 1];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> p[i];
    }
    for (int i = 0; i <= n; ++i)
    {
        cin >> q[i];
    }
    for (int i = 1; i != n + 2; ++i)
    {
        e[i][i-1] = q[i-1];
        w[i][i-1] = q[i-1];
    }

    for (int l = 1; l <= n; ++l)
    {
        for (int i = 1; i <= n - l + 1; ++i)
        {
            int j = i + l - 1;
            e[i][j] = (1 << 21);
            w[i][j] = w[i][j-1] + p[j] + q[j];
            for (int k = i; k <= j; ++k)
            {
                double t = e[i][k-1] + e[k+1][j] + w[i][j];
                if (t < e[i][j])
                {
                    e[i][j] = t;
                    r[i][j] = k;
                }
            }
        }
    }
    cout << fixed << setprecision(8) << e[1][n] << endl;
    return 0;
}


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 1e5;
using P = pair<int,int>;

vector<P> g[MAX];
vector<int> c(MAX,-1);

void dfs(int v, int u, int p) {
  int t = 1;
  for(auto k : g[v]) {
    if(c[k.second] == -1) {
      if(t == p) {
        c[k.second] = ++t;
        dfs(k.first,v,t);
        t++;
      } else {
        c[k.second] = t++;
        dfs(k.first,v,t-1);
      }
    }
  }
}

int main(){
  int n;
  cin >> n;
  int a[n-1], b[n-1];
  vector<int> num(n,0);
  rep(i,n-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    num[a[i]]++; num[b[i]]++;
    g[a[i]].push_back(P(b[i],i));
    g[b[i]].push_back(P(a[i],i));
  }
  int m = 0;
  rep(i,n) m = max(m,num[i]);
  dfs(0,-1,-1);
  cout << m << endl;
  rep(i,n-1) cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 9216
// AOJ 2707: Jail
// 2017.10.9 bal4u@uu

#include <stdio.h>

int main()
{
	int n, k, k1, i;
	long long x;

	scanf("%d%d", &n, &k); k1 = k-1;
	for (x = 0, i = 1; i < n; i++)
		x = (x/k1)*k + x%k1 + 1;
	printf("%lld\n", x);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int s;
  cin >> s;

  // unordered_map<int, int> ai;

  // int i;
  // for (i = 1; !ai.count(s); ++i) {
  //   ai[s];
  //   if (s % 2) {
  //     s = s * 3 + 1;
  //   } else {
  //     s /= 2;
  //   }
  // }

  int i;
  for (i = 1; s != 1 && s != 2 && s != 4; ++i) {
    if (s % 2) {
      s = s * 3 + 1;
    } else {
      s /= 2;
    }
  }
  i += 3;

  cout << i << '\n';

  return 0;
}


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

ll n, x;
ll num_p[51] = {};
ll num_l[51] = {};

ll dfs(int level, ll &x) {
  // cerr << level << " " << x << " " << num_l[level] << " " << num_p[level] << endl;
  if (x >= num_l[level]) {
    x -= num_l[level];
    return num_p[level];
  }

  ll ret = 0;
  if (x > 0)
    x -= 1; // B
  if (x > 0)
    ret += dfs(level - 1, x); // (L-1) Burger
  if (x > 0)
    ret++, x -= 1; // P
  if (x > 0)
    ret += dfs(level - 1, x); // (L-1) Burger
  if (x > 0)
    x -= 1; // B;

  return ret;
}

int main() {
  cin >> n >> x;

  num_p[0] = 1;
  num_l[0] = 1;
  for (int i = 1; i < 51; i++) {
    num_p[i] = num_p[i - 1] * 2 + 1;
    num_l[i] = num_l[i - 1] * 2 + 3;
    // cerr << i << " " << num_p[i] << " " << num_l[i] << endl;
  }

  cout << dfs(n, x) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long long hw[2];
  scanf("%lld %lld", hw, hw + 1);

  long long ret = 10E11;

  for (int turn = 0; turn < 2; turn++) {
    long long h = hw[turn];
    long long w = hw[1 - turn];

    if (h % 3 == 0) {
      ret = 0;
    } else {
      ret = (ret < w) ? ret : w;
    }

    for (long long i = 1; i < h; i++) {
      long long a = i * w;      
      long long w_half = w / 2;
      long long b = (h - i) * w_half;
      long long c = (h - i) * (w - w_half);

      long long Smax = (a > b) ? a : b;
      Smax = (c > Smax) ? c : Smax;
      long long Smin = (a < b) ? a : b;
      Smin = (c < Smin) ? c : Smin;

      if (ret > Smax - Smin) ret = Smax - Smin;
    }
  }

  printf("%lld\n", ret);
}


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

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	int N;
	char s[101];
	char t[101];
	cin >> N >> s >> t;
	Rep(i, N + 1){
		char st[201] = "";
		strncpy(st, s, i);
		strcat(st, t);
		if(strncmp(st, s, N) == 0){
			PrintLn(i + N);
			return 0;
		}
	}
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;
    ll x = min(a, k);
    a -= x;
    k -= x;
    if (a == 0) {
        x = min(b, k);
        b -= x;
        k -= x;
    }
    cout << a << ' ' << b << '\n';
    return 0;
}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


int main(){
	
	int n, m;
	
	cin >> n>> m;
	
	int k,pp;

	//以下がダメな理由を考えておくこと
	/*
	vector<vector<int> > arr(m, vector<int>(n));
	*/

	//以下がダメな理由を考えておくこと
	/*
	for (int i = 0; i < m; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> pp;
			arr[i][pp-1]++;
		}
	}
	*/

	vector<vector<int>> arr(m);

	for (int i = 0; i < m; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> pp; --pp;
			//cin >> pp;
			arr[i].push_back(pp);
		}
	}

	
	vector<int> p(m);

	for (int i = 0; i < m; i++) cin >> p[i];
	
	//bit全探索
	int ans = 0;	
	
	//ありうるパターンを列挙
	//pow→xのn乗（この場合は2の3乗）
	for (int i = 0; i < (1<<n); i++) {
		
		//判定部分
		bool ok = true;

		//Sw個数分探索
		//j→行を変化させている(電球ごと)
		for (int h = 0; h < m; h++) {

			int count = 0;

			for (int j : arr[h]) {

				if (i & (1 << j))count++;
			}
				/*
				//k→列を変化させている（同じ電球の中でのSwの変化）
				for (int k = 0; k < n; k++) {
					//各パターンでのbit列の対応づけ
					//該当の部分がある
					if (i& (1<<arr[j][k]))count++;
				}
				*/

				//条件判定開始
				//列ごとに1回でも以下に引っかかったらアウト
				//その後のSWでOKでもOKに戻すことがない

				if (p[h] != count % 2) {
					ok = false;
				}

			
		}
		//これは各ビット列ごとに実施
		//そのパターンで一度もfalseに引っかからなければ以下。
		if (ok) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// 出力用(カードの種類ごとに用意)
		StringBuilder output_s = new StringBuilder();
		StringBuilder output_h = new StringBuilder();
		StringBuilder output_c = new StringBuilder();
		StringBuilder output_d = new StringBuilder();
		// 種類ごとに全部の数字を配列で用意
		int[] spades = new int[13];
		int[] hearts = new int[13];
		int[] clubs = new int[13];
		int[] diamonds = new int[13];
		
		// 初期化
		for (int i = 0; i < 13; i++) {
			spades[i] = i + 1;
			hearts[i] = i + 1;
			clubs[i] = i + 1;
			diamonds[i] = i + 1;
		}
		
		int amount = scan.nextInt();
		String mark;
		int number;
		// 持っているカードのところを0で上書き
		for (int j = 0; j < amount; j++) {
			mark = scan.next();
			number = scan.nextInt();
			if ("S".equals(mark)) {
				spades[number - 1] = 0;
			}
			if ("H".equals(mark)) {
				hearts[number - 1] = 0;
			}
			if ("C".equals(mark)) {
				clubs[number - 1] = 0;
			}
			if ("D".equals(mark)) {
				diamonds[number - 1] = 0;
			}
		}
		
		// 0ではない要素(足りてないカード)を出力用のやつにくっつける
		for (int i = 0; i < 13; i++) {
			if (spades[i] != 0) {
				output_s.append("S" + " " + (i + 1)).append('\n');
			}
			if (hearts[i] != 0) {
				output_h.append("H" + " " + (i + 1)).append('\n');
			}
			if (clubs[i] != 0) {
				output_c.append("C" + " " + (i + 1)).append('\n');
			}
			if (diamonds[i] != 0) {
				output_d.append("D" + " " + (i + 1)).append('\n');
			}
		}
		
		// 出力
		System.out.print(output_s);
		System.out.print(output_h);
		System.out.print(output_c);
		System.out.print(output_d);
	}

}

Measured memory_bytes: 18084
n = int(input())
h = []
tmp = ["a", "b", "c", "d", "e", "f", "g",
       "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
        "r", "s", "t", "u", "v", "w", "x", "y", "z"]
name = ""

while n != 0:
    mod = n % 26
    h.append(mod)
    n //= 26
    if mod == 0:
        n -= 1
h.reverse()
for i in h:
    name += tmp[i - 1]
print(name)


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

int main() {
    long n, m, l;
    cin >>n >>m >>l;
    vector<vector<long>> A(n, vector<long> (m, 0));
    vector<vector<long>> B(m, vector<long> (l, 0));
    for (long i=0; i<n; i++)
        for (long j=0; j<m; j++)
            cin >>A.at(i).at(j);
    for (long i=0; i<m; i++)
        for (long j=0; j<l; j++)
            cin >>B.at(i).at(j);
    for (long i=0; i<n; i++) {
        for (long j=0; j<l; j++) {
            long S=0;
            for (long x=0; x<m; x++)
                S +=A.at(i).at(x)*B.at(x).at(j);
            if (0!=j)
                cout <<' ';
            cout <<S;
        }
        cout <<endl;
    }
    return 0;
}


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

using namespace std;


int main() {
	//code
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m,sum=0;
        cin>>n>>m;
        vector<int > a(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        if(sum>n) cout<<"-1"<<endl;
        else cout<<n-sum<<endl;
        
	}
	return 0;
	
}

Measured memory_bytes: 7216
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int h,N;
  cin >> h >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  ll sum=0;
  rep(i,N){
    sum+=a[i];
  }
  if(sum>=h){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int R,G;
int main(){
    cin>>R>>G;
    cout<<G+(G-R)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long a, b;
  Solver() {
    S002 r;
    r >= a >= b;
  }
  void solve() {
    if( a == 1 ) a = 14;
    if( b == 1 ) b = 14;
    if( a < b ) puts("Bob");
    else if( a > b ) puts("Alice");
    else puts("Draw");
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 049 D / Link: http://abc049.contest.atcoder.jp/tasks/abc049_d  ----- */



struct UnionFind {
	vector<int> data;
	UnionFind(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

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

	LL N, K, L; cin >> N >> K >> L;
	UnionFind A(N), B(N);
	FOR(i, 0, K) {
		int a, b; cin >> a >> b;
		a--, b--;
		A.unionSet(a, b);
	}
	FOR(i, 0, L) {
		int a, b; cin >> a >> b;
		a--, b--;
		B.unionSet(a, b);
	}
	map<PII, int>M;
	FOR(i, 0, N) {
		M[PII(A.root(i), B.root(i))]++;
	}

	FOR(i, 0, N) {
		cout << M[PII(A.root(i), B.root(i))] << " \n"[i == N - 1];
	}

	return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll A[3][3];
ll N;
ll b;

void solve() {
	rep(i, 3) rep(j, 3) cin >> A[i][j];
	cin >> N;
	rep(i, N) {
		cin >> b;
		rep(j, 3) rep(k, 3) if (b == A[k][j]) A[k][j] = -1;
	}
	rep(i, 3) {
		if (A[i][0] == -1 && A[i][2] == -1 && A[i][1] == -1) {
			cout << "Yes" << endl;
			return;
		}
	}
	rep(j, 3) {
		if (A[0][j] == -1 && A[2][j] == -1 && A[1][j] == -1) {
			cout << "Yes" << endl;
			return;
		}
	}
	if (A[0][0] == -1 && A[2][2] == -1 && A[1][1] == -1) {
		cout << "Yes" << endl;
		return;
	}
	if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) {
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD=1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();
        int[] fridge = new int[a];
        int[] microwave = new int[b];
        int min_fridge=Integer.MAX_VALUE;
        int min_microwave = Integer.MAX_VALUE;

        for(int i=0;i<a;i++){
            fridge[i]=sc.nextInt();
            min_fridge=Math.min(min_fridge,fridge[i]);
        }
        for(int i=0;i<b;i++){
            microwave[i]=sc.nextInt();
            min_microwave=Math.min(min_microwave,microwave[i]);
        }

        int ans = min_fridge+min_microwave;

        for(int i=0;i<m;i++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            int c = sc.nextInt();
            ans = Math.min(ans,fridge[x]+microwave[y]-c);
        }

        System.out.println(ans);


    }
}




Measured memory_bytes: 153916
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,l,min1;
  scanf("%d %d",&n,&l);
  int i=0;
  int l1[n];
  int cnt=0;
  int min=10000;
  for(i=0;i<n;i++){

    l1[i]=l+i;
    //printf("%d",l1[i]);
  }
  for(i=0;i<n;i++){
    cnt+=l1[i];
  }
  for(i=0;i<n;i++){
    if(abs(l1[i])<min){
      min=abs(l1[i]);
      min1=i;
    }
  }
  printf("%d",cnt-l1[min1]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;


signed main()
{
    int N; cin>>N;
    vint a(N),b(N);

    REP(i,N) cin>>a[i];
    REP(i,N) cin>>b[i];

    for(int i=1;i<N;i++) a[i]+=a[i-1];
    for(int i=N-2;i>=0;i--) b[i]+=b[i+1];

    int ans=0;
    REP(i,N){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long long n,m;
    long long S,L;
    long long i,k,j;
    scanf("%lld%lld",&n,&m);
    k=m-n-n;
    if(k>0)
    {
        m=m-n-n;
        m=m/4;
        S=n+m;
    }
    else if(k<0)
    {
        S=m/2;
    }
    printf("%lld",S);
    return 0;
}

Measured memory_bytes: 128
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	// 入力
	int N;
	cin >> N;
	
	N = N * 100;
	int ret;
	for (int i = 1; i <= 50000; i++) {
		ret = i * 108;
		ret = ret - (ret % 100);
		if (ret == N) {
			cout << i << endl;
			return 0;
		}
	}

	cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
S = list(input())
l = len(S)
counter1 = 0
counter2 = 0
current1 = '0'
current2 = '1'
for i in range(l):
    if S[i] != current1:
        counter1 += 1
    else:
        counter2 += 1
    current1, current2 = current2, current1
print(min(counter1, counter2))

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

int main()
{
    int n, x[100], y[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];

    // p = 1
    int d1 = 0;
    for (int i = 0; i < n; i++) {
        d1 += abs(x[i] - y[i]);
    }
    printf("%d\n", d1);

    // p = 2
    double d2 = 0;
    for (int i = 0; i < n; i++) {
        d2 += (x[i] - y[i]) * (x[i] - y[i]);
    }
    d2 = sqrt(d2);
    printf("%.6f\n", d2);

    // p = 3
    double d3 = 0;
    for (int i = 0; i < n; i++) {
        d3 += abs((x[i] - y[i])) * (x[i] - y[i]) * (x[i] - y[i]);
    }
    d3 = pow(d3, 1.0/3.0);
    printf("%.6f\n", d3);

    // p = INF
    int di = 0;
    for (int i = 0; i < n; i++) {
        di = max(di, (int)abs(x[i] - y[i]));
    }
    printf("%d\n", di);

    return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
//{
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define all(v) (v).begin(),(v).end()
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)


#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
};
//{
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);
//}

int n, k;
VI v;

int dodaj[2000005];

int main() {
	read2(n, k);
	readv(v, n);
	if (k > 50) {
			FOR(i,0,n) {
				printf("%d ", n);
			}
			printf("\n");
			return 0;
	}
	FOR(j,0,k) {
		FOR(i,0,n) dodaj[i] = 0;
		FOR(i,0,n) {
			int minx = max(0, i-v[i]);
			int maxx = min(n-1, i+v[i]);
			dodaj[minx]++;
			dodaj[maxx+1]--;
		}
		int act = 0 ;
		FOR(i,0,n) {
			act += dodaj[i];
			v[i] = act;
		}

	}
	FOR(i,0,n) {
		printf("%d ", v[i]);
	}
	printf("\n");
}


Measured memory_bytes: 5032
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, K;

	std::cin >> N >> K;
	ll ans = N * N;
	repeq(b, 1, N) {
		ans -= N / b * min(K, b) + max(0LL,min(K-1, N % b));
	}
	std::cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ull cusum[100005];

ll getnum(ull x, const vector<ll>& v){
  ll num = 0;
  rep(i,v.size()){
    ll lb = -1, ub = v.size();
    while(ub-lb>1){
      ll mid = (lb+ub)/2;
      if(mid >=0 && v[i] + v[mid]>=x) lb = mid;
      else ub = mid;
    }
    num += ub;
  }
  return num;
}
ull getval(ull x, const vector<ll>& v){
  ull ret = 0;
  rep(i,v.size()){
    ll lb = -1, ub = v.size();
    while(ub-lb>1){
      ll mid = (lb+ub)/2;
      if(mid >=0 && v[i]+v[mid]>=x) lb = mid;
      else ub = mid;
    }
    if(lb>=0){
      ret += cusum[lb];
      ret += v[i] * (ull)ub;
    }
  }
  return ret;
}

bool check1(ull x, const vector<ll>& v, ll M){
  return getnum(x,v) >= M;
}
bool check2(ull x, const vector<ll>& v, ll M){
  return getnum(x,v) < M;
}

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  sort(ALLOF(v));
  reverse(ALLOF(v));
  cusum[0] = v[0];
  REP(i,1,N){
    cusum[i] = cusum[i-1] + v[i];
  }
  
  ll ret1, ret2;
  {
    ull lb=0, ub=ULLONG_MAX;
    while(ub-lb>1){
      ull mid = lb + (ub-lb)/2;
      if(check1(mid, v, M)) lb = mid;
      else ub = mid;
    }
    ret1 = lb;
  }
  {
    ull lb=0, ub=ULLONG_MAX;
    while(ub-lb>1){
      ull mid = lb + (ub-lb)/2;
      if(check2(mid, v, M)) ub = mid;
      else lb = mid;
    }
    ret2 = ub;
  }

  ll m1 = getnum(ret1, v);
  ll m2 = getnum(ret2, v);
  //cout << ret1 << " " << m1 << endl;
  //cout << ret2 << " " << m2 << endl;

  if(m1 == M){
    cout << getval(ret1, v) << endl;
  }else{
    ull ret = getval(ret2, v);
    ret += ret1 * (M-m2);

    cout << ret << endl;
  }
  
  return 0;
}



Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+7, LINF = 1e18;


int main()
{
    ll n,d,ans=0;
    cin>>n>>d;
    ll a[n][d];
    rep(i,n)rep(j,d)cin>>a[i][j];
    rep(i,n)for(ll j=i+1;j<n;j++){
        ll sum=0;
        rep(k,d) sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]); 
        map<ll,ll> z;
        for(ll i=2;sum>1;i++)if(sum%i==0)sum/=i,z[i]++,i--;
        bool sq=1;
        for(auto x:z) if(x.second%2==1)sq=0;
        if(sq==1)ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int H,W;
	cin>>H>>W;
	int m[H+2][W+2]={0};
	queue<pair<int,int>> start;
	char c;
	pair<int,int> p;
	rep(i,1,H+1){
		rep(j,1,W+1){
			cin>>c;
			if(c=='.'){
				m[i][j]=1;
				p.first=i;
				p.second=j;
				start.push(p);
			}
		}
	}
	int ans=0;
	while(!start.empty()){
		pair<int,int>st=start.front();start.pop();
		queue<pair<int,int>> q;

		int cnt[H+2][W+2]={0};
		cnt[st.first][st.second]=1;
		q.push(st);
		while(!q.empty()){
			int pre_h,pre_w;
			pair<int,int> next;
			pair<int,int> v=q.front();q.pop();
			pre_h = v.first;
			pre_w = v.second;
			if(m[pre_h+1][pre_w]==1&&cnt[pre_h+1][pre_w]==0){
				next.first =pre_h+1;
				next.second=pre_w;
				cnt[pre_h+1][pre_w]=cnt[pre_h][pre_w]+1;
				ans=max(ans,cnt[pre_h+1][pre_w]);
				q.push(next);
			}
			if(m[pre_h-1][pre_w]==1&&cnt[pre_h-1][pre_w]==0){
				next.first =pre_h-1;
				next.second=pre_w;
				cnt[pre_h-1][pre_w]=cnt[pre_h][pre_w]+1;
				ans=max(ans,cnt[pre_h-1][pre_w]);
				q.push(next);
			}
			if(m[pre_h][pre_w+1]==1&&cnt[pre_h][pre_w+1]==0){
				next.first =pre_h;
				next.second=pre_w+1;
				cnt[pre_h][pre_w+1]=cnt[pre_h][pre_w]+1;
				ans=max(ans,cnt[pre_h][pre_w+1]);
				q.push(next);
			}
			if(m[pre_h][pre_w-1]==1&&cnt[pre_h][pre_w-1]==0){
				next.first =pre_h;
				next.second=pre_w-1;
				cnt[pre_h][pre_w-1]=cnt[pre_h][pre_w]+1;
				ans=max(ans,cnt[pre_h][pre_w-1]);
				q.push(next);
			}
		}
	}
	if(ans) ans--;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int a, b;

int main(int argc, char *argv[]) {
    scanf("%d%d", &a, &b);
    int cnt = 0;
    for (int i = a; i < b + 1; ++i) {
        if (i % 10 == i / 10000 &&
            (i / 10) % 10 == (i - 10000 * (i / 10000)) / 1000)
            ++cnt;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 256
def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans)


from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


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

int main(){
  int n, k, cnt = 0;
  cin >> n >> k;
  vector<int> d(k), ans(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int c;
      cin >> c;
      ans.at(c - 1)++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans.at(i) == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3560