akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,w,i,j,no=1,tmp=0,tc=0,tr=0,p;
    cin >> h >> w;
    int r[h+1];
    int c[w+1];
    for(i=0;i<h+1;i++)
        r[i] = -1;
    for(i=0;i<w+1;i++)
        c[i] = -1;
    char a[h+1][w+1];
    char st;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
            cin >> a[i][j];
    }
    for(i=0;i<h;i++)
    {
        no = 1;
        st = a[i][0];
        if(st == '.')
        {
            for(j=1;j<w;j++)
            {
                if(a[i][j] != st)
                    break;
            }
            if(j == w)
            {
                r[tmp] = i;
                tmp++;
            }
        }
    }
    tmp = 0;
    for(i=0;i<w;i++)
    {
        no = 1;
        st = a[0][i];
        if(st == '.')
        {
            for(j=1;j<h;j++)
            {
                if(a[j][i] != st)
                    break;
            }
            if(j == h)
            {
                c[tmp] = i;
                tmp++;
            }
        }
    }
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            p = 1;
            tr = 0;
            tc = 0;
            while(r[tr] != -1)
            {
                if(r[tr] == i)
                {
                    p = 0;
                    break;
                }
                tr++;
            }
            while(c[tc] != -1)
            {
                if(c[tc] == j)
                {
                    p = 0;
                    break;
                }
                tc++;
            }
            if(p == 1)
                cout << a[i][j];
        }
        tr = 0;
        p = 1;
        while(r[tr] != -1)
        {
            if(r[tr] == i)
            {
                p=0;
                break;
            }
            tr++;
        }
        if(p == 1)
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int segtree[262146]={};
pair<int,int> seg[262146];
int n=1;

void update(int i, int x){
    segtree[n+i]=x;
    for(int idx=(n+i)/2; idx>=1; idx/=2){
        segtree[idx] = min(segtree[idx*2], segtree[idx*2+1]);
    }
}

int find(int x, int y, int idx){
    int ans=2147483647;
    
    int l = seg[idx].first;
    int r = seg[idx].second;
    
    if(r<x || y<l){
        return 2147483647;
    }
    if(x<=l && r<=y){
        return segtree[idx];
    }
    
    return min(find(x,y,idx*2), find(x,y,idx*2+1));

}

int a[262146];
int main(){

    for(int i=0; i<262146; i++){
        a[i] = 2147483647;
        segtree[i]=a[i];
    }

    int n_in;
    int q;
    cin >> n_in >> q;
    
    
    int segsize=1;
    while(n<n_in){
        n*=2;
    }
    for(int i=n*2-1; i>=1; i--){
        if(i>=n){
            seg[i].first=i-n;
            seg[i].second=i-n;
        }else{
            seg[i].first=seg[i*2].first;
            seg[i].second=seg[i*2+1].second;
        }
    }

    
    for(int cnt=0; cnt<q; cnt++){
        int com, x, y;
        cin >> com >> x >> y;
        
        if(com==0){
            a[x]=y;
            update(x,y);
        }else if(com==1){
            cout << find(x,y, 1) << endl;
        }
    }
    /*
    for(int i=1; i<2*n; i++){
        cout<<"i:"<<i<<" "<<seg[i].first<<" "<<seg[i].second<<endl;
    }
     */
    return 0;
}



