akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(a)
b =[]
tmp = 1
for i in range(0,n-1):
  if a[i]==a[i+1]:
    tmp +=1
  else:
    b.append(tmp)
    tmp = 1

if a[n-2]==a[n-1]:
  b.append(tmp)
elif a[n-2]!=a[n-1]:
  b.append(tmp)
  
b = sorted(b)
if len(b)<=k:
  print(0)
else:
  print(sum(b[:len(b)-k]))

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

using namespace std;

class Inverse {
private:
  long long mod;
	vector<long long> inv;
  
public:
  Inverse() {}
  
	Inverse(long long mod, long long n = 1000000) : mod(mod) {
    inv = vector<long long>(n, 1);
    for (int i = 2; i < n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  }
  
	long long operator()(long long a) const {
		if (a < (int)inv.size()) return inv[a];
		long long b = mod, x = 1, y = 0;
		while (b) {
			long long t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return (x %= mod) < 0 ? x + mod : x;
	}
};

class Mint {
private:
  static long long mod;
  static Inverse inverse;
  long long val;
	
public:
	Mint() {}

	Mint(const long long& val) {
    this->val = val % mod;
    if (this->val < 0) this->val += mod;
  }

  static void setMod(const long long& m) {
    mod = m;
    inverse = Inverse(m);
  }
	
	Mint operator+=(const Mint& m) {
		val += m.val;
		if (val >= mod) val -= mod;
		return *this;
	}
  
	Mint operator-=(const Mint& m) {
		val -= m.val;
		if (val < 0) val += mod;
		return *this;
	}
  
	Mint operator*=(const Mint& m) {
		val *= m.val;
		val %= mod;
		return *this;
	}
  
	Mint operator/=(const Mint& m) {
		val *= inverse(m.val);
		val %= mod;
		return *this;
	}
	
	Mint operator+(const Mint& m) const {
		Mint res = *this;
		res += m;
		return res;
	}
	
	Mint operator-(const Mint& m) const {
		Mint res = *this;
		res -= m;
		return res;
	}
	
	Mint operator*(const Mint& m) const {
		Mint res = *this;
		res *= m;
		return res;
	}
	
	Mint operator/(const Mint& m) const {
		Mint res = *this;
		res /= m;
		return res;
	}
	
	Mint operator++() {return val += 1;}
	
	operator long long() {
		return val;
	}
};

Mint pow(const Mint& m, long long n) {
  if (n == 0) {
    return 1;
  } else if (n < 0) {
    return pow(m, -n);
  }
  Mint mm = pow(m, n / 2);
  mm *= mm;
  if (n % 2) mm *= m;
  return mm;
}

long long Mint::mod;
Inverse Mint::inverse;

ostream& operator<<(ostream& os, Mint a) {
	os << (long long)a;
	return os;
}

istream& operator>>(istream& is, Mint& a) {
	long long n;
	is >> n;
	a = Mint(n);
	return is;
}

int main() {
  Mint::setMod(1000000007);
  Mint m;
  int n;
  cin >> m >> n;
  cout << pow(m, n) << endl;
}

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

int main( )
{
    int n, i, j, k = 1;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        if (j == k) {
            k++;
        }
    }
    k--;
    if (k == 0) {
        cout << "-1\n";
    }
    else {
        cout << (n - k) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

vector<ll> vec;

void dfs(ll v){
    if(to_string(v).size() == 10) return;
    for(ll i=-1; i<=1; i++){
        ll res = v;
        ll k = res%10;
        if((k==0 and i==-1) or (k==9 and i==1)) continue;
        res *= 10;
        dfs(res + k + i);
        vec.push_back(res + k + i);
    }
    return;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    for(int i=1; i<10; i++){
        vec.push_back(i);
        ll res = i;
        dfs(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec[K-1] << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);
#define MN_Mind ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"  //comment it on debug
#define Endl "\n"

int arr[(int)1e6+7];
  
 //vector<vector<ll> > dp( n+1 , vector<ll> (x+1, 1)); 
//cout<<flush;
int main() {
	MN_Mind


int x;
cin>>x;
cout<<(x+1)%2;

	return 0;
}

Measured memory_bytes: 3584
from sys import stdin


def main():
    h, w = map(int, input().split())
    a = [next_str() for _ in range(h)]

    ans = []
    for i in range(h + 2):
        ans += ["#"]
        if not 0 < i <= h:
            ans[i] += "#" * w
        else:
            ans[i] += a[i - 1]
        ans[i] += "#"

    print("\n".join(ans))


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

typedef long long ll;

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

    for(int i=0;;i++){
        int a,b;
        char op;
        cin >> a >> op >> b;
        if(op=='?') break;
        if(op=='+') cout << a+b << endl;
        else if(op=='-') cout << a-b << endl;
        else if(op=='*') cout << a*b << endl;
        else cout << a/b << endl;
    }
    return 0;
}


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

int main() {
  int a;
  int b;
  int c;
  int d;
  
  cin >> a;
  cin >> b;
  cin >> c;
  d = 0;
  
  for (int i = a; i <= b; i++) {
    if (i%c == 0) {
      d++; 
    }
  }
  
  cout << d;
   
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,s=0,m;
    cin>>n;
    ll a[n];
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        a[i-1]=x;
        s+=x;

    }
    //for(int i=0;i<n;i++)cerr<<a[i]<<" ";
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        ll x,p;
        cin>>p>>x;
       cout<< (s-(a[p-1])+x)<<endl;;
       
    }

}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    int cnt=1;
    string s;
    cin>>s;
     for(long long i=1;i<n;i++)
     {
         if(s[i-1]==s[i])
         {
             continue;
         }
         cnt++;
     }
     cout<<cnt<<endl;

}



Measured memory_bytes: 512
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;

mint w[105], v[105];
int main()
{
    //freopen("in.txt","r",stdin);
    mint N, W;
    cin >> N >> W;
    Rep(i,N)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<mint> > dp(N + 1, vector<mint>(3*N + 1, -1));
    dp[0][0] = 0;
    mint w1 = w[0];
    int jst = N;
    while(jst * w1 > W)
    {
        jst--;
    }
    Rep(i,N)
    {
        for(int j = jst; j > 0; j--)
        {
            mint ext = w[i] - w1;
            int kst = 3*j;
            while(j * w1 + kst > W)
            {
                kst--;
            }
            for(int k = kst; k >= ext; k--)
            {
                if(dp[j - 1][k - ext] == -1)
                {
                    continue;
                }
                else
                {
                    dp[j][k] =  max(dp[j][k], dp[j - 1][k - ext] + v[i]);
                    //cout << j <<" " <<k <<" "<< dp[j][k] << endl;
                }
            }
        }
    }
    mint ans = 0;
    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; i * w1 + j <= W && j <= 3*N; j++)
        {
            //cout << i <<" "<<j<<" "<< dp[i][j] << endl;
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h> 
#define int long long
using namespace std;
void print (vector<char>&v){
	int k=0;
	for (char i:v) cout<<i<<" ";
	cout<<endl;
}
void printv (vector<vector<char>>&v){
	for (vector<char> i:v) print(i);
	cout<<endl;
}
int mod=1e9+7;
int solve(vector<string>& graph, int R, int C){
	vector<vector<int>> ans(R,vector<int>(C,0));
	for (int i=0;i<R;i++){
		if (graph[i][0]=='#') break;
		else ans[i][0]=1;
	}
	for (int i=0;i<C;i++){
		if (graph[0][i]=='#') break;
		else ans[0][i]=1;
	}
	for (int i=1;i<R;i++){
		for (int j=1;j<C;j++){
			if (graph[i][j]!='#'){
				ans[i][j]=(ans[i-1][j]%mod+ans[i][j-1]%mod)%mod;
			}
		}
	}
	return ans[R-1][C-1];
}
signed main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
	int R,C;
    cin>>R>>C;
    vector<string> graph(R);
    for (int i=0;i<R;i++){
    	cin>>graph[i];	
    }
	cout<< solve(graph,R,C)<<endl;
    return 0; 
}


Measured memory_bytes: 13000
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long mod = 1000000007;

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

