akhauriyash/Code-Regression huggingface dataset:
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        int k = 0;
        vector<int> v;
        for(int i = 1; i <= 9; i++)
            v.push_back(i);
        while(v.size() < n) {
            int x = v[k], y = x % 10;
            if(y == 0) {
                v.push_back(10 * x);
                v.push_back(10 * x + 1);
            }
            else if(y == 9) {
                v.push_back(10 * x + 8);
                v.push_back(10 * x + 9);
            }
            else {
                v.push_back(10 * x + y - 1);
                v.push_back(10 * x + y);
                v.push_back(10 * x + y + 1);
            }
            k++;
        }

        cout << v[n - 1] << '\n';
        
    }
    
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    string temp;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == 'C' || s[i] == 'F')
        {
            temp.push_back(s[i]);
        }
    }

    if (temp.find("CF") != -1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
str = [nil] + gets.chomp.split("") + [nil]
flag = false
("keyence".length + 1).times do |i|
  if (str[0..("keyence".length - i)] + str[-i-1..-1]).join == "keyence"
    flag = true
    break
  end
end
puts flag ? "YES" : "NO"


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

typedef long long ll;

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

    string s; cin >> s;
    //since repeated reversing the string is time consuming, instead we save the state of the string 1 or 2
    short state = 1;
    int q=0; cin >> q;
    while(q--)
    {
        int t,f; char c;
        cin >> t;
        if(t==1){
            state = (state==1) ? 0 : 1;
        }
        else if(t==2){
            cin >> f >> c;
            if(state==1)
            {
                if(f==1)
                    s.insert(s.begin(), c);
                else
                    s.insert(s.end(), c);
            }
            else
            {
                if(f==1)
                    s.insert(s.end(), c);
                else
                    s.insert(s.begin(), c);
            }
        }
    }
    if(state==0) reverse(s.begin(), s.end());
    cout << s; return 0;
}

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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        string inp1,inp2;
        cin>>inp1>>inp2;
        ll n=inp1.size(),m=inp2.size();
        ll dp[n+1][m+1];
        for(ll i=0;i<=n;i++){
            for(ll j=0;j<=m;j++){
                if(i==0 || j==0){
                    dp[i][j]=0;
                }
                else if(inp1[i-1]==inp2[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else {
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
        vector<char> v;
        ll i=n,j=m;
        while(i>0 && j>0){
            if(inp1[i-1]==inp2[j-1]){
                v.push_back(inp1[i-1]);
                i--,j--;

            }
            else if(dp[i-1][j]>=dp[i][j-1]){
                i--;
            }
            else j--;
        }
        reverse(v.begin(),v.end());
        for (auto elem:v){
            cout<<elem;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 70656
#!/usr/bin/env python3
import sys
rl = sys.stdin.buffer.readline

N = int(rl())
AS = tuple(map(int, rl().split()))

posession = 1000
for i in range(N-1):
  if AS[i] < AS[i+1]:
    quantity = posession // AS[i]
    posession = (posession - quantity * AS[i]) + quantity * AS[i+1]

print(posession)


Measured memory_bytes: 9224
import math

dp = [0, 9, 0, 0, 0, 0]
for i in range(2, 6):
	 if i&1:
	 	dp[i] = dp[i-1] + pow(10, i-1)*9
	 else:
	 	dp[i] = dp[i-1]

n = int(input())
max_pow = int(math.log10(n))

if max_pow&1:
	ans = dp[max_pow]
else:
	ans = n - pow(10, max_pow) + dp[max_pow] + 1
print(ans)

Measured memory_bytes: 38384
#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 ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, now;
    cin >> n >> now;
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        ans = GCD(ans, llabs(x - now));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll h;
    cin>>h;
    ll ans=0;
    ll cry=1;
    while(h>0)
    {
        ans+=cry;
        cry=cry+cry;
        h>>=1;
    }
    cout<<ans;
    return 0;
}


//252908XL

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

using namespace std;

#define ll long long

vector <vector <int>> g;

int MOD = 1e9+7;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans = k;
    g.resize(n, vector <int> (0));
    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);
    }

    int s = 0;

    queue <int> q;
    vector <bool> used(n, 0);

    q.push(s);

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        used[u] = 1;
        ll i = -1;
        for (int v:g[u]) {
            if (!used[v]) {
                ++i;
                q.push(v);
                if (u != s) {
                    ans *= (k-i-2);
                    if (i+2 >= k)
                        ans = 0;
                }

                else {
                    ans *= (k-i-1);
                    if (i+1 >= k)
                    ans = 0;
                }

                ans %= MOD;
            }
        }
    }


    cout << ans;


}

Measured memory_bytes: 6520
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    REP(i,0,n) {
        if (s.substr(i,n-i) + s.substr(0,i) == t) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 256
//
// C - Go Home
//

#include <iostream>

using namespace std;
using LL = long long;

int main() {

    LL X;
    cin >> X;

    LL i, left, rigth;

    left = 0;
    rigth = X + 1;

    while (left < rigth) {
        i = (rigth - left) / 2 + left;
        LL x = i * (i + 1) / 2;
        if (x < X) {
            left = i + 1;
        } else if (X <= x - i) {
            rigth = i;
        } else {
            break;
        }
    }

    cout << i << endl;
}

Measured memory_bytes: 888
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

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

void solve() {
    int k, n;
    cin >> k >> n;
    int a; cin >> a;
    int f = a, p = a;
    int x = 0;
    for (int i = 1; i < n; ++i) {
        cin >> a;
        x = max(x, a - p);
        p = a;
    }
    x = max(x, k + f - a);
    cout << k - x << '\n';
}

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

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}


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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	// scanf("%d", &x);
	cin >> x;
	return x;
}