Measured memory_bytes: 7220
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <map>
using namespace std;
int main() {
  int a, b;  cin >> a >> b;
  scanf ( "%d%d", &a, b );
  int cnt;
  for ( int i = a; i <= b; i++ ) {
    int s = i % 10, t= i/10000 % 10;
    int x = i/10 % 10, y = i/1000 % 10;
    if ( s==t && x==y ) cnt++;
  }
  printf ( "%d\n", cnt );
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

template<typename _T> void OutIter(_T beg, _T end, string separator = " ", bool eol = true) {
	cout << *beg;
	for (auto it = beg + 1; it != end; ++it) {
		cout << separator << *it;
	}
	if(eol)cout << endl;
}

int main()
{
	cout << fixed << setprecision(6);
	//IN(ll, n);
	IN(string, s);
	IN(string, t);
	//IN_V(ll, als, n);


	cout << ((s[0] == t[0] ? 1 : 0) + (s[1] == t[1] ? 1 : 0) + (s[2] == t[2] ? 1 : 0)) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b,t;
	cin>>a>>b>>t;
	cout<<(t/a)*b;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

int main()
{
    ll n,x,t;
    cin >> n>>x>>t;
    ll tt=n/x;
    if(n%x)tt++;
    cout << tt*t;
    return 0;
}


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

int main(){
	int n;
	while(cin>>n){
		int a[4];
		int k=3;
		while(n){
			a[k--]=n%10;
			n/=10;
		}
		int cnt=1;
		int MAX=-1;
		for(int i=0;i<4;i++){
			if (a[i]==a[i+1]){
				cnt++;
				MAX=max(cnt,MAX);
			}
			else
				cnt=1;
		}
		if (MAX>=3) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N, M;
    cin >> N >> M;

    vector<size_t> salary[M];
    for (size_t i = 0; i < N; ++i) {
        size_t a, b; cin >> a >> b;
        if (a <= M) {
            a--; salary[a].emplace_back(b);
        }
    }

    size_t res = 0;
    priority_queue<size_t> heap;
    for (size_t i = 0; i < M; ++i) {
        for (auto &si: salary[i]) {
            heap.emplace(si);
        }
        if (!heap.empty()) {
            res += heap.top();
            heap.pop();
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define rg register
using namespace std;
const int MAXN=1e5+5;
int n,a[MAXN],num;
int main(){
	scanf("%d",&n);
	for(rg int i=1;i<=n;++i){
		scanf("%d",&num);
		a[num]=i;
	}
	for(rg int i=1;i<=n;++i)
		printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 1152
#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;
    bool four = false;

    rep(i,N) {
        string S;
        cin >> S;
        if (S == "Y") four = true;  
    }
    if (four) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 3572
#pragma GCC optimize (2)
#include<bits/stdc++.h>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
const int N=205, M=100005, P=1000000007;
void add(int &a, int b){a=a+b>=P?a+b-P:a+b;}
void minus(int &a, int b){a=a+b<0?a+b+P:a+b;}
int mul(int a, int b){return 1ll*a*b-1ll*a*b/P*P;}
int inv[N], s[N], f[N][M];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	int n=read(), X=read(), fac=1, ans=0; f[0][X]=1; inv[1]=1; 
	rep(i, 2, n) fac=mul(fac, i), inv[i]=mul(inv[P%i], P-P/i);
	rep(i, 1, n) s[i]=read();
	sort(s+1, s+n+1); reverse(s+1, s+n+1);
	rep(i, 1, n) rep(j, 0, X)
		add(f[i][j], mul(f[i-1][j], P+1-inv[n-i+1])),
		add(f[i][j%s[i]], mul(f[i-1][j], inv[n-i+1]));
	rep(i, 0, X) add(ans, mul(mul(f[n][i], i%s[n]), fac));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 79872
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	ll w,h,x,y;
	std::cin >> w >> h >> x >> y;

	ld ans = static_cast<ld>(w*h) / 2.0;
	bool judge = (w == 2*x && h == 2*y) ? true : false;
	
	std::cout << std::fixed << std::setprecision(15) << ans << " " << judge << std::endl;

	return 0;
}

Measured memory_bytes: 3728
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int H,W,K;
	int[] dx = {0,0,-1,1},dy = {-1,1,0,0};
	char[][] ch;
	boolean[][] canGo;

	public boolean isRange(int x,int y){
		return x >= 0 && x < W && y >= 0 && y < H;
	}

	public void first_bfs(int sx,int sy){
		ArrayDeque<Long> q = new ArrayDeque<Long>();
		q.add(sx * 1000000000L + sy * 1000000L + 0);

		while(q.size() > 0){
			long p = q.poll();

			int x = (int)(p/1000000000L);
			int y = (int)((p/1000000L)%1000);
			int c = (int)(p%1000000);

			if(canGo[y][x])continue;
			canGo[y][x] = true;
			for(int i = 0;i < 4;i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				if(isRange(nx,ny) && !canGo[ny][nx] && ch[ny][nx] == '.' && c + 1 <= K){
					q.add(nx * 1000000000L + ny * 1000000L + c+1);
				}
			}
		}
	}

	public void solve(){
		H = nextInt();
		W = nextInt();
		K = nextInt();

		ch = new char[H][];
		for(int i = 0;i < H;i++){
			ch[i] = next().toCharArray();
		}

		int sx = -1,sy = -1;
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(ch[i][j] == 'S'){
					sx = j;
					sy = i;
				}
			}
		}
		canGo = new boolean[H][W];
		first_bfs(sx,sy);

		ArrayList<Integer> points = new ArrayList<Integer>();
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(canGo[i][j]){
					points.add(j * 1000 + i);
				}
			}
		}

		int min = Integer.MAX_VALUE;

		for(int p : points){
			int x = p / 1000;
			int y = p % 1000;

			if(x == 0 || y == 0 || x == W-1 || y == H-1){
				min = 1;
				continue;
			}

			int x1 = x;
			int y1 = y;
			int x2 = W-x-1;
			int y2 = H-y-1;

			int minDis = Math.min(Math.min(x1,y1), Math.min(x2, y2));
			min = Math.min(min, ((int)Math.ceil(minDis*1.0/K))+1);
		}

		out.println(min);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 53036
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

int run(istream& in, ostream& out) {
    ll N;
    string S;
    in >> N;
    in >> S;
    ll ans = 0;
    REP(i, S.size()-2) {
        if (S[i]=='A' && S[i+1]=='B' && S[i+2] == 'C') {
            ++ans;
        }
    }

    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
const double pi=3.141592653589793238;
#define d(x) cout<<x<<endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define rev(a) reverse(a.begin(),a.end())
const int inf = 100000000000000000;
#define maxn 1000005
#define mod 998244353
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) x.begin(),x.end()
//#define f(i,n) for(int i=1;i<=n;i++)
#define fo(i,k,n) for(int i=k;k<=n?i<=n:i>=n;k<=n?i+=1:i-=1)
void pv(vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<endl;}
void pa(int a[],int n,int p){for (int i = p; i < n+p; ++i){cout<<a[i]<<" ";}cout<<endl;}
int modexp(int x,int y) {
   int res = 1;
   x = x % mod;
   while (y > 0)
   {
       if (y & 1LL)
           res = (res*x) % mod;
       y = y>>1;
       x = (x*x) % mod;  
   }
   return res;}
int invmod(int a){

   return modexp(a,mod-2);}
vector<int> edge[maxn];
void ipgraph(int m) {
   fo(i,1,m)
   {
       int a,b;
       cin>>a>>b;
       edge[a].pb(b);
       edge[b].pb(a);
   } }
void dfs(int node,int p) {
   for(int u : edge[node])
   {
       if(u!=p)
           dfs(u,node);
   }}
//////////////////////////////////////////////////////////////////////////////////////////////////
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    fo(i,1,n) cin>>a[i];
    int l = 1,r = (int)1e9;
    int ans = 0;
    while(l<=r)
    {
        int mid = (l+r)/2,temp = 0;
        fo(i,1,n) a[i]%mid==0 ? temp+=a[i]/mid-1 : temp+=a[i]/mid;
        if(temp<=k)
        {
            ans = mid;
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }
    d(ans)
}
int32_t main()
{
   IOS;
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
    #endif
   int t=1;
   //cin>>t;
   fo(i,1,t)
   {
       //cout<<"Case "<<i<<": ";
       solve();
   }
}


Measured memory_bytes: 28568
#include <stdio.h>


int main(){
	int i;
	int N;
	double total = 0;

	scanf("%d", &N);

	if (N % 2 != 0){
		total = N / 2 + 1;
		printf("%lf\n", total / (double)N);
	}
	else{
		total = N / 2;
		printf("%lf\n", total / (double)N);
	}
	return 0;

	
	
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


ll modSum(ll a, ll b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modSubtract(ll a, ll b) {
  return (((a % MOD) - (b % MOD)) + MOD + MOD) % MOD;
}


ll modProd(ll a, ll b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


ll getInverse(ll x) {
  return getPowMod(x, MOD-2);
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}














string s;


void input() {
  cin >> s;
}


void preprocess() {
}


void solve() {
  int ans = 0;
  char pre = s[0];
  for (char ch : s) {
    if (pre != ch) {
      ans++;
    }
    pre = ch;
  }
  cout << ans;
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<int>L(M);
  vector<int>R(M);
  for(int i=0;i<M;i++)
    cin>>L.at(i)>>R.at(i);
  int maxL=L.at(0);
  int minR=R.at(0);
  for(int i=0;i<M;i++){
    if(maxL<=L.at(i))
      maxL=L.at(i);
    if(R.at(i)<=minR)
      minR=R.at(i);
  }
  if(minR<maxL)
    cout<<0<<endl;
  else
    cout<<minR-maxL+1<<endl;

return 0;
}

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

#define int long long int

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 arr[n];
map<int,int>m1;
for(int i=0;i<n-1;i++){
    cin>>arr[i];
    m1[arr[i]]++;

}
for(int i=1;i<=n;i++){
    cout<<m1[i]<<endl;
}

}

}





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

void solve() {
  string s;
  cin >> s;
  char* ptr = &s[0];
  for (int i = 0; i < s.length(); i++) {
    if (*ptr == '9') {
      printf("Yes\n");
      return;
    }
    ptr++;
  }
  printf("No\n");
}

int main() {
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    string s;
    ll k;
    cin >> s >> k;
    bool same = 1;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[0]) {
            same = 0;
            break;
        }
    }
    if (same) {
        cout << (ll)s.size() * k / 2 << endl;
        return;
    }

    if (s[0] == s[s.size() - 1]) {
        ll left = 0, right = 0;
        for (;s[left]==s[0];left++) {}
        for (;s[s.size() - 1 - right]==s[0];right++) {}
        ll ans = 0;
        ans += left / 2;
        ans += right / 2;
        ans += (k - 1) * (ll)((left + right) / 2);
        ll middle = 0;
        char before = s[left];
        ll cnt = 1;
        
        for (int i = left + 1; i <= s.size() - 1 - right; i++) {
            if (s[i] == before) cnt++;
            else {
                middle += cnt / 2;
                before = s[i];
                cnt = 1;
            }
        }

        cout << ans + k * middle + cnt / 2 * k << endl;
        return;
    }
    ll middle = 0;
    char before = s[0];
    ll cnt = 1;
    
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == before) cnt++;
        else {
            middle += cnt / 2;
            before = s[i];
            cnt = 1;
        }
    }

    cout << middle * k + cnt / 2 * k << endl;

}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int,int>
#define vi            vector<int>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;


