akhauriyash/Code-Regression huggingface dataset:
'use strict'
// L+i−1
function main(input) {
  input = input.split(' ')
  let apples = []
  let min = Number.MAX_SAFE_INTEGER
  const N = ~~input[0]
  const L = ~~input[1]

  for (let i = 0; i < N; i++) {
    if (Math.abs(L + i) < Math.abs(min)) {
      min = L + i
    }
    apples.push(L + i)
  }
  console.log(apples.reduce((a, b) => a + b) - min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read(),m=read();
	cout<<(n*3+m)/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int h,w,d;
           cin>>h>>w>>d;
           vector<vin> a(h,vin(w));
           rep(i,0,h)rep(j,0,w)cin>>a[i][j];
           map<int,P> pl;
           rep(i,0,h){
            rep(j,0,w){
             pl[a[i][j]]=mp(i+1,j+1); 
            }
           }
           vll sum(h*w+1);//1ind 
           rep(i,1,d+1){
            sum[i]=0; 
           }
           rep(i,d+1,h*w+1){
             sum[i]=sum[i-d];
             sum[i]+=abs(pl[i].first-pl[i-d].first)+abs(pl[i].second-pl[i-d].second);
           }
           int q;
           cin>>q;
           int l,r;
           rep(i,0,q){
             cin>>l>>r;
             cout<<sum[r]-sum[l]<<endl;
           }
}

Measured memory_bytes: 9700
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int a[1001];
	int d;
	
	while (scanf("%d", &n), n != 0){
		d = 1000001;
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		
		sort(a, a + n);
		
		for (int i = 1; i < n; i++){
			if (a[i] <= a[i-1]){
				if (a[i-1] - a[i] < d) d = a[i-1] - a[i];
			}
			if (a[i] > a[i-1]){
				if (a[i] - a[i-1] < d) d = a[i] - a[i-1];
			}
		}
		
		printf("%d\n", d);
	}
}

Measured memory_bytes: 2624
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d,e,sum;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	sum=0;
	if(a<0){
		a*=-1;
		sum+=c*a+d;
	}
	else{
		b-=a;
	}
	sum+=b*e;
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		StringBuilder sb = new StringBuilder();
		while (n > 0L) {
			--n;
			sb.append((char) ('a' + n % 26L));
			n /= 26L;
		}
		sb.reverse();
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 35776
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
    int a[1000], n, x, min, ans = 0;
     for (int i = 0; i < 2; ++i) {
         scanf("%d", &a[i]);
    }
    n = a[0];
    x = a[1];
    for (int i = 0; i < n; ++i) {
         scanf("%d", &a[i]);
    }
    min = a[0];
    for(int i=0; i<n; i++){
        if(min>a[i]) min = a[i];
        x = x - a[i];
        ++ans;
    }
    while(x>=min){
        x = x-min;
        ++ans;
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll op(ll a, ll b) { return max(a, b); };
ll e() { return -INF; };

// ACL template
int main() {
    ll N, Q;
    cin >> N >> Q;
    vl A(N);
    rep(i, N) cin >> A[i];

    segtree<ll, op, e> seg(A);

    ll compv;
    auto comp = [&](ll a) { return a < compv; };

    rep(_, Q) {
        ll t, a, b;
        cin >> t >> a >> b;
        if(t == 1){
            seg.set(a - 1, b);
        }else if(t == 2){
            cout << seg.prod(a - 1, b) << '\n';
        }else{
            compv = b;
            cout << seg.max_right(a - 1, comp) + 1 << '\n';
        }
    }
}

Measured memory_bytes: 9048
def main():
    from bisect import bisect_left
    I=10**9+1
    n,q,*t=map(int,open(0).read().split())
    d=tuple(t[-q:])
    t=t[:-q]
    N0=2**(q-1).bit_length()
    data=[I]*2*N0
    for x,l,r in sorted(((x,bisect_left(d,s-x)+N0,bisect_left(d,t-x)+N0)for s,t,x in zip(t[::3],t[1::3],t[2::3])),reverse=1):
        while l<r:
            if r&1:
                r-=1
                data[r-1]=x
            if l&1:
                data[l-1]=x
                l+=1
            l>>=1
            r>>=1
    for k in range(N0-1,q+N0-1):
        s=I
        while~k:
            if data[k]<s:s=data[k]
            k=(k-1)//2
        print(-(s==I)or s)
if __name__=='__main__':
    main()

Measured memory_bytes: 166364
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

ll modInv(ll n){
    return powmod(n, mod-2) % mod;
}

ll comb(ll n, ll r){
    ll m1 = 1, m2 = 1;
    REP(i, r){
        m1 = (m1 * (n-i)) % mod;
        m2 = (m2 * (r-i)) % mod;
    }
    return (m1 * modInv(m2)) % mod;
}

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    ll ans = powmod(2, n) - 1;
    ans -= comb(n, a) + comb(n, b);
    ans += mod + mod;
    ans %= mod;
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 384
from itertools import combinations

n = int(input())
a_array = [int(x) for x in input().split()]
q = int(input())
m_array = [int(x) for x in input().split()]

array = []
for j in range(n + 1):
    x = combinations(a_array, j)
    for y in x:
        array.append(sum(y))

for m in m_array:
    print("yes" if m in array else "no")


Measured memory_bytes: 43056
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int A, B, M;
    cin >> A >> B >> M;
    VI a(A);
    REP(i, A) cin >> a[i];
    VI b(B);
    REP(i, B) cin >> b[i];
    VI x(M), y(M), c(M);
    REP(i, M) {
        cin >> x[i] >> y[i] >> c[i];
    }

    int ans = INF;
    REP(i, M) {
        chmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }

    SORT(a);
    SORT(b);
    chmin(ans, a[0] + b[0]);

    cout << ans << endl;
}


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