const int L = 20;
const int N = 1 << L;
bool fft_initialized = false;

using ld = long double;
using base = complex<ld>;
using Poly = vector<ld>;

const ld pi = acosl(-1);
base angles[N + 1];
int bitrev[N];

// don't know why such eps, may be changed
const ld eps = 1e-7;

inline bool eq(ld x, ld y) {
	return abs(x - y) < eps;
}

void fft_init() {
	for (int i = 0; i <= N; ++i) {
		angles[i] = {cosl(2 * pi * i / N), sinl(2 * pi * i / N)};
	}

	for (int i = 0; i < N; ++i) {
		int x = i;
		for (int j = 0; j < L; ++j) {
			bitrev[i] = (bitrev[i] << 1) | (x & 1);
			x >>= 1;
		}
	}

	fft_initialized = true;
}

inline int revBit(int x, int len) {
	return bitrev[x] >> (L - len);
}

void fft(vector<base>& a, bool inverse = false) {
	assert(fft_initialized && "you fucking cunt just write fft_init()");
	int n = a.size();
	assert(!(n & (n - 1)));	// work only with powers of two
	int l = __builtin_ctz(n);

	for (int i = 0; i < n; ++i) {
		int j = revBit(i, l);
		if (i < j) {
			swap(a[i], a[j]);
		}
	}

	for (int len = 1; len < n; len *= 2) {
		for (int start = 0; start < n; start += 2 * len) {
			for (int i = 0; i < len; ++i) {
				base x = a[start + i], y = a[start + len + i];
				int idx = N / 2 / len * i;
				base w = y * angles[inverse ? N - idx : idx];
				a[start + i] = x + w;
				a[start + len + i] = x - w;
			}
		}
	}

	if (inverse) {
		for (auto& x : a) {
			x /= n;
		}
	}
}

Poly multiply(Poly a, Poly b) {
	int n = 1;
	while (n < (int)a.size() || n < (int)b.size()) {
		n *= 2;
	}
	vector<base> ar(n + n), br(n + n);
	for (int i = 0; i < (int)a.size(); ++i) {
		ar[i] = a[i];
	}
	for (int i = 0; i < (int)b.size(); ++i) {
		br[i] = b[i];
	}
	fft(ar);
	fft(br);
	for (int i = 0; i < n + n; ++i) {
		ar[i] = ar[i] * br[i];
	}
	fft(ar, true);
	while (!ar.empty() && eq(norm(ar.back()), 0)) {
		ar.pop_back();
	}
	a.resize(ar.size());
	for (int i = 0; i < (int)a.size(); ++i) {
		a[i] = real(ar[i]);
	}
	return a;
}

