akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;

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

    int n;
    int m;
    cin >> n >> m;

    int a;
    int sum = 0;
    for (int i=0;i<m;i++){
        cin >> a;
        sum += a;
    }

    int ans = 0;
    ans = n - sum;
    
    if(ans < 0)
        ans = -1;

    cout << ans;
}

Measured memory_bytes: 3644
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

#define ARRAY_MAX_NUM 50
#define ARRAY_LEN 26

static uint32_t array[ARRAY_MAX_NUM][ARRAY_LEN];

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    string str;
    cin >> str;

    for (uint32_t j = 0; j < str.size(); j++) {
      array[i][str[j] - 'a']++;
    }
  }

  for (uint32_t i = 0; i < ARRAY_LEN; i++) {
    uint32_t count = UINT32_MAX;
    for (uint32_t j = 0; j < n; j++) {
      count = min(count, array[j][i]);
    }

    for (uint32_t k = 0; k < count; k++) {
      cout << (char)('a' + i);
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

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

	cout << ans << endl;

	return 0;
}

//AAAAAAAAAAAAAAAAA
//int main() {
//	int k, x;
//	cin >> k >> x;
//
//	if (k * 500 >= x) cout << "Yes" << endl;
//	else cout << "No" << endl;
//
//	return 0;
//}

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int N_MAX = 2000;
typedef pair<int,int> CT;
int main()
{
  int n,t;
  cin >> n >> t;
  CT ct[N_MAX];
  for(int i=0;i<n;i++)
    cin >> ct[i].first >> ct[i].second;
  int mc = N_MAX;
  for(int i=0;i<n;i++)
    if(ct[i].second<=t && ct[i].first<mc)
      mc = ct[i].first;
  if(mc==N_MAX)
    cout << "TLE" << endl;
  else
    cout << mc << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 10005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int g[405][405],f[405][405],ind[405],H,col[405],all;
int N,A[100005],B[100005],C[100005],D[100005],cnt;
bool vis[405],flag,has[405];
void dfs(int u) {
    all += ind[u];
    if(ind[u]) flag = 1;
    vis[u] = 1;
    for(int i = 1 ; i <= 2 * H ; ++i) {
        if(f[u][i] && !vis[i]) dfs(i);
    }
}
void Solve() {
    read(N);read(H);
    for(int i = 1 ; i <= N ; ++i) {
        read(A[i]);read(B[i]);read(C[i]);read(D[i]);
        int s,t;
        if(C[i]) s = C[i];
        else s = A[i] + H;
        if(D[i]) t = D[i] + H;
        else t = B[i];
        g[s][t]++;ind[t]++;ind[s]--;
        f[s][t]++;f[t][s]++;
        has[s] = has[t] = 1;
    }
    for(int i = 1 ; i <= H ; ++i) {
        if(ind[i] < 0) {puts("NO");return;}
    }
    for(int i = H + 1 ; i <= 2 * H ; ++i) {
        if(ind[i] > 0) {puts("NO");return;}
    }
    for(int i = 1 ; i <= 2 * H ; ++i) {
        if(!has[i]) continue;
        if(!vis[i]) {
            flag = 0;
            dfs(i);
            if(all != 0 || !flag) {puts("NO");return;}
        }
    }
    puts("YES");
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 3072
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long now=100;
	for(int i=1;;i++){
		now=1.01*now;
		if(now>=n)return cout<<i,0;
	}
	return 0;
}

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

static bool is_used_alpha[256];

inline bool is_check_encode(string s, const string &encode_s) {
	memset(is_used_alpha, false, sizeof(is_used_alpha));
	is_used_alpha['a'] = true;

	for(int i = 0; i < static_cast<int>(s.size()); ++i) {
		if(!is_used_alpha[s[i]]) {
			is_used_alpha[s[i]] = true;
			--s[i];
		}
		if(s[i] != encode_s[i]) return false;
	}
	return true;
}

int main() {
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	string s;
	vector<string> anses;

	while(true) {
		cin >> s;

		if(s[0] == '#') break;
		const int N = s.size();
		anses.clear();

		for(int i = 0; i < (1 << N); ++i) {
			int ii = i;
			string tmp_s(s);

			for(int j = 0; j < N; ++j) {
				if((ii & 1)) {
					if(tmp_s[j] == 'z') goto ng;
					tmp_s[j] = (char)(tmp_s[j] + 1);
				}
				ii = ii >> 1;
			}

			if(is_check_encode(tmp_s, s)) {
				anses.push_back(move(tmp_s));
			}

		ng:;
		}

		sort(begin(anses), end(anses));
		cout << anses.size() << endl;
		if(anses.size() <= 10) {
			for(const auto &e : anses) {
				cout << e << endl;
			}
		}
		else {
			for(int i = 0; i < 5; ++i) {
				cout << anses[i] << endl;
			}
			for(int i = anses.size() - 5; i < anses.size(); ++i) {
				cout << anses[i] << endl;
			}
		}
	}

	return EXIT_SUCCESS;
}

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

int main(){
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int main(void){
    int result = 0;
    long n;

    cin >> n;

    for(long i = 1; i < n+1; i++){
        if(1 <= i/(100000)){
            ;
        }else if(1 <= i/(10000)){
            result++;
        }else if (1 <= i/(1000)){
            ;
        }else if(1 <= i/100){
            result++;
        }else if(1 <= i/10){
            ;
        }else{
            result++;
        }

    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();

        var aList = Console.ReadLine().ToLongArray().OrderByDescending(n => n).ToArray();

        var lis1 = aList.TakeWhile(n => n >= 0).ToList();
        var lis2 = aList.SkipWhile(n => n >= 0).ToList();

        if (lis1.Count == 0)
        {
            var val = lis2.First();
            lis2.Remove(val);
            lis1.Add(val);
        }
        else if (lis2.Count == 0)
        {
            var val = lis1.Last();
            lis1.Remove(val);
            lis2.Add(val);
        }

        var q1 = new Queue<long>(lis1);
        var q2 = new Queue<long>(lis2);
        

        var ans = q1.Sum() - q2.Sum();
        Console.WriteLine(ans);

        while(q1.Any() && q2.Any())
        {
            if (q1.Count == 1 && q2.Count == 1)
            {
                Console.WriteLine($"{q1.Dequeue()} {q2.Dequeue()}");
                return;
            }
            else if (q1.Count >= q2.Count)
            {
                var v1 = q2.Dequeue();
                var v2 = q1.Dequeue();
                Console.WriteLine($"{v1} {v2}");
                var n = v1 - v2;
                q2.Enqueue(n);
            }
            else
            {
                var v1 = q1.Dequeue();
                var v2 = q2.Dequeue();
                Console.WriteLine($"{v1} {v2}");
                var n = v1 - v2;
                q1.Enqueue(n);
            }
        }
    }
}

Measured memory_bytes: 33116
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<long long> Asum(A);
  for (int i = 0; i < N - 1; i++) {
    Asum[i + 1] += Asum[i];
  }

  int idx = N - 2;
  while (idx >= 0 && 2*Asum[idx] >= A[idx + 1]) idx--;
  cout << (N - idx - 1) << endl;


  return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;

ll n;

void solve()
{
	int sol = (int) max(log10(1)+1, log10(n)+1);

	for(ll i = 2; i*i <= n; i++)
	{
		if(n%i == 0)
			sol = min((int)max(log10(i)+1, log10(n/i)+1), sol);
	}

	cout << sol << endl;
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	solve();
	return 0;	
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

int main(){
  ll A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  ll Z = max(X,Y);
  ll ans = INF;
  for(ll i = 0; i <= Z; i++){
    ll p = C*(2LL*i)+max((X-i),0LL)*A+max(0LL,(Y-i))*B;
    chmin(ans,p);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

var scanner *bufio.Scanner

func printIt() {
	n := nextInt()
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		nums[i] = nextInt()
	}
	for j := n - 1; j >= 0; j-- {
		fmt.Print(nums[j])
		if j != 0 {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}


func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1128
#include<iostream>
#include<algorithm>
#include<cstdint>

int64_t const MOD = 1e9+7;
int const MAXN = 2e5;
int64_t C[MAXN];
int N;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
  operator int64_t() const { return v_; }
};
typedef mod_int<MOD> mint;

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> C[i];
  std::sort(C, C+N, [](int64_t l, int64_t r){ return l > r; });
  mint ans;
  for(int i = 0; i < N; ++i) ans += mint(C[i])*mint(i+2);
  ans *= mint(2).pow(2*N-2);
  std::cout << ans << std::endl;
  return 0;
}



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


int main() {
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B << endl;
  }else if(A<=5){
    cout << 0 << endl;
  }else{
    cout << B/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
    // int t;
     // cin >> t;

//      while(t--){

// }
     int a;
     cin >> a;
     int a2 = a*a;
     int a3 = a2*a;
     cout << a + a2 + a3 << endl;




return 0;
}





Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define Maxn 3007
int n,a[Maxn],l;
const double pi=acos(-1.0);
int main()
{
    scanf("%d%d",&n,&l);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    double ansx=0.0,ansy=0.0;
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
        {
            double tmpx=cos(pi*(a[i]+a[j])/(1.0*l));
            double tmpy=sin(pi*(a[i]+a[j])/(1.0*l));
            ansx+=tmpx*(n-2-(j-i-1));
            ansy+=tmpy*(n-2-(j-i-1));
            tmpx=cos(pi+pi*(a[i]+a[j])/(1.0*l));
            tmpy=sin(pi+pi*(a[i]+a[j])/(1.0*l));
            ansx+=tmpx*(j-i-1);
            ansy+=tmpy*(j-i-1);
        }
    double r=1.0*n*(n-1)*(n-2)/6.0;
    ansx/=r;
    ansy/=r;
    printf("%.15lf %.15lf\n",ansx,ansy);
    return 0;
}

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

using namespace std;

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
	vector<int> size; // 連結成分のサイズ

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n);
		rank.resize(n);
		size.resize(n);
        for (int i = 0; i < n; ++i){
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
    }

    int find(int x) {
        if (par[x] == x)  return x;

        int r = find(par[x]);
        return par[x] = r;
    }

    bool issame(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y) {
	    x = find(x);
		y = find(y);
	    if (x == y) return false;

	    if (rank[x] < rank[y]) swap(x, y);
	    if (rank[x] == rank[y]) ++rank[x];
	    par[y] = x;
		size[x] += size[y];
	    return true;
    }

	int getSize(int x){
		return size[find(x)];
	}

	int getRank(int x){
		return rank[find(x)];
	}
};


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

	int n, m;
	cin >> n >> m;

	vector<pli> a(n);
	rep(i, n){
		cin >> a[i].first;
		a[i].second = i;
	}

	UnionFind uf(n);
	rep(i, m){
		int x, y;
		cin >> x >> y;

		uf.unite(x, y);
	}

	set<int> st;
	map<int, vector<pli>> mpv;
	rep(i, n){
		int p = uf.find(i);
		if(st.count(p) == 0){
			st.insert(p);
		}
		mpv[p].push_back(a[i]);
	}

	int nfor = mpv.size();
	if(n < 2 * nfor - 2){
		cout << "Impossible" << endl;
		return 0;
	}

	if(nfor == 1){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	vector<bool> used(n, false);
	for(int p : st){
		sort(mpv[p].begin(), mpv[p].end());
		ll cost = mpv[p][0].first;
		int idx = mpv[p][0].second;
		ans += cost;
		used[idx] = true;
	}

	int left = nfor - 2;
	int pos = 0;
	sort(a.begin(), a.end());
	while(left > 0){
		ll cost = a[pos].first;
		int idx = a[pos].second;
		if(!used[idx]){
			used[idx] = true;
			ans += cost;
			left--;
		}
		pos++;
	} 

	cout << ans << endl;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if(abs(A - B) > 1e+18){ 
        cout << "Unfair\n";
    }else if(K%2 == 1){
        cout << B - A << "\n";
    }else{
        cout << A - B << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 100010


int main(){
    IOS;
 	
 	
	ll n,k;cin>>n>>k;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	rep(i,0,k)sum+=a[i];
	cout<<sum;
	
    
     
    return 0;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define int ll
const double PI = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;
const int MX = 777777 + 5;
const int mod = 1777777777;
const double EPS = 1e-10;
const ll MXP = 8999251775770639633;


int fac[MX+5];
int power(int x, int y, int p)
{
    int res = 1;

    x = x % p;

    while (y)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

int C(int n, int r, int p)
{
    if (r==0)
        return 1;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

void init(int mod){
    fac[0] = 1;
    for (int i=1 ; i<=MX; i++)
        fac[i] = fac[i-1]*i%mod;
}

int CC(int a, int b){
    int res = 1;
    rep(i,a+1,a-b+1)res *= i,res/=a-i+1;
//    rep(i,1,b+1)res /= i;
    return res;
}
void _() {
    
        int n;
        cin >> n;
        int d = floor(log10(n))+1;
        if(n%(int)pow(10,d-1) != pow(10,d-1)-1)cout << n/(int)pow(10,d-1) + 9*(d-1) -1<< endl;
        else cout << n/(int)pow(10,d-1) + 9*(d-1) << endl;
    

};

#undef int
int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


}

Measured memory_bytes: 384
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, W = list(map(int, sys.stdin.buffer.readline().split()))
S = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(H)]


def black(h, w):
    if 0 <= h < H and 0 <= w < W:
        return S[h][w] == '#'
    return False

def test(h, w):
    if S[h][w] == '.':
        return True
    cnt = 0
    cnt += black(h - 1, w)
    cnt += black(h + 1, w)
    cnt += black(h, w - 1)
    cnt += black(h, w + 1)
    return cnt >= 1


ok = True
for h, w in itertools.product(range(H), range(W)):
    ok &=test(h, w)
if ok:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 13680
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);

  int ans = 0;
  if (a > b)
  {
    ans = a--;
  }
  else
  {
    ans = b--;
  }

  ans += max(a, b);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
def seekDistance(n,nodes):
    max_z,min_z = searchMaxAndMinZ(n,nodes)
    max_w,min_w = searchMaxAndMinW(n,nodes)
    return max(max_z-min_z,max_w-min_w)

def searchMaxAndMinZ(n,nodes):
    max_z = -1
    min_z = 2 * 10 ** 9
    for i in range(n):
        curr_z = nodes[i][0] + nodes[i][1]
        if(curr_z > max_z):
            max_z = curr_z
        if(curr_z < min_z):
            min_z = curr_z
    return max_z,min_z

def searchMaxAndMinW(n,nodes):
    max_w = -10**9
    min_w = 2 * 10 ** 9
    for i in range(n):
        curr_w = nodes[i][0] - nodes[i][1]
        if (curr_w > max_w):
            max_w = curr_w
        if (curr_w < min_w):
            min_w = curr_w
    return max_w, min_w

n = int(input())
nodes = [list(map(int,input().split())) for i in range(n)]
print(seekDistance(n,nodes))

Measured memory_bytes: 45292
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,ans,cnt,tmp,k,t;
	while(cin>>a>>b){
		if(a==b){
			cout<<a<<endl;
			continue;
		}
		ans=0;
		for(ll i=0LL;(1LL<<i)<=b;i++){
			tmp=(b+1LL)/(1LL<<(i+1LL))*(1LL<<i)+max((b+1LL)%(1LL<<(i+1LL))-(1LL<<i),0LL);
		//	cout<<tmp<<" ";
			if(a){
				tmp-=a/(1LL<<(i+1LL))*(1LL<<i)+max(a%(1LL<<(i+1LL))-(1LL<<i),0LL);
		//		cout<<a/(1LL<<(i+1LL))+max(a%(1LL<<(i+1LL))-(1LL<<i),0LL)<<" ";
			}
		//	cout<<tmp<<endl;
			if(tmp&1LL)
				ans+=(1LL<<i);
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
N = N%10
if N == 2 or N == 4 or N == 5 or N == 7 or N == 9:
    print("hon")
if N ==0 or N== 1 or N == 6 or N == 8:
    print("pon")
if N== 3 :
    print("bon")


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
const int MAX_M = 100005;
int N, M;
struct Query {
  int L, R, C;
  const bool operator < (const Query& q) const {
    return R < q.R;
  }
}Q[MAX_M];

class Node {
public:
    Node(LL v = unitValue) : value(v) {

    }

    Node operator + (const Node& monoid) const {
        return Node(min(this->getValue(), monoid.getValue()));
    }

    static Node unit() {
        return Node(unitValue);
    }

    void setValue(LL l) {
        this->value = l;
    }

    LL getValue() const {
        return this->value;
    }

private:
    LL value;
    static const LL unitValue = INF_LL;
};

template <class T>
class SegmentTree {
public:
    SegmentTree(int size) {
        init(size);
    }

    void init(int size) {
        vec.clear();
        k = 1;
        while(k < size) {
            k *= 2;
        }
        for(int i = 0; i < 2*k; i++) {
            vec.push_back(T::unit());
        }
    }

    void update(int i, T x) { //iをxに変更する
        i += k-1;
        vec[i] = x;
        while(i > 0) {
            i = (i-1)/2;
            vec[i] = vec[i*2+1] + vec[i*2+2];
        }
    }

    T find(int l, int r) {
        return _find(l, r, 0, 0, k);
    }

private:
    vector<T> vec;
    int k;

    T _find(int l, int r, int k, int x, int y) {
        if (r <= x || y <= l) { //重なってない場合
            return T::unit();
        } else if (l <= x && y <= r) { //完全にかぶってる場合
            return vec[k];
        } else { //中途半端にかぶってる場合
            int mid = (x+y)/2;
            T lNode = _find(l, r, 2*k+1, x, mid);
            T rNode = _find(l, r, 2*k+2, mid, y);
            return lNode + rNode;
        }
    }
};

SegmentTree<Node> sg(MAX_N);

signed main()
{
  cin >> N >> M;
  REP(m,M) {
    cin >> Q[m].L >> Q[m].R >> Q[m].C;
    Q[m].L--; Q[m].R--;
  }

  sort(Q,Q+M);

  sg.update(0,0);

  int m = 0;
  FOR(pos,1,N) {
    int tmp = INF_LL;
    while(m < M && Q[m].R == pos) {
      tmp = min(tmp, sg.find(Q[m].L, Q[m].R).getValue() + Q[m].C);
      m++;
    }
    sg.update(pos, tmp);
  }

  int ans = sg.find(N-1,N).getValue();
  if(ans == INF_LL) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int N,M;
  cin >> N;
  double b;
  if (N % 2 == 0 ){
    cout << 1.0 / 2.0 << endl;
  }
  else if(N % 2 == 1){
    b = N / 2 + 1;
    cout << b / N << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        PriorityQueue pq = new PriorityQueue ();
        
        for(int i = 0; i < 2*N; i++) {
            pq.add(scan.nextInt());
        }
        
        int total = 0, value;
        for(int i = 0; i < N; i++) {
            total += (int)pq.poll();
            pq.poll();
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,n;
	int ans=0;
	cin >>h>>n;
	VPi data(n);
	cin >> data;
	VVi dp(n+1, Vi(h + 3, INF));//at,hp-> mp
	dp[0][0] = 0;
	for (int i = 0; i < n;i++){
		for (int j = 0; j < h + 1;j++){
			chmin(dp[i+1][j],dp[i][j]);
			chmin(dp[i + 1][min(j + data[i].F, h)], dp[i+1][j] + data[i].S);
		} }
	cout << dp[n][h] << endl;
}

Measured memory_bytes: 42428
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define vi vector<ll>
const int INF = 1e9;
const int N = 100005;
vi h(N, 0);
vi dp(N, INF);
void solve() {
	ll n, k; cin >> n >> k;
	for (ll i = 0; i < n; i++) cin >> h[i];

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (ll i = 2; i < n; i++) {
		for (ll j = 1; j <= k && i - j >= 0; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n - 1];
}

int main() {

	FASTIO;
/*
#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
*/
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
map<int,int> m;
  int tmp=0;
  for(int i=1;i<N+1;i++){
    int t;
    cin>>t;
    m[(tmp+t)%M]++;
    tmp=(tmp+t)%M;
  }
  long long ans=0;
  for (auto d:m)ans+=(long long)d.second*(d.second-1)/2+((d.first==0)?d.second:0);
  cout<<ans<<endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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


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

int64_t GCD(int64_t a, int64_t b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int64_t LCM(int64_t a, int64_t b) {
    return (a / GCD(a, b)) * b;
}

int main() {
    int N, M;
    cin >> N >> M;

    string S, T;
    cin >> S >> T;

    for (int64_t i = 0; i < N; i++) {
        if ((i * M) % N == 0) {
            int j = (i * M) / N;

            if (j < M and S[i] != T[j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << LCM(N, M) << endl;

    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3

output:
5
0 0
2 1
4 2
3 3
1 3

The operator module functions allow multiple levels of sorting. For example, to sort by grade then by age:

sorted(student_tuples, key=itemgetter(1,2))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]

sorted(student_objects, key=attrgetter('grade', 'age'))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]
"""

import sys
from operator import attrgetter

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        # print('COUNTER_CLOCKWISE')
        flag = 1
    elif cross(a, b) < -1 * EPS:
        # print('CLOCKWISE')
        flag = -1
    elif dot(a, b) < -1 * EPS:
        # print('ONLINE_BACK')
        flag = 2
    elif abs(a) < abs(b):
        # print('ONLINE_FRONT')
        flag = -2
    else:
        # print('ON_SEGMENT')
        flag = 0
    return flag


def convex_check_Andrew(_polygon):
    upper, lower = list(), list()
    _polygon.sort(key=attrgetter('real', 'imag'))

    upper.extend((_polygon[0], _polygon[1]))
    lower.extend((_polygon[-1], _polygon[-2]))

    for i in range(2, points):
        n1 = len(upper)
        while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
            n1 -= 1
            upper.pop()
        upper.append(_polygon[i])

    for j in range(points - 3, -1, -1):
        n2 = len(lower)
        while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
            n2 -= 1
            lower.pop()
        lower.append(_polygon[j])

    # print(upper, lower)
    lower.reverse()
    # lower.sort(key=attrgetter('imag', 'real'))
    lower_min = min(lower, key=attrgetter('imag', 'real'))
    # print(lower_min)
    min_index = lower.index(lower_min)
    lower_right = lower[min_index:]
    lower_left = lower[:min_index]
    for k in range(len(upper) - 2, 0, -1):
        lower_right.append(upper[k])
    return lower_right + lower_left


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    points = int(_input[0])
    p_info = map(lambda x: x.split(), _input[1:])

    polygon = [int(x) + int(y) * 1j for x, y in p_info]
    ans = convex_check_Andrew(polygon)
    print(len(ans))
    for ele in ans:
        print(int(ele.real), int(ele.imag))

Measured memory_bytes: 31016
#include <bits/stdc++.h>
#define M 1000000007

using namespace std;

int main() {
	int n;
	cin >> n;
	long long factorial = 1;
	for (int i = 1; i <= n; i++) {
		factorial *= i;
		factorial %= M;
	}
	cout << factorial;
	return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
r, c = map(int, input().split())

d = getSomeInputListInt(r)
d.append([])

for i in range(c):
    tmp = 0
    for j in range(r):
        tmp += d[j][i]
    d[r].append(tmp)

for i in range(r+1):
    tmp = 0
    for j in range(c):
        tmp += d[i][j]
    d[i].append(tmp)

d[r][c] = sum(d[r][0:c])

for tmp_d in d:
    print(*tmp_d, sep=" ")



Measured memory_bytes: 7628
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  ans = N > K ? (N  - K - 1) / (K - 1) + 2  : 1;
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  // Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
      scanf("%lld", &A[i]);
      if(A[i] == 1) {
        B = i;
      }
    }
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
  }

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
struct Pair{
	long long leftnum;
	long long rightnum;
};
int main()
{
	long long N;
	cin >> N;
	Pair pair[N];
	long long A[N];
	long long i;
	for(i = 0;i < N;i++)
	{
		pair[i].rightnum = 0;
		pair[i].leftnum = 0;
	}
	for(i = 0;i < N;i++)
	{
		cin >> A[i];
	}
	for(i = 0;i < N;i++)
	{
		if(i - A[i] >= 0) pair[i-A[i]].rightnum += 1;
		if(A[i] + i <= N-1) pair[A[i]+i].leftnum += 1;
	}
	long long ans = 0;
	for(i = 0;i < N;i++)
	{
		ans += (pair[i].rightnum)*(pair[i].leftnum);
	}
	cout << ans;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
char op[MAXN];
int n,dat[MAXN],nxt[MAXN],fst;
ll suf[MAXN],cur,res=-1ll<<60;

int main()
{
	scanf("%d%d",&n,&fst);
	for(int i=1;i<n;i++)
		scanf(" %c%d",&op[i],&dat[i]);
	cur=n;
	for(int i=n-1;i;i--)
	{
		suf[i]=suf[i+1]+dat[i];
		if(op[i]=='-') nxt[i]=cur,cur=i;
	}
	cur=0;
	for(int i=1;i<n;i++)
		if(op[i]=='-') 
			res=max(res,cur-suf[i]+2*suf[nxt[i]]),cur-=dat[i];
		else cur+=dat[i];
	res=max(res,cur);
	printf("%lld",res+fst);
	return 0;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int ab = a + b;
        int ac = a + c;
        int bc = b + c;

        int ans = Math.min(ab, ac);
        ans = Math.min(ans, bc);
        System.out.println(ans);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse( Console.ReadLine());
            int h, m, s;
            h = S / 3600;
            m = (S - (h * 3600)) / 60;
            s = S % 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    string rotate = "ABC";
    for(size_t i = 0; i + 2 < s.size(); ++i){
        if(s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C'){
            ans += ++cnt;
            if(cnt == 1){
                s[i + 2] = 'A';
            } else if(cnt == 2){
                s[ i + 1] = s[i + 2] = 'A';
                cnt = 0;
            } else {
                i += 1;
                s[i + 1] = 'A';
                --cnt;
            }
        } else if(s[i] == 'A'){
            ++cnt;
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MOD 1000000007
#define MAXN 100005
//---------------------

ll dp[MAXN][2],sz;
string s;
int main(){
  	cin>>s;
  	sz=s.size();
  	dp[0][0]=1;
  	dp[0][1]=2;
  	REP(i,sz-1){
  		if(s[i+1]=='1') dp[i+1][0]=((dp[i][0]*3)%MOD+dp[i][1])%MOD,dp[i+1][1]=(dp[i][1]<<1)%MOD;
  		else dp[i+1][0]= dp[i][0]*3%MOD , dp[i+1][1]=dp[i][1]%MOD;
  	}
  	//PRTLST2(dp,sz,2);
  	cout<<(dp[sz-1][0]+dp[sz-1][1])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 2048
/*input
2 3 -10
1 2 3
3 2 1
1 2 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[30][30];
ll b[30];
ll c;

int main()
{
	IOS;
	int n,m;
	cin>>n>>m>>c;
	REP(i,m) cin>>b[i];
	REP(i,n) REP(j,m){
		cin>>a[i][j];
	}
	ll ans=0;
	REP(i,n){
		ll cur=c;
		REP(j,m) cur+=a[i][j]*b[j];
		if(cur>0) ans++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256