const int INF = 1e9+7; 

int main(){
    int n;cin>>n;
    vector<int> nums(n);
    for(int i=0;i<n;i++) cin>>nums[i];
    vector<int> dp(n+1,INF);
    dp[0] = 0;
    dp[1] = 0;
    for(int i=1;i<dp.size();i++){
    	for(int x:{i-1,i-2}){
    		if(x>0) dp[i] = min(dp[i],abs(nums[x-1]-nums[i-1])+dp[x]);
    	}
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4036
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DModSum {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        ll n;
        in>>n;
        out<<n*(n-1)/2<<endl;
    }
};

int main() {
    DModSum solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func gcd(x int, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	y := nextInt()

	if x < y {
		y, x = x, y
	}

	fmt.Println(gcd(x, y))

}



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


// type {{{
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
// }}}


// macro {{{
#define rep(i,n) for (ll i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i,n) for (ll i=1, i##_len=(n); i<=i##_len; ++i)
#define FOR(i,a,n) for (ll i=(a), i##_len=(n); i<i##_len; ++i)
#define SZ(x) ((ll)(x).size())
#define all(x) begin(x),end(x)
// }}}


// debug {{{
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    rep (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}
// }}}


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



// constants {{{
#define inf(T) numeric_limits<T>::max()
const ll MOD = 1e9+7;
const ld EPS = 1e-9;
// }}}


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

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vvi t(n, vi(n+1));
        rep(i, n) rep(j, n+1) cin >> t[i][j];

        auto cost = [&](int s, int j) {
            int ret = t[j][0];
            rep(i, n) if (s >> i & 1) {
                chmin(ret, t[j][i+1]);
            }
            return ret;
        };

        vi dp(1<<n, inf(int));
        rep(i, n) {
            dp[1<<i] = t[i][0];
        }
        rep(s, 1<<n) {
            if (dp[s] == inf(int)) continue;
            rep(j, n) {
                if (s >> j & 1) continue;
                chmin(dp[s | 1<<j], dp[s] + cost(s, j));
            }
        }

        int ans = dp[(1<<n)-1];
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3436
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;
int mod=998244353;

int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    {
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

int dis[100005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
     clock_t clk;
 	clk = clock();
 
// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    int d[n];
    int mx=0;
    int z=0;
    for(int i=0;i<n;i++)
    {
        cin>>d[i];
        if(d[i]==0)
            z++;
        mx=max(mx,d[i]);
        dis[d[i]]++;
    }
    if(z>1||d[0]!=0)
    {
        cout<<0;
        return 0;
    }
    // cout<<power(0,0,mod)<<"\n";
    int ans=1;
    for(int i=1;i<=mx;i++)
    {
        ans=(ans*power(dis[i-1],dis[i],mod));
        ans%=mod;
    }

    cout<<ans;
// -------------------------------------Code ends here------------------------------------------------------
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 1792
// 2011/08/24 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int data[100];
		for(int i=0; i<n; i++)
			cin >> data[i];

		int key;
		cin >> key;

		int cnt = 0;
		int left  = 0;
		int right = n-1;
		while(left<=right){
			int middle = (left+right)/2;
			cnt++;
			if(key==data[middle])
				break;
			else if(key<data[middle])
				right = middle-1;
			else
				left  = middle+1;
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

int main() {

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<vector<int>> ans(H, vector<int>(W, 0));
    for (int i = 0; i < B; i++) {
        for (int j = 0; j < A; j++) {
            ans[i][j] = 1;
        }
    }

    for (int i = B; i < H; i++) {
        for (int j = A; j < W; j++) {
            ans[i][j] = 1;
        }
    }

    for (int i = 0; i < H; i++) {
        for(int j = 0;j<W;j++) cout << ans[i][j];
        cout << endl;
    }

    return 0;
}




































Measured memory_bytes: 5120
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

#リストをソート
a = sorted(a)
b = sorted(b)
c = sorted(c)

# x以上のイテレータを
def lower_bound(arr , x):
    l = 0
    r = len(c)
    for j in range(30):
        mid = (l + r) // 2
        # print(l , r , mid)
        if x <= arr[mid]:
            r = mid
        else:
            l = mid
    return r


count = 0
for i in range(n):
    a_count = lower_bound(a , b[i])
    c_count = len(c) - lower_bound(c , b[i] + 1)
    count += a_count * c_count

print(count)


Measured memory_bytes: 29472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int main()
{
	 int n,m;
	cin>>n>>m;
	cout<<2*m-n; 
	return 0;
}












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

void fnInsertionSort(vector<int> &argviSort, int argiGap, int &argiSortCnt)
{
  for (int ixSorting = argiGap; ixSorting < argviSort.size() ; ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - argiGap;

    while (ixSorted >= 0              &&
           iTarget < argviSort[ixSorted])
    {
      argviSort[ixSorted + argiGap] = argviSort[ixSorted];
      ixSorted -= argiGap;

      argiSortCnt++;
    }
    argviSort[ixSorted + argiGap] = iTarget;
  }
}

void fnShellSort(vector<int> &argviSort, vector<int> &argviGap, int &argiSortCnt)
{
  for (int iGap = 1; iGap < argviSort.size(); iGap = 3 * iGap + 1)
    argviGap.push_back(iGap);
  
  for (int i = argviGap.size() - 1; i >= 0; i--)
    fnInsertionSort(argviSort, argviGap[i], argiSortCnt);
}

void fnOutput(const vector<int> &argviSort, const vector<int> &argviGap, int argiSortCnt)
{
  if (argviGap.size() == 0)             // argviGap.size() == 0 ?????´???
  {
    cout << 1 << endl;                    // argviGap.size() ??? 1 ??¨??¨???
    cout << 1 << endl;                    // argviGap[0]     ??? 1 ??¨??¨???
  }
  else
  {
    cout << argviGap.size() << endl;

    for (int i = argviGap.size() - 1; i >= 0; i--)
    {
      if (i != argviGap.size() - 1) cout << " ";
      cout << argviGap[i];
    }
    cout << endl;
  }

  cout << argiSortCnt << endl;

  for (int i = 0; i < argviSort.size(); i++)
    cout << argviSort[i] << endl;
}

int main()
{
  vector<int> viSort;
  vector<int> viGap;
  int iSortCnt = 0;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnShellSort(viSort, viGap, iSortCnt);
  fnOutput(viSort, viGap, iSortCnt);

  return 0;
}

Measured memory_bytes: 6728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
typedef pair<ll,ll> P;
#define N 100010
ll n,k;
vector<ll> v[N];
P d[N];
bool vis[N];
vector<P> koh;
int main(){
    cin>>n>>k;
    lol(i,n){
      ll a,b;cin>>a>>b;
      v[a].push_back(b);
      d[i]=make_pair(b,a);
    }
    lol(i,N){
      if(v[i].size()==0)continue;
      sort(v[i].begin(),v[i].end(),greater<ll>());
      koh.push_back(make_pair(v[i][0],i));
      vis[i]=0;
    }
    sort(d,d+n,greater<P>());
    sort(koh.begin(),koh.end(),greater<P>());
    ll cur=0,cnt=0;
    priority_queue<ll,vector<ll>,greater<ll> > q;
    lol(i,k){
      cur+=d[i].first;
      if(vis[d[i].second]==1){
	q.push(d[i].first);
      }
      else cnt++;
      vis[d[i].second]=1;
    }
    //cout<<endl;for(auto r:koh)cout<<r.first<<" "<<r.second<<endl;cout<<endl;
    //cout<<q.size()<<endl;
    ll ans=cur+cnt*cnt;
    for(auto r:koh){
      if(q.empty())break;
      ll val=r.first;
      ll ind=r.second;
      if(vis[ind])continue;
      cur+=val;
      cur-=q.top();q.pop();
      cnt++;
      //cout<<cur<<" "<<cnt<<endl;
      ans=max(ans,cur+cnt*cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    int n; cin >> n;
    vector<ll> h(n); rep(i,n) cin >> h[i];
    ll high = 0;
    int judge = 1;
    rep(i,n){
        if(high < h[i]) high = h[i];
        else{
            if(high - h[i] >= 2){
                judge = 0;
                break;
            }
        }
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int l;
  cin >> l;

  vector<int> sum_pow2{0}, pow2;
  int n = 0;
  for (int i = 1; i <= l; i *= 2) {
    sum_pow2.push_back(sum_pow2.back() + i);
    pow2.push_back(i);
    n++;
  }

  int m = (n - 1) * 2, lim = l;
  stringstream sout;
  for (int idx = 0, cur = l; cur != 1; idx++, cur /= 2) {
    if (cur % 2 == 1) {
      lim = lim - 1 - sum_pow2[idx];
      sout << idx + 1 << ' ' << n << ' ' << lim << '\n';
      m++;
      cur--;
    }

    if (idx < n - 1) {
      sout << idx + 1 << ' ' << idx + 2 << ' ' << 0 << '\n';
      sout << idx + 1 << ' ' << idx + 2 << ' ' << pow2[idx] << '\n';
    }
  }

  cout << n << ' ' << m << '\n';
  cout << sout.str();
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int N;
	cin >> N;
	int a[100000];
	int saidai = 0;
	int saidaii;
	rep(i, N) {
		cin >> a[i];
		if (saidai < a[i]){
			saidai = a[i];
			saidaii = i;
		}
	}
	double b;
	double saishou = 1e9;
	int kotae;
	rep(i, N) {
		b = abs(1.0 * a[i] - 1.0 * saidai / 2.0);
		if (saishou > b && saidaii != i) {
			saishou = b;
			kotae = a[i];
		}
	}
	cosp(saidai);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
object Main extends App {
    val steps = scala.io.StdIn.readLine.zipWithIndex
    val odd = steps.filter(s => (s._2 + 1) % 2 != 0).map(_._1)
    val even = steps.filter(s => (s._2 + 1) % 2 == 0).map(_._1)

    val isEasyOdd = odd.forall(s => Set('R', 'U', 'D').contains(s))
    val isEasyEven = even.forall(s => Set('L', 'U', 'D').contains(s))

    val isEasy = if (isEasyOdd && isEasyEven) "Yes" else "No"
    println(isEasy)
}

Measured memory_bytes: 25544
a,b,c,x,y=map(int,input().split())
if a+b <= 2*c:
    print(a*x+b*y)
elif x > y:
    print(min(a,2*c)*(x-y)+2*c*y)
else:
    print(min(b,2*c)*(y-x)+2*c*x)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int lo = d[n / 2 - 1];
    int hi = d[n / 2];
    cout << hi - lo << "\n";
    return 0;
}

Measured memory_bytes: 640
from itertools import accumulate
from bisect import bisect_right

N = int(input())
As = list(map(int, input().split()))

accAs = [0] + list(accumulate(As))

# As[iFr]～As[iTo]の和を求める
def getSum(iFr, iTo):
    return accAs[iTo+1] - accAs[iFr]


# As[iFr]～As[iTo]を前後半の総和の差が最小となるように分解する
def getDivision(iFr, iTo):
    sumB = getSum(iFr, iTo)
    iMid = bisect_right(accAs, accAs[iFr]+sumB/2, iFr+1, iTo+2) - 1

    diff1, diff2 = float('inf'), float('inf')
    if iMid != iFr:
        sum1L = getSum(iFr, iMid-1)
        sum1R = getSum(iMid, iTo)
        diff1 = abs(sum1L - sum1R)
    if iMid != iTo:
        sum2L = getSum(iFr, iMid)
        sum2R = getSum(iMid+1, iTo)
        diff2 = abs(sum2L - sum2R)

    return [sum1L, sum1R] if diff1 <= diff2 else [sum2L, sum2R]


# 真ん中の区切りを全通り試す
ans = float('inf')
for iMid in range(1, N-3+1):
    sumD = []
    sumD += getDivision(0, iMid)
    sumD += getDivision(iMid+1, N-1)

    ans = min(ans, max(sumD) - min(sumD))

print(ans)


Measured memory_bytes: 24176
a, b, c = map(int, input().split())
A = a % 2
B = b % 2
C = c % 2
cnt = 0
s = [a,b,c]
flag = [0,0,0,0]
if A == B == C:
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[0] += 1
elif A == B:
    cnt = cnt + 1
    a = a + 1
    b = b + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[1] += 1
elif B == C:
    cnt = cnt + 1
    b = b + 1
    c = c + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[2] += 1
elif C == A:
    cnt = cnt + 1
    c = c + 1
    a = a + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[3] += 1
print(cnt)
# print(t)
# print(flag)

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

int main(){
	int K,A,B;
    cin >> K >> A >> B;
     
    bool ans = false;
    for(int i=A; i<=B; i++){
     	if(i%K==0)
        	ans = true;
    }
    if(ans)
    	cout << "OK" <<endl;
    else
    	cout << "NG" <<endl;
}

Measured memory_bytes: 3632
import itertools
import math
import fractions
import functools
s = input()
y = int(s[0]) * 1000 + int(s[1]) * 100 + int(s[2]) * 10 + int(s[3])

m = int(s[5]) * 10 + int(s[6])
d = int(s[8]) * 10 + int(s[9])

if (y == 2019 and m > 4) or y >= 2020:
    print('TBD')
else:
    print('Heisei')

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

int main (){
    ll N;
    cin >> N;
    ll t;
    ll  ans= 1;

    for(ll i = 0; i < N; i++){
        cin >> t;
        if(ans > 1000000000000000000/t) {
            for(int j = i + 1; j < N; j++) {
                cin >> t;
                if(t) {
                    continue;
                }
                cout << 0 << endl;
                return 0;
            }
            cout << -1 << endl;
            //cout << i << ',' << t << endl;
            return 0;
        }
        ans *= t;

    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << fixed << setprecision(15) << 2*r*3.141592 << endl;
    return 0;
}

Measured memory_bytes: 3808
require 'pp'

# サイズが H, W の文字の2次元配列を返却する
def gets_HW_char
  h, w = gets.split.map(&:to_i)
  board = h.times.map { gets.chomp.chars }
  return h, w, board
end

H, W, b = gets_HW_char

# 4方向走査
H.times do |i|
  W.times do |j|
    if b[i][j] == "#"
      canDraw = false
      [
        [-1,  0], # 上
        [ 1,  0], # 下
        [ 0, -1], # 左
        [ 0,  1], # 右
      ].each do |di, dj|
        if 0 <= i + di && i + di < H && 0 <= j + dj && j + dj < W
          canDraw = true if b[i + di][j + dj] == "#"
        end
      end

      unless canDraw
        puts "No"
        exit
      end
    end
  end
end
puts "Yes"


Measured memory_bytes: 2428
n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n+1):
  si = str(i)
  a = int(si[0])
  b = int(si[-1])
  c[a][b] += 1

res = 0
for i in range(10):
  for j in range(10):
    res += c[i][j] * c[j][i]
print(res)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			string t = cin.Next();

			int sn = s.Length;
			int tn = t.Length;
			int m = 26;
			List<long>[] sCount = new List<long>[m];
			for (int i = 0; i < m; i++) {
				sCount[i] = new List<long>();
			}

			long[] smoji = new long[m];
			long[] tmoji = new long[m];
			for (int i = 0; i < sn; i++) {
				int ii = s[i] - 'a';
				smoji[ii]++;
			}

			for (int i = 0; i < tn; i++) {
				int ii = t[i] - 'a';
				tmoji[ii]++;
			}

			for (int i = 0; i < m; i++) {
				if (tmoji[i] > 0 && smoji[i] == 0) {
					Console.WriteLine(-1);
					return;
				}
			}

			for (int i = 0; i < sn; i++) {
				int ii = s[i] - 'a';
				sCount[ii].Add(i);
			}

			long ans = 0;
			long index = 0;
			for (int i = 0; i < tn; i++) {
				int tt = t[i] - 'a';

				if (index > sCount[tt].Last()) {
					ans += sn - index;
					index = sCount[tt].First() + 1;
					ans += index;
				} else {
					int tempIndex = BinarySearch(sCount[tt], index);
					long nextIndex = sCount[tt][tempIndex];
					ans += nextIndex - index + 1;
					index = nextIndex + 1;
				}
			}

			Console.WriteLine(ans);
		}

		static int BinarySearch(List<long> sl, long ai)
		{
			int left = -1;
			int right = sl.Count();

			while (right - left > 1) {
				int mid = left + (right - left) / 2;

				if (sl[mid] >= ai) {
					right = mid;
				} else {
					left = mid;
				}
			}

			return right;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

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

		public long Long()
		{
			return long.Parse(Next());
		}

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

		public double Double()
		{
			return double.Parse(Next());
		}

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


Measured memory_bytes: 16608
N = gets.to_i 
S = Array.new(N).map{gets.strip.chars} 

a = S.inject {|u, c| u & c}.uniq
h = {}
a.each do |c|
  h[c] = S.map{|x| x.count(c)}.min
end

puts a.sort.map{|c| c * h[c]}.join('')

Measured memory_bytes: 1916
// #include<bits/stdc++.h>
// using namespace std;
// #define F first
// #define S second
// #define PB push_back
// #define MP make_pair
// #define REP(i,a,b) for (int i = a; i <= b; i++)

// typedef long long ll;
// typedef vector<int> vi;
// typedef pair<int,int> pii;

// int main() {
//   ios::sync_with_stdio(0);
//   cin.tie(0);
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
//   //(a + b) mod m = (a mod m + b mod m) mod m;
//   //(a - b) mod m = (a mod m - b mod m) mod m;
//   //(a * b) mod m = (a mod m * b mod m) mod m;
//   // x = x % m;
//   // if (x < 0) x += m;
// }

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
//typedef vector<vector<char> > nums( h , vector<char> (w, 'a'));

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

ll dist(ll x, ll y){
  return x * x + y * y;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n, d;
  cin >> n >> d;
  d = d * d;
  int cnt = 0;
  while (n--)
  {
    ll x, y;
    cin >> x >> y;
    if(dist(x,y)<=d)
    cnt++;
  }
  cout << cnt;
  return 0;
}

// read the question correctly (ll vs int)
// template by bqi343




Measured memory_bytes: 3652
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int A[SIZE],ll[SIZE],rr[SIZE];
int main(){
    int n;
    R(n);
    FOR(i,1,n){
        R(A[i]);
        ll[i]=max(A[i],ll[i-1]);
    }
    for(int i=n;i>0;i--)rr[i]=max(rr[i+1],A[i]);
    FOR(i,1,n)W(max(ll[i-1],rr[i+1]));
    return 0;
}


Measured memory_bytes: 10624
#include <stdio.h>
int main(void) {
    int n, x, l[100000], d=0, i;
    
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++) scanf("%d",&l[i]);
    
    for(i=0;i<n;i++){
        d+=l[i];
        if(d>x) break;
    }
    printf("%d\n",i+1);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
///-------------------------
const int MAXN = 1e5+5;
vector<int> g[MAXN];

int main()
{
    Phuong_; /// <3333
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    for(int &x:h) cin >> x;
    while (m--){
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans=0;
    for(int i=0; i<n; ++i){
        bool can=true;
        for(int x:g[i]){
            if (h[x]>=h[i])
            {
                can=false;
                break;
            }
        }
        if(can) ans++;
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();

  int ans = 0;
  if (K == 1) {
    ans = 0;
  } else {
    ans = N - K;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){
  int m,f,r;
  while (cin >> m >> f >> r ){
    if (m == -1 && f == -1 && r == -1) break;
    else if (m == -1 || f == -1) cout << "F" << endl;
    else if (m + f >= 80) cout << "A" << endl;
    else if (m + f >= 65) cout << "B" << endl;
    else if (m + f >= 50) cout << "C" << endl;
    else if (m + f >= 30){
      if (r >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else cout << "F" << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    pout(0, k * pow(k-1, n-1));
}

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

using namespace std;

int main(void)

{
    long long int w,r,i,a;
    cin>>w>>r;
    if(w == 1 || r == 1)
        a = 1;
    else
        a = (w*r+1)/2;
    cout<<a<<endl;
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int p, m, s;
    p = a + b; m = a - b; s = a * b;
    int max = p;
    if(max < m) max = m;
    if(max < s) max = s;
    cout << max << endl;
    return 0;
}

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

#define SIZE (200005)

int main() {
    char s[SIZE], t[SIZE];
    cin >> s >> t;
    int cnt = 0;

    for (int i = 0;i < strlen(s);i++) {
        if(s[i] != t[i]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3984
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s;
    cin >> t;
    if(s[0] != t[0]){
        cout << -1 << endl;
        return 0;
    }
    int l = lcm(n,m);
    map<int,char> ma;
    rep(i,n){
        ma[1+i*l/n]=s[i];
    }
    rep(i,m){
        char c = ma[1+i*l/m];
        if('a' <= c && c <= 'z' && c != t[i]){
            cout << -1 << endl;
            return 0;
        }
        ma[1+i*l/m] = t[i];
    }
    cout << l << endl;
}


Measured memory_bytes: 10880
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint ca2(lint a,lint b,lint c){
	return max(a,max(b,c))-min(a,min(b,c));
}
lint cal(lint t,lint h,lint w){
	lint ret=ca2(t,(h/2)*w,(h-h/2)*w);
	if(w>1) ret=min(ret,ca2(t,(w/2)*h,(w-w/2)*h));
	return ret;
}
int main()
{
	lint out=1234567890123456LL;int h,w;
	cin>>h>>w;
	REP(i,1,h){
		out=min(out,cal((lint)i*w,w,h-i));
	}
	REP(i,1,w){
		out=min(out,cal((lint)i*h,h,w-i));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
n = int(input())
prev_dst = prev_t = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    dst = x + y
    ddst = abs(dst - prev_dst)
    dt = t - prev_t
    if t % 2 != dst % 2 or ddst > dt:
        print('No')
        exit()
    prev_t, prev_dst = t, dst
print('Yes')

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

#define int long long

const double pi = 6.28318530717958623200/2;

signed main(){
	int n,m;
	cin>>n>>m;
	vector<int>a(m);
	int sum=0;
	for(auto &i:a)cin>>i,sum+=i;
	if(sum>n)cout<<-1<<endl;
	else{
		cout<<n-sum<<endl;
	}
}


Measured memory_bytes: 3580
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  int n;
  cin >> n;
  vector<ll> graph[n];
  int a,b;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int d[n];
  int ans[n];
  for (int i=0;i<n;i++){
    d[i] = -1;
    ans[i] = -1;
  }
  d[0] = 0;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int i=0;i<graph[now].size();i++){
      if(d[graph[now][i]] != -1) continue;
      d[graph[now][i]] = d[now]+1;
      q.push(graph[now][i]);
    }
  }
  int red=0,blue=0;
  for(int i=0;i<n;i++){
    if(d[i]%2 == 0) red++;
    else blue++;
  }
  queue<int> q0,q1,q2;
  for(int i=1;i<n+1;i++){
    if(i%3 == 0) q0.push(i);
    else if(i%3 == 1) q1.push(i);
    else if (i%3 == 2) q2.push(i);
  }
  if(red <= n/3){
    for(int i=0;i<n;i++){
      if(d[i]%2 == 0){
        ans[i] = q0.front();
        q0.pop();
      }
    }
  }
  else if(blue <= n/3){
    for(int i=0;i<n;i++){
      if(d[i]%2 == 1){
        ans[i] = q0.front();
        q0.pop();
      }
    }
  }
  else{
    for(int i=0;i<n;i++){
      if(d[i]%2 == 0){
        if(!q1.empty()){
          ans[i] = q1.front();
          q1.pop();
        }
        else{
          ans[i] = q0.front();
          q0.pop();
        }
      }
      else{
        if(!q2.empty()){
          ans[i] = q2.front();
          q2.pop();
        }
        else{
          ans[i] = q0.front();
          q0.pop();
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    if(ans[i] != -1) continue;
    if(!q0.empty()){
      ans[i] = q0.front();
      q0.pop();
      continue;
    }
    if(!q1.empty()){
      ans[i] = q1.front();
      q1.pop();
      continue;
    }
    if(!q2.empty()){
      ans[i] = q2.front();
      q2.pop();
      continue;
    }
  }
  for(int i=0;i<n;i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 16232