const int P = 200003;
int cnt[P];

const int g = 2;
int dlog[P];

void solve() {
	for (int i = 0, cur = 1; i < P - 1; ++i, cur = 1ll * cur * g % P) {
		assert(dlog[cur] == 0);
		dlog[cur] = i;
	}
	fft_init();

	int n = nxt();
	for (int i = 0; i < n; ++i) {
		int x = nxt();
		if (!x) {
			continue;
		}
		cnt[dlog[x]] += 1;
	}

	Poly p(P);
	for (int i = 0; i < P; ++i) {
		p[i] = cnt[i];
	}
	p = multiply(p, p);
	long long ans = 0;
	while ((int)p.size() > P - 1) {
		p[(int)p.size() - P] += p.back();
		p.pop_back();
	}
	long long cur = 1;
	for (int i = 0; i < P - 1; ++i) {
		ans += cur * (long long)roundl(p[i]);
		ans -= cur * cur % P * cnt[i];
		cur = cur * g % P;
	}
	cout << ans / 2 << "\n";
}

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

	int t = 1; // nxt();
	while (t--) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 90592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		Integer n = sc.nextInt();

		List<String> card = new ArrayList<>();

		for (Integer i = 0; i < n; i++) {
			String mark = sc.next();
			Integer number = sc.nextInt();

			card.add(mark + number);
		}

		// S H C D
		String[] markList = { "S", "H", "C", "D" };

		// 1 to 13
		for (Integer i = 0; i < 4; i++) {
			for (Integer j = 1; j < 14; j++) {
				if (!card.contains(markList[i] + j)) {
					System.out.println(markList[i] + " " + j);
				}

			}
		}

	}
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
int main() {
 int k;
 string s;
 cin >> k >> s;
  if(s.size() <= k){
    cout << s << endl;
  } else {
    for(int i=0;i<k;i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,k;
  int a[200010]={0};
  int p;
  int ans;
  cin>>n>>k;
  rep(i,n){
    cin>>p;
    a[p]++;
  }
  ans=n;
  sort(a,a+n+1,greater<int>());
  rep(i,k){
    ans-=a[i];
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 1024
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<math.h>
#include <iostream>
#include<iomanip>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

struct node {
	int p;
	int y;
	friend bool operator < (const node &a, const node &b)
	{
	   if (a.p == b.p) return a.y < b.y;
	   else return a.p < b.p;
	}
}nodes[maxn], pos[maxn];

int cnt[maxn], sum[maxn];

int n, m;

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> nodes[i].p >> nodes[i].y;
		pos[i].p = nodes[i].p;
		pos[i].y = nodes[i].y;
		cnt[pos[i].p] ++;
	}
	sort(nodes, nodes + m);
	for (int i = 1; i <= n; ++i)
		sum[i] = sum[i - 1] + cnt[i];
	for (int i = 0; i < m; ++i) {
		int poj = lower_bound(nodes, nodes + m, pos[i]) - nodes;
		//cout << poj+1 << endl ;
		poj -= sum[pos[i].p - 1];
        cout<<setw(6)<<setfill('0')<<pos[i].p << setw(6)<<setfill('0') << poj + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3840
import math
# map(int, input().split())
#
# input().split()

X = int(input())
ans = 0
while X > 5:
    if X >= 500:
        a = X//500
        ans += a*1000
        X-=a*500
    else:
        a = X//5
        ans += a*5
        X-=a*5
print(ans)

Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)

function main()
	n = readline() |> x -> parseInt(x)
	a = readline() |> split |> x -> parseInt.(x)
	count = 0
	streak = 1
	for i in 2:n
		if a[i] == a[i-1]
			streak += 1
		else
			if streak >= 2
				count += div(streak, 2)
			end
			streak = 1
		end
	end
	if streak >= 2
		count += div(streak, 2)
	end
	print(count)
end

main()

Measured memory_bytes: 117136
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    if (n == 1) return false;

    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) { 
              return false;
         }
    }
    return true;
}

