akhauriyash/Code-Regression huggingface dataset:
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,i;
    cin>>n;
    set<string> sa;
    for(i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	sa.in(s);
    }
    cout<<sa.size();
}

Measured memory_bytes: 19200
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable(toList)
import Data.Maybe(fromMaybe)


r :: IO [Int]
r  = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    where toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,k] <- r :: IO [Int]
    s <- getLine 
    let b = borders s
    let mA = div b 2
    let add = min k mA
    let restB = b - (add*2)
    let restS = k - mA
    let spA = if restB > 0 && restS > 0 then 1 else 0 
    --print (hap s, add*2, spA)
    print $ hap s + (add * 2) + spA



hap :: String -> Int
hap ls = let ls' = 'X':ls++"X"
            in  sum $ zipWith3 happ ls' (tail ls') (tail $ tail ls')
    where
        happ :: Char -> Char -> Char -> Int
        happ 'L' 'L'  _  = 1
        happ  _  'R' 'R' = 1
        happ  _   _   _  = 0

borders :: String -> Int 
borders = pred . length . group



{-
maxAdd :: String -> Int
maxAdd ls = let (x,y) = grenz (0,0) ls 
    in div x 2 + (div y 2)

grenz :: (Int,Int) -> String -> (Int,Int) 
grenz (lr,rl) ('L':'R':xs) = grenz (lr+1,rl) ('R':xs)
grenz (lr,rl) ('R':'L':xs) = grenz (lr,rl+1) ('L':xs)
grenz (lr,rl) ( _ : x :xs) = grenz (lr,rl) (x:xs)
grenz ac _ = ac 
-}


Measured memory_bytes: 7548
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

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

const char kBlack = 'B', kWhite = 'W';

string S;

void input() {
    cin >> S;
}

ll solve() {
    ll count = 0;
    ll cB = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S[i] == kWhite) {
            count += cB;
        } else {
            cB++;
        }
    }
    return count;
}


int main() {
    input();
    cout << solve() << endl;;
    
    return 0;
}



Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;cin>>s;
  int ans=0,cnt=0;;
  rep(i,s.size()){
    if(s[i]=='R')cnt++;
    if(s[i]=='S')cnt=0;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

map<string, int> res;

int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    res[s]++;
  }
  cout << "AC x " << res["AC"] << endl;
  cout << "WA x " << res["WA"] << endl;
  cout << "TLE x " << res["TLE"] << endl;
  cout << "RE x " << res["RE"] << endl;
}