	int n;
	cin >> n;

	int* a;
	a = new int[n];
	rep(i, n) cin >> a[i];

	bool flag = true;
	int ans = 0;
	int counter = 1;
	rep(i, n) {
		if (a[i] == counter) {
			++counter;
			flag = false;
		}
		else ++ans;
	}

	if (flag) cout << -1 << "\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
import heapq

n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]

heap_lst = []
heapq.heapify(heap_lst)
j = 0
res = 0

sorted_lst = sorted(lst, key = lambda x: x[0])
for i in range(1, m+1):
    while j < n and sorted_lst[j][0] <= i:
        a, b = sorted_lst[j]
        heapq.heappush(heap_lst, (-b, a))
        j += 1
    if len(heap_lst) == 0:
        continue
    else:
        minus_b, a = heapq.heappop(heap_lst)
        res += -minus_b
print(res)

Measured memory_bytes: 38568
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MX = 200005;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for(int i=0;i<(1<<n);++i){
        vector<int> b(m,0);
        int sum = 0;
        rep(j,n){
            if(i & (1<<j)){
                rep(k,m){
                    b[k] += a[j][k];
                }
                sum += c[j];
            }
        }
        bool success=true;
        rep(j, m){
            if(b[j]<x) success = false;
        }
        if(success) ans = min(ans, sum);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
//program luogu.AT2201
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int ls;
char s[100100];

int main(){
//	freopen("read.in","r",stdin);
	scanf("%s",s);
	ls=strlen(s);
	if( ls%2==1 ){
		printf("No\n");
		return 0;
	}
	for(int i=0,j=ls-1;i<j;i++,j--){
		if( ( s[i]=='p' && s[j]=='q' ) || ( s[i]=='q' && s[j]=='p' ) || ( s[i]=='d' && s[j]=='b' ) || ( s[i]=='b' && s[j]=='d' ) )
			continue;
		else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <regex>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int INF = 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> vec;

    for (int i=0; i<n ; i++) {
        int tmp;
        cin >> tmp;
        vec.push_back(tmp);
    }

    for (int i=0; i<n; i++) {
        //cout << vec[i] << endl;
    }

    int dp[100010];
    for (int i=0; i<100010; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        dp[i+1] = dp[i+1] < abs(vec[i+1] - vec[i]) + dp[i] ?
         dp[i+1] : abs(vec[i+1] - vec[i])+dp[i];
        dp[i+2] = dp[i+2] < abs(vec[i+2] - vec[i]) + dp[i] ?
         dp[i+2] : abs(vec[i+2] - vec[i])+dp[i];
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1144
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[2][105];
int dp[2][105];
int n;


int main() {
	cin >> n;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int mx = 0;
	int sum1 = 0;
	for (int i = 0; i < n; i++) {
		sum1 += a[0][i];
		int sum2 = 0;
		for (int j = i; j < n; j++) {
			sum2 += a[1][j];
		}
		mx = max(sum1+sum2, mx);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n-2) {
    if(s.substr(i,3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long a[n];
    long long b[n];
    int diff = 0;
    int count = 0;
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    	b[i] = a[i];
    }
    sort(a,a+n);
    for(int i = 0; i < n; i++){
    	if(a[i] != b[i])diff++;
    }
    int x,y;
    int ok = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> x >> y;
    	x--;
    	y--;
    	if(i == 0 && diff == 0){
    		cout << 0 << endl;
    		ok = 1;
    	}
    	if(a[x] == b[x])diff++;
    	if(a[y] == b[y])diff++;
    	swap(b[x],b[y]);
    	if(a[x] == b[x])diff--;
    	if(a[y] == b[y])diff--;
    	count++;
    	if(ok == 0 && diff == 0){
    		cout << count << endl;
    		ok = 1;
    	}
    	if(ok == 0 && i == n - 1){
    		cout << -1 << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 7844
#include<iostream>
#include<iomanip>
int main()
{
	double result[2000][2];
	int num;
	for(int i = 0;; i++)
	{
		double a, b, c, d, e, f;
		std::cin >> a >> b >> c >> d >> e >> f;
		if(std::cin.eof())
		{
			num = i;
			break;
		}
		result[i][0] = (b * f - c * e) / (b * d - a * e);
		result[i][1] = (c * d - a * f) / (b * d - a * e);
		for(int j = 0; j < 2; j++)
		{
			if(result[i][j] == -0)
			{
				result[i][j] = 0;
			}
		}
	}
	std::cout << std::fixed << std::setprecision(3);
	for(int i = 0; i < num; i++)
	{
		std::cout << result[i][0] << ' ' << result[i][1] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3244
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
print(s[:4], s[4:])


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

int main() {
    int N; 
    cin >> N; 
    int a[114514]; 
  for (int i = 0; i < N; ++i){
  int n;
  cin >> n; if(n < 114514) a[n]++; 
  }
  int S = N; 
  for (int i = 1; i <= N; ++i){
  if(a[i] < i) S -= 0; 
  else S -= i; 
  }
    cout << S << endl; 
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstddef>
#include <algorithm>
#include <utility>

using ul = unsigned long long;
using uint = unsigned int;
using st = std::size_t;
template <class T>
using vec = std::vector<T>;

int main() {
    uint n;
    std::scanf("%u", &n);
    vec<std::pair<ul, ul>> DC(n);
    for(st i = 0; i < n; ++i) {
        std::scanf("%llu %llu", &DC[i].second, &DC[i].first);
    }

    std::sort(DC.begin(), DC.end());

    ul total_cost = 0;

    for(auto && DCi : DC) {
        total_cost += DCi.second;
        if(total_cost > DCi.first) {
            std::puts("No");
            return 0;
        }
    }

    std::puts("Yes");
}

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



int main() {
  ll n;
  cin >> n;
 
  vector<pair<ll,int>> fs;
  for (ll i = 2; i*i <= n; ++i) {
    int x = 0;
    while (n%i == 0) {
      n /= i;
      ++x;
    }
    fs.emplace_back(i,x);
  }
  if (n != 1) fs.emplace_back(n,1);
 
  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19772
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    H, W = map(int, input().split())
    print("#" * (W + 2))
    for i in range(H):
        line = input()
        print("#" + line + "#")
    print("#" * (W + 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include<iostream>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 768
N = int(input())

count = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0
    if count == 3:
        flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
long long int inf = 1e18;

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

  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  cout << accumulate(l.begin(), l.begin()+k, 0) << endl;

  return 0;
}




//


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
#include <assert.h>
#include <complex.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define FILL(A,val) memset(A,val,sizeof(A))

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double Pi = acos(-1.0);
const int INF = 1000000000;
const Int INF2 = Int(INF) * 5000;
const Int INF3 = Int(INF) * INF;
const int MAX = 100007;
const int MAXE = 2007000;
const int MAXV = 5000;
const int BASE = 1000000000;
const int ST = 1000000007;

const int MOD = 1000000007;

string solve(string s)
{
    if (s[0] == 'a')
    {
        VI A;
        VI B;
        FOR(i,0,SZ(s))
        {
            if (s[i] == 'a')
            {
                A.push_back(i);
            } else
            {
                B.push_back(i);
            }
        }

        string res = "";
        int last = -1;
        FOR(i,0,SZ(A))
        {
            if (A[i] > last)
            {
                last = B[i];
                res += "ab";
            }
        }
        return res;
    }

    string res = "";

    int n = SZ(s) / 2;

    FOR(j,0,n)
    {
        int cntA = 0;
        int cntB = 0;
        string r = "";
        FOR(i,0,SZ(s))
        {
            if (s[i] == 'a')
            {
                ++ cntA;
                if (cntA > j) r += 'a';
            }
            if (s[i] == 'b')
            {
                ++ cntB;
                if (cntB > j) r += 'b';
            }
        }
        res = max(res , r);
    }

    return res;
}

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


    int n;
    cin >> n;
    string s;
    cin >> s;

    int L = 0;

    vector<string> A;

    int bal = 0;

    FOR(i,0,SZ(s))
    {
        if (s[i] == 'a')
        {
            bal ++;
        } else
        {
            bal --;
        }
        if (bal == 0) {
            A.push_back(solve(s.substr(L, i - L + 1)));
            L = i + 1;
        }
    }

    string res = "";
    RFOR(i,SZ(A) , 0)
    {
        if (A[i] + res > res)
            res = A[i] + res;
    }

    cout << res << endl;

}

Measured memory_bytes: 384
B=[]
B+=[list(map(int,input().split()))]
B+=[list(map(int,input().split()))]
B+=[list(map(int,input().split()))]
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if B[i][j] == a:
                B[i][j] = 0

for i in range(3):
    if B[i][0]+B[i][1]+B[i][2] == 0:
        print("Yes")
        exit()
    if B[0][i]+B[1][i]+B[2][i] == 0:
        print("Yes")
        exit()

if B[0][0]+B[1][1]+B[2][2] == 0:
    print("Yes")
    exit()

if B[0][2]+B[1][1]+B[2][0] == 0:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

int main()
{
	ll x, sum = 0;
	
	cin >> x;

	for (ll i = 1; ; i++) {
		sum += i;
		if (x <= sum) {
			cout << i << endl;
			break;
		}
	}
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
#define MCONS 1001
#define LIMIT 1000000000

using namespace std;

ll ret;
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll n; vector<ll> vec(5, 0); cin >> n; for(int i = 0; i < 5; i++) cin >> vec[i];
    ll m = LLONG_MAX;
    int idx = -1;
    for(int i = 0; i < 5; i++)
    {
        if(m > vec[i])
        {
            m = vec[i];
            idx = i;
        }
    }
    if(n % m)
        cout << 5 + (n / m) << endl;
    else
        cout << 5 + (n / m) - 1 << endl;

    return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

ll const mod = 1e9+7;

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

int const MAX_N = 100010;
vector<ll> prime;
vector<bool> is_prime(MAX_N,true);
void Eratosthenes() {
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2;i*i < MAX_N;++i) if (is_prime[i]) for (ll j = 2*i;j < MAX_N;j += i) is_prime[j] = false;
    for (ll i = 0;i < MAX_N;++i) if (is_prime[i]) prime.push_back(i);
}

vector<pair<ll,int>> prime_factorization(ll a) {
    vector<pair<ll,int>> prime_factor;
    if (is_prime[0]) Eratosthenes();
    for (ll& i : prime) {
        if (i*i > a) break;
        if (a%i == 0) {
            P p = P(i,0);
            while (a%i == 0) {
                a /= i;
                p.second++;
            }
            prime_factor.push_back(p);
        }
    }
    if (a != 1) prime_factor.push_back(P(a,1));
    return prime_factor;
}

void rec(vector<ll>& div,vector<pair<ll,int>>& fact,int i,ll d) {
    if (i == fact.size()) {
        div.push_back(d);
        return;
    }
    for (int j = 0;j <= fact[i].second;++j) {
        rec(div,fact,i+1,d);
        d *= fact[i].first;
    }
}

// unsorted
vector<ll> divisor(ll a) {
    vector<ll> div;
    vector<pair<ll,int>> prime_factor = prime_factorization(a);
    rec(div,prime_factor,0,1);
    return div;
}

int main() {
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll> cnt(k+1,0);
    for (int i = k;i > 0;--i) {
        (cnt[i] += pow_mod(k/i,n)) %= mod;
        for (int d : divisor(i)) if (d < i) (cnt[d] -= cnt[i]) %= mod;
        (ans += cnt[i]*i%mod) %= mod;
    }
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 4400
package main

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

func main() {
	In := readLineInt()
	fmt.Println(max(In[0]-In[1], 0))
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func max(a ...int) int {
	result := 0

	for _, i := range a {
		if result < i {
			result = i
		}
	}

	return result
}

Measured memory_bytes: 640
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let mut lines: Vec<Vec<i64>> = stdin
        .lock()
        .lines()
        .map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|w| w.parse().unwrap())
                .collect()
        })
        .collect();
    let (n, k, mut al, mut fl) = (lines[0][0], lines[0][1], lines.remove(1), lines.remove(1));
    if al.iter().sum::<i64>() <= k {
        println!("0");
        return;
    } else {
        al.sort();
        al.reverse();
        fl.sort();
        let mut list: Vec<_> = al.iter().zip(fl.iter()).collect();
        list.sort();
        list.reverse();
        let mut lp: i64 = 1;
        let mut rp: i64 = 1 << 40;
        let mut mp: i64 = (lp + rp) / 2;
        while (lp != mp) || (mp != rp) {
            let cnt: i64 = list
                .iter()
                .filter(|&&(a, f)| (a * f) > mp)
                .map(|&(a, f)| a - (mp / f))
                .sum();
            // let mut cnt = 0;
            // for &(a, f) in &list {
            //     if (a * f) > mp {
            //         cnt += a - (mp / f);
            //     } else {
            //         break;
            //     }
            // }
            if k < cnt {
                lp = mp + 1;
            } else {
                rp = mp;
            }
            mp = (lp + rp) / 2;
        }
        println!("{}", mp);
    }
}


Measured memory_bytes: 15068
N,M = map(int,input().split())
stu = []
for v in range(N):
    ai,bi = map(int,input().split())
    stu.append((v,ai,bi))
cp = []
for w in range(M):
    ci,di = map(int,input().split())
    cp.append((w,ci,di))
#大きい番号から調べることで同じ値のとき最小のチェックポイントに行ける
cp = cp[::-1]
ans = [0]*N
#ある学生について    
for i,x,y in stu:
    #あるチェックポイントについて
    mindist = 10**16
    cp_num = 0
    for j,k,l in cp:
        dist = abs(x-k) + abs(y-l)
        if mindist >= dist:
            mindist = dist
            cp_num = j+1
    ans[i] = cp_num
for n in ans:
    print(n)

Measured memory_bytes: 9232
n = input()
n = int(n)
a = input().split()
a = [int(aa) for aa in a]

ans = 10000000000000000

l = -100000000000
r =  100000000000

for count in range(100):
    mid = (l + r) // 2
    temp = 0
    for i in range(n):
        temp1= abs(a[i] - (mid + i + 1))
        temp2= abs(a[i] - ((mid - 1) + i + 1))
        temp += temp1 - temp2
    if temp > 0:
        r = mid
    else:
        l = mid
for b in range(l, r + 1):
    temp = 0
    for i in range(n):
        temp += abs(a[i] - (b + i + 1))
    ans = min(ans, temp)
print(ans)

Measured memory_bytes: 88040
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	string s; cin >> s;
	list<int> ans;
	int i = n;
	while (i != 0) {
		int mi = i - m;
		if (mi <= 0) {
			ans.push_front(i);
			break;
		}

		bool has_next = false;
		while (mi < i) {
			if (s[mi] == '0') {
				ans.push_front(i - mi);
				i = mi;
				has_next = true;
				break;
			}
			mi++;
		}
		if (has_next) continue;
		cout << -1 << endl;
		return 0;
	}

	for (auto j : ans) {
		cout << j << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3664
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define inf 2147483640
#define pi acos(-1.0)
#define IL inline
#define RG register
#define LL long long
#define db double
#define N 200005
using namespace std;
IL int gi()
{
	RG int res=0,s=1;RG char ch;
	for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
	if(ch=='-') s=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*s;
}
char s[N];
LL n;LL ans=0;
int cnt[26];
int main()
{
	//freopen("2.in","r",stdin);
	//freopen("2.out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	ans=(n+1)*n>>1;
	for(RG int i=1;i<=n;++i)
		{
			cnt[s[i]-'a']+=1;
			ans-=cnt[s[i]-'a'];
		}
	printf("%lld\n",ans+1);
	//fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            //入力
            int n = int.Parse(Console.ReadLine());

            //sの位置に応じて場合分けする
            Console.WriteLine(2 * n * Math.PI);
        }
    }

}


Measured memory_bytes: 27620
M=10**9+7
def extended_gcd(a, b)
  last_remainder, remainder = a.abs, b.abs
  x, last_x, y, last_y = 0, 1, 1, 0
  while remainder != 0
    last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)
    x, last_x = last_x - quotient*x, x
    y, last_y = last_y - quotient*y, y
  end
  return last_remainder, last_x * (a < 0 ? -1 : 1)
end

def invmod(e)
  g, x = extended_gcd(e, M)
  x % M
end

n,k,*as=$<.read.split.map &:to_i
as.sort!

cvs=[0]*(k-1)
t=1
(n-k+1).times{|i|
  cvs.push(t)
  t=t*(i+k)*invmod(i+1)%M
}
puts (0...n).reduce(0){|s,i|
  (s+(cvs[i]-cvs[n-i-1])*as[i])%M
}


Measured memory_bytes: 13292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main() {
 
    int h,a;
    cin >> h >> a ;
    
    int i, tmp ,res;
    tmp = 0;
    
    while(h>0){
        h=h-a;
        tmp++;
    }

    cout << tmp ;
}


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

int main()
{
    int n;
    int t = 1000000001;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
        t = min(t,vec[i]);
    }

    int m = t;
    while(true)
    {
        int cnt = 0;
        for(int i = 0; i < n; ++i)
        {
            vec[i] = vec[i] % t;
            if(vec[i] == 0)
            {
                vec[i] = t;
            }
            if(m > vec[i])
            {
                m = vec[i];
            }
            else
            {
                ++cnt;
            }
        }
        if(cnt == n
        || m == 1)
        {
            break;
        }
        else
        {
            t = m;
        }
        
    }
    cout << m << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Stack;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] mem = new int[10];
		int pos = 0;
		StringBuilder sb = new StringBuilder();
		for (char c : sc.next().toCharArray()) {
			int idx = (c - 33) / 10;
			for (int i = 0; i < Math.abs(pos - idx); ++i) {
				sb.append(idx < pos ? '<' : '>');
			}
			pos = idx;
			for (int i = 0; i < Math.abs(mem[pos] - c); ++i) {
				sb.append(c < mem[pos] ? '-' : '+');
			}
			mem[pos] = c;
			sb.append('.');
		}
		System.out.println(sb);
	}

}

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

int main() {
  int n, k, sum = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
  	int x;
    cin >> x;
    if(pow((x - k), 2) >= pow(x, 2)){
    	sum += 2 * x;
    }else if(x >= k){
    	sum += 2 * (x - k);
    }else{
    	sum += 2 * (k - x);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, m;
VI h(100010);
VI ma(100010, 0);

signed main() {
    cin >> n >> m;
    h.resize(n);
    ma.resize(n);
    REP(i, n) {
        cin >> h[i];
    }

    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    int res = 0;
    REP(i, n) {
        DEBUGP(make_pair(h[i], ma[i]));
        if (h[i] > ma[i])
            res++;
    }

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


Measured memory_bytes: 6264
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  char *s=(char *)malloc(sizeof(char)*4);

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%s", s);

  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
    printf("Bad\n");
  }
  else{
    printf("Good\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c<=0){
            cout << "Yes" << endl;
            break;}
        a -= d;
        if (a<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define MOD 1000000007

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  long c[2001][2001] = {};
  c[0][0] = 1;
  c[1][0] = 1;
  c[1][1] = 1;
  for(int a=2;a<2001;a++){
    c[a][0] = 1;
    c[a][a] = 1;
    for(int b=1;b<a;b++){
      c[a][b] = (c[a-1][b-1] + c[a-1][b]) % MOD;
    }
  }
  long answer;
  for(int i=1;i<=k;i++){
    if(i <= n-k+1){
      answer = (c[n-k+1][i] % MOD)*(c[k-1][i-1] % MOD);
      printf("%ld\n",answer % MOD);
    }else{
      printf("0\n");
    }
  }
  return 0;
}

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

int main() {
    int N; cin >> N;
    int K; cin >> K;
    int counter = 0;
    rep(i, N){
        int a; cin >> a;
        if(a >= K)counter++;
    }
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  lint a, b;
  cin >> a >> b;

  if((a+b)%2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  ll n;
  cin >> n;
  int b = n;
  int a = 0;
  int x = 0;
  for(int i = 0; i < 30; i++) {
    a = n % 10;
    n = n - a;
    n = n / 10;
    x = x + a;
    if(n == 0) break;
  }
  if(b % x == 0) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n,m,a[N];
int g[N];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m;
	rep(i,1,n){
		cin>>a[i];
	}
	rep(i,1,m){
		int x,y;
		cin>>x>>y;
		g[x]=max(g[x],a[y]);
		g[y]=max(g[y],a[x]);
	}
	int ans=0;
	rep(i,1,n){
		if(a[i]>g[i]){
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    char a, b, c;
    
    cin >> a >> b >> c;
    
    int count = 0;
    if (a == '1') count++;
    if (b == '1') count++;
    if (c == '1') count++;
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

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

  int a, b;
  while(cin >> a >> b) cout << a+b << endl;

  return 0;
}

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

int ans[200005];
bool chk[200005];

int main()
{
  int n,x,len;

  scanf("%d%d",&n,&x);
  len=(n*2)-1;
  if (x==1||x==len)printf("No\n");
  else
  {
    printf("Yes\n");
    ans[n]=x;
    chk[x]=true;
    ans[n-1]=x-1;
    chk[x-1]=true;
    ans[n+1]=x+1;
    chk[x+1]=true;
    if (x+2<=(2*n)-1)ans[n-2]=x+2,chk[x+2]=true;
    if (x-2>0)ans[n+2]=x-2,chk[x-2]=true;
    int ptr=1;
    while(chk[ptr])ptr++;
    for(int c=1;c<=len;c++)
    {
      if (ans[c]==0)
      {
        ans[c]=ptr;
        chk[ptr]=true;
        while(chk[ptr])ptr++;
      }
    }
    for(int c=1;c<=len;c++)printf("%d\n",ans[c]);
  }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    // youtube解説
   
    int m;
    cin >> m;
    
    ll sum = 0;
    ll di = 0;
    rep(i, m) {
        int d; ll c;
        cin >> d >> c;
        sum += d * c;
        di += c;
    }
    
    ll last = sum % 9;
    if (last == 0) last = 9; // 最後なりうる数, 和に置き換えて0はなり得ない
    
    // 両方毎回9減る形にする(桁を9倍する)
    // 1桁減らすのも合計9減らすのも同じ操作と見れる
    ll A = 9 * di + sum;
    ll B = 9 * 1 + last;
    // cout << A << " " << B << endl;
    
    // 差は9の倍数, 9で割れば回数
    cout << (A - B) / 9 << endl;
}


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

int main () {
    int n;
    cin >> n;
    ll in;
    ll now;
    ll ans = 0;
    for (int i = 0;i < n;i++) {
        cin >> in;

        if (i == 0) {
            now = in;
        } else {
            if (in <= now) ans += (now - in);
            else now = in;
        }
    }

    cout << ans << endl;

    return(0);
}


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

int koubai(int,int);
int kouyaku(int, int);

int main(void){
	long int n;
	int m = 2;

	cin >> n;
	cout << koubai(m,n);

	return 0;
}

int koubai(int x,int y){
	return(x * y / kouyaku(x,y));
}

int kouyaku(int x,int y){
	int z;

	while((z = x % y) != 0){
		x = y;
		y = z;
	}
	
	return y;
}

Measured memory_bytes: 256