akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[100001];
int K[100001];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	K[a] += K[b];
	return true;
}

int Size(int A) {
	return -P[Find(A)];
}

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

	
	int N;
	cin >> N;

	vector<int> XY[100001];
	rep(i, N) {
		int x, y;
		cin >> x >> y;

		XY[x].pb(y);
	}

	rep1(i, 100000) P[i] = -1;

	rep1(i, 100000) {
		if (XY[i].size()) {
			for (int j = 0; j < (int)XY[i].size() - 1; j++) {
				Unite(XY[i][j], XY[i][j + 1]);
			}
			K[Find(XY[i][0])]++;
		}
	}

	ll kotae = 0;
	rep1(i, 100000) {
		if (Find(i) == i) {
			kotae += 1ll * K[i] * Size(i);
		}
	}
	co(kotae - N);

	Would you please return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

int g[55][55];
int n,m;
int a[55],b[55];
int al[55] = {0};

bool connect(int a, int b) {
  bool flag = false;
  FOR(i, 1, n + 1) {
    if(i == a) continue;
    if(g[a][i] && !al[i]) {
      if(i == b) return true;
      al[i] = 1;
      if(connect(i,b)) flag = true;
    }
  }
  return flag;
}

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

  cin>>n>>m;
  rep(i,55) {
    rep(j,55) g[i][j] = 0;
  }
  rep(i,m) {
    cin>>a[i]>>b[i];
    g[a[i]][b[i]] = 1;
    g[b[i]][a[i]] = 1;
  }
  int ans = 0;
  rep(i,m) {
    g[a[i]][b[i]] = 0;
    g[b[i]][a[i]] = 0;
    al[a[i]] = 1;
    if(!connect(a[i], b[i])) ans++;
    g[a[i]][b[i]] = 1;
    g[b[i]][a[i]] = 1;
    rep(j, 55) al[j] = 0;
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 384
while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    if b == "?":
        break
    if b == "+":
        print(a + c)
    elif b == "-":
        print(a - c)
    elif b == "*":
        print(a * c)
    elif b == "/":
        print(a // c)
    else:
        break


Measured memory_bytes: 5596
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+9;
const long double pi=3.14159265358979323846;
void raushan_kumar(){

    /////////////////variables///////////////
    int d=0,e=0,f=0,g=0;
    double f1=0.0,f2=0.0,f3=0.0;
    int flag=0,ans=0,res=0,cnt=0,sum=0;
    /////////////////////////////////////////
    ld n;cin>>n;
    ld k=2*pi*n;
    cout<<k;    
}

int32_t main()
{
    fast;int t=1;
    //cin>>t;
    while(t--){
        raushan_kumar();
    }

}

Measured memory_bytes: 3796
#include <iostream>
#include <string>
using namespace std;
int a[100000];
int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;


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

    int l, r;
    for(int i=0; i<q; i++) {
        cin >> l >> r;
        l--; r--;
        cout << a[r] - a[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, m, i, a;
	ll ans = 0;
	priority_queue<int> que;
	cin >> num >> m;
	for (i = 0; i < num; i++) {
		cin >> a;
		que.push(a);
	}
	for (i = 0; i < m; i++) {
		a = que.top();
		que.pop();
		a >>= 1;
		que.push(a);
	}
	while (!que.empty()) {
		ans += que.top();
		que.pop();
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
int hoge[5];
hoge[0]=a%10;
hoge[1]=b%10;
hoge[2]=c%10;
hoge[3]=d%10;
hoge[4]=e%10;
int t;
t=((a-1)/10+(b-1)/10+(c-1)/10+(d-1)/10+(e-1)/10+5)*10;
int m=10;
for(int i=0;i<5;i++){
    if(hoge[i]==0) continue;
    if(hoge[i]<m) m=hoge[i];
}
cout<<t-10+m<<endl;
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > w(n);
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin >> a >> b;
		w[i]=make_pair(b,a);
	}

	sort(w.begin(),w.end());
	reverse(w.begin(),w.end());
	for(int i=0;i<n;i++)
		swap(w[i].first,w[i].second);
	sort(w.begin(),w.end());
	priority_queue<int> good;

	int itr=0;
	long long ans=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=itr;j<n;j++)
		{
			itr=j;
			if(w[j].first>i)break;
			good.push(w[j].second);
			itr++;
		}
		
		if(good.size()!=0)
		{
			ans+=(good.top());
			good.pop();
		}
	}
	cout << ans << endl;
		
}


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

using namespace std;

const long long MINF = -(1LL << 60);

auto solve() {
    int n, m;
    cin >> n >> m;
    vector<long long> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }

    long long res = 0;
    for (int _t = 0; _t < 1 << 3; _t++) {
        vector<long long> dp(m + 1, MINF);
        dp[0] = 0;

        vector<long long> sm(n);
        for (int i = 0; i < n; i++) {
            if (_t == 0) sm[i] = x[i] + y[i] + z[i];
            else if (_t == 1) sm[i] = x[i] + y[i] - z[i];
            else if (_t == 2) sm[i] = x[i] - y[i] + z[i];
            else if (_t == 3) sm[i] = x[i] - y[i] - z[i];
            else if (_t == 4) sm[i] = -x[i] + y[i] + z[i];
            else if (_t == 5) sm[i] = -x[i] + y[i] - z[i];
            else if (_t == 6) sm[i] = -x[i] - y[i] + z[i];
            else if (_t == 7) sm[i] = -x[i] - y[i] - z[i];
        }

        for (int i = 0; i < n; i++) {
            for (int j = m - 1; j >= 0; j--) {
                dp[j + 1] = max(dp[j + 1], dp[j] + sm[i]);
            }
        }

        res = max(res, dp[m]);
    }

    cout << res << endl;
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 892
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	int n;
	cin >> n;
	switch (n) {
	case 1:
		cout << "Hello World" << endl;
		break;
	case 2:
		int a,b;
		cin >> a >> b;
		cout << a + b << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int x,k=1;
	cin>>x;
	for(int i=1;i<x;i++){
        for(int j=2;j<x;j++){
			if(pow(i,j)<=x&&k<pow(i,j))k=pow(i,j);
			}
        }
        cout<<k<<endl;
	return 0;
	}


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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
vector<int> gays[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 2; i <= n; ++i) {
        int a;
        cin >> a;
        gays[a].emplace_back(i);
    }

    return true;
}