Measured memory_bytes: 3636
/*
    Problem 14
    https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll ans = LINF;
    for (int b = 0; b < (1 << (n - 1)); b++) {
        if (__builtin_popcount(b) != k - 1) continue;
        ll maxH = a[0], sum = 0;
        for (int i = 1; i < n; i++) {
            if ((b >> (i - 1)) & 1) {
                if (maxH >= a[i]) {
                    maxH++;
                    sum += maxH - a[i];
                }
                else maxH = a[i];
            }
            else maxH = max(maxH, a[i]);
        }
        ans = min(sum, ans);
    }
    cout << ans << '\n';
}

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

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int Q, L;
    while(scanf("%d %d", &Q, &L) != EOF && Q > 0){
        deque<int> deq;
        for(int q, x; Q--;){
            scanf("%d %d", &q, &x);
            while(deq.size() > L) deq.pop_front();
            if(q == 0) deq.push_back(x);
            if(q == 1) deq.erase(deq.begin() + x - 1);
            if(q == 2) printf("%d\n", deq[x - 1]);
            if(q == 3) deq.erase(find(deq.begin(), deq.end(), x));
        }
        puts("end");
    }
    return 0;
}

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

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

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

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

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> 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 (a > b) { a = b; return true; }return false; }

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

	int N; cin >> N;
	string s = "MARCH";
	map<char, int>mp;
	rep(i, 0, s.size()) {
		mp[s[i]] = i;
	}
	vector<int>v(s.size());
	loop(N) {
		string t; cin >> t;
		if (not mp.count(t[0]))continue;
		v[mp[t[0]]]++;
	}
	dump(v);
	int ans = 0;
	rep(i, 0, s.size())rep(j, i + 1, s.size())rep(k, j + 1, s.size()) {
		ans += v[i] * v[j] * v[k];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())

C=[]

for i in range(h):
    tmp=list(input())
    C.append(tmp)


for i in range(2*h):
    ans=["0"]*w
    for j in range(w):
        ans[j]=C[i//2][j]
    print(''.join(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


ll c[55][55];
ll C(ll n, ll k) {
    if(k==0 || n==k) return 1;
    if(c[n][k]!=-1) return c[n][k];
    return c[n][k]=C(n-1, k)+C(n-1, k-1);
}


int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    ll v[55];
    ll i;
    ll cnt=0;
    ll rem=0;
    double ave=0;
    
    memset(c, -1, sizeof(c));
    
    for(i=0; i<N; i++) cin >> v[i];
    sort(v, v+N);
    reverse(v, v+N);
    
    for(i=0; i<A; i++) ave+=v[i];
    ave/=A;
    
    for(i=0; i<N; i++)
        if(v[A-1]==v[i]) cnt++;

    for(i=0; i<N; i++) {
        if(v[i]>v[A-1]) rem=i+1;
    }

    ll ans=0;
    if(rem==0) {
        for(i=A; i<=min(B, cnt); i++) {
            ans+=C(cnt, i-rem);
        }
    }else {
        ans=C(cnt, A-rem);
    }
    
    printf("%.10f\n", ave);
    pt(ans);
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> b(n+1,0);
    b[0]=abs(a[0]);
    ll tot=b[0];
    rep(i,n-1){
        b[i+1]=abs(a[i+1]-a[i]);
        tot+=b[i+1];
    }
    b[n]=abs(a[n-1]);
    tot+=b[n];
    //cout<<tot<<endl;
    rep(i,n){
        ll res=tot;
        res-=(b[i]+b[i+1]);
        if(i==0){
            res+=abs(a[i+1]);
        }else if(i==n-1){
            res+=abs(a[i-1]);
        }else{
            res+=abs(a[i+1]-a[i-1]);
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ans = min(A, B) + min(C, D);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import*
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    for i, j in enumerate(a):
        l += [i + j]
        r += [i - j]

    cnt = 0
    l = Counter(l)
    for r in r:
        cnt += l.get(r, 0)

    
    return cnt




print(solve())



Measured memory_bytes: 50624
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

int N,K;
int V[50];

int dp[50][50][101];
int solve(int l, int r, int nokori){
	if(l > r) return 0;
	if(nokori == 0) return 0;
	if(nokori == -1) return INT_MIN/2;
	if(dp[l][r][nokori] != INT_MIN) return dp[l][r][nokori];
	int ret = 0;
	ret = max(ret, V[l]+solve(l+1, r, nokori-1));
	ret = max(ret, solve(l+1, r, nokori-2));
	ret = max(ret, V[r]+solve(l, r-1, nokori-1));
	ret = max(ret, solve(l, r-1, nokori-2));
	return dp[l][r][nokori] = ret;
}

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> V[i];
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			for(int k=0; k<=K; k++) dp[i][j][k] = INT_MIN;
	cout << solve(0,N-1,K) << endl;
	
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    double ans = 0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") x *= 380000.0;
        ans += x;
    }
    cout << fixed << setprecision(5);
    cout << (double)ans << '\n';
    return 0;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') ans++;
    }

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



Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> P;

template<typename T>
void print_array(T *A_, s32 size) {
  //printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}

int main() {

  for(;;) {
    int n, m, a;
    std::cin >> n >> m >> a;
    if( n == 0 and m == 0 and a == 0 ) break;

    int next[128][1024];

    for(int i = 0; i < 128; ++i) {
      for(int j = 0; j < 1024; ++j) {
        next[i][j] = i;
      }
    }

    for(int i = 0; i < m; ++i) {
      int h, p, q;
      std::cin >> h >> p >> q;
      std::swap(next[p][h], next[q][h]);
    }

    int line = a;
    int y = 1020;
    while( y != 0 ) {
      line = next[line][y];
      y -= 1;
    }

    std::cout << line << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vc=vector<char>;

const double pi = acos(-1);

int io(int x){
  int a=1;
  for(int i=0;i<x;i++){
    a*=10;
  }
  return a;
}

int main(){
  long i,N,count=0;
  double D;
  cin>>N>>D;
  vector<vector<long>> p(N,vector<long>(2));
  for(i=0;i<N;i++){
    cin>>p[i][0]>>p[i][1];
    if(sqrt(p[i][0]*p[i][0]+p[i][1]*p[i][1])<=D)count++;
  }
  cout<<count<<endl;
    
    
}
  


Measured memory_bytes: 14424
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
int main(void){
    ll h;
    cin >> h;
    ll ans = 1;
    ll cnt = 1;
    while(h!=1){
        h/=2;
        ans+=(pow(2,cnt));
        cnt++;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
const int MOD = 1e9+7;
int A[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
	}
	sort(A,A+N);
	bool flag = true;
	if (N % 2 != 0)
	{
		if (A[0] != 0) flag = false;
		for (int i = 1; i < N; ++i)
		{
			if (A[i] != (i+1)/2*2) flag = false;
		}
	}
	else
	{
		rep(i,N)
		{
			if (A[i] != i/2*2+1) flag = false;
		}
	}
	if (!flag)
	{
		cout << "0" << endl;
	}
	else
	{
		int time = N/2;
		ll ans = 1;
		rep(i,time)
		{
			ans = (ans * 2) % MOD;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

void solve () {

}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

	int n, k;
	scanf("%d %d", &n, &k);
	if (k == 1) {
		printf("0\n");
	}	 else {
		printf("%d\n", n - k);
	}
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int n,c;
	double xa,ya,ra,xb,yb,rb,l;
	cin >> n;
	for (n;n>0;n--) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
        l=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
        if (l+rb<ra) c=2; else
			if (l+ra<rb) c=-2; else
				if (l>ra+rb) c=0; else c=1;
        cout << c << endl;
	}
	return 0;
	}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
ll dp[110][60][60];
ll p[60];

ll solve2(ll a,ll b,ll c)
{
	if(b>c||a==0)return 0;
	if(dp[a][b][c]!=-mod)return dp[a][b][c];
	ll ans=-mod;
	ans=max(ans,solve2(a-1,b+1,c)+p[b]);
	ans=max(ans,solve2(a-1,b,c-1)+p[c]);
	if(a>1)ans=max(ans,solve2(a-2,b+1,c));
	if(a>1)ans=max(ans,solve2(a-2,b,c-1));
	return dp[a][b][c]=ans;
	
}
void solve()
{
	ll n,k;
	rl2(n,k);
	fr(i,0,n)
		rl(p[i]);
	fr(i,0,110)
	{
		fr(j,0,60)
			fr(k,0,60)
				dp[i][j][k]=-mod;
	}
	ll ans=0;
	fr(i,1,k+1)
	{
		ans=max(ans,solve2(i,0,n-1));
	}
	wl(ans);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

constexpr int MOD = 998244353;

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  struct Robot {
    int x, d;
    bool visit = false;
  };

  vector<Robot> rs(N);
  F0R(i, N) {
    cin >> rs[i].x >> rs[i].d;
  }

  // ロボットの接触起動を、ロボットごとの繋がりと考えると有向グラフにできる。

  // "ロボットを好きなだけ選び、そのロボットと、接続先すべてのロボットを黒に塗る。
  // 塗り方の組み合わせを求めよ。" みたいな。

  // ロボットは正方向にしか移動しない + 初期位置は必ず違う、ことより閉路は存在しない。
  // そのかわり、A→B→DとA→C→Dのようなパターンが存在し、これをどう計算するかが問題…

  // A→B→D , A→C→E だと組み合わせは 3(0DB) * 3(0EC) + 1(A) = 10
  // A→B→D , A→C→D だと組み合わせは 6. こちらの計算式が不明…
  // D 単体のパターン数を pD (=2) とすると、 pD - 1 + 2(0B) * 2(0C) + 1(A) = 6 という感じ？

  // よく考えたら A→B→DとA→C→D はありえない。BかCどちらかがもう一方に繋がらないといけない。

  // ------

  // C に繋がる A, B が存在するとき、A→B か B→A どちらかに必ず繋がっている。
  // この場合、A→C か B→C の接続を切っていくことで、有向グラフをただの木にすることができる。
  // そうすると単純なDFSで解けると思う

  // さて切り方だけど…Union Findを使ってみるのはどうか。
  // X 昇順にソートしたデータをDFSで辿っていくが、子にうつる際に同じグループに追加していく。
  // 既に同じグループにいた場合、「新しく作ろうとしている方の」リンクを繋げなければ、おそらく
  // 長い方のつながりが残るはず。
  // データ全体ではなく、それぞれの子リストも全てXソートする必要があるからそこを気を付ける。

  // Union Find いらない気がする。
  // DFS で辿る際に、始点だけ記憶しておけば判定できるから。それなら探索が1回で済む。O(N)かも。
  // 始点ではなく既に訪れたかのflagさえあれば大丈夫かも

  // ------

  // 接続きっていいの？解は変わらない？
  // 接続前のロボットに色が塗られていたら、接続後にも必ず塗る、というのさえ守られれば良いため
  // A→B→C→Dの接続があるときに、A→CやB→Dの接続は切っても大丈夫。解は変わらない。多分…

  sort(rs.begin(), rs.end(), [](const Robot& l, const Robot& r)->bool {
    return l.x < r.x;
    });

  int index = 0;
  i64 result = 1;
  while (index < rs.size()) {
    auto dfs = [&](auto dfs, int v)->int {
      Robot& r = rs[v];
      r.visit = true;

      //cout << r.x << " " << r.d << newl;

      i64 result = 1;

      // 子に対して処理
      int rx = r.x + r.d;
      while (index+1 < rs.size() && rs[index+1].x < rx) {
        // 既に訪問済なら行かない（接続を切る）
        if (rs[++index].visit) continue;

        //cout << ">" << newl;
        result = result * dfs(dfs, index) % MOD;
        //cout << "<" << newl;
      }
      if (++result >= MOD) result -= MOD;
      return (int)result;
    };
    result = result * dfs(dfs, index) % MOD;
    index++;
  }

  cout << result;
}
#endif


Measured memory_bytes: 6400
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,L[200];
	cin >> n;
	rep(i, n*2)cin >> L[i];
	sort(L,L+n*2);
	int ans = 0;
	rep(i,n) {
		ans += L[i * 2];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

const int N(1e5 + 10);
std::set<std::pair<int, int> > P[10];
std::set<std::pair<int, int> > B;
int n, H, W, a[N], b[N];
long long ans[10];

int main()
{
	scanf("%d%d%d", &H, &W, &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", a + i, b + i);
	for (int i = 1; i <= n; i++) B.insert(std::make_pair(a[i], b[i]));
	for (int t = 1; t <= n; t++)
	{
		int dx = std::max(a[t] - 2, 1), dy = std::max(b[t] - 2, 1);
		for (int x = dx; x <= a[t] && x + 2 <= H; x++)
			for (int y = dy; y <= b[t] && y + 2 <= W; y++)
			{
				int cnt = 0;
				for (int i = x; i < x + 3; i++)
					for (int j = y; j < y + 3; j++)
						cnt += (B.find(std::make_pair(i, j)) != B.end());
				P[cnt].insert(std::make_pair(x, y));
			}
	}
	ans[0] = 1ll * (H - 2) * (W - 2);
	for (int i = 1; i <= 9; i++) ans[i] = P[i].size(), ans[0] -= ans[i];
	for (int i = 0; i <= 9; i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 47872
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int W=in.nextInt(),H=in.nextInt(),x=in.nextInt(),y=in.nextInt(),r=in.nextInt();
		
		if((x+r<=W && x-r>=0) && (y+r<=H && y-r>=0))System.out.println("Yes");
		else System.out.println("No");
	}

}



Measured memory_bytes: 26264
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	string a;
	cin >> a;
	if (a == "a" || a == "b" || a == "c" || a == "d" || a == "e" || a == "f" || a == "g" || a == "h" || a == "i" || a == "j" || a == "k" || a == "l" || a == "m" || a == "n" || a == "o" || a == "p" || a == "q" || a == "r" || a == "s" || a == "t" || a == "u" || a == "v" || a == "w" || a == "x" || a == "y" || a == "z") {
		cout << "a";
	}
	else {
		cout << "A";
	}
	return 0;
}

Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input!{
    n: usize,
    capacity: i64,
    items: [(i64, usize); n]
  }
  let mut dp = vec![vec![1_000_000_000_000_000_000i64; 100_001]; 2];
  dp[0][0] = 0;
  for (idx, item) in items.iter().enumerate() {
    for value in 0..100_001 {
      dp[(idx + 1) % 2][value] = dp[idx % 2][value];
      if item.1 <= value {
        dp[(idx + 1) % 2][value] = cmp::min(dp[(idx + 1) % 2][value], dp[idx % 2][value - item.1] + item.0);
      }
    }
  }
  let ans = dp[n % 2].iter().enumerate().filter(|&(_, w)| *w <= capacity).last().unwrap().0;
  println!("{}", ans)
}


Measured memory_bytes: 6524
/*
 * aoj/1611_3rd/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll N;
vector<ll> A(310);

ll dp[310][310]; // dp[l][r] := [l:r) で落とせた最大数

bool input() {
  cin >> N;
  if (N==0) return false;
  ll a;
  loop(n,0,N) {
    cin >> A[n];
  }
  return true;
}

ll receive() {
  memset(dp, 0, sizeof(dp));
  for (int len=2; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      int r = l+len;
      if (len == 2) { dp[l][r] = 2 * (abs(A[l] - A[l+1]) <= 1); continue; }
      if (abs(A[l] - A[r-1]) <= 1 && dp[l+1][r-1] == len - 2) {
        chmax(dp[l][r], dp[l+1][r-1] + 2);
      }
      for (int k=l+1; k<r; k++) {
        chmax(dp[l][r], dp[l][k] + dp[k][r]);
      }
    }
  }
  return dp[0][N];
}

void solve() {
  cout << receive() << endl;
}

int main() {
  // cout.precision(15);
  while (input()) solve();
  return 0;
}



Measured memory_bytes: 3840
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String result = "";
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        if (a <= b && b >= c && a <= c|| a >= b && b <= c && a >= c){
            result = "Yes";
        } else {
            result = "No";
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 23760
import sys

s = input()
t = list(input())

string = s
length = 1

for i in range(len(t)):
	if s.find(t[i])==-1:
		print(-1)
		sys.exit()
	if string.find(t[i])==-1:
		string = s
		length += 1
	string = string[string.find(t[i])+1 : ]
	
print(length*len(s)-len(string))

Measured memory_bytes: 4236
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
S = list(input())
table = [0]*(N+5)
table[1] = 1
for i in range(2,N+3):
    num = i
    cnt = 0
    while num != 0:
        a = num % 2
        num = num // 2
        cnt += a
    p = i % cnt
    table[i] = table[p]+1
c = 0
for s in S:
    if s == "1":
        c += 1
p = 0
q = 0

for i in range(N):
    ss = S[N-1-i]
    p += int(ss)*pow(2,i,c+1)
    if c != 1:
        q += int(ss)*pow(2,i,c-1)
    p %= (c+1)
    if c != 1:
        q %= (c-1)
for i in range(N):
    ss = S[i]
    if ss == "0":
        ans = (p+pow(2,N-1-i,c+1))%(c+1)
        print(table[ans]+1)
    else:
        if c == 1:
            print(0)
        else:
            if c != 1:
                ans = (q-pow(2,N-1-i,c-1))%(c-1)
                print(table[ans]+1)
            else:
                print(0)
        

Measured memory_bytes: 13836
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

a = iIn()

print(a + a**2 + a**3)

Measured memory_bytes: 62112
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split(' ');
            int x = int.Parse(inp[0]);
            int y = int.Parse(inp[1]);

            string ans = "No";
            
            for(int i=0;i<=x;i++)
            {
                int tsuru = i;
                int kame = x - i;

                int ashi = tsuru * 2 + kame * 4;
                if(ashi==y)
                {
                    ans = "Yes";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27520
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int l;
  while(cin >> l, l) {
    bool f = 0;
    int a[12], b[12];
    REP(i,12) {
      cin >> a[i] >> b[i];
    }
    REP(i,12) {
      l -= a[i]-b[i];
      if (l <= 0) {
        cout << i+1 << endl;
        f = 1;
        break;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
ans = 0
a_sum = sum(a)
a_sum -= a[0]
for i in range(n - 1):
    ans += a[i] * a_sum
    a_sum -= a[i + 1]
ans %= 1000000007
print(ans)


Measured memory_bytes: 31656
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define debug(x) cout<<#x<<"="<<x<<endl;
#define chk() cout<<C((n-j+1)*(k-1)+(n-i)-1,k-2)<<endl;
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^'0');
	return x*f;
}
const int maxn=2010;
const int mod=1e9+7;
int ifac[maxn*maxn],fac[maxn*maxn],inv[maxn*maxn];
int f[maxn][maxn];
inline int C(int n,int m){
	if(m==0)return 1;
	if(n<m)return 0;
	return 1ll*fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
int n,k;
inline void init(){
	n=read(),k=read();
	if(n==0 || k==0)printf("0"),exit(0);
	if(k==1)puts("1"),exit(0);
	inv[0]=inv[1]=1;
	for(register int i=2;i<=maxn*maxn;++i)
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	fac[0]=fac[1]=1;
	for(register int i=2;i<=maxn*maxn;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	ifac[0]=ifac[1]=1;
	for(register int i=1;i<=maxn*maxn;++i)
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;

}
inline void solve(){
	f[1][0]=1;
	for(register int i=0;i<=n;++i)
		for(register int j=0;j<=i;++j){
			if(i)(f[i][j]+=f[i-1][j])%=mod;
			if(j)(f[i][j]+=1ll*C((n-j+1)*(k-1)+(n-i)-1,k-2)*f[i][j-1]%mod)%=mod;
		}
	cout<<1ll*f[n][n]*fac[n]%mod;
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 62464
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
#define MOD 1000000007
using namespace std;
int n,m,in[M],dp[M];
int main()
{
    while (~scanf("%d %d", &n, &m)) {
        set<int> s;
        REP(i,1,m) {
            int x;
            scanf("%d", &x);
            s.insert(x);
        }
        
        MSET(dp, 0);
        dp[0] = 1;
        REP(i,1,n) if (s.find(i)==s.end()) {
            if (i>=1) dp[i] = (dp[i] + dp[i-1]) % MOD;
            if (i>=2) dp[i] = (dp[i] + dp[i-2]) % MOD;
        }
        printf("%d\n", dp[n]);
    }
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N,X;
	int m[110];
	cin >> N>>X;

	int m_total = 0;
	for (int i = 0; i < N; ++i) {
		cin >> m[i];
		m_total = m_total+ m[i];
	}

	int amari = 0;
	amari = X - m_total;

	int m_min=1000;

	for (int i = 0; i < N; ++i) {
		if ( m_min>m[i]) m_min = m[i];
	}
	
	int p = 0;
	int c = 0;
	while (true) {
		if (amari < m_min * p) {
			c = p - 1;
			break;
		}
		p = p + 1;
	}


	cout << N+c << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
int main()
{ 
    cool;
    string s;
    cin>>s;
    string arr[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0;i<7;i++)
    {
    	if(s==arr[i])
    	{
    		cout<<(7-i);
    		break;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N; cin>>N;
    int answer=0;
    for(int i=1; i<=N; i+=2) {
        int counter=0;
        for(int j=1; j<=i; j++) {
            if(i%2==1&&i%j==0) counter++;
        }
        if(counter==8) answer++;
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
bool flag = true;

int main(){
    cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) != t.at(i)) {
            flag = false;
        }
    }
    if(flag == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
// ＡＢＣの過去問を解くだけだよ

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string S;
    cin >> S;

    for (int i = 0; i < 10; ++i)
    {
        cout << (i == 3 ? '8' : S[i]);
    }

    return 0;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  ans=[[] for _ in range(n)]
  basho=0
  f=inf
  for i in range(2*n+1):
    if f==inf and len(ans[basho])>1:
      f=basho
    ans[basho].append(i)
    basho=l[basho]-1

  # print(ans)
  # print(f)

  if k<(2*n+1):
    for i,x in enumerate(ans):
      if k in x:
        return i+1

  k-=ans[f][0]
  span=ans[f][2]-ans[f][1]
  # print(span)
  xx=k%span
  # print(k,span,xx)
  start=f
  while xx>0:
    start=l[start]-1
    xx-=1

  return start+1

# main()
print(main())


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

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

    int h, w;
    cin >> h >> w;
    char C[h][w];
    int D[h][w];

    int bc = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            if(C[i][j] == '#'){
                bc++;
            }
            D[i][j] = 1e9;
        }
    }

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

    queue<pair<int, int>> q;
    q.push({0, 0});

    D[0][0] = 0;
    while(!q.empty()){
        pair<int, int> p = q.front();
        q.pop();

        int x = p.first;
        int y = p.second;
        for(int i = 0; i < 4; i++){
            int nx = dx[i] + x;
            int ny = dy[i] + y;
            if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                continue;
            }

            if(C[nx][ny] == '#'){
                continue;
            }
            if(D[x][y] + 1 < D[nx][ny]){
                D[nx][ny] = D[x][y] + 1;
                
                if(nx == h - 1 and ny == w - 1);
                else q.push({nx, ny});
            }
        }
    }


    int ans = h * w - bc - D[h - 1][w - 1] - 1;
    cout << (D[h - 1][w - 1] == 1e9 ? -1 : ans) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  int a1,a2,a3;

  cin>>a1>>a2>>a3;
  int sum=a1+a2+a3;
  if(sum>=22)cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}


Measured memory_bytes: 256
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int d, t, s;

void read_input()
{
    cin >> d >> t >> s;
}

void solve()
{
    cout << (d <= s * t ? "Yes\n" : "No\n");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3628
#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 a,b,c,d;
           cin>>a>>b>>c>>d;
           if(a+b>c+d){
            cout<<"Left"<<endl; 
           }
           else if(a+b==c+d)cout<<"Balanced"<<endl;
           else cout<<"Right"<<endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {
  string s;
  cin >> s;
  cout << s.substr(0, s.size()-8) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[200010],b[200010];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]; b[i]=a[i];
  }
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(a[i]==b[n-1])cout<<b[n-2]<<endl;
    else cout<<b[n-1]<<endl;
  }
  return 0;
}


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

const int BTC = 380000.0;
int main()
{
  int N;
  float x, yen=0, btc=0;
  string u;
  cin >> N;
  for(int i=0;i<N;++i)
  {
    cin >> x >> u;
    if(u=="BTC")
      btc+=x;
    if(u=="JPY")
      yen+=x;
  }
  cout << yen+btc*BTC << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
    for j in range(min(i, k)):
        dp[i] = min(dp[i], dp[i-j-1]+abs(h[i-j-1]-h[i]))
print(dp[n-1])

Measured memory_bytes: 55008
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
using namespace std;
using ll = unsigned long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll C = A + B;
    ll cnt = floor(N / C);
    ll ans = cnt * A;

    ll rest = N - C * cnt;
    if (rest > 0) {
        if (rest <= A) ans += rest;
        if (rest > A) ans += A;
    }

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


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  string a, b;
  cin >> a >> b;

  string c = b.substr(0, a.size());
  debug(c);

  if (a == c) {
    cout << "Yes" << endl;

  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) (int)x.size()
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<ll, ll> point;

const int MAXN = 55;

ll a[MAXN];

int main(){
  ll k; cin >> k;
  cout << 50 << "\n";
  ll add = k / 50;
  ll ostatak = k % 50;

  REP(i, 50)
    a[i] = add + 49;
  REP(i, 50){
    if(ostatak > i)
      a[i] ++;
    else if(ostatak)
      a[i] -= ostatak;
    cout << a[i] << " ";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::map<char, int> map;
    map.emplace('a',0);
    map.emplace('b',0);
    map.emplace('c',0);
    map.emplace('d',0);
    map.emplace('e',0);
    map.emplace('f',0);
    map.emplace('g',0);
    map.emplace('h',0);
    map.emplace('i',0);
    map.emplace('j',0);
    map.emplace('k',0);
    map.emplace('l',0);
    map.emplace('m',0);
    map.emplace('n',0);
    map.emplace('o',0);
    map.emplace('p',0);
    map.emplace('q',0);
    map.emplace('r',0);
    map.emplace('s',0);
    map.emplace('t',0);
    map.emplace('u',0);
    map.emplace('v',0);
    map.emplace('w',0);
    map.emplace('x',0);
    map.emplace('y',0);
    map.emplace('z',0);
    string s;
    cin>>s;
    for (int i=0;i<s.size();i++) {
        map.at(s.at(i))++;
    }
    int flag=0;
    for (auto itr=map.begin();itr!=map.end();itr++) {
        if (itr->second%2==1) {
            cout<<"No"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256