int main() {
    int Q;
    cin >> Q;
    vi a(100010, 0);
    vi b(100010, 0);
    int res = 0;
    rep(k, 0, a.size()) {
        if (k % 2 != 0) {
            if (is_prime(k)) {
                if (is_prime((k+1)*0.5)) {
                    ++res;
                    b[k] = 1;
                }
            }
        }
        a[k] = res;
    }
    vi s(100010, 0);
    rep(i, 0, a.size()) {
        s[i+1] = s[i] + a[i];
    }

    rep(i, 0, Q) {
        int l, r;
        cin >> l >> r;
        if (l == r) {
            cout << b[r] << endl;
        } else {
            cout << a[r] - a[l-1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l;
  cin>>l;
  double ans=0;
  int s=l/3;
  int r=l%3;
  double d=r/3.00;
  s+=d;
  ans=(l*l*l)/27.00;
  //for(int i=1;i<=l;i++)
  //{
  //  for(int j=1;j<=l-i;j++)
  //  {
  //    int k=l-i-j;
  //    if(k>0)
  //    {
  //      ans=max(ans,i*j*k);
  //    }
  //  }
  //}
  cout<<setprecision(30)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
min = a.inject(:+).to_f / 4.0 / m
count = 0
a.each do |aa|
    count += 1 if aa >= min
end
if count >= m
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1916
#include <stdio.h>
#include <math.h>

int main(){
  int n;
  int i;
   while(scanf("%d",&n)!=EOF){

    if(n==0)break;

      int m = (int)sqrt(n);
      int s = 0;

      for(i=1;i<=m;i++){
        if(n%i==0){
          s += i ;
          s += (n/i);
        }
      }


       if(n==m*m){s-=m;}
        s -= n;

      if(s<n){printf("deficient number\n");}
      else if(s==n){printf("perfect number\n");}
      else{printf("abundant number\n");}
   }
   return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<int> A(N),B(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i] >> B[i];
        sum += A[i];
    }
    if(A == B){
        cout << 0 << endl;
        return 0;
    }
    int ans = INF;
    rep(i,N){
        if(A[i] > B[i]){
            ans = min(ans,B[i]);
        }
    }
    ll ans2 = sum-ans;
    cout << ans2 << endl;   
}


Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N, K; cin >> N >> K;
	long res = 0;

	for (int b = 1; b <= N; b++) {
		//bで割ったあまりがK以上となるN以下の整数
		//余りは0 ~ b - 1;
		//剰余類の中の候補数
		long overK = max(b - K, (long)0);

		//Kが0でないときN以下の非負整数とできる
		long maxbs = N - (N % b); // N以下の最大のbの倍数
		long perfdivg = maxbs / b;//N以下のb-完全剰余類の数は
		res += overK * perfdivg;
		maxbs += K; //余りをK以上に
		res += max((long)0, N - maxbs + 1);//残りの候補

	}
    if (K == 0) res -= N; // (a == 0)を省く
	cout << res << endl;

}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[]
for _ in range(n):
  x,y=map(int,input().split())
  d=[x,y]
  a.append(d)
  
a.sort()
ans=0
ans1=0

for d in a:
  if (ans+d[1])>=k:
    ans1=d[0]
    break
    
  else:
    ans+=d[1]
    
print(ans1)


Measured memory_bytes: 24456
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int X1 = sc.nextInt();
		int Y1 = sc.nextInt();
		int X2 = sc.nextInt();
		int Y2 = sc.nextInt();
		
		
		X2 = X2 - X1;
		Y2 = Y2 - Y1;
		
		
		int X3 = X2 - Y2;
		int Y3 = X2 + Y2;
		int X4 = 0 - Y2;
		int Y4 = X2;
		
		X3 = X3 + X1;
		Y3 = Y3 + Y1;
		X4 = X4 + X1;
		Y4 = Y4 + Y1;
		
		
		System.out.println(X3 + " " + Y3 + " " + X4 + " " + Y4);
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll ans = -2;
  ll now = 8;
  rep(i,N){
    ll d;
    ll c;
    cin >> d >> c;
    ans += c;
    now += d*c;
    ans += now/9;
    now = now%9;
  }
  cout << ans << endl;
  return 0;
}


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

struct card{
  int N;
  char C;

  //????????????????????????????????§????????¢??°?????????
  bool operator<(const card& another) const;
  bool operator==(const card& another) const;
};

int C2int(char C);

bool card::operator<(const card& another) const
{
  int a = C2int(C);
  int b = C2int(another.C);
  
  if(a != b)  //?????????????¨???\???????????´???
    return a < b;  //?¨???\?????????
  else  //????????´???
    return N < another.N;  //??°????????????
}

bool card::operator==(const card& another) const
{
  if(N == another.N && C == another.C)
    return true;
  else
    return false;
}

int main()
{
  int n;  //?????£???????????????????????°
  
  //cout << "?????£??????????????????????????°?????\?????????????????????\n";
  
  cin >> n;

  vector<card> cards;
  card temp;
  
  //cout << n << "???????????????????¨???\??¨??°????????\??????????????£???????????????\n";
  
  for(int i=0; i<n; ++i){
    cin >> temp.C >> temp.N;
    cards.push_back(temp);
  }
  
  sort(cards.begin(), cards.end());

  vector<card> all_cards;
  for(int i=0; i<4; ++i){
    for(int j=0; j<13; ++j){
      card CD;
      if(i==0)
	CD.C = 'S';
      if(i==1)
	CD.C = 'H';
      if(i==2)
	CD.C = 'C';
      if(i==3)
	CD.C = 'D';
      CD.N = j+1;
      all_cards.push_back(CD);
    }
  }

  int index_all = 0;
  int index = 0;
  while(index_all <= 51){
    if(cards[index] == all_cards[index_all]){
      ++index_all;
      ++index;
    }
    else{
      cout << all_cards[index_all].C << " " << all_cards[index_all].N << "\n";
      ++index_all;
    }
  }
}

int C2int(char C)
{
  int out;
  if(C == 'S')
    out = 1;
  else if(C == 'H')
    out = 2;
  else if(C == 'C')
    out = 3;
  else if(C == 'D')
    out = 4;
  else{
    cout << "Error: undefined card type was typed";
    return 0;
  }

  return out;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;


int main()
{
    int a,b,c;

    cin >> a >> b >> c;

	if( a > b ){
		if( ( a - b ) > ( a - c ) && (a - c) > 0 ){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}  else{
		if( ( b - a ) > ( c - a ) && (c - a) > 0 ){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}		
	}




    return 0;
}

Measured memory_bytes: 256
# cook your dish here
n = int(input())
p = [int(input())for i in range(n)]

a = [n+1] * (n+1)
b = []
k = 1

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

print(n-max(b))

        

Measured memory_bytes: 20504
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x = sorted(x, reverse=False)[-1]
y = sorted(y, reverse=False)[0]
flg = 'War'
if x < x+1 <= y:
    if x+1 > X:
        if x+1 <= Y:
            flg = 'No War'

print(flg)    


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int ans = 0;
  int tmp = 0;
  cin >> s;
  for (char si:s) {
    if(si == 'A' || si == 'C' || si == 'G' || si == 'T'){
      tmp++;
    }else{
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define debug(x) if(MODE==x)
#define MODE 0
using namespace std;



int main()
{
    int i,j;
    LLI N;

    scanf("%lld",&N);
    printf("%lld\n",(N-1)*(N)/2);


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int x,a;
    cin>x>a;
    cout<((x<a)?0:10)<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N, M, S, T;
vector<ll> to[100005];


int main(){
	cin >> N >> M;
	rep(i, M) {
		ll u, v;
		cin >> u >> v;
		u--;v--;
		to[u].push_back(v);
	}
	cin >> S >> T;
	S--;T--;


	//cost, pos, mod
	priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll> >, greater<tuple<ll, ll, ll> > > Q;
	//pos, mod
	map<pair<ll, ll>, ll >done;

	Q.push(make_tuple(0, S, 0));

	while(!Q.empty()) {
		tuple<ll, ll, ll> t = Q.top();
		ll pos = get<1>(t);
		ll mod = get<2>(t);
		ll cost = get<0> (t);
		Q.pop();

		if(done.count(make_pair(pos, mod)) != 0) continue;

		done[make_pair(pos, mod)] = cost;

		for(ll next: to[pos]) {
			tuple<ll, ll, ll> ntuple = make_tuple(cost + 1, next, (mod + 1) % 3);
			Q.push(ntuple);
		}
	}

	if(done[make_pair(T, 0)] == 0) {
		cout << -1 << endl;
	} else {
		cout << done[make_pair(T, 0)]/3L << endl;
	}
}


Measured memory_bytes: 27804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    ll N, X, M;
    cin >> N >> X >> M;

    ll ans = 0;

    vector<bool> seen(M + 1);
    ll now = X;
    seen[X] = true;
    while (N) {
        N--;
        ans += now;
        now *= now;
        now %= M;
        if (seen[now]) {
            break;
        }
        seen[now] = true;
    }

    ll tmp = now;
    ll csum = 0, csiz = 0;
    do {
        csum += tmp;
        csiz++;
        tmp *= tmp;
        tmp %= M;
    } while (tmp != now);

    ans += (N / csiz) * csum;
    N %= csiz;

    for (int i = 0; i < N; ++i) {
        ans += now;
        now *= now;
        now %= M;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
object Main {

  def read(): (Int, Array[Int]) = {
    val n = scala.io.StdIn.readInt()
    val hArr = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    (n, hArr)
  }


  def solve(n: Int, hArr: Array[Int]): Int = {
    var maxMovedCount = 0
    var tmpCount = 0
    for(i <- 0 until hArr.length - 1) {
      if(hArr(i) >= hArr(i+1)) {
        tmpCount += 1
        maxMovedCount = Math.max(maxMovedCount, tmpCount)
      } else {
        tmpCount = 0
      }
    }
    maxMovedCount
  }


  def main(args: Array[String]): Unit = {
    val (n, hArr) = read()
    println(solve(n, hArr))
  }

}


Measured memory_bytes: 46504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

constexpr int MOD = 1e9+7;

constexpr int COMB_MAX = 110000;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];
ll p2[COMB_MAX], p3[COMB_MAX];

void initComb(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COMB_MAX; i ++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void initPow(){
    p2[0] = p3[0] = 1;
    for(int i = 1; i < COMB_MAX; i ++){
        p2[i] = (p2[i-1] * 2) % MOD;
        p3[i] = (p3[i-1] * 3) % MOD;
    }
}

int main(void){
    Cin(string, n);
    initComb();
    initPow();
    
    ll ans = 0;
    int top = 0;
    int s = (int)n.size();
    for(int d = s; d > 0; d --){
        if(n[s-d] == '1'){
            // Cout("top = ", top, ", d = ", d);
            ans = (ans + (p2[top] * p3[d-1]) % MOD) % MOD;
            top ++;
        }
        // Cout(d, "(", n[s-d], ") ", ans);
    }
    ans = (ans + p2[top]) % MOD;
    Cout(ans);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<ll> P(N);
    vector<ll> Q(N);
    priority_queue<ll, vector<ll>, greater<ll>> que;
    //priority_queue<ll> que;
    ll ans = 0;
    REP(i,N){
        ll p;
        cin >> p;
        que.push(p);
        ll top = que.top();
        if(top >= p) ans++;
    }

    //sort(Q.begin(), Q.end());
    //
    //ll ans = 0;
    //REP(i,N){
    //    ll p = P[i];
    //    ll tmp = 0;
    //    tmp = upper_bound(Q.begin(), Q.end(), p) - Q.begin();
    //    ans += tmp;
    //}

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


Measured memory_bytes: 5492
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())
T, A = inpl()
H = inpl()
good = 1e9
ans = 0
for i in range(N):
    temp = abs(A - (T - 0.006*H[i]))
    if good > temp:
        good = temp
        ans = i + 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string A,B,C;
	cin>>A>>B>>C;
	if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0])
        {
            cout<<"YES\n";
        }
        else
        {
            cout<<"NO\n";
        }
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
#if DEBUG
#define debug(...) //printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 1234560
#else
#define SIZE 1234560
#endif

int N,A[SIZE];
vector<int> F(SIZE,0);

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i];
    REP(i,N) {
        int a = A[i];
        if (F[a]>=2) continue;
        REP1(j,SIZE) {
            if (a*j>SIZE) break;
            F[a*j] += 1;
        }
    }
    int ans = 0;
    REP(i,N) {
        if (F[A[i]]>=2) continue;
        ans++;
        debug("%lld\n", A[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 14552
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int n = (int)s.size(), ans = 0;
    rep(i, 1, n) {
        if (s[i] != s[i-1]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

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

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

int main()
{
	llint n, p;
	ci >> n >> p;

	if(n == 1) {
		co << p << en;
		return 0;
	}
	
	llint ans = 0;
	for(llint i = 1; i <= sqrt(p) + 1; i++) {
	    llint ai = pow(i, (n - 1));
	    llint tmp = p / ai;
	    if(p % ai) continue;
	    ans = max(ans, gcd(i, tmp));
	}
	
	co << ans << en;
  
	return 0;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

ll h[100000];
int main() {
  int n;
  cin >> n;
  repi(n) cin >> h[i];
  bool re = true;
  ll x = LLONG_MIN;
  repi(n) {
    if (h[i] < x) {
      re = false;
      break;
    } else if (h[i] > x) {
      x = h[i] - 1;
    }
  }
  cout << (re ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=1e5+5;

int n,x,k;

int sg(int n,int k) {
	if (!(n%k)) return n/k;
	if (n<k) return 0;
	int l=(n/k)*k,t=n/k+1;
	int x=(n-l)/t+((n-l)%t>0);
	return sg(n-x*t,k);
}

int main() {
	scanf("%d",&n);
	int nim=0;
	fo(i,1,n) {
		scanf("%d%d",&x,&k);
		nim^=sg(x,k);
	}
	puts(nim?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define INF 0x3fffffff
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 200005
int a[N],c[N];
signed main()
{
	int n,p;
	cin>>n>>p;
	for(int i=1;i<=n;i++) scanf("%1d",&a[i]);
	if(p==2||p==5)
	{
		int ans=0;
		for(int i=1;i<=n;i++) if(a[i]%p==0) ans+=i;
		cout<<ans<<endl;
		return 0;
	}
	int cur=0,ans=0,mul=1;
	c[0]=1;
	for(int i=n;i>=1;i--)
	{
		cur=(cur+a[i]*mul)%p;
		ans+=c[cur];
		c[cur]++;
		mul=mul*10%p;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








string S; int N;
string T = "ATCG";
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	N = S.length();

	int ans = 0;
	rep(L, 0, N) rep(R, L, N) {
		int ok = 1;
		rep(x, L, R + 1) if (T.find(S[x]) == string::npos) ok = 0;
		if (ok) chmax(ans, R - L + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
char s[15][15];
char solve(int i,int j){
if(s[i][j]=='1'&&s[i+1][j]=='1'&&s[i][j+1]=='1'&&s[i+1][j+1]=='1'){
return 'A';
}
if(s[i][j]=='1'&&s[i+1][j]=='1'&&s[i+2][j]=='1'&&s[i+3][j]=='1'){
return 'B';
}
if(s[i][j]=='1'&&s[i][j+1]=='1'&&s[i][j+2]=='1'&&s[i][j+3]=='1'){
return 'C';
}
if(s[i][j]=='1'&&s[i][j+1]=='1'&&s[i+1][j+1]=='1'&&s[i+1][j+2]=='1'){
return 'E';
}
if(s[i][j]=='1'&&s[i+1][j]=='1'&&s[i+1][j+1]=='1'&&s[i+2][j+1]=='1'){
return 'F';
}
if(j>0){
if(s[i][j]=='1'&&s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i+2][j-1]=='1'){
return 'D';
}
if(s[i][j]=='1'&&s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i][j+1]=='1'){
return 'G';
}
}
return 0;
}
int main(){
while(!cin.eof()){
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
s[i][j]='0';
}
}
for(int i=0;i<8;i++){
cin>>s[i];
}
char ans;
bool solved=true;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(s[i][j]!='1')continue;
if(solved){
ans=solve(i,j);
cout<<ans<<endl;
solved=false;
}
}
}
}
return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <stack>

using namespace std;

int main(void){
int n;
cin >> n;
int sum=0;
for(int i=1;i<=n;i++){sum+=i;}
cout << sum << endl;
return 0;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 256