int calc(int v) {
    if (gays[v].empty())
        return 1;

    vector<int> vec;

    for (const auto& i : gays[v])
        vec.emplace_back(calc(i));

    sort(vec.rbegin(), vec.rend());

    auto h = 1;
    int ans = 1 + vec.size();

    for (const auto& i : vec)
        ans = max(ans, i + h++);

    return ans;
}

void solve() {
    cout << calc(1) - 1 << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    string s;
    cin >> n >> s;
    int rctr=0;
    rp(i,n){
        if(s[i]=='R') rctr++;
    }
    int ans=0;
    rp(i,rctr){
        if(s[i]=='W') ans++;
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

using namespace std;

void print_each_digit(int x)
{
    if(x >= 10)
       print_each_digit(x / 10);

    int digit = x % 10;

    std::cout << digit << '\n';
}

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

    int digits[4];
    for(int i = 0; i < 4; i++)
    {
        digits[i] = number % 10;
        number = number / 10;
    }

    for (int i = 0; i < 3; i++)
    {
        if(digits[i] == digits[i + 1])
        {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}

int main()
{
    ios::sync_with_stdio(false);

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

    cout << (A * B / gcd(A, B)) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int calcYear(int date){
    if(date % 10 == 0) date /= 10;
    else date = (date / 10) + 1;

    if(date % 365 == 0) return date / 365;
    else return (date / 365) + 1;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int dp[40];
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i=3;i<31;i++){
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
    int n;
    vector<int> ans;
    while(1){
        cin >> n;
        if(n == 0) break;
        ans.push_back(dp[n] / 3650 + 1);
    }
    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3116
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

void solv()
{
	char S[200]; scanf("%s", S);
	int len = strlen(S);

	int last = len - 1;
	int cnt = 0;
	for (int i = 0; i < last; i++, last--){
		if (S[i] != S[last]){
			cnt++;
		}
	}

	printf("%d", cnt);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if(s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int max = 0;
    for (int i = 0; i < S.length(); i++) {
      char c = S.charAt(i);
      if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
        int j = i+1;
        int count = 1;
        if (j >= S.length()) {
          if (count > max) {
            max = count;
          }
          break;
        }
        while (S.charAt(j)=='A' || S.charAt(j)=='C' || S.charAt(j)=='G' || S.charAt(j)=='T') {
          j++;
          count++;
          if (j >= S.length()) break;
        }
        if (count > max) {
          max = count;
        }
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 22612
#include <stdio.h>
int main(){
  int H,W,i,j,k;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
      break;
    }
    if(H%2==0 && W%2==0){
	for(j=0;j<H/2;j++){
	  for(i=0;i<W/2;i++){
	    printf("#.");
	  }printf("\n");
	  for(k=0;k<W/2;k++){
	    printf(".#");
	  }printf("\n");
	}printf("\n");
    }
	
    if(H%2==0 && W%2!=0){
	  for(j=0;j<H/2;j++){ 
	    printf("#");
	    for(i=0;i<(W-1)/2;i++){
	      printf(".#");
	    }printf("\n.");
	    for(k=0;k<(W-1)/2;k++){
	      printf("#.");
	    }printf("\n");
	  }printf("\n");
	}
	  
	if(H%2!=0 && W%2==0){
	    for(i=0;i<W/2;i++){
	    printf("#.");
	  }
	    printf("\n");
	    for(j=0;j<(H-1)/2;j++){
	      for(i=0;i<W/2;i++){
		printf(".#");
	      }
	      printf("\n");
	      for(k=0;k<W/2;k++){
		printf("#.");
	      }printf("\n");
	    }
	    printf("\n");
	    }
	  
	  if(H%2!=0 && W%2!=0){
	    printf("#");
	    for(i=0;i<(W-1)/2;i++){
	      printf(".#");
	    }
	    printf("\n");
	    for(j=0;j<(H-1)/2;j++){
	      printf(".");
	    for(i=0;i<(W-1)/2;i++){
	      printf("#.");
	    }
	    printf("\n#");
	    for(k=0;k<(W-1)/2;k++){
	      printf(".#");
	    }printf("\n");
	    }printf("\n");
	    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    ll n, k;
    cin >> n >> k;
    ll t = 1, ans = 0;
    while(t <= n) t *= k, ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int K, X;  cin >> K >> X;

    rep(i, 2 * K - 1) {
        cout << X - K + i + 1 << " ";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n , m , q; cin >> n >> m >> q;
    vector<vector<ll>> train(n+1,vector<ll>(n+1,0));
    rep(i,m){
        ll l,r; cin >> l >> r;
        train.at(l).at(r)++;
        train.at(r).at(l)++;
    }
    vector<vector<ll>> rui(n+1,vector<ll>(n+1,0));
    rep(i,n+1){
        for(int j=1;j<n+1;j++){
            rui[i][j] = rui[i][j-1] + train[i][j];
        }
    }
    rep(i,n+1){
        for(int j=1;j<n+1;j++){
            rui[j][i] += rui[j-1][i];
        }
    }
    //pr2d(rui);

    rep(i,q){
        ll a,b; cin >> a >> b;
        ll ans = rui[b][b] - rui[b][a-1] - rui[a-1][b] + rui[a-1][a-1];
        cout << ans/2 << "\n";
    }
    return 0 ;
}


Measured memory_bytes: 4864
// AOJ 0626 Collecting Stamps 2
// 2018.2.15 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef long long ll;

char s[100003], *p;
int J[100003], I[100003];

int main()
{
	int N, i;
	ll a, b, c, t, ans;

	fgets(s, 10, stdin), N = atoi(s);
	fgets(s, sizeof(s), stdin);

	p = s; for (i = 0; i < N; i++) {
		J[i+1] = J[i] + (*p == 'J');
		I[i+1] = I[i] + (*p == 'I');
		p++;
	}

	ans = a = b = c = 0;
	for (i = 1; i < N; i++) {
		t = (ll)J[i] * (I[N]-I[i]);
		if (a < t) a = t;
	}

	for (i = 0; i < N; i++) if (s[i] == 'O') {
		b += I[N] - I[i+1];
		c += J[i];
		ans += (ll)(I[N]-I[i+1]) * J[i];
	}
	if (a < b) a = b;
	if (a < c) a = c;
	printf("%lld\n", ans + a);
	return 0;
}






Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans = 0;
void Main(){
    ll n, q;
    cin >> n >> q;
    ans = (n - 2) * (n - 2);
    vector<pair<int,int>> t(q);
    For(i,0,q) cin >> t[i].first >> t[i].second;
    auto itr = t.begin();
    For(i,1,q){
        if(t[i].first != t[i-1].first){
            sort(itr, t.begin() + i);
            reverse(itr, t.begin() + i);
            itr = t.begin() + i;
        }
    }
    sort(itr, t.end());
    reverse(itr, t.end());
    /*cout << endl;
    for(auto p:t) cout << p.first << " " << p.second << endl;*/
    map<int, int> imax, jmax;
    imax[0] = n - 2;
    jmax[0] = n - 2;
    For(_,0,q){
        auto [i, x] = t[_];
        x--;
        if(i == 1){
            auto itr = imax.upper_bound(x);
            itr--;
            ans -= itr->second;
            imax[x] = itr->second;
            if(jmax[0] > x-1){
                jmax[0] = x-1;
            }
        }
        else{
            auto itr = jmax.upper_bound(x);
            itr--;
            ans -= itr->second;
            jmax[x] = itr->second;
            if(imax[0] > x-1){
                imax[0] = x-1;
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 14356
a=[]
b=[]
nums=[]
ans="No"

for i in range(3):
    l=list(map(int,input().split()))
    a.append(l)

n=int(input())

for i in range(n):
    s=int(input())
    b.append(s)

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0
                num=10*(j+1)+k+1
                nums.append(num)

nums.sort()


if a[0][0]==a[0][1]==a[0][2]==0:
    ans="Yes"
if a[1][0]==a[1][1]==a[1][2]==0:
        ans="Yes"
if a[2][0]==a[2][1]==a[2][2]==0:
    ans="Yes"
if a[0][0]==a[1][0]==a[2][0]==0:
    ans="Yes"
if a[0][1]==a[1][1]==a[2][1]==0:
        ans="Yes"
if a[0][2]==a[1][2]==a[2][2]==0:
    ans="Yes"
        
if 11 in nums and 22 in nums and 33 in nums:
    ans="Yes"

if 13 in nums and 22 in nums and 31 in nums:
    ans="Yes"
    
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int a[1000005],check[1000006];
  
  memset(check,-1,sizeof(check));
  cin>>a[1];
  check[a[1]]=1;
  for(int i=1;i<=1000000;i++){
    if(a[i]%2){
      a[i+1]=3*a[i]+1;
    }else{
      a[i+1]=a[i]/2;
    }
    if(check[a[i+1]]==-1){
      check[a[i+1]]=1;
    }else{
      cout<<i+1<<"\n";
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 6144
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int mod = 1000000007;
    long power = 1;
    for (int i = 1; i <= n; i++) {
      power = (power * i) % mod;
    }
    System.out.println(power);

  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
//#define sz 2

using namespace std;

bool vis[ 1000001 ];
int prime[ 1000000 ];
int num = 0;

void pre();

int main() {
	int ans = 1, tmp;
	ll n, m;
	pre();
	scanf( "%lld", &n );
	m = n - 1;
	if( n == 2 ) {
		printf( "1" );
		return 0;
	}
	for( int i = 0; i < num && prime[ i ] <= m; ++i ) {
		tmp = 1;
		while( m % prime[ i ] == 0 ) {
			++tmp;
			m /= prime[ i ];
		}
		ans *= tmp;
	}
	if( m > 1 )
		ans <<= 1;
	for( ll i = 2; i * i <= n; ++i ) {
		if( n % i )
			continue;
		m = n;
		while( m % i == 0 )
			m /= i;
		if( m % i == 1 )
			++ans;
	}
	printf( "%d", ans );
	return 0;
}

void pre() {
	memset( vis, false, sizeof( vis ) );
	vis[ 0 ] = vis[ 1 ] = true;
	for( int i = 2; i <= 1000000; ++i ) {
		if( !vis[ i ] ) {
			prime[ num++ ] = i;
		}
		for( int j = 0; j < num; ++j ) {
			if( i * prime[ j ] > 1000000 )
				break;
			vis[ i * prime[ j ] ] = true;
			if( !( i % prime[ j ] ) )
				break;
		}
	}
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int gcd(int one,int two) {
	while (one != 0 && two != 0) {
		if (one > two) {
			one = one % two;

		}
		else {
			two = two % one;
		}

	}

	return std::max(one,two);
	
}
int main()
{
	
	int a = 0, b = 0, c = 1, d = 0, e = 0, min = 0, ma = 0, ans = 0, count = 0, nagax = 0, nagay = 0, size = 0;
	int sa[100020] = {}, info[100020] = {};
	std::string str[150], strs;
	

	bool okada = false, okada2 = true;
	cin >> a>>b;
	for (int i = 0; i < a; i++) {
		cin >> info[i];
		sa[i] = std::abs(info[i] - b);
	}
	for (int i = 0; i < a; i++) {
		d = sa[i];
		if (i == 0) {
			c = d;
	}
		c = gcd(c, d);
	}
	

	cout <<c << endl;
	



	return 0;




}





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

using ll = long long; 

int main() {
  int H, N;
  cin >> H >> N;
  
  vector <int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int sum = 0;
  for (int i=0; i<N; i++){
    sum += A.at(i);
  }

  if (sum >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
	long long int A,B,C;
	long long int sum;
	cin>>A>>B>>C;
	if(A%2==0||B%2==0||C%2==0){cout<<0<<endl;}
	else {
		if(A>=B&&A>=C){
			sum=B*C;
			cout<<sum<<endl;
		}
		else if(B>=A&&B>=C){
			sum=A*C;
			cout<<sum<<endl;
		}
		else if(C>=A&&C>=C){
			sum=A*B;
			cout<<sum<<endl;
		}
	} 
}

Measured memory_bytes: 888
import java.io.BufferedReader
import java.util.*

/**
 * Created by takefumiota on 2017/02/16.
 */

fun main(args: Array<String>) {
    /** comment in when you submit **/
    System.`in`.bufferedReader().use { println(getOutputString(it)) }

    /** delete below after your test **/
    //executeTest()
}

fun getOutputString(reader: BufferedReader): String {
    val sc = Scanner(reader)
    val a = sc.nextInt().let {
        if (it == 1) 14 else it
    }
    val b = sc.nextInt().let {
        if (it == 1) 14 else it
    }
    if (a == b) {
        return "Draw"
    } else {
        return if (a > b) "Alice" else "Bob"
    }
}

/** delete below after your test **/
fun String.mustBe(expected: String): Unit {
    if (this != expected) throw Exception("\"$this\" must be \"$expected\"")

    println("ok")
}

fun executeTest() {
    getOutputString("8 6".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("Alice")
    getOutputString("1 1".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("Draw")
    getOutputString("13 1".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("Bob")
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> a(N), b(N), c(M), d(M);
  rep(i, N) cin >> a[i] >> b[i];
  rep(i, M) cin >> c[i] >> d[i];

  vector<pair<int,int>> ans(N, make_pair(INT_MAX, INT_MAX));
  for(int i=0; i<N; ++i) {
    for(int j=0; j<M; ++j) {
      int distance = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(distance < ans[i].first) {
        ans[i].first = distance;
        ans[i].second = j;
      }
      else if(distance == ans[i].first) {
        ans[i].second = min(ans[i].second, j);
      }
    }
  }
  rep(i, N) cout << ans[i].second+1 << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
minv, maxv = 0, 0
for i in range(n):
    x = int(input())
    if i == 0: minv = x
    elif i == 1: maxv = x - minv 
    if maxv < x - minv: maxv = x - minv
    if minv > x: minv = x
print(maxv)


Measured memory_bytes: 5620
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int INF = 1000000000 + 8;

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m, 0));

    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int min_cost = INF;

    for (int i = 0; i < 1 << n; i++) {
        vector<int> learn(m);
        int cost = 0;

        for (int j = 0; j < n; j++) {
            if (i & 1 << j) {
                cost += c[j];
                for (int k = 0; k < m; k++) {
                    learn[k] += a[j][k];
                }
            }
        }

        bool acheve = true;
        for (auto &&l : learn) {
            acheve &= l >= x;
        }

        if (acheve) {
            min_cost = min(cost, min_cost);
        }
    }

    cout << (min_cost != INF ? min_cost : -1) << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin >>N;
  vector<vector<int>> v(N,vector<int>(3));
  rep(i,N) cin>>v[i][0]>>v[i][1]>>v[i][2];//それぞれa,b,c。v[i]はi+1日目の幸福度の選択肢。
  vector<vector<int>> dp(N+1,vector<int>(3,0));//dp[i][0-2]はi日目の最大の幸福度。
  for(int i=1;i<=N;i++){
    rep(j,3){
      rep(k,3){
        if(j!=k) dp[i][k]=max(dp[i][k],dp[i-1][j]+v[i-1][k]);
      }
    }
  }
  int ans=max(dp[N][0],dp[N][1]);
  ans=max(ans,dp[N][2]);

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


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


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 void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        for (int i = 0; i < s.Length; i++)
            Console.Write("x");


        Console.Out.Flush();
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>G;
vector<bool>seen;
vector<int> cost;
void dfs(int v,int p=-1){
  seen[v]=true;
  if(v!=0)cost[v]+=cost[p];
  for(auto next_v:G[v]){
    if(next_v==p)continue;
    if(seen[next_v])continue;
    dfs(next_v,v);
  }
}
int main(){
  int n,q;
  cin>>n>>q;
  G.resize(n);
  cost.assign(n,0);
  seen.assign(n,false);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    a--;
    cost[a]+=b;
  }
  for(int i=0;i<n;i++){
    if(seen[i])continue;
    dfs(i);
  }
for(int i=0;i<n;i++){
  cout<<cost[i]<<" ";
}
cout<<endl;
}

Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}

int main() {
    int n = 3;
    int k;
    cin >> k;

    ll r = 0;
    vector<int> a(k + 1);
    for (int i = k; i > 0; i--) {
        ll t = powmod(k / i, n);
        for (int j = i * 2; j <= k; j += i) {
            t -= a[j];
        }
        t %= P;
        if (t < 0) t += P;
        r += t * i % P;
        a[i] = t;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

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

using namespace std;

const int MAXN = 100;
int w[MAXN];
int v[MAXN];
vector<int> groups[4];

int solve(int groupNum, int weight, int curWeight, int curVal, int a)
{
    if (groupNum == 3)
    {
        for (int i = 0; i < min((int) groups[groupNum].size(), (weight - curWeight) / (a + 3)); i++)
        {
            curVal += groups[groupNum][i];
        }
        return curVal;
    }
    else
    {
        int ans = solve(groupNum + 1, weight, curWeight, curVal, a);
        for (int i = 0; i < (int) groups[groupNum].size(); i++)
        {
            curWeight += a + groupNum;
            curVal += groups[groupNum][i];
            if (curWeight > weight)
                break;
            ans = max(ans, solve(groupNum + 1, weight, curWeight, curVal, a));
        }
        return ans;
    }
}

int main()
{
    int n, weight;
    cin >> n >> weight;
    int a = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
        if (i == 0)
            a = w[i];
        groups[w[i] - a].push_back(v[i]);
    }
    for (int i = 0; i < 4; i++)
        sort(groups[i].rbegin(), groups[i].rend());
    cout << solve(0, weight, 0, 0, a) << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = input().split()
N = int(N)
M = int(M)
ans = ["-" for _ in range(N)]
p = []
for _ in range(M):
   p.append(input().split())

def check(i,p,N):
    i = str(i)
    if len(i) != N:
        return False
    for pp in p:
        if int(pp[0]) > len(i):
            return False
        elif i[int(pp[0])-1] != pp[1]:
            return False
    return True

c = False
for i in range(10**N):
    if check(i,p,N):
        c = True
        break
if len(str(i)) != N:
    c = False
if c:
    print(i)
else:
    print(-1)

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

int main(){
	string s;

	while ( getline(cin,s) ){
		for (int i=0 ; i<s.size() ; i++){
			if ( s[i]>='a' && s[i]<='z'){
				s[i] = s[i] + ('A'-'a');
			}
		}
		cout << s << endl;
	}

	return 0;
}

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

int main()
{
  int n;
  string s;
  cin>>n>>s;
  if(n&1)
  {
    cout<<"No\n";
    return 0;
  }
  int h=n/2;
  for(int i=0;i<h;i++)
    if(s[i]!=s[i+h])
    {
       cout<<"No\n";
       return 0;
    }
  
  cout<<"Yes\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n,ch=0,ch1=0;
    cin>>n;
    ch1=ceil(sqrt(n));
    ch=floor(sqrt(n));
    //cout<<ch<<" "<<ch1;
    while(1)
    {
        if(n%ch==0)
        break;
       ch--;
      
    }
    //cout<<"*";
    cout<<(ch-1)+(n/ch-1);
    return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "algorithm" 

using namespace std;

const int maxm=2e5+10;; 

int n,m,q,Ans[maxm],Bit[maxm]; 

struct Line{
	int l;
	int r;
	bool operator <(const Line &x)const{
		return r<x.r; 
	} 
}L[maxm];

struct ask{
	int l;
	int r;
	int ID;
	bool operator <(const ask &x)const{
		return r<x.r; 
	} 
}Ask[maxm]; 

void Update(int i,int x){
	while(i<=n){
		Bit[i]+=x;
		i+=i&-i; 
	}
	return; 
}

int query(int i){
	int ans=0;
	while(i>0){
		ans+=Bit[i];
		i-=i&-i; 
	}
	return ans; 
} 

int main(){
	register int i,j,k; 
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=m;i++){
		scanf("%d%d",&L[i].l,&L[i].r);
		if(L[i].l>L[i].r) swap(L[i].l,L[i].r); 
	}
	for(i=1;i<=q;i++){
		scanf("%d%d",&Ask[i].l,&Ask[i].r); 
		if(Ask[i].l>Ask[i].r) swap(Ask[i].l,Ask[i].r);
		Ask[i].ID=i; 
	}
	sort(L+1,L+1+m);
	sort(Ask+1,Ask+1+q);
	for(i=1,j=1,k=1;i<=n;i++){ 
		while(L[j].r<=i && j<=m){
			Update(L[j].l,1);
			j++;
		}
		while(Ask[k].r<=i && k<=q){
			Ans[Ask[k].ID]=j-1-query(Ask[k].l-1);
			k++; 
		}
	}
	for(i=1;i<=q;i++){
		printf("%d\n",Ans[i]); 
	} 
	return 0;
} 

Measured memory_bytes: 4608
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	int num = r * 100 + g * 10 + b;
	if (num % 4 == 0){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline

class SegmentTree:
    def __init__(self, a):
        self.padding = -float('inf')
        self.n = len(a)
        self.N = 2 ** (self.n-1).bit_length()
        self.data = [self.padding]*(self.N-1) + a + [self.padding]*(self.N-self.n)
        for i in range(2*self.N-2, 0, -2):
            self.data[(i-1)//2] = max(self.data[i], self.data[i-1])
    
    def __len__(self):
        return self.n
    
    def update(self, i, x):
        idx = self.N - 1 + i
        self.data[idx] = x
        while idx:
            idx = (idx-1) // 2
            self.data[idx] = max(self.data[2*idx+1], self.data[2*idx+2])
    
    def query(self, i, j):
        # [i, j)
        if i == j:
            return self.data[self.N - 1 + i]
        else:
            idx1 = self.N - 1 + i
            idx2 = self.N - 2 + j # 閉区間にする
            result = self.padding
            while idx1 + 1 < idx2:
                if idx1&1 == 0: # idx1が偶数
                    result = max(result, self.data[idx1])
                if idx2&1 == 1: # idx2が奇数
                    result = max(result, self.data[idx2])
                    idx2 -= 1
                
                idx1 //= 2
                idx2 = (idx2 - 1)//2
            
            if idx1 == idx2:
                result = max(result, self.data[idx1])
            else: # idx1 + 1 == idx2
                result = max(result, self.data[idx1], self.data[idx2])
            
            return result


MOD = 998244353
N = int(input())
XD = [list(map(int, input().split())) for i in range(N)]
XD.sort()

X = [xd[0] for xd in XD]

dp = [0] * (N+1)
dp[-1] = 1
st = SegmentTree([i for i in range(N)])
for i in range(N-1, -1, -1):
  idx = bisect.bisect_left(X, sum(XD[i])) - 1
  if idx > i:
    idx = st.query(i, idx+1)
    st.update(i, idx) 
  dp[i] = (dp[i+1] + dp[idx+1]) % MOD

print(dp[0])

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, k;
void solve(){
	cin >> n >> k;
	
	int cnt = 1;
	for(i64 i = k; i <= n; i*=k){
		cnt++;
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 100000
using namespace std;
 
int Partition(int A[], int p, int r) //[p,r]
{
	int tmp;
	int x = A[r];
	int i = p-1;
	for (int j = p;j < r;j++)
	{
		if (A[j] <= x)
		{
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp;
	return i+1;
}

int main ()
{
	int n, A[MAX];
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> A[i];
	}
	
	int q = Partition(A, 0, n-1);
	
	cout << A[0];
	for (int i = 1;i < n;i++)
	{
		if (i == q)
		{
			cout << " [" << A[i] << "]";
		}
		else cout << " " << A[i];
	}
	cout << endl;
	
	return 0;
 } 


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

int main(void){
    string S;
    cin >> S;
    
    if(S[2] == S[3]){
        if(S[4] == S[5]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
N=int(input())
A=list(map(int,input().split()))

A.sort(reverse=True)

B=[]
B.append(A[0])
for i in range(1,N):
    B.append(A[i])
    B.append(A[i])

ans=0
for i in range(N-1):
    ans += B[i]

print(ans)

Measured memory_bytes: 122844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    ll k, cnt = 0;
    string s;
    ll ans = 0;
    cin >> s >> k;
    ll n = s.size();
    char c = s[0];
    bool all = true;
    for(int i = 0; i < n; i++){
        if(c != s[i]) all = false; 
    }
    if(all) {
        cout << (n * k) / 2 << endl;
        return 0;
    }
    int l = 0, r = 0;
    while(c == s[l])l++;
    while(c == s[n-1-r])r++;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]){
            cnt++;
            i++;
        }
    }
    ans += k * cnt;
    if(r != 0) ans += ((l+r) / 2 - r/2 - l/2) * (k-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int N;
std::vector<vector<int> > G;


void preorder(int i) {
    cout << " " << i;
    if (G[i][0] != -1) preorder(G[i][0]);
    if (G[i][1] != -1) preorder(G[i][1]);
}

void inorder(int i) {
    if (G[i][0] != -1) inorder(G[i][0]);
    cout << " " << i;
    if (G[i][1] != -1) inorder(G[i][1]);
}

void postorder(int i) {
    if (G[i][0] != -1) postorder(G[i][0]);
    if (G[i][1] != -1) postorder(G[i][1]);
    cout << " " << i;
}

int main() {

    cin >> N;
    for (int i = 0; i < N; i++) {
        G.push_back(vector<int>());
    }
    std::vector<int> notroot(N, 0);

    for (int i = 0; i < N; i++) {
        int id;
        cin >> id;
        for (int j = 0; j < 2; j++) {
            int child;
            cin >> child;
    
            if (child != -1) notroot[child] = 1;
            G[id].push_back(child);
        }
    }

    int root;
    for (int i = 0; i < N; i++) {
        if (notroot[i] == 0) {
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    preorder(root);
    cout << endl << "Inorder" << endl;
    inorder(root);
    cout << endl << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int find_idx(Vint &A, int k){
  // A(i) = kなる i を二分探索で求める
  int lb = -1, ub = A.size() - 1;
  while(ub - lb > 1){
    int m = (lb + ub) / 2;
    if(A.at(m) > k) ub = m;
    else if(A.at(m) < k) lb = m;
    else return m;
  }
  return ub;
}

int main(void){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  Vint A(n), sorted_A(n);
  REP(i, n){
    cin >> A.at(i);
    sorted_A.at(i) = A.at(i);
  }
  SORT(sorted_A);
  int cnt = 0;
  REP(i, n){
    int idx = find_idx(sorted_A, A.at(i));
    if( ((idx - i) & 1) != 0) cnt++;
  }
  cout << cnt / 2 << BR;
  return 0;
}

Measured memory_bytes: 1024