akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
#define ll long long
#define inf 1000000001
using namespace std;
#define N 300005
#define mod 998244353
int n,a,b,fac[N],inv[N],ans;ll K;
int ksm(int x,int p){
    int ret=1;
    for (;p;p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
    return ret;
}
int getinv(int x){
    return ksm(x,mod-2);
}
void init(int n){
    fac[0]=1;rep (i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
    inv[n]=getinv(fac[n]);per (i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
    return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
    scanf("%d%d%d%lld",&n,&a,&b,&K);
    init(n);
    rep (i,0,n){
        ll j=K-(ll)a*i;
        if (j<0||j%b) continue;
        j/=b;
        if (j<=n) ans=(ans+(ll)C(n,i)*C(n,j)%mod)%mod;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    int a, b, c; cin >> a >> b >> c;

    int k; cin >> k;
    int cnt = 0;
    while (b <= a) {
        b = 2 * b;
        cnt++;
    }
    while (c <= b) {
        c = 2 * c;
        cnt++;
    }

    if (cnt <= k) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3616
def main():
    a, b, c, d = map(int, input().split())
    ans_a = a * c
    ans_b = a * d
    ans_c = b * c
    ans_d = b * d
    if ans_a <= ans_b:
        if ans_c <= ans_b:
            if ans_d <= ans_b:
                print(ans_b)
                return 0
            elif ans_b <= ans_d:
                print(ans_d)
                return 0
        elif ans_b <= ans_c:
            if ans_d <= ans_c:
                print(ans_c)
                return 0
            elif ans_c <= ans_d:
                print(ans_d)
                return 0
        
    if ans_b <= ans_a:
        if ans_c <= ans_a:
            if ans_d <= ans_a:
                print(ans_a)
                return 0
            elif ans_a <= ans_d:
                print(ans_d)
                return 0
        elif ans_a <= ans_c:
            if ans_d <= ans_c:
                print(ans_c)
                return 0
            elif ans_c <= ans_d:    
                print(ans_d)
                return 0
main()

Measured memory_bytes: 9240
#include<cstdio>
#include<set>
#include<cstring>
#include<algorithm>
using namespace std;
typedef pair<int,int> Point;
set<Point>S[310];
int n,m,a[310][310],b[310][310],cnts[310],ans=2147483647;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			scanf("%d",&a[i][j]);
			b[i][a[i][j]]=j;
		}
	}
	int l=1,r=n;
	while(l<r){
		int mid=(l+r>>1);
		for(int j=1;j<=n;++j){
			S[j].clear();
			for(int k=1;k<=m;++k){
				S[j].insert(make_pair(b[j][k],k));
			}
		}
		for(int j=1;j<=m;++j){
			memset(cnts,0,sizeof(cnts));
			for(int k=1;k<=n;++k){
				++cnts[(*S[k].begin()).second];
			}
			int maxx=-1,whi;
			for(int k=1;k<=m;++k){
				if(cnts[k]>maxx){
					maxx=cnts[k];
					whi=k;
				}
			}
			if(maxx<=mid){
				r=mid;
				goto OUT;
			}
			for(int k=1;k<=n;++k){
				S[k].erase(make_pair(b[k][whi],whi));
			}
		}
		l=mid+1;
		OUT:;
	}
	printf("%d\n",l);
//	for(int i=1;i<=m;++i){
//		for(int j=1;j<=n;++j){
//			S[j].clear();
//			S[j].insert(make_pair(b[j][i],i));
//		}
//		for(int j=1;j<=m;++j) if(j!=i){
//			memset(cnts,0,sizeof(cnts));
//			for(int k=1;k<=n;++k){
//				S[k].insert(make_pair(b[k][j],j));
//				++cnts[(*S[k].begin()).second];
//			}
//			int maxx=-1,whi;
//			for(int k=1;k<=m;++k){
//				if(cnts[k]>maxx){
//					maxx=cnts[k];
//					whi=k;
//				}
//				else if(cnts[k]==maxx && k==i){
//					whi=k;
//				}
//			}
//			if(whi!=i){
//				for(int k=1;k<=n;++k){
//					S[k].erase(make_pair(b[k][j],j));
//				}
//			}
//			else{
//				ans=min(ans,maxx);
//			}
//		}
//	}
//	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>

using namespace std;

double cross_product(double ax, double ay, double bx, double by) {
    return ax * by - ay * bx;
}

int main() {
    double x1, y1, x2, y2, x3, y3, xp, yp;

    while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
        double s1, s2, s3;

        s1 = cross_product(x2 - x1, y2 - y1, xp - x1, yp - y1);
        s2 = cross_product(x3 - x2, y3 - y2, xp - x2, yp - y2);
        s3 = cross_product(x1 - x3, y1 - y3, xp - x3, yp - y3);

        if ((s1 > 0 && s2 > 0 && s3 > 0) || (s1 < 0 && s2 < 0 && s3 < 0)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1216
#include<iostream>
#include<stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.length();++i) {
		if (S[i] == '+')ans++;
		else ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;

int a[100001];
int b[100001];
int n, x;

char swtch(char c){
  return c == '0' ? '1' : '0';
}

int main() {
  int a[3];
  rep(i, 3)

    cin >> a[i];
  sort(a,a+3);
  string b =(to_string(a[2]) + to_string(a[1]));
  cout << a[0] + stoi(b) << endl;

}



Measured memory_bytes: 256
N,M=map(int,input().split())

ansAC=0
ansP=0

n=[0]*N
AC=[0]*N

for i in range(M):
    p,s =map(str,input().split())
    p=int(p)-1
    if AC[p]==1:continue
    if s=="AC":
        ansP+=n[p]
        ansAC+=1
        AC[p]=1
    else:
        n[p]+=1

print(ansAC,ansP)


Measured memory_bytes: 4596
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	if (A <= 5)
	{
		cout << 0;
	}
	else if (A <= 12)
	{
		cout << B / 2;
	}
	else
	{
		cout << B;
	}

	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n,c,k;
    cin>>n>>c>>k;
    int t[n];
    for(int i=0;i<n;i++)
    {
        cin>>t[i];
    }
    sort(t,t+n);
    int ans = 0;
    for(int i=0;i<n;)
    {
        int j =i;
        int temp = 0;
        while((t[i]+k)>=t[j]&&temp<c)
        {
            j++;
            temp++;
            if(j==n)
                break;
        }
        ans++;
        i = j;

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

Measured memory_bytes: 640
s = list(input())

for i in range(1,len(s)):
    len_s = len(s) - 2 * i
    for j in range(1,len(s)):
        left = s[0:j]
        right = s[j:len_s]
        if left == right:
            ans = len(left + right)
            print(ans)
            exit()
        elif len(left) > len(right):
            break

Measured memory_bytes: 3060
N = int(input())

def func(cur, use, counter):
	#今の値がNより大きければ処理をやめる
	if cur > N:
		return
	#現在の値が7, 5, 3を一つ以上使っていればカウンタを1増やす
	if use == 0b111:
		counter.append(1)

	#7を追加する
	func(cur*10+7, use | 0b001, counter)
	#5を追加する
	func(cur*10+5, use | 0b010, counter)
	#3を追加する
	func(cur*10+3, use | 0b100, counter)

res = []
func(0, 0, res)
print(sum(res))

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

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

const int MAXN = 1e5 + 5;

int N, M;
int a[MAXN];
pii p[MAXN];
vector <int> E[MAXN];
bool bio[MAXN], used[MAXN];
int opt, cnt;
ll sol;

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)	
		scanf("%d", a + i);
	for (int i = 0; i < M; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
}

void dfs(int x) {
	bio[x] = true;
	if (a[x] < a[opt])
		opt = x;
	for (auto it : E[x])
		if (!bio[it])
			dfs(it);
}

void add(int x) {
	sol += a[x];
	used[x] = true;
	cnt++;
}

void solve() {
	a[N] = 2e9;
	int comp = -1;
	for (int i = 0; i < N; i++) {
		if (bio[i])
			continue;
		opt = N;
		dfs(i);
		add(opt);
		comp++;
	}
	
	if (!comp) {
		puts("0");
		return;
	}
	
	for (int i = 0; i < N; i++)
		p[i] = {a[i], i};
		
	sort(p, p + N);
	
	for (int i = 0; i < N && cnt < 2 * comp; i++)
		if (!used[p[i].second])
			add(p[i].second);
	
	if (cnt < 2 * comp)
		puts("Impossible");
	else
		printf("%lld\n", sol);
}

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

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

int main(void) {
  int A, B;
  cin >> A >> B;
  for (int i = 13; i < 1300; i++) {
    if (i * 8/100 == A && i * 1/10 == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

int main() {
	int m,f,r;
	for(;;){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)break;
		if(m==-1||f==-1)cout<<"F"<<endl;
		else{
		if(m+f>=80)cout <<"A"<<endl;
		if(m+f>=65&&m+f<80)cout <<"B"<<endl;
		if(m+f>=50&&m+f<65)cout <<"C"<<endl;
		if(m+f>=30&&m+f<50){
			if(r>=50)cout<<"C"<<endl;
			else cout<<"D"<<endl;
		}
		if(m+f<30)cout<<"F"<<endl;
		}
		
	}
	return 0;
}

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

int main(){
	string s;
  	int n,minv=753;
	cin>>s;
  	for(int i=0;i<s.size()-2;++i){
      n=(int)(s[i]-'0')*100+(int)(s[i+1]-'0')*10+(int)(s[i+2]-'0');
      n=753-n;
      if(n<0)n=-n;
      minv=min(minv,n);
    }cout<<minv<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int V;
int cost[110][110];
int mincost[110];
bool vis[110];
const int INF=1e9;

int prim(){
	for(int i=0;i<V;i++){
		mincost[i]=INF;
		vis[i]=false;
	}

	mincost[0]=0;
	int res=0;

    while(true){
        int v=-1;
        for(int u=0;u<V;u++){
            if(!vis[u] && (v==-1 || mincost[u]<mincost[v])) v=u;
        }

        if(v==-1) break;
        vis[v]=true;
        res+=mincost[v];

        for(int u=0;u<V;u++){
            mincost[u]=min(mincost[u],cost[v][u]);
        }
    }
    return res;
}

int main(void){
	          int i,j;

	          cin >> V;
	          for(i=0;i<V;i++){
	        	  for(j=0;j<V;j++){
	        		  int a;
	        		  cin >> a;
	        		  if(a==-1) cost[i][j]=INF;
	        		  else cost[i][j]=a;
	        	  }
	          }

	          cout << prim() << endl;

	          return 0;
}

Measured memory_bytes: 3100
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 10007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=200010;
int n,k;
string a,b,c;
map<string,int>H;
int main()
{
	//freopen("1.in","r",stdin);
	cin>>a>>b;
	cin>>H[a]>>H[b];
	cin>>c;
	--H[c];
	cout<<H[a]<<' '<<H[b]<<endl;
	return 0;
}


Measured memory_bytes: 256
S = list(input())
K = int(input())
H=S[0]

flag=0
if(S[0]==S[len(S)-1]):
    flag=1
count=0
if(flag==0):
    for i in range(len(S)-1):
        if(S[i]==S[i+1]):
            S[i+1]="#"
            count+=1        
    print(count*K)
    exit()

flag2=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        flag2=1
if(flag2==0):
    print((len(S)*K)//2)
    exit()

S1=S[:]
S2=S[:]+S[:]

count1=0
for i in range(len(S1)-1):
    if(S1[i]==S1[i+1]):
        S1[i+1]="#"
        count1+=1
count2=0
for i in range(len(S2)-1):
    if(S2[i]==S2[i+1]):
        S2[i+1]="#"
        count2+=1

print(count1+(K-1)*(count2-count1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main() {
    string s;cin>>s;
    if(s=="BBB"||s=="AAA")out("No");
    else out("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

void solve() {
    set<int> mp;
    int n;cin>>n;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        if(mp.count(x)) mp.erase(x);
        else mp.insert(x);
    }
    cout<<mp.size();
}

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

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}
 

void solve(){
    
    ll n,d;
    cin >> n >> d;
    ll ans=0;
    while(n--){
        ll x,y;
        cin >> x >> y;
        ll A = x*x + y*y;
        ll B = d*d;
        if(A <= B){
            ans++;
        }
    }
    cout << ans;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3652
# coding: utf-8
n = int(input())
m = list(map(int, input().split()))
y = list(map(int, input().split()))

cnt = 0
for i in range(n):
    if m[i] >= y[i]:
        cnt += y[i]
        continue
    else:
        if m[i] + m[i + 1] <= y[i]:
            cnt += m[i] + m[i + 1]
            m [i + 1] = 0
        else:
            m[i + 1] -= y[i] - m[i]
            cnt += y[i]

print(cnt)


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

#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug4(a,b,c,d) cout<<a<<" "<< b <<" "<<c<<" "<<d<<"\n";

ll mod = 1000000007;

using namespace std;

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

	 int n,h,w;
	 cin>>n>>h>>w;
	 int l,b;
	 int count =0;
	 for (int i = 0; i < n; ++i)
	 {
	 	cin>>l>>b;

	 	int temp1 = l/h;
	 	int temp2 = b/w;
	 	count += min(temp1,temp2);

	 }	

	 cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, s, n) for(int i = s; i < n; i++)
using namespace std;
typedef long long ll;

int main(void) {
    ll l, r;
    cin >> l >> r;

    r = min(r, l+2019);
    ll mini = 1e9;
    repp(i, l, r) {
        repp(j, i+1, r+1) {
            mini = min(mini, (ll)i * j % 2019);
        }
    }
    cout << mini << endl;
}



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

int main() {
    int h, w; cin >> h >> w;
    vector<string> a(h);
    vector<string> ans(h+2);
    for(int i = 0; i < h; i++) cin >> a[i];
    for(int i = 0; i < h+2; i++) {
        for(int j = 0; j < w+2; j++) {
            if(i == 0 || j == 0 || i == h+1 || j == w+1) cout << '#';
            else cout << a[i-1][j-1];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
A,B,C,D=input()

if int(A)+int(B)+int(C)+int(D) == 7:
	ans=A+'+'+B+'+'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)+int(C)-int(D) == 7:
	ans=A+'+'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)+int(B)-int(C)+int(D) == 7:
	ans=A+'+'+B+'-'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)-int(C)-int(D) == 7:
	ans=A+'+'+B+'-'+C+'-'+D+'=7'
	print(ans)

elif int(A)-int(B)+int(C)+int(D) == 7:
	ans=A+'-'+B+'+'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)+int(C)-int(D) == 7:
	ans=A+'-'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)+int(D) == 7:
	ans=A+'-'+B+'-'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)-int(D) == 7:
	ans=A+'-'+B+'-'+C+'-'+D+'=7'
	print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[100000] = {};
	
	int ans = 0;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) {
			count++;
		}else{
			count++;
			if (count % 2 == 0) {
				count = 0;
			}
			else {
				ans++;
				count = 0;
			}
		}
		
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using pint = pair<int, int>;
using pll = pair<ll,ll>;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,h;
    cin >> n >> h;
    vector<int>b(n+1,0);
    int cut_max=0,a;
    REP(i,n){
        cin >> a >> b[i];
        cut_max = max(a,cut_max);
    }
    sort(b.begin(),b.end(),greater<>());
    int index=0,count=0;
    while(h>0){
        if(cut_max<b[index]){
            h-=b[index];
            index++;
            count++;
        }
        else{
            count += (h+cut_max-1)/cut_max;
            break;
        }
    }
    COUT(count);
    return 0;
} 

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        int count = 0;
        String[] sar = s.split("");
        for (int i = 1; i < s.length(); i++) {
            if (sar[i-1].equals(sar[i])) {
                count++;
                if (sar[i].equals("0")) {
                    sar[i] = "1";
                } else {
                    sar[i] = "0";
                }
            }
        }
        System.out.println(count);
    }

}


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


int main()
{
	const int MOD=1e9+7;
	int N;
	cin>>N;
	ll ans=1;
	Rep(i,1,N+1)
	{
		(ans*=i)%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static List<String> list = new ArrayList<String>();
    static int[] kazuSet = {1000,100,10,1};

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	list.add("m");
	list.add("c");
	list.add("x");
	list.add("i");

	int kaisu = sc.nextInt();//vZw¦Ìñ

	while(kaisu!=0){
	    String mcxi0 = sc.next();
	    String mcxi1 = sc.next();

	    System.out.println(solve(mcxi0,mcxi1));

	    kaisu--;
	}
    }

    public static String solve(String mcxi0, String mcxi1){

	int sum = toInt(mcxi0) + toInt(mcxi1);

	String ans = toString(sum);

	return ans;
    }

    //MCXI¶ñðMCXIlÖ
    public static int toInt(String mcxi){
	int sum = 0;
	int kazu = 1;
	for(int i=0; i<mcxi.length(); i++){
	    if(!list.contains(mcxi.substring(i,i+1))){//iÔÚªÈç
		kazu = Integer.parseInt(mcxi.substring(i,i+1));
	    }
	    else{//iÔÚª¶Èç
		sum += kazu * kazuSet[list.indexOf(mcxi.substring(i,i+1))];
		kazu = 1;
	    }
	}
	return sum;
    }

    //MCXIlðMCXI¶ñÖ
    public static String toString(int sum){
	String mxci = "";
	int[] suzi = new int[4];
	//1000A100A10A1ðÔÉø¯é¾¯ø«ÂÂA½ðø¢½©ðL^·é
	for(int i=0;i<kazuSet.length;i++){
	    if(sum-kazuSet[i]>=0){
		sum = sum-kazuSet[i];
		suzi[i]++;
		i--;
	    }
	}
	//ãÌL^É]ÁÄMCXI¶ñðì¬B0Æ1Í\¦µÈ¢B
	for(int i=0; i<kazuSet.length; i++){
	    if(suzi[i]==1){
		mxci += list.get(i);
	    }else if(suzi[i]!=0){
		mxci += suzi[i] + list.get(i);
	    }
	}
	return mxci;
    }
}

Measured memory_bytes: 13000
import sys
import math
import fractions
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = defaultdict(lambda: 0)
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct[b] += 1
        b = b + 1
    if n > 1:
        fct[n] += 1
    return fct


def divmod(x, mod=10**9 + 7):
    return pow(x, mod - 2, mod)


def solve():

    N = int(input())
    A = list(map(int, input().split()))
    B = [[1] for _ in range(N)]

    fac_list = defaultdict(lambda: 0)
    for i in range(N):
        d = factorize(A[i])
        for k, v in d.items():
            fac_list[k] = max(fac_list[k], v)

    lcm = 1
    for k, v in fac_list.items():
        lcm *= (k**v)
        lcm %= mod

    ans = 0
    for i in range(N):
        ans += divmod(A[i])
        ans %= mod

    ans *= lcm
    ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7348
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

	vector<pair<long long, long long> > s(N);
	for(auto & x: s) cin >> x.first >> x.second;

	sort(s.begin(), s.end());
	long long out = 0;
	for(int i = 0; M > 0; i++) {
		out += s[i].first * min(s[i].second , M);
		M -= min(s[i].second, M);
	}

	cout << out << endl;
}


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

int isPrime(int num){
    if(num == 2) return 1;
    if(num == 3) return 1;
    if(num == 4) return 0;
    if(num == 5) return 1;
    
    for (int i = 2; i*i <= num; i++) {
        if (num % i == 0) {
            return 0;
        }
    }
    return 1;
}


int main(){
    
    int input, div = 2;
    
    cin >> input;
    
    printf("%d:", input);
    
    if (isPrime(input)) {
        printf(" %d\n", input);
        return 0;
    }
    
    while (input != div) {
        if (input % div == 0) {
            input /= div;
            printf(" %d", div);
        }else{
            div++;
        }
    }
    printf(" %d\n", div);
    
    return 0;
}

Measured memory_bytes: 1148
// 条件を満たす最大を全てソート
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
int main()
{
	long x, y, z, k, l;
	std::vector<long> a, b, c;
	std::cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
	{
		std::cin >> l;
		a.push_back(l);
	}
	for (int i = 0; i < y; i++)
	{
		std::cin >> l;
		b.push_back(l);
	}
	for (int i = 0; i < z; i++)
	{
		std::cin >> l;
		c.push_back(l);
	}
	std::sort(a.begin(), a.end(), std::greater<long>());
	std::sort(b.begin(), b.end(), std::greater<long>());
	std::sort(c.begin(), c.end(), std::greater<long>());
	std::vector<long> buf;
	for (unsigned int i = 1; i <= a.size(); i++)
	{
		for (unsigned int j = 1; j <= b.size(); j++)
		{
			for (unsigned int h = 1; h <= c.size(); h++)
			{
				if (i * j * h <= k)
				{
					buf.push_back(a[i - 1] + b[j - 1] + c[h - 1]);
				}
			}
		}
	}
	std::sort(buf.begin(), buf.end(), std::greater<long>());
	for (unsigned int i = 0; i < k; i++)
	{
		std::cout << buf[i] << "\n";
	}
	return 0;
}



Measured memory_bytes: 1412
/* author   : mpily :-()
title : Competing.cpp
time :Sun Mar 22 15:02:46 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int ans = (N*(N-1))/2 + (M*(M-1))/2;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long gcd(long long x, long long y){
	if(y == 0) return x;
	return gcd(y, x % y);
}

long long lcm(long long x, long long y){
	return (x / gcd(x, y)) * y;
}

int main(){
	long long n, ans = 1;
	cin >> n;
	for(int i = 0; i < n; i++){
		long long a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[200005], n, m;

int main(){
	int i, j, k=0;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i];
		k ^= a[i];
	}

	for(i=1;i<=n;i++){
		a[i] ^= k;
		cout << a[i] << ' ';
	}
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	ll x;
	cin >> x;

	rep(ai, 10000) {
		ll aa = (ll)pow(ai, 5);
		rep(bi, 10000) {
			ll bbi = (ll)pow(bi, 5);
			if (aa - x == bbi) {
				cout << ai << " " << bi;
				return 0;
			}
			if (aa - x == -bbi) {
				cout << ai << " " << -bi;
				return 0;
			}
		}

	}
}


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

main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<P> p(m);
  rep(i,m){
    int b, c;
    cin >> b >> c;
    p[i] = make_pair(c,b);
  }
  sort(p.begin(),p.end());
  rep(i,n){
    if(a[i] < p[p.size()-1].first){
      a[i]=p[p.size()-1].first;
      p[p.size()-1].second--;
      if(p[p.size()-1].second==0)p.pop_back();
    }
  }
  //answer
  ll ans=0;
  rep(i,n){
    ans+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5556
import sys
n = int(input())
if n%2 == 1:
    print(0)
    sys.exit()
else:
    cur_two, cur_ten = 2, 10
    num_two, num_ten = 0, 0
    while cur_two <= n:
        num_two += n//cur_two
        cur_two *= 2
    while cur_ten <= n:
        num_ten += n//cur_ten
        cur_ten *= 5
    print(min(num_two, num_ten))

Measured memory_bytes: 3060
/*input
35897 932
*/
#include <bits/stdc++.h>
using namespace std;
long long a[1000005],n,k,ans;

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		++a[i%k];
	}
	for(int i=0;i<k;++i){
		int x = i;
		int y = (k-i)%k;
		int z = i;
		if(i*2%k==0){
			ans += a[x]*a[y]*a[z];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
N=int(input())
alp=["a","b","c","d","e","f","g","h","i","j"]
alp=alp[:N]
ans=[]
def dfs(now):
    
    if len(now)==N:
        ans.append(now)
        return
    for i,s in enumerate(alp):
        if len(set(now))>=i:
            next_s=now+s
            dfs(next_s)
dfs("a")
ans=sorted(ans)
for a in ans:
    print(a)


Measured memory_bytes: 12684
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll a, b, k;
	map<ll, ll> memo;
	cin >> a >> b >> k;
	if (b - a - 1 < k) {
		rep(i, a, b+1)cout << i << endl;
		system("pause");
		return 0;
	}

	rep(i, a, a + k)memo[i] = 1;
	rep(i, b - k+1, b+1)memo[i] = 1;
	for (auto itr : memo) {
		if (itr.second == 1)cout << itr.first << endl;
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1000

main(){
    int n, m, P[MAX], sum;
    while(1){
	cin >> n >> m;
	if ( n == 0 && m == 0 ) break;
	sum = 0;
	for ( int i = 0; i < n; i++ ) {
	    cin >> P[i];
	    sum += P[i];
	}
	sort(P, P+n, greater<int>());
	for ( int i = m-1; i < n; i += m ) sum -= P[i];
	cout << sum << endl;
    }
    
}

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

int main() {
	int s, k;
	long count;
	cin >> k >> s;
	for (int a=0; a<=k; a++) {
		for (int b=0; b<=k; b++) {
			if (s-a-b >= 0 && s-a-b <= k) {
				count++;
			}
		}
	}
	cout << count << endl;
}

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

int main() {
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int ans = 0;
  ans += min(k,a);
  k -= min(k,a);
  if(k > 0) {
    k -= min(k,b);
  }

  if(k > 0) ans -= k;

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
bool visprime[10000000];
vector<ll>prime;
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime.pb(i);}}


bool vis[100000+10];
int main()
{

  sieve();
  ll x;
  cin>>x;

  ll it=lower_bound(prime.begin(),prime.end(),x)-prime.begin();
 // cout<<it<<endl;
  cout<<prime[it]<<endl;


}

















Measured memory_bytes: 2424
//@Author: wxyww
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
#define pi pair<double,double>
const int N = 110;
ll read() {
	ll x = 0,f = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
	while(c >= '0' && c <= '9') {x = x * 10 + c - '0',c = getchar();}
	return x * f;
}
pi a[N];
bool cmp(const pi &A,const pi &B) {
	return atan2(A.second , A.first) < atan2(B.second , B.first);
}
int main() {
	int n = read();
	for(int i = 0;i < n;++i) a[i].first = read(),a[i].second = read();
	sort(a,a + n,cmp);
	double ans = 0;
	for(int i = 0;i < n;++i) {
		double X = a[i].first,Y = a[i].second;
		ans = max(ans,X * X + Y * Y);
		for(int j = (i + 1) % n;j != i;j = (j + 1) % n) {
			X += a[j].first,Y += a[j].second;
			ans = max(ans,X * X + Y * Y);
		}
	}
	printf("%.10lf",sqrt(ans));
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX 100010
#define MOD 1000000007
int n,A[MAX];

bool check() {
  map<int,int> counter;
  rep(i,n) ++counter[A[i]];
  if( ( n & 1 ) && counter[0] != 1 ) return false;
  for(auto v : counter) {
    if( v.first == 0 ) continue;
    if( v.second != 2 ) return false;
  }
  return true;
}

int main() {
  cin >> n;
  rep(i,n) cin >> A[i];
  if( !check() ) puts("0");
  else {
    if( n & 1 ) --n;
    n /= 2;
    long long answer = 1;
    rep(i,n) {
      answer *= 2LL;
      answer %= MOD;
    }
    cout << answer << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int n,l,r;
  int ans = 0;
  cin >> n;
  for(int i = 0; i < n ;i+=1){
    cin >> l >> r;
    ans = ans + r - l + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    S = input()
    days = len(S)
    win = S.count('o')
    possible_win = 15 - len(S)
    print('YES' if win + possible_win >= 8 else 'NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
i = -1
l = input()
iline = []
iline = input().split(" ")
ilinei = [int(a) for a in iline]
ilinei.reverse()
l = int(l) - 1
for i in range(l):
    print(str(ilinei[i]) + " ",end="")
i = i + 1
print(str(ilinei[i]))


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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 1; i < S.size(); i++){
        if(S[i - 1] != S[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const double pi = acos(-1.0);
template<class Type>
Type solve(Type res = Type()){
    ll A,B,H,M; cin >> A >> B >> H >> M;

    double T = H*60 + M;

    double ragA = 2*pi * (T/(12*60));
    double ragB = 2*pi * (M/60.0);

    double Ax = A*cos(ragA);
    double Ay = A*sin(ragA);

    double Bx = B*cos(ragB);
    double By = B*sin(ragB);

    res = sqrt((Ax-Bx)*(Ax-Bx) + (Ay-By)*(Ay-By));
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<double>() << endl;
    return 0;
}

Measured memory_bytes: 4076
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

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

  // ll n, w;
  // cin >> n >> w;
  // vector<ll> x(n), v(n);
  // for (int i = 0; i < n; ++i) {
  //   cin >> x[i] >> v[i];
  // }
  // vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
  // for (int i = 1; i <= n; ++i) {
  //   for (int j = 0; j <= w; ++j) {
  //     dp[i][j] = dp[i - 1][j];
  //     if (x[i - 1] <= j) {
  //       dp[i][j] = max(dp[i][j], dp[i - 1][j - x[i - 1]] + v[i - 1]);
  //     }
  //   }
  // }
  // cout << dp[n][w];


  int h,w;
  cin>>h>>w;
  vector<vector<bool>> grid(h, vector<bool>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char c;
      cin>>c;
      if (c == '.') {
        grid[i][j] = 1;
      }
    }
  }
  vector<vector<int>> dp(h, vector<int>(w));
  dp[0][0] = 1;
  for (int i = 1; i < w; ++i) {
    dp[0][i] = dp[0][i - 1] && grid[0][i];
  }
  for (int i = 1; i < h; ++i) {
     dp[i][0] = dp[i-1][0] && grid[i][0];
  }
  for (int i = 1; i < h; ++i){
    for (int j = 1; j < w; ++j) {
      dp[i][j] = grid[i][j] ? (dp[i - 1][j] + dp[i][j - 1] ) % ((int) 1e9 + 7): 0;
    }
  }
  cout << dp[h-1][w-1];
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

int st[100001];

int acs(const void *a, const void *b)
{
  return st[*(int*)a] - st[*(int*)b];
}

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

  int i;
  for (i = 0; i< n; i++)
    scanf("%d", &st[i]);

  int idx[100001];
  for (i = 0; i < n; i++)
    idx[i] = i;

  qsort(idx, n, sizeof(int), acs);
  for (i = 0; i< n; i++)
    printf("%d ", idx[i] + 1);
  printf("\n");
  return 0;
}


Measured memory_bytes: 1532
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<string.h>

using namespace std;

bool field[11][9][9];
bool field_initialize[11][9][9]={0};

int sp[3]={0,1,-1};

int k_move[2][12]={
    -1, 0, 1,-2,-2,-2,-1, 0, 1, 2, 2, 2,
    -2,-2,-2,-1, 0, 1, 2, 2, 2,-1, 0, 1
};



struct kaeru_xy{
    int x;
    int y;
    int now;
};

void set_field(int x, int y, int now){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(0<=x+sp[i]&&x+sp[i]<9&&0<=y+sp[j]&&y+sp[j]<9)field[now][x+sp[i]][y+sp[j]]=true;
        }
    }
}





int main(){
    
    
    
    
    int px,py;
    while(cin>>px>>py){
        if(px==0&&py==0)break;
        kaeru_xy kaeru;
        kaeru.x=px;
        kaeru.y=py;
        kaeru.now=0;
        queue<kaeru_xy> BFS;
        BFS.push(kaeru);
        
        
        
        memcpy(field, field_initialize, sizeof(bool)*81*11);
        int n;
        cin>>n;
        
        for(int i=0; i<n; i++){
            int tx,ty;
            cin>>tx>>ty;
            set_field(tx, ty, i);
            
            
        }
        int flag =0;
        while(!BFS.empty()){
            kaeru=BFS.front();
            if(kaeru.now==n){
                flag=1;
                break;
            }
            
            BFS.pop();
            for(int i=0; i<12; i++){
                if(0<=kaeru.x+k_move[0][i]&&kaeru.x+k_move[0][i]<9&&0<=kaeru.y+k_move[1][i]&&kaeru.y+k_move[1][i]<9){
                    if(field[kaeru.now%n][kaeru.x+k_move[0][i]][kaeru.y+k_move[1][i]]){
                        kaeru_xy next_k;
                        next_k.x=kaeru.x+k_move[0][i];
                        next_k.y=kaeru.y+k_move[1][i];
                        next_k.now=kaeru.now+1;
                        BFS.push(next_k);
                    }
                }
            }
        }
        if(flag==1)cout<<"OK"<<endl;
        else cout<<"NA"<<endl;
        
        
    }
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9 + 7;
ll N;
stack<ll> ans;
int main(void) {
	cin >> N;
	ll i = 2, cnt = 1;
	if (N == 0) { ct(0); return 0; }
	while (N != 0) {
		if (N % i != 0) {
			ans.push(1);
			if(cnt%2!=0)N -= i / 2;
			else N += i / 2;
		}
		else ans.push(0);

		cnt++;
		i *= 2;
	}
	while (!ans.empty()) {
		cout<<ans.top(); ans.pop();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int H, W, D;
	scanf("%d%d%d", &H, &W, &D);

	pair<int, int> pos[90000];
	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {
			int A;
			scanf("%d", &A);
			A--;
			pos[A].first = row;
			pos[A].second = col;
		}
	}

	int dist[90000];
	for (int i = 0; i < 90000; i++) {
		dist[i] = -1;
	}

	for (int i = 0; i < H * W; i++) {
		if (dist[i] > -1)
			continue;
		dist[i] = 0;
		for (int j = i + D; j < H * W; j += D) {
			dist[j] = dist[j - D] + abs(pos[j - D].first - pos[j].first) + abs(pos[j - D].second - pos[j].second);
		}
	}

	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		int L, R;
		scanf("%d%d", &L, &R);
		L--; R--;
		printf("%d\n", dist[R] - dist[L]);
	}

	return 0;
}


Measured memory_bytes: 2176