void solve() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  
  vi p(a), q(b), r(c);
  rep(i, 0, a) cin >> p[i];
  rep(i, 0, b) cin >> q[i];
  rep(i, 0, c) cin >> r[i];
  sort(all(p));
  sort(all(q));
  sort(all(r));

  vi ba(x), bb(y);
  rep(i, 0, x) ba[i] = p[a - 1 - i];
  rep(i, 0, y) bb[i] = q[b - 1 - i];

  ll ans = 0;
  int p1 = x - 1, p2 = y - 1, p3 = c - 1;
  while (p1 >= 0 || p2 >= 0) {
    if (p3 >= 0) {
      pii mn = mp(1e9 + 1, 1e9 + 1);
      if (p1 >= 0)
        mn = min(mn, mp(ba[p1], 0));
      if (p2 >= 0)
        mn = min(mn, mp(bb[p2], 1));
      if (mn.fi < r[p3]) {
        if (mn.se) p2--;
        else p1--;
        ans += r[p3--];
      }
      else {
        if (p1 >= 0) ans += ba[p1--];
        if (p2 >= 0) ans += bb[p2--];
      }
    }
    else {
      if (p1 >= 0) ans += ba[p1--];
      if (p2 >= 0) ans += bb[p2--];
    }
  }
  
  cout << ans << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int d = b-a;
		int ra = (d-1)*d/2;
		System.out.println(ra-a);
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion

