akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    int n; string s, t; cin >> n >> s >> t;
    string r = s + t;
    int res = r.size();
    for(int i=n-1; i>=0; i--){
        if(r.size() == 1) break;
        r.erase(i, 1);
        string a = r.substr(0, n), b = r.substr(r.size()-n);
        if(a == s && b == t)
            res = r.size();
    }
    cout << res << ln;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  int n;
  cin >> n;
  if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)cout << "hon" << endl;
  else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)cout << "pon" << endl;
  else cout << "bon" << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){
  int n;
  double l;
  int cunt[6]={0},c=0;

  cin>>n;
  while(1){
    cin>>l;
    if(l<165.0)
      cunt[0]++;
    else if(165.0<=l && l<170.0)
      cunt[1]++;
    else if(170.0<=l && l<175.0)
      cunt[2]++;
    else if(175.0<=l && l<180.0)
      cunt[3]++;
    else if(180.0<=l && l<185.0)
      cunt[4]++;
    else if (185.0<=l)
      cunt[5]++;

    if(c==n-1)
      break;
    c++;
  }

  for(int i=0;i<6;i++){
    cout<<i+1<<":";
    for(int j=0;j<cunt[i];j++)
      cout<<"*";
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	int t = N / 1.08 - 5;

	rep(i, 10) {
		if ((int)((t + i) * 1.08) == N) {
			cout << t + i << endl;
			return 0;
		}
	}

	cout << ":(" << endl;

	return 0;
}

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

int main(void) {
    while (true) {
        int H,W;cin>>H>>W;
        if (H == 0 && W == 0) break;
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                if (i % 2 == 1) {
                    if (j % 2 == 1) cout << "#";
                    else cout << ".";
                } else {
                    if (j % 2 == 1) cout << ".";
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const ll MAX = 1e13 + 5;

ll n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	ll x = sqrt(n);
	while(n % x != 0){
		x--;
	}
	ll sum = 0;
	sum += x - 1 + (n / x -1);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

if n == 3:
    print(2)
    print(1, 3)
    print(2, 3)
    exit()

p = [None]
ans = []
if n % 2:
    for i in range(1, n//2+1):
        p.append((i, n-i))
    for i in range(1, n//2+1):
        x, y = p[i]
        ans.append((n, x))
        ans.append((n, y))
    for i in range(1, n//2+1):
        for j in range(i+1, n//2+1):
            x, y = p[i]
            s, t = p[j]
            ans.append((x, s))
            ans.append((x, t))
            ans.append((y, s))
            ans.append((y, t))
    k = len(ans)
    print(k)
    for i in range(k):
        print(*ans[i])
else:
    for i in range(1, n//2+1):
        p.append((i, n+1-i))
    for i in range(1, n//2+1):
        for j in range(i+1, n//2+1):
            x, y = p[i]
            s, t = p[j]
            ans.append((x, s))
            ans.append((x, t))
            ans.append((y, s))
            ans.append((y, t))
    k = len(ans)
    print(k)
    for i in range(k):
        print(*ans[i])



Measured memory_bytes: 4004
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    string S;
    cin >> S;

    int x = 0;
    int ans = 0;

    for (int i = 0; i < N; ++i) {
        if (S[i] == 'I') {
            ++x;
        } else {
            --x;
        }

        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;

int main() {
    int N, t[100001], y[100001], x[100001];
    t[0] = 0;
    y[0] = 0;
    x[0] = 0;

    cin >> N;
    for (int i = 1; i <= N; ++i) cin >> t[i] >> y[i] >> x[i];

    string ans = "Yes";
    for (int i = 1; i <= N; ++i) {
        int y_ = abs(y[i] - y[i - 1]);
        int x_ = abs(x[i] - x[i - 1]);
        if (y_ + x_ > t[i] || ((y_ + x_) % 2) != ((t[i] - t[i - 1]) % 2)){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
ll a,b,c;cin>>a>>b>>c;
if(c+b-a<=0)cout<<"No";
else{
  if(4*b*c<(c+b-a)*(c+b-a)){cout<<"Yes";}
  else{cout<<"No";}
}


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// long ncrmodp(long n,long r,long p){
//     long ans = 1;
//     for(long i=n-r+1;i<=n;i++){
//         ans *= i;
//         ans %= p;
//     }
//     long tmp = 1;
//     for(long i=2;i<=r;i++){
//         tmp *= i;
//         tmp %= p;
//     }
//     for(long i=1;i<=p-2;i*=2){
//         if(i & p-2){
//             ans *= tmp;
//             ans %= p;
//         }
//         tmp *= tmp;
//         tmp %= p;
//     }
//     return ans;
// }
int main(){
    int n,m;
    cin >> n >> m;
    long const mod = 1e9+7;
    if(n < m)swap(n,m);   //n>=m
    long ans = 0;
    if(n==m){
        ans = 2;
        for(long i=2;i<=n;i++){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
    }else if(n-m==1){
        ans = 1;
        for(long i=2;i<=m;i++){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
        ans *= n;
        ans %= mod;
    }
    cout << ans << endl;
}

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

const int INF = (int)2e9;
int N, K;
vector<int> H;
vector<int> dp;

void input_init(void) {
	cin >> N >> K;
	H.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> H[i];
	dp.resize(N + 1, INF);
	dp[1] = 0;
	dp[2] = abs(H[2] - H[1]);
}

void solve(void) {
	for (int i = 3; i <= N; ++i) {
		for (int j = 1; j <= K; ++j) {
			if (i - j < 1)
				break;
			int step = abs(H[i] - H[i - j]) + dp[i - j];
			dp[i] = min(step, dp[i]);
		}
	}
}

int main(void) {
	input_init();
	solve();
	cout << dp[N] << '\n';
	return 0;
}


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

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


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

const int MAX_N = 105;
int w[MAX_N];
int v[MAX_N];

const int MAX_V = 112345;
ll dp[MAX_V];

int main2() {
  int N = nextInt();
  int W = nextInt();
  REP(i, N) {
    w[i] = nextInt();
    v[i] = nextInt();
  }
  const int INF = 1001001001;
  REP(i, MAX_V) dp[i] = INF;
  dp[0] = 0;
  REP(i, N) {
    for (int vv = MAX_V-1; vv - v[i] >= 0; vv--) {
      chmin(dp[vv], dp[vv - v[i]] + w[i]);
    }
  }
  ll ans = 0;
  REP(vv, MAX_V) {
    if (dp[vv] <= W) ans = vv;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10000000)


def is_parindrome(s, i, j):
    string = s[i:j]
    n = len(string)
    for i in range(n//2):
        start = i
        end = n - i - 1
        if string[start] != string[end]:
            return False
    return True


def main():
    S = input()
    N = len(S)
    if is_parindrome(S, 0, N) and is_parindrome(S, 0, (N - 1)//2) and is_parindrome(S, (N + 3) // 2 - 1, N):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    string a;
    cin >> a;
    int q;
    cin >> q;
    string part1 = "";
    string part2 = "";
    int num_t1 = 0;
    for(int i=0; i<q; i++){
        int t;
        cin >> t;
        if(t == 1){
            num_t1++;
        }
        else{
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(num_t1 % 2 == 0){
                if(f == 1){
                    part1 = c + part1;
                }
                else if(f == 2){
                    part2 = part2 + c;
                }
            }
            else{
                if(f == 1){
                    part2 = part2 + c;
                }
                else if(f == 2){
                    part1 = c + part1;
                }
            }
        }
    }
    if(num_t1 % 2 == 0){
        cout << part1 + a + part2 << endl;
    }
    else{
        reverse(part2.begin(), part2.end());
        reverse(a.begin(), a.end());
        reverse(part1.begin(), part1.end());
        cout << part2 + a + part1 << endl;
    }
    return 0;
}

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

int main() {
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k <= a){
    cout << k << endl;
  }else if(k <= a + b){
    cout << a << endl;
  }else{
    cout << a - (k-(a+b)) << endl;
  }
  return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin>>n;
    double a[n+1],h[n+1],t[n+1];
    a[0]=0;
    h[0]=1;
    t[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        h[i]=h[i-1]*a[i];
        t[i]=t[i-1]*(1-a[i]);
    }
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)dp[i][j]=t[i];
            else if(i==j)dp[i][j]=h[i];
            else dp[i][j]=dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i];
        }
    }
    
    double ans=0;
    
    for(int i=n/2 + 1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<ans<<"\n";
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
using namespace std;
main(){
	string str,str2;
	int tmp,tmp2;
	while(getline(cin,str)){
		for(int i=0;i<str.size();++i){
			str2="";
			tmp='t'-str[i];
			for(int j=0;j<4;++j){
				tmp2=str[i+j];
				if(tmp2>'e')tmp2-=26;
				tmp2+=tmp;
				if(tmp2>'z')tmp2-=26;
				else if (tmp2<'a')tmp2+=26;
				str2+=tmp2;
				if(str2=="the")break;
			}
			if(str2=="this" || str2=="that" || str2=="the"){
				break;
			}
		}
		str2="";
		for(int i=0;i<str.size();++i){
			tmp2=str[i];
			if(tmp2>='a' && tmp2<='z'){
				if(tmp2>'e')tmp2-=26;
				tmp2+=tmp;
				if(tmp2>'z')tmp2-=26;
				else if (tmp2<'a')tmp2+=26;
			}
			str2+=tmp2;
		}
		cout<<str2<<endl;
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int x;
    cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


#最大公約数
def gcd(x,y):
    x = abs(x)
    y = abs(y)

    if x < y:
        x,y = y,x

    if y == 0:
        return x
    else:
        return gcd(y,x%y)


#最小公倍数
def lcm(x,y):

    return (x*y)//(gcd(x,y))


A = [None]*3
M = [None]*3
cycle = [None]*3


while True:
    A[0],M[0],A[1],M[1],A[2],M[2] = map(int,input().split())
    if A[0] == 0 and M[0] == 0 and A[1] == 0 and M[1] == 0 and \
        A[2] == 0 and M[2] == 0:
        break

    for i in range(3):
        count = 0
        x = 1
        while True:
            x = (A[i]*x)%M[i]
            count += 1
            if x == 1:
                break
        cycle[i] = count

    ans = 1 #3つの周期の最小公倍数
    for i in range(3):
        ans = lcm(ans,cycle[i])

    print("%d"%(ans))



Measured memory_bytes: 13888
import numpy as np
n = int(input())
h = np.array([0] + [int(i) for i in input().split()])
cnt = 0
for i in range(max(h), 0, -1):
    hh = h >= i
    cnt += sum([not hh[j] and hh[j + 1] for j in range(n)])
print(cnt)

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

using namespace std;

long long k, n;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	k = sqrt(n);
	for (int i=k; i>0; i--) {
		if (n % i) continue;
		cout << i + (n / i) - 2 << endl;
		exit(0);
	}
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public static int n = 0;
        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            // 入力
            var intArr = cin.ReadIntArray(2);
            var x = intArr[0];
            var a = intArr[1];
            WriteLine(x < a ? 0 : 10);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll oddcnt = 0;
    rep(i, 0, n) {
        ll a;
        cin >> a;
        if (a % 2 == 1) oddcnt++;
    }
    if (oddcnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
par = list(range(n+1))
dis = [0] * (n+1)

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dis[x] += dis[par[x]]
  par[x] = r
  return r

def cost(x):
  # xからxの根までのコスト
  if x == par[x]:
    return 0
  return dis[x] + cost(par[x])

for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が違ってればマージ
  # 同じなら入力されたdistanceがこれまでの入力データからなる
  # 現在の木の構造から計算した数値とあっているか判断
  # rootl, rootr = root(l), root(r)
  # 確かめ用
  rootl = root(l)
  rootr = root(r)
  if rootl != rootr:
    if r != rootr:
      # 直接yにつなげる
      dis[rootl] = d - cost(l)
    else:
      # 根につなげる
      dis[rootl] = d - (dis[l] - dis[r])
    # ここで親を更新
    par[rootl] = r
  else:
    if d != cost(l) - cost(r):
      print("No")
      exit()

  """
  ちょっとなにがダメなのかわかんないので確かめる
  if rootl != rootr:
    # lをrにマージする
    if r == rootr:
      dis[rootl] = d - cost(l)
    else:
      dis[rootl] = d - (dis[l] - dis[r]) # (cost(l) - cost(r))
    par[rootl] = r
  else:
    # コストが同じかどうか
    if d == cost(l) - cost(r):
      continue
    else:
      print("No")
      exit()
  """
print("Yes")

Measured memory_bytes: 11376
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

using int64 = long long;

int64 Solve(int64 n) {
  auto sum = [](int64 n) {
    int64 s = 0;
    for (; n; n /= 10)
      s += n % 10;
    return s;
  };

  int64 ret = 0;
  for (int64 base = 1; n > 0; base *= 10) {
    int64 s = sum(n);
    ret = max(s, ret);
    n = n / base * base - 1;
  }
  return ret;
}

int main() {
  int64 n;
  cin >> n;
  cout << Solve(n) << "\n";
  return 0;
}


Measured memory_bytes: 256
N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
cnt=0
for i in range(N):
    x=0
    for j in range(M):
        x += A[i][j] * B[j]
    x += C
    if x>0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define REP(i,n) for(int i=0;i<n;i++)
	#define FOR(i,a,b) for(int i=a;i<=b;i++)
	#define FORR(i,a,b) for(int i=a;i>=b;i--)
	#define ALL(c) (c).begin(),()c.end() 

	#define PI 3.14159265358979323846
	const int N = 500 + 10;  
   
    
   int sum,maxi,tot;
   
   void solve() {      
       
         int n,m,to;
         cin>>n>>m;
         to=m;
         vi v(n,0);
         vi a(n,0);
         vector<pii> vp;
         
         for(int i=0;i<n;i++)
            cin>>a[i];       
            
            
         while(to--) {
             
             int x,y;
             cin>>x>>y;
             vp.pb({y,x});
          }
          
          
          sort(a.begin(),a.end());
          sort(vp.rbegin(),vp.rend());
          
            int idx=0;
            
            for(int i =0;i<n;i++) {
                
                if(idx>=m)
                  sum+=a[i];
                  
                else {
                    
                    sum+=max(a[i],vp[idx].fe);
                    vp[idx].se--;
                    if(vp[idx].se==0)
                      idx++;                      
                }
            } 
                         
             cout<<sum;  
   }
   
      int32_t main() {
	    cool;
	    int t=1;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


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

string str;

int main( void ) {
    
    cin >> str;
    sort( str.begin(), str.end() );
    
    bool ok = true;
    for( int i = 1; i < str.length(); i ++ )
        if( str[i - 1] == str[i] ) ok = false;
    
    cout << ( ok == true ? "yes" : "no" ) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p.at(i);
        cin >> c.at(i);
    }
    int answer = 1000000;
    for (int i = 0; i < (1 << D); i++) {
        int sum = 0;
        int problems = 0;
        bool added = false;
        for (int j = 0; j < D; j++) {
            if (i >> j & 1) {
                sum += 100 * (j + 1) * p.at(j) + c.at(j);
                problems += p.at(j);
            }
        }
        for (int j = D - 1; j >= 0; j--) {
            if (!(i >> j & 1) && sum < G) {
                int problem = ((G - sum) / 100 + j) / (j + 1);
                if (problem <= p.at(j)) {
                    problems += ((G - sum) / 100 + j) / (j + 1);
                }
                else {
                    problems += 1000000;
                }
                break;
            }
        }
        // print(problems);
        answer = min(answer, problems);
    }
    cout << answer << endl;
}

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

int main(){
    int N;
    string S;
    int K;
    cin>>N>>S>>K;
    char c=S[K-1];
    for(int i=0;i<N;i++){
        if(S[i]==c){
            cout<<c;
        }
        else{cout<<"*";}
    }
    cout<<endl;
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
N = int(input())
A = [int(input()) for i in range(N)]

X = deque([])

for a in A:
    i = bisect_left(X, a)
    if i == 0:
        X.appendleft(a)
    else:
        X[i - 1] = a


print(len(X))


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

int main(){
    int n,max=0;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec.at(i);
    for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++)
    {
        if(max<abs(vec.at(i)-vec.at(j))) max=abs(vec.at(i)-vec.at(j));
    }
}
cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct S {
    ll s, t, x;
    
    bool operator<(const S &b) const {
        if (x == b.x) {
            return s < b.s;
        }
        return x < b.x;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    vector<S> vs(n);
    rep(i, n) cin >> vs[i].s >> vs[i].t >> vs[i].x;
    sort(all(vs));
    set<pair<ll, ll>> d;
    rep(i, q) {
        ll tmp;
        cin >> tmp;
        d.insert(make_pair(tmp, i));
    }
    vector<ll> ans(q, -1);
    rep(i, n) {
        ll l = vs[i].s - vs[i].x;
        ll r = vs[i].t - vs[i].x;
        for(auto it = d.lower_bound(make_pair(l, -1)); it != d.end(); ) {
            if (it->first >= r) break;
            ans[it->second] = vs[i].x;
            d.erase(it++);
        }
    }
    rep(i, q) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 20608
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	for (int i = 0; i < 7; ++i) {
		int a, b; cin >> a >> b; cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using i64 = long long;

int main() {
    int n;
    i64 v[3];
    std::cin >> n >> v[0] >> v[1] >> v[2];
    const i64 s = v[0] + v[1] + v[2];

    std::vector<std::pair<int, int>> qs;
    std::string in;
    for (int i = 0; i < n; i++) {
        std::cin >> in;
        qs.emplace_back(in.front() - 'A', in.back() - 'A');
    }

    std::string ret;

    auto f = [&](const int j, const int k) {
        ret += 'A' + j;
        v[j]++;
        v[k]--;
    };
    if (s >= 3) {
        const auto [x, y] = qs.front();
        if (!v[x] && !v[y]) {
            std::cout << "No" << std::endl;
            return 0;
        }
        for (int i = 0; i < n; i++) {
            const auto [j, k] = qs[i];
            if (v[j] > v[k]) {
                f(k, j);
            } else {
                f(j, k);
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            const auto [j, k] = qs[i];
            if (!v[j] && !v[k]) {
                std::cout << "No" << std::endl;
                return 0;
            } else {
                if (v[j] == 2) {
                    f(k, j);
                } else if (v[k] == 2) {
                    f(j, k);
                } else if (i + 1 < n && v[j] == 1 && v[k] == 1) {
                    const auto [x, y] = qs[i + 1];
                    if (x == j || y == j) f(j, k);
                    else f(k, j);
                } else {
                    if (v[j]) f(k, j);
                    else f(j, k);
                }
            }
        }
    }

    std::cout << "Yes\n";
    for (auto c : ret) std::cout << c << '\n';

    return 0;
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

const ll L = 1e5+5;

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

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

    ll A, B;
    cin >> A >> B;

    cout << max(A+B, max(A-B, A*B)) << endl;    

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        long count = 0;
        for (long i = a[0]; i <= a[1]; i++) {
            var s = i.ToString();
            if (s[0] == s[4] && s[1] == s[3]) count++;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13396
#include<cstdio>
int main() {
	int n,k,x,ans=0;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i) {
		scanf("%d",&x);
		ans+=(x>=k);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    int n,p;
    while (cin >> n >> p && n){
        vector<int> v(n);
        int a=p , i=0;
        while (1){
            if (p){
                v[i]++;
                p--;
            }else{
                p+=v[i];
                v[i]=0;
            }
            if (v[i] == a)
                break;
            i = (i+1)%n;
        }

        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#define MAXLEN 150
//全局 初始值 为 0
int arr[3][MAXLEN];
int dp[3][MAXLEN];
int max(int a, int b) {
    return a > b ? a : b;
}
int main() {
    int nCol = -1;
    scanf("%d", &nCol);
    for(int i = 1; i <= 2; i++) {
        for(int j = 1; j <= nCol; j++) {
            scanf("%d", &arr[i][j]);
        }
    }
    for(int j = 1; j <= nCol; j++) {
        for(int i = 1; i <= 2; i++) {
            dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) +
            arr[i][j];
        }
    }
    printf("%d\n", dp[2][nCol]);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){

    int a,b,c,d=0;

    scanf("%d %d %d",&a,&b,&c);

    for(a=a;a<=b;a++){
       if(c%a==0){
         d++;
       }
    }

    printf("%d\n",d);

    return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        
        int ans = Integer.MAX_VALUE;
        for(int i=0;i<N;i++){
            int c = sc.nextInt();
            int t = sc.nextInt();
            
            if(t<=T){
                if(c<ans)
                    ans=c;
            }
        }
        
        System.out.println(ans!=Integer.MAX_VALUE ? ans : "TLE");
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e5+5;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

struct Tree{
	int left,right,val;
	Tree *left_child,*right_child;
}t[2][N*4];

int n,m[2];
map<int,int> elenum;

void update(Tree *pos){
	pos->val=min(pos->left_child->val,pos->right_child->val);
}

void build(Tree *pos,Tree *root,int &M,int x,int y){
	pos->left=x;pos->right=y;pos->val=INT_MAX;
	if(x==y) return;
	int mid=(x+y)>>1;
	pos->left_child=root+M;M++;
	pos->right_child=root+M;M++;
	build(pos->left_child,root,M,x,mid);
	build(pos->right_child,root,M,mid+1,y);
}

void def(Tree *pos,int x,int val){
//	printf("%d %d\n",pos->left,pos->right);
	if(pos->left>x||pos->right<x) return;
	if(pos->left==pos->right&&pos->left==x){
		pos->val=val;
//		printf("%d %d\n",x,val);
		return;
	}
	def(pos->left_child,x,val);
	def(pos->right_child,x,val);
	update(pos);
}

int query(Tree *pos,int x,int y){
	if(pos->left>=x&&pos->right<=y) return pos->val;
	if(pos->left>y||pos->right<x) return INT_MAX;
	return min(query(pos->left_child,x,y),query(pos->right_child,x,y));
}

priority_queue<piii,vector<piii>,greater<piii> > pq;

void add(int x,int y){
	if(x>y) return;
	pq.push(make_pair(query(t[x%2],x,y),make_pair(x,y)));
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<2;i++){
		m[i]=1;
		build(t[i],t[i],m[i],1,n);
	}
//	printf("%d %d\n",m[0],m[1]);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		elenum[x]=i;
		def(t[i%2],i,x);
	}
//	for(int i=1;i<=n;i++) printf("%d\n",query(t[i%2],i,i));
	add(1,n);
	while(!pq.empty()){
		piii now=pq.top();pq.pop();
//		printf("(%d,%d,%d)\n",now.first,now.second.first,now.second.second);
		int B=now.second.first;
		int E=now.second.second;
		int ind1=elenum[now.first],ind2;
//		printf("%d:%d %d\n",1-B%2,ind1+1,E);
		int mn=query(t[1-B%2],ind1+1,E);
		ind2=elenum[mn];
		printf("%d %d ",now.first,mn);
//		system("pause");
		add(B,ind1-1);add(ind1+1,ind2-1);add(ind2+1,E);
	}
	puts("");
	return 0;
}

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

#define rmin(a,b) a = min(a,b)
#define rmax(a,b) a = max(a,b)

#define fi first
#define se second

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	ll n; cin >> n;
	vector<ll> v(n);
	fr(i,n) cin >> v[i];
	
	sort(all(v));
	
	ll ans = 0;
	fr(i,sz(v)) fr(j,i) fr(k,j){
		if(v[k]+v[j]>v[i]){
			if(v[j]!=v[k] and v[i]!=v[j] and v[i]!=v[k]) ans++;
		
		}
	}	
	
	cout << ans << "\n";
}

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

void matSet(int* mat, int size) {
	int num;
	for (int i = 0; i < size; i++) {
		cin >> num;
		mat[i] = num;
	}
}

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	int* matA = new int[n * m];
	int* matB = new int[m * l];
	matSet(matA, n * m);
	matSet(matB, m * l);
	
	for (int i = 0; i < n; i++) {
	    for(int j = 0; j < l; j++){
		    long cElm = 0;
	    	for(int k = 0 ; k < m; k++){
		        cElm += matA[i * m + k] * matB[k * l + j];
		    }
		    cout << cElm << (j < l - 1 ? " " : "\n");
	    }
	}
	delete[] matA;
	delete[] matB;
	return 0;
}

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

int f(int n){
    int sum=0;
    while(n>0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    //if(N>f(N)){
        if(N%f(N)==0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
   // }
    //else{
      //  cout << "No" <<endl;
    //}
}

Measured memory_bytes: 3600
def main():
    n, k, *xy = map(int, open(0).read().split())
    _x_ = sorted(xy[::2])
    ans = 4 * 10 ** 18
    for _x in _x_:
        for x_ in _x_[1:]:
            w = x_ - _x
            c = 0
            _h_ = []
            for x, y in zip(xy[::2], xy[1::2]):
                if _x <= x <= x_:
                    c += 1
                    _h_.append(y)

            if c >= k:
                _h_.sort()
                h = min(_h_[i + k - 1] - _h_[i] for i in range(c - k + 1))
                ans = min(ans, h * w)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74316
#include<stdio.h>
int main(){
  int a,b,n;
  scanf("%d",&n);
  scanf("%d",&a);
  scanf("%d",&b);
  if(a+b<=n){
    if(a<b){
      printf("%d %d",a,0);
    }else{
      printf("%d %d",b,0);
    }
  }else{
    if(a<b){
      printf("%d %d",a,a-(n-b));
    }else{
      printf("%d %d",b,b-(n-a));
    }
  }
  return 0;
}

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

int main()
{
	int ans = 0, N, S[100],s = 0;

	cin >> N;

	for (int n = 0; n < N; n++) {
		cin >> S[n];
		s += S[n];
	}

	for (int n = 0; n < N; n++) {
		int sum = 0;
		for (int nn = 0; nn < N; nn++) {
			if (n == nn)continue;
			sum += S[nn];
			if (ans < sum && sum % 10 != 0)ans = sum;
		}
	}

	if(s % 10 == 0)cout << ans << endl;
	else cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long double INF=1e30;
 

map<pair<long,long>,long>mp;

int main(){
    LL H,W,N;
    cin>>H>>W>>N;
    vector<PII>xy;
    mp.clear();
    REP(i,N){
        long a,b;
        cin>>a>>b;
        REP(j1,3)REP(j2,3)mp[MP(a-j1,b-j2)]++;
    }
    long sum[10];
    CLR(sum);
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        auto pi=itr->first;
        auto val=itr->second;
        if(pi.first>0&&pi.second>0&&pi.first<=H-2LL&&pi.second<=W-2LL){
            //cout<<pi.first<<" "<<pi.second<<" "<<val<<endl;
            sum[val]++;
        }
    }
    LL ssum=0;
    FOR(i,1,10)ssum+=sum[i];
    cout<<(H-2LL)*(W-2LL)-ssum<<endl;
    FOR(i,1,10){
        cout<<sum[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 56448
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

//const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__

void solve(void){
  
  int N;
  string S;
  
  cin >> N >> S;
  
  string T="";
    
  T += S[0];
  char tmp=S[0];
  
  REP2(i,1,N){
    if(S[i]==tmp){continue;}
    T += S[i];
    tmp=S[i];
  }
  
  cout << T.size() << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N, K;
	int cnt = 0;
	cin >> N >> K;
	while (N) {
		cnt++;
		N /= K;
	}
	cout << cnt << endl;
	return (0);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long C(long n,long k)
        {
            if (n < k||k<0) return 0;
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n; i >n-k; i--)
            {
                bunsi *= i;
            }
            for (int i = 1; i <=k; i++)
            {
                bunbo *= i;
            }
            return bunsi / bunbo;
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var data = new long[n + 1];
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                data[a[i]]++;
            }
            for (int i = 1; i <= n; i++)
            {
                ans += C(data[i], 2);
            }
            for (int i = 0; i <n ; i++)
            {     
                var rel = ans - C(data[a[i]], 2) + C(data[a[i]] - 1, 2);
                Console.WriteLine(rel);
            }
          

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 39360
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> p(N, 0);
  rep(i, K)
  {
    int d;
    cin >> d;
    rep(j, d)
    {
      int h;
      cin >> h;
      p[h - 1]++;
    }
  }
  int ans = 0;
  rep(i, N)
  {
    if (p[i] == 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    vector<int> z(1000005);
    for (i = 0; i < n; i++) {
        if (i>0 && a[i - 1] == a[i]) {
            z[a[i]] = 1;
            continue;
        }
        int tmp = a[i]*2;
        while (tmp < 1000005) {
            z[tmp] = 1;
            tmp += a[i];
        }
    }
    int cnt = 0;
    for (i = 0; i < n; i++) {
        if (z[a[i]] == 0) cnt++;
    }
    printf("%d\n", cnt);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}





Measured memory_bytes: 7536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int c, times=0;
        cin >> c;
        while (c%2 == 0) {
            c /= 2;
            times++;
        }
        ans += times;
    }
    ct(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int d,t,s; cin >> d >> t >> s;
  if(t*s >= d) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD=1e9+7;
using namespace std;

int h,w;
char c[1005][1005];

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

int main(){
	cin >> h >> w;
  queue<tuple<int,int,int>> q;
  int cnt = 0;

  rep(i,h){
    rep(j,w){
      cin >> c[i][j];
      if(c[i][j]=='#'){
        q.push(make_tuple(i,j,0));
      }else{
        cnt++;
      }
    }
  }
  int ans = 0;

  while(!q.empty() && cnt){
    tuple<int,int,int> tmp = q.front();
    q.pop();
    int ctmp = get<2>(tmp);
    int tx,ty;
    for(int i=0;i<4;i++){
      ty = get<0>(tmp) + dy[i];
      tx = get<1>(tmp) + dx[i];

      if(ty>=0 && ty<h && tx>=0 && tx<w && c[ty][tx]=='.'){
        q.push(make_tuple(ty,tx,ctmp+1));
        c[ty][tx] = '#';
        cnt--;
        if(cnt==0){
          ans = ctmp+1;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13328