int main() {
    int n, k;
    cin >> n >> k;
    chmin(k, 50);
    vector<vector<int>> a(k + 1, vector<int>(n + 1));
    rep(i, n) cin >> a[0][i];
    rep(_k, k) {
        rep(i, n) {
            int l = max(0, i - a[_k][i]);
            int r = min(n, i + a[_k][i] + 1);
            a[_k + 1][l]++;
            a[_k + 1][r]--;
        }

        rep(i, n - 1) a[_k + 1][i + 1] += a[_k + 1][i];
    }
    rep(i, n) cout << a[k][i] << " ";
    cout << endl;
}

Measured memory_bytes: 43892
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    int a , c = 100;
    cin >> n;
    for ( ll i = 1 ; i * i <= n ; i++ ) {
        if ( n % i == 0 ) {
            a = (int)max( to_string(i).length() , to_string( n / i ).length() );
            c = min( c , a );
        }
    }
    cout << c;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n);
	vector<VE>x(n), y(n);
	rep(i, n) {
		cin >> a[i];
		x[i].resize(a[i]);
		y[i].resize(a[i]);
		rep(j, a[i]) {
			cin >> x[i][j] >> y[i][j]; x[i][j]--;
		}
	}
	int ans = 0;
	rep(bit, 1 << n) {
		vector<int>tmp(n);
		bool ok = true;
		int now = 0;
		rep(i, n) {
			if (bit & (1 << i)) {
				tmp[i] = true;
				now++;
			}
		}
		rep(i, n) {
			rep(j, a[i]) {
				if (tmp[i] && tmp[x[i][j]]!=y[i][j]) {
					ok = false;
				}
			}
		}
		if (ok) {
			chmax(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	long long k,a,b,x=1;
	cin>>k>>a>>b;
	if(b-a<=2){
		cout<<x+k<<endl;
		return 0;
	}
	k=k-a+1;
	x=a;
	cout<<x+(b-a)*(k/2)+(k%2)<<endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations
N = int(input())
S = set([input() for i8 in range(N)])
march = dict(zip("MARCH",[0,0,0,0,0]))

for i in S:
    if i[0] in march:
        march[i[0]] += 1

result = 0
for a,b,c in combinations(march.values(), 3):
    result += a*b*c
print(result)


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

int p[2][100000];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        p[i % 2][a]++;
    }

    int q[2][2][2];
    for (int j = 0; j < 2; j++) {
        int i0, i1, m0 = -1, m1 = -1;
        for (int i = 0; i < 100000; i++) {
            if (p[j][i] > m1) {
                if (p[j][i] > m0) {
                    m1 = m0;
                    i1 = i0;
                    m0 = p[j][i];
                    i0 = i;
                } else {
                    m1 = p[j][i];
                    i1 = i;
                }
            }
        }
        q[j][0][0] = m0;
        q[j][0][1] = i0;
        q[j][1][0] = m1;
        q[j][1][1] = i1;
    }

    int r;
    n /= 2;
    if (q[0][0][1] == q[1][0][1]) {
        int t0 = n - q[0][0][0] + n - q[1][1][0];
        int t1 = n - q[0][1][0] + n - q[1][0][0];
        r = min(t0, t1);
    } else {
        r = n - q[0][0][0] + n - q[1][0][0];
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int z = sc.nextInt();

			System.out.println(z + " " + x + " " + y);
		}

	}

}


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

int main(){
    string W,s;
    int j = 0;
    cin >> W;

    while(1){
        cin >> s; 
        if(s == "END_OF_TEXT"){
            break;
        }
        for(int i = 0; i < s.length(); i++){
            if(s[i] >= 'A' && s[i] <= 'Z'){
                s[i] = s[i] + 32;
            }
        }
        if(s == W){
            j += 1;
        }
    }
    cout << j << endl;
    return 0;
}


Measured memory_bytes: 3168
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume0_0029
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var dic = new Dictionary<string, int>(input.Length);

            var maxLen = input
                .Aggregate((s_max, s_next) => s_max.Length > s_next.Length ? s_max : s_next);

            input
                .All(s =>
                {
                    if (dic.ContainsKey(s)) dic[s]++;
                    else dic.Add(s, 1);
                    return true;
                });
            var maxFreq = dic
                .Aggregate((s_max, s_next) => s_max.Value > s_next.Value ? s_max : s_next)
                .Key;
            
            Console.WriteLine(maxFreq + " " + maxLen);
        }
    }
}

Measured memory_bytes: 9296
s = input()
x=0
listA = ["a","b","c","d","e","f","g","h","i","j","k",
         "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
  if s.count(listA[i])==0:
    print(listA[i])
    x=1
    break
if x==0:
  print("None")

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:00 2019

@author: Yamazaki Kenichi
"""

N,M = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**N):
    t = '{:010b}'.format(i)
    flg = True
    for j in range(M):
        tmp = 0
        for k in range(ks[j][0]):
            tmp += int(t[-ks[j][k+1]])
#        print(i,j,t,tmp,ans)
        if tmp%2 == p[j]:
            continue
        else:
            flg = False
            break
#    print(i,j,t,tmp,ans,flg)
    if flg:
        ans += 1

            
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  string s;
  while(cin >> s){
    int n = s.size() + 1;
    vector<int> a(n+2, -1);

    a[1] = 0;
    
    FORE(i,2,n){
      if(s[i-2] == '>') a[i] = a[i-1] - 1;
      else a[i] = a[i-1] + 1;
    }

    int d = *min_element(a.begin()+1, a.begin()+1+n);

    FORE(i,1,n){
      a[i] -= d;
    }

    vector<int> ord(n+2);
    iota(ALL(ord), 0);

    sort(ALL(ord),[&](int i, int j){return a[i] < a[j];});
    
    FORE(i,2,n+1){
      int k = ord[i];
      if(a[k] < a[k-1] and a[k] < a[k+1]){
        a[k] = 0;
      }else if(a[k] > a[k-1] and a[k] > a[k+1]){
        a[k] = max(a[k-1], a[k+1]) + 1;
      }else{
        a[k] = min(a[k-1], a[k+1]) + 1;
      }
    }

    

    dump(a);

    LLI ans = 0;
    FORE(i,1,n){
      ans += a[i];
    }
    
    cout << ans << endl;

    
  }

  return 0;
}


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

using ll = unsigned long long;

int N, M, head[100002], size[100002];

int find(int f) {
  return ((f == head[f]) ? f : (head[f] = find(head[f])));
}

ll merge(int u, int v) {
  int ru = find(u);
  int rv = find(v);
  if (ru != rv) {
    head[ru] = rv;
    ll ret = size[rv] * size[ru];
    size[rv] += size[ru];
    return ret;
  }
  return (ll) 0;
}

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

  for (int i = 0; i <= 100001; ++i) {
    head[i] = i;
    size[i] = 1;
  }

  cin >> N >> M;
  vector<pair<int, int>> V(M);
  for (int i = M - 1; i >= 0; --i) {
    cin >> V[i].first >> V[i].second;
  }

  vector<ll> res(M);
  ll inconvenience = (((ll) N) * ((ll) N - 1)) >> 1;
  for (int i = 0; i < M; ++i) {
    res[i] = inconvenience;
    int u, v;
    tie(u, v) = V[i];
    inconvenience -= merge(u, v);
  }

  for (int i = M - 1; i >= 0; --i) {
    cout << res[i] << '\n';
  }
}


Measured memory_bytes: 3712
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    vint ss(26),ts(26);
    int ls = s.length();
    int lt = t.length();
    REP(i,ls){
        ss[(s[i]-'a')]+=1;
    }
    REP(i,lt){
        ts[(t[i]-'a')]+=1;
    }
    REP(i,26){
        if(ts[i]>0&&ss[i]==0){
            cout <<"-1\n";
            return 0;
        }
    }
    vvint sx(26);
    REP(i,ls){
        sx[(s[i]-'a')].pb(i);
    }
    REP(i,26){
        sort(ALL(sx[i]));
    }
    ll ans = 0;
    int now = -1;
    REP(i,lt){
        //cout << i << endl;
        char c = t[i];
        ll ok = (ll)(sx[(c-'a')].size());
        ll ng = -1;
        while(abs(ok-ng)>1){
            ll mid = (ok+ng)/2;
            if(sx[(c-'a')][mid]>now){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        if(ok==(int)(sx[(c-'a')].size())){
            ans++;
            now=-1;
            ng=-1;
            while(abs(ok-ng)>1){
                ll mid = (ok+ng)/2;
                if(sx[(c-'a')][mid]>now){
                    ok = mid;
                }else{
                    ng = mid;
                }
            }
            now=sx[(c-'a')][ok];
        }else{
            now=sx[(c-'a')][ok];
        }
        //cout <<ans << " "<< c << " " << now << endl;
    }
    cout << (ll)ans*(ll)ls+(ll)now+1 << endl;;
    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
int main()
{
    unsigned long long int n;
    scanf("%lld", &n);
    unsigned long long int ans;
    if (n == 1){
        ans = 0;
    }else {
        ans = (n*(n-1)) / 2;
    }

    printf("%lld\n", ans);
    return 0;

}

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

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}


int main(){
    ll L, R; cin >> L >> R;
    ll dp[61][2][2][2];
    memset(dp,0,sizeof(dp));
    dp[0][1][1][0] = 1;
    REP(i,60) REP(j,2) REP(k,2) REP(l,2) {
        ll nl = (L>>(59-i))&1;
        ll nr = (R>>(59-i))&1;
        REP(a,2) REP(b,2) {
            if(j==1 && nl==1 && a==0) continue;
            if(k==1 && nr==0 && b==1) continue;
            if(b<a) continue;
            if(l==0 && a!=b) continue;
            int ni = i+1;
            int nj = j && (nl==a);
            int nk = k && (nr==b);
            int nl = l || (a==1 && b==1);
            dp[ni][nj][nk][nl]
                = add(dp[ni][nj][nk][nl], dp[i][j][k][l]);
        }
    }
    ll ans = 0;
    REP(j,2) REP(k,2) ans = add(ans, dp[60][j][k][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t,m,p,x;
    cin >> n;
    vector<int> time;
    for(int i=0;i<n;i++){
        cin >> t;
        time.push_back(t);
    }
    cin >> m;
    vector<pair<int,int>> drink;
    for(int i=0;i<m;i++){
        cin >> p >> x;
        drink.push_back(make_pair(p,x));
    }
    int ans=0;
    for(int i=0;i<drink.size();i++){
        for(int j=0;j<time.size();j++){
            if(j==drink[i].first-1){
                ans+=drink[i].second;
            }
            else ans+=time[j];
        }
        cout << ans << endl;
        ans=0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[11], t[11];

  scanf("%s%s", s, t);

  if (strncmp(s, t, strlen(s)) == 0 && strlen(t) == strlen(s) + 1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}




Measured memory_bytes: 1688
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=200005;
const double EPS=1e-6;

char s[SIZE];

int main(){
	/*main function start*/
	scanf("%s",s);
	int n=strlen(s);
	long long ans=0;
	long long tmp=0;
	for(int i=0;i<n;i++) if(s[i]=='W'){
		tmp++;
	}
	for(int i=0;i<n;i++) if(s[i]=='B'){
		ans+=tmp;
	}
	else tmp--;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mod (int)(1e9+7)
#define int long long int
using namespace std;
int cnt=0;
int fun(int s,vector<int> &dp){
    if(s==0){
        return 1;
    }
    if(s<0)
        return 0;
    if(dp[s]!=-1){
        return dp[s];
    }
    int x=0;
    for(int i=3;i<=s;i++){
        x=(x%mod+fun(s-i,dp))%mod;
    }
    return dp[s]=x%mod;
}
signed main() {
   int s;
   cin>>s;
   vector<int> dp(s+1,-1);
   
   cout<<(fun(s,dp))%mod;
  
   cout<<endl;
  
   
  
}

Measured memory_bytes: 3648
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return T(0);}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define RM_REF_T(x) remove_reference<decltype(x)>::type
#define CHECK(a,b) static_assert(std::is_same<RM_REF_T(a), RM_REF_T(b)>::value, "REP diff types");

#define REPP__(d,c,t,f,m,n) CHECK(m,n) for(auto d; ((f) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REP__(d,c,t,f,m,n) CHECK(m,n) for(auto d; c; t)
#define REPP_(...) REPP__(__VA_ARGS__)
#define REP_(...) REP__(__VA_ARGS__)

#define FOR4(i,m,n,s) i=(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s),i==(m),m,n
#define FOR3(i,m,n) i=(m),i<(n),++i,i==(m),m,n
#define FOR2(i,n) i=begin(n),i!=end(n),++i,i==begin(n),n,n
#define FOR(...) GET_MACRO(__VA_ARGS__, FOR4, FOR3, FOR2)(__VA_ARGS__)

#define REPP(...) REPP_(FOR(__VA_ARGS__))
#define REP(...) REP_(FOR(__VA_ARGS__))

template<class T> inline void _read(T &x) {cin >> x;}
inline void _read(size_t &x) {scanf("%zu", &x);}
inline void _read(int &x) {scanf("%d", &x);}
inline void _read(LL &x) {scanf("%lld", &x);}
inline void _read(ULL &x) {scanf("%llu", &x);}
inline void _read(double &x) {scanf("%lf", &x);}
inline void _read(char &x) {scanf(" %c", &x);}
inline void _read(char *x) {scanf("%s", x);}

inline void read() {}
template<class T, class... U> inline void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> inline void _print(const T &x) {cout << x;}
inline void _print(const size_t &x) {printf("%zu", x);}
inline void _print(const int &x) {printf("%d", x);}
inline void _print(const LL &x) {printf("%lld", x);}
inline void _print(const ULL &x) {printf("%llu", x);}
inline void _print(const double &x) {printf("%.16lf", x);}
inline void _print(const char &x) {putchar(x);}
inline void _print(const char *x) {printf("%s", x);}
inline void _print(const string &x) {printf("%s", x.c_str());}

inline void print() {putchar('\n');}
template<class T, class... U> inline void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

int main()
{
    LL N, A, B;
    read(N, A, B);
    if((A & 1) == (B & 1)) {
        print((B - A) / 2);
    } else {
        LL a = (A - 1) + 1 + ((B - 1) - A) / 2;
        LL b = (N - B) + 1 + (B - (A + 1)) / 2;
        print(min(a, b));
    }
    return 0;
}


Measured memory_bytes: 256