akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> box(n);
    set<ll> ans;
    for(int i = n - 1; i >= 0; --i){
        ll num = i + 1;
        ll sum = 0;
        for(int j = num + num; j <= n; j += num){
            sum += box[j - 1];
        }
        if(sum % 2 != a[i]){
            box[i] = 1;
            ans.insert(i + 1);
        }
    }
    print(ans.size());
    if(ans.size()){
        for(auto a : ans){
            print(a);
        }
    }

}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for(int i = 0; i < W + 2; i++)
  {
    cout << "#";
  }
  
  cout << endl;
  vector<string> str(H);//文字列のデータ
  
  //文字列のデータを受け取る
  for(int i = 0; i < H; i++)
  {
    cin >> str.at(i);
  }
  
  for(int i = 0; i < H; i++)
  {
    cout << "#" << str.at(i) << "#" << endl;
  }
  
  for(int i = 0; i < W + 2; i++)
  {
    cout << "#";
  }
  
  return 0;
    
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;


public class Main{
	public static void main(String args[]){

		// 値取得
		Scanner sc = new Scanner(System.in);
		int total = 0;
		int n = sc.nextInt();
		ArrayList<Integer> a = new ArrayList<>();
		ArrayList<Integer> b = new ArrayList<>();
		ArrayList<Integer> c = new ArrayList<>();

		for(int i = 0;i<n;i++){
			a.add(sc.nextInt());
		}
		for(int j = 0;j<n;j++){
			b.add(sc.nextInt());			
		}
		for(int k = 0;k<n-1;k++){
			c.add(sc.nextInt());			
		}
		c.add(0);

		// b得点
		for(int l =0;l<n;l++){
			total = total + b.get(l);
		}

		// c得点
		for(int m=0; m<a.size()-1;m++){
			if(a.get(m)+1 == a.get(m+1)){
				total = total + c.get(a.get(m)-1);
			}
		}

		System.out.println(total);
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[1000000]; 
void Calc(){
	int H = rei();
	int W = rei();
	DP[0] = 1;
	for(int h=0;h<H;h++){
		string s = res();
		for(int w=0;w<W;w++){
			if(s[w] == '#'){
				DP[h*1000+w] = 0;
			}
			else{
				DP[h*1000+w] %= mod;
			}
			if(h != H-1){
				DP[(h+1)*1000+w] += DP[h*1000+w];
			}
			if(w != W-1){
				DP[h*1000+w+1] += DP[h*1000+w];
			}
		}
	}
	cout << DP[(H-1)*1000+W-1];
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using namespace std;
using ll = long long;
int N;

void solve() {
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        // A[j] < B[i]を満たすjの個数
        ll x = distance(A.begin(), lower_bound(A.begin(), A.end(), B[i]));

        // C[k] > B[i]を満たすkの個数
        ll y = distance(lower_bound(C.begin(), C.end(), B[i] + 1), C.end());
        
        ans += x * y;
    }
    cout << ans << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<string.h>

int main(void){
  int x;
  int a[6];
  int dp[7][100010];
  
  scanf("%d",&x);
  
  for(int i=0;i<6;i++){
    a[i] = 100 + i;
  }
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  
  for(int i=0;i<6;i++){
    for(int j=0;j<=x;j++){
        dp[i+1][j] = dp[i][j];
      if(j>=a[i])
        dp[i+1][j] = dp[i][j] | dp[i+1][j-(a[i])];
    }  
  }
   //printf("%d %d\n",dp[1][100],dp[1][1000]);
  if(dp[6][x])
    printf("1\n");
  else
    printf("0\n");
  return 0;
}

Measured memory_bytes: 2944
s = list(str(input()))
sentence = []
ans = ''

for i in range(len(s)):
    if s[i] == '0':
        sentence.append(0)
    elif s[i] == '1':
        sentence.append(1)
    else:
        if sentence == []:
            continue
        else:
            sentence.pop(-1)

for i in range(len(sentence)):
    ans += str(sentence[i])

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int x, max = 1;
    cin >> x;
    for (int i = 2; i <= x; ++i) {
        for (int j = 2; j <= x; ++j) {
            int tmp = pow(i, j);
            if (tmp > max && tmp <= x) max = tmp;
            if (tmp > x) break;
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

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

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    string s;
    cin>>s;
    for (int i=0;i<len(s);i++){
        if (i>=1&&s[i]==s[i-1]){
            cout<<(i-1)+1<<" "<<(i)+1<<"\n";
            return 0;
        }
        if (i>=2&&s[i]==s[i-2]){
            cout<<(i-2)+1<<" "<<(i)+1<<"\n";
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<"\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e6 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

 
int n, a[N], cnt[N];
bool bad[N];

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i]; 
		++cnt[a[i]];
	}

	int ans = 0;

	for (int i = 1; i < N; ++i)
		if (cnt[i] && !bad[i]) {
			if (cnt[i] == 1)
				++ans;
			for (int j = i + i; j < N; j += i)
				bad[j] = 1;
		}

	cout << ans << endl;

	
}



Measured memory_bytes: 13904
//ベルマン・フォード法
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>

using namespace std;

#define INF 1e9
using vvi = vector< vector<int> >;

int main(){
  int v, e, r;
  cin >> v >> e >> r;
  vector< pair<int, pair<int, int> > > edge;
  for(int i = 0; i < e; i++){
    int s,t,d;
    cin >> s >> t >> d;
    edge.push_back({s, {t,d}});
  }
  vector<int> d(v, INF);
  d[r] = 0;
  for(int i = 0; i < v; i++){
    for(int j = 0; j < e ; j++){
      if(d[edge[j].first] != INF && d[edge[j].second.first] > d[edge[j].first] + edge[j].second.second){
        d[edge[j].second.first] = d[edge[j].first] + edge[j].second.second;
        if(i == v-1){
          cout << "NEGATIVE CYCLE" << endl;
          return 0;
        }
      }
    }
  }
  for(int i = 0; i < v; i++){
    if(i == r){
      cout << 0 << endl;
    }
    else{
      if(d[i] == INF) cout << "INF" << endl;
      else cout << d[i] << endl;
    }
  }
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1000000007
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<ll> DP(n+2,0);
    vector<ll> A(m,0);
    REP(i,m){
        cin >> A[i];
        DP[A[i]]= -1;
    }
    DP[0]= 1;
    REP(i,n){
        if(DP[i]==-1) continue;
        if(DP[i+1]!=-1) DP[i+1]= (DP[i+1]+DP[i])%tl;
        if(DP[i+2]!=-1) DP[i+2]= (DP[i+2]+DP[i])%tl;
    }
    cout << DP[n] << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    if K*500 >= X:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

ll n, m, v, p, a[N];

bool isval(int x){
	if (x <= p) return 1;
	ll d = max(v - (p - 1) - (n - x + 1), (ll)0);
	ll sum = 0;
	for (int i = p; i < x; i++){
		if (a[i] > a[x] + m) return 0;
		sum += min(m, a[x] + m - a[i]);
	}
	//cout << x << ' ' << d << ' ' << sum << '\n';
	return d * m <= sum;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> v >> p;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int l = 1, r = n + 1;
	while (r - l > 1){
		int mid = (l + r) >> 1;
		if (isval(mid)) l = mid;
		else r = mid;
	}
	cout << l;









	return 0;
}


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

using namespace std;

int
main(void){
	long long n, m; cin >> n >> m;
	long long ans = (n - 2) * (m - 2);
	if(n == 1 && m == 1){
		ans = 1;
	}
	else if(n == 1){
		ans = m - 2;
	}
	else if(m == 1){
		ans = n - 2;
	}
	
	cout << max(ans, (long long)0);
	/*vector<vector<bool> > vec(n, vector<bool> (m, 1));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			for(int k = i - 1; k < i - 1 + 3; k++){
				for(int l = j - 1; l < j - 1 + 3; l++){
					if(k >= 0 && k < n && l >= 0 && l < m){
						vec[k][l] = !vec[k][l];
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << vec[i][j];
		}
		cout << endl;
	}*/
}

Measured memory_bytes: 256
<?php 
fscanf(STDIN, "%d%d%d%d", $a,$b,$c,$d);

if(($a+$b)>($c+$d)){
    echo 'Left';
}elseif(($a+$b)==($c+$d)){
    echo 'Balanced';
}else{
    echo 'Right';
}

Measured memory_bytes: 3576
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cb = []
for i in range(m):
	x, y = map(int, input().split())
	cb.append((y, x))
cb.sort(reverse=True)
i = 0
for c, b in cb:
	if c <= a[i]:
		break
	# print("%d: %d" % (c, i))
	while i < len(a) and b > 0 and a[i] < c:
		a[i] = c
		i += 1
		b -= 1
	if i == len(a):
		break
print(sum(a))

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

int main(void)
{
	string str;
	while (cin >> str)
	{
		int id;
		double kg, m;
		for (int i = 0; i < str.size(); i++) if (str[i] == ',') str[i] = ' ';
		stringstream ss(str);
		ss >> id >> kg >> m;
		double bmi = kg / (m * m);
		if (bmi >= 25.0) cout << id << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
vector<vector<int>>edge;
int ans=0;
signed main(){
    int n,m; cin>>n>>m;
    vector<vector<int>>d(n,vector<int>(n,INF));
    rep(i,n)d[i][i]=0;
    vector<pii>edge;
    rep(i,m){
        int to,hoge; cin>>to>>hoge;
        --to,--hoge;
        d[hoge][to]=d[to][hoge]=1;
        edge.push_back(pii(to,hoge));
    }
    rep(i,edge.size()){
        pii unused=edge[i];
        bool flag=true;
        vector<vector<int>>temp=d;
        temp[unused.first][unused.second]=temp[unused.second][unused.first]=INF;
        rep(k,n)rep(i,n)rep(j,n){
            cmin(temp[i][j],temp[i][k]+temp[k][j]);
        }
        rep(i,n)rep(j,n)if(temp[i][j]==INF&&flag){ans++;flag=false;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






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

int main() {
    ll N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    ll pass = 0, bPass = 0;
    for(ll i = 0; i < N; i++) {
        if(pass < A + B && (S[i] == 'a' || (S[i] == 'b' && bPass < B))) {
            cout << "Yes" << endl;
            pass++;
            if(S[i] == 'b') {
                bPass++;
            }
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3740
#include <cstdio>


int a[3], h[5];

int main(){
    while(scanf("%d", &h[0]) != EOF){
        if(h[0] == 0) break;

        a[h[0] - 1]++;
        for(int i = 1; i < 5; i++){
            scanf("%d", &h[i]);
            a[h[i] - 1]++;
        }

        if((a[0] > 0 && a[1] > 0 && a[2] > 0) || a[0] == 5 || a[1] == 5 || a[2] == 5) printf("3\n3\n3\n3\n3\n");
        else{
            int w;
            if(!a[0]) w = 1;
            if(!a[1]) w = 2;
            if(!a[2]) w = 0;

            for(int i = 0; i < 5; i++){
                if(w == h[i] - 1) printf("1\n");
                else printf("2\n");
            }
        }

        for(int i = 0; i < 3; i++) a[i] = 0;
    }
    return 0;
}

Measured memory_bytes: 2620
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int z=0,L=0,R=0,min=0,max=100001;
		while(z<M){
			L=stdIn.nextInt();
			R=stdIn.nextInt();
			if(min<L)
				min=L;
			if(max>R)
				max=R;
			z++;
		}
		if(max-min+1>=0)
			System.out.println(max-min+1);
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 62876
_ = Int(readLine()!)!
let CN = Array(readLine()!)

var an: [Int] = [0]
var count = 0
for i in 0..<CN.count {
    if CN[i] == "R" {
        count += 1
    }
    an.append(count)
}

var result = CN.count
for i in 0..<an.count {
    let tmp = max(i - an[i], an[an.count-1] - an[i])
    result = min(result, tmp)
}
print(result)


Measured memory_bytes: 12836
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/


















int main(){
     ll n,k;
     cin>>n>>k;
     ll a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     int ct[n][60];
     memset(ct,0,sizeof(ct));
     for(int i=0;i<n;i++){
          ll t=a[i];
          for(int j=0;j<50;j++){
               ct[i][j]=t%2;
               t/=2;
          }
     }
     ll res=0LL,tmp=0LL;
     for(int j=59;j>=0;j--){
          int count1=0;
          for(int i=0;i<n;i++){if(ct[i][j]==1)count1++;}
          if(count1>=n-count1){
               res+=count1*(1LL<<j);
          }
          else{
               ll ty=(tmp+(1LL<<j));
               if(ty<=k){
                    tmp=ty;
                    res+=(n-count1)*(1LL<<j);
               }
               else{
                    res+=(count1)*(1LL<<j);
               }
          }
     }
     cout<<res;
  
}



















































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

typedef long long ll;


void solve(long long N, std::vector<long long> A){
  ll pv = 0;
  ll rv = 0;
  for (size_t i = 0; i < A.size(); ++i) {
    if (A[i] < pv) {
      rv += pv - A[i];
    }
    pv = max(pv, A[i]);
  }
  cout << rv << endl;
}

int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

typedef long long ll;
const int MAXN = 1010;
const ll MOD = 1000000007;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, m;
char s[MAXN][MAXN];
ll K, a, b, c;
bool h, v;
struct Matrix {
	ll m[2][2];
	Matrix(int x = 0) {
		memset(m, 0, sizeof(m));
		if(x == 1) m[0][0] = m[1][1] = 1;
	}
}A;

Matrix operator * (const Matrix A, const Matrix B) {
	Matrix res(0);
	for(int i = 0; i < 2; i++)
		for(int j = 0; j < 2; j++) 
			for(int k = 0; k < 2; k++)
				res.m[i][j] = (res.m[i][j]+A.m[i][k]*B.m[k][j]%MOD)%MOD;
	return res;
}

ll qpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1LL) res = res * a % MOD;
		b >>= 1, a = a * a % MOD;
	}
	return res;
}

Matrix qpow(Matrix A, ll b) {
	Matrix res(1);
	while(b) {
		if(b & 1LL) res = res * A;
		b >>= 1, A = A * A;
	}
	return res;
}

int main() {

	n = read<int>(), m = read<int>();
	K = read<ll>();
	for(int i = 1; i <= n; i++) scanf("%s", s[i]+1);

	if(K == 0) {
		printf("1\n");
		return 0;
	}

	for(int i = 1; i <= n; i++) 
		if(s[i][1] == s[i][m] && s[i][1] == '#')
			h = true;
	for(int i = 1; i <= m; i++)
		if(s[1][i] == s[n][i] && s[1][i] == '#')
			v = true;
	if(h && v) {
		printf("1\n");
		return 0;
	}
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(s[i][j] == '#') a++;
	if(!h && !v) {
		printf("%lld\n", qpow(a, K-1));
		return 0;
	}

	if(h) {
		for(int i = 1; i <= n; i++)
			for(int j = 1; j < m; j++)
				if(s[i][j] == '#' && s[i][j] == s[i][j+1]) b++;
		for(int i = 1; i <= n; i++)
			if(s[i][1] == s[i][m] && s[i][1] == '#') c++;
	}
	else {
		for(int j = 1; j <= m; j++) 
			for(int i = 1; i < n; i++)
				if(s[i][j] == s[i+1][j] && s[i][j] == '#') b++;
		for(int i = 1; i <= m; i++)
			if(s[1][i] == s[n][i] && s[1][i] == '#') c++;
	}

	//printf("%lld %lld %lld\n", a, b, c);
	A.m[0][0] = a, A.m[0][1] = MOD-b;
	A.m[1][0] = 0, A.m[1][1] = c;
	A = qpow(A, K-1);

	printf("%lld\n", (A.m[0][0]+A.m[0][1])%MOD);
	return 0;
}


Measured memory_bytes: 1280
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //



// --------- library end - //




int main(){

  ll N = il();
  vector<ll> As;
  rep(i, N){
    As.p_b(il());
  }

  // まずは0が含まれる場合を検出
  rep(i, N){
    if (As[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  // 含まれない
  ll ans = 1;
  rep(i, N){
    ll tmp = ans;
    ans *= As[i];
    if (ans < tmp){
      // オーバーフロー
      cout << -1 << endl;
      return 0;
    }
    else if (ans > 1000000000000000000){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;



}

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

int main() {
    int n,k;
    cin >> n >> k;
    int h[100000];
    int dp[100000];
    for(int i = 0; i < n; i++) {
        cin >> h[i];
        dp[i] = 1000000000;
    }

    dp[0] = 0;



    for(int i = 0; i < n; i++) {
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1];
    return 0;

}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<iterator>
#include<math.h>
#include<cmath>
#include<sstream>
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include<algorithm>
#include<map>
#include<thread>
#include<stack>
#include<numeric>
#include<functional>
#include<queue>
#include<set>
#include<list>
#include<bitset>
#include <cassert>

typedef long long ll;

using namespace std;

const ll MOD = (ll)1000000007;
const ll inf = (ll)1e18;
const long double eps = 0.0000001;

struct th
{
	ll first = -1, second = -1;
	ll third = -1;
};


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

#ifdef _DEBUG
	/*freopen("sorting.in", "r", stdin);
	freopen("sorting.out", "w", stdout);*/

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a;
	cin >> a;

	string s;
	cin >> s;

	if (a >= 3200) cout << s;
	else cout << "red";

	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc064/tasks/abc064_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    map<int, int> mp;
    REP(i, n) {
        cin >> t;
        mp[t / 400]++;
    }
    int ans = 0, val = 0;
    for (auto &x : mp) {
        if (x.first <= 7) {
            ans++;
        } else {
            val += x.second;
        }
    }
    cout << max(1, ans) << " " << ans + val << endl;

    return 0;
}


Measured memory_bytes: 256
L = int(input())
B = [int(input()) for _ in range(L)]

A = []
for b in B:
    if b % 2:
        A.append(1)
    else:
        A.append(0 if b == 0 else 2)

dpLBack = [10**10] * (L + 1)
dpLBack[0] = 0
cnt = 0
for i, a in enumerate(A, start=1):
    cnt += B[i - 1]
    dpLBack[i] = min(dpLBack[i - 1] + 2 - a, cnt)

dpL = [10**10] * (L + 1)
dpL[0] = 0
cnt = 0
for i, a in enumerate(A, start=1):
    cnt += B[i - 1]
    dpL[i] = min(dpL[i - 1] + (a != 1), dpLBack[i - 1] + (a == 0), cnt)

dpRBack = [10**10] * (L + 1)
dpRBack[0] = 0
cnt = 0
for i, a in enumerate(A[:: -1], start=1):
    cnt += B[-i]
    dpRBack[i] = min(dpRBack[i - 1] + 2 - a, cnt)

dpR = [10**10] * (L + 1)
dpR[0] = 0
cnt = 0
for i, a in enumerate(A[:: -1], start=1):
    cnt += B[-i]
    dpR[i] = min(dpR[i - 1] + (a != 1), dpRBack[i - 1] + (a == 0), cnt)

dpR = dpR[:: -1]
dpRBack = dpRBack[::-1]

ans = min(dpL[L], dpR[0])
for mid in range(L + 1):
    ans = min(ans, dpL[mid] + dpRBack[mid], dpLBack[mid] + dpR[mid], dpLBack[mid] + dpRBack[mid])

print(ans)


Measured memory_bytes: 47128
#include<stdio.h>

int main(){

	int i = 0, a[10000], j;

	while (1){
		scanf("%d", &a[i]);
		if(a[i] == 0){
			break;
		}
		printf("Case %d: %d\n",i + 1, a[i]);
		i++;
	}


	return 0;
}

Measured memory_bytes: 1068
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {

    int N, T;
    std::cin >> N >> T;

    int cost = 1001;

    for (int i = 0; i < N; i++) {
        int c, t;
        std::cin >> c >> t;

        if (t <= T) {
            cost = std::min(cost, c);
        }
    }

    if (cost == 1001) {
        std::cout << "TLE" << "\n";
    } else {
        std::cout << cost << "\n";
    }


    return 0;
}


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

using namespace std;
#define ll long long int

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

	string s,n;
	cin>>s>>n;
  	ll diff=0;
  	for(int i=0;i<s.size();i++){
      if(s[i]!=n[i])
        diff++;
    }
  	cout<<diff<<endl;

	return 0;
}


Measured memory_bytes: 3776
import numpy as np
 
N, M, C = map(int,input().split())
 
B = list(map(int,input().split()))
 
count = 0
for i in range (N):
    A = list(map(int,input().split()))
    if np.sum(np.array(A)*np.array(B)) + C> 0:
        count += 1
print(count)

Measured memory_bytes: 13024
# ABC159b


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    s = input()
    n = len(s)
    if s != s[::-1]:
        print('No')
        exit(0)
    if s[: (n - 1) // 2] != s[: (n - 1) // 2:-1]:
        print('No')
        exit(0)
    if s[(n+3)//2-1:n] != s[(n+3)//2-1:n][::-1]:
        print('No')
        exit(0)
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int O[10]={512,256,128,64,32,16,8,4,2,1};
  int g,i,m,j;
  int flg[10];
  
  while(scanf("%d",&g)!=EOF){
    for(i=0;i<10;i++)
      flg[i]=0;
    m=g;
    for(i=0;i<10;i++){
      if(!m)
	break;
      else{
	if(O[i]<=m){
	  if(m==g)
	    j=i;
	  flg[i]++;
	  m=m-O[i];
	}
      }
    }
    for(i=9;i>j;i--){
      if(flg[i])
	printf("%d ",O[i]);
    }
    if(g)
      printf("%d\n",O[j]);
    else
      printf("\n");
    //    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#https://atcoder.jp/contests/dp/tasks/dp_b
import sys
inf = sys.maxsize

n, k = map(int,input().split())
h = [int(i) for i in input().split()]

dp = [0 for _ in range(n)]
dp[0] = 0

for i in range(1, n): #段数
    tmp = min(k, i)
    dp[i] = min([dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, tmp + 1)])
    '''
    tmp = inf
    for j in range(1, k + 1): #一度に登る段数
        if i - j >= 0:
            tmp = min(tmp, dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = tmp
    '''

print(dp[n - 1])

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

int main(){
	double x1,y1,x2,y2,tmp,ans;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	tmp=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	ans=sqrt(tmp);
	printf("%lf\n",ans);
	
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> a >> b >> c >> x;
    mx = max({a, b, c});
    cout << a + b + c - mx + mx * pow(2, x) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>

using namespace std;

int main() {
	string S;
	cin >> S;
	long long int Y = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'g') {
			if (i % 2 == 1)Y++;
		}
		else {
			if (i % 2 == 0)Y--;
		}
}
	cout << Y << endl;
	return 0;
}



Measured memory_bytes: 512
n = int(input())
nl = set(range(n))
txy = [[0, 0, 0]]
ans = 'Yes'
for i in nl:
    txy.append(list(map(int, input().split())))
    tmp = [txy[i+1][k] - txy[i][k] for k in range(3)]
    time_diff = tmp[0]
    time_even_odd = 'Even' if time_diff % 2 == 0 else 'Odd'
    distance_diff = abs(tmp[1]) + abs(tmp[2])
    distance_even_odd = 'Even' if distance_diff % 2 == 0 else 'Odd'
    if (time_diff < distance_diff) or (distance_even_odd != time_even_odd):
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 34692
n=int(input())
v=list(map(int,input().split()))
numg=[]
numk=[]
for i in range(n):
    if i%2==0:
        numk.append(v[i])
    else:
        numg.append(v[i])
numk.sort()
numg.sort()
numk2=[]
numg2=[]
num1=0
cnt=0
for i in range(len(numk)):
    if num1!=numk[i]:
        numk2.append([num1,cnt])
        num1=numk[i]
        cnt=1
    else:
        cnt+=1
numk2.append([num1,cnt])
num1=0
cnt=0
for i in range(len(numg)):
    if num1!=numg[i]:
        numg2.append([num1,cnt])
        num1=numg[i]
        cnt=1
    else:
        cnt+=1
numg2.append([num1,cnt])
str1= lambda val: val[1]
numg2.sort(key=str1)
numk2.sort(key=str1)
if numg2[-1][0]==numk2[-1][0]:
    print(n-max(numg2[-1][1]+numk2[-2][1],numg2[-2][1]+numk2[-1][1]))
else:
    print(n-(numg2[-1][1]+numk2[-1][1]))


Measured memory_bytes: 22768
A,B = list(map(int,input().split()))
X = B-A
if A%2==0:
    if X%4==0:
        out = B
    if X%4==1:
        out = 1
    if X%4==2:
        out = B^1
    if X%4==3:
        out = 0
else:
    if X%4==0:
        out = A
    if X%4==1:
        out = A^B
    if X%4==2:
        out = A^1
    if X%4==3:
        out = A^B^1
print(out)

Measured memory_bytes: 61876
n = int(input())
a = list(map(int, input().split()))

alice = []
bob = []

for i in range(1, n+1):
    if i%2!=0:
        alice.append(a.pop(a.index(max(a))))
    else:
        bob.append(a.pop(a.index(max(a))))

print(sum(alice) - sum(bob))

Measured memory_bytes: 38384
#a
"""
import math
a, b = map(str, input().split())
j = int(a + b)
if math.sqrt(j).is_integer():
    print("Yes")
else:
    print("No")
"""

#b
"""
ans = ["Positive","Negative"]
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    print(ans[(b-a)%2-1])
"""

#C
"""
import itertools
n = int(input())
MARCH = ["M", "A", "R", "C", "H"]
march = [0 for _ in range(5)]
for i in range(n):
    s = input()
    if s[0] in MARCH:
        march[MARCH.index(s[0])] += 1
num = list(range(5))
a = list(itertools.combinations(num, 3))
ans = 0
for i in a:
    bf = 1
    for k in i:
        bf *= march[k]
    ans += bf
print(ans)
"""

#D
"""
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
q = int(input())
p = [int(input()) for _ in range(q)]
for i in range(n):
    D[i].insert(0, 0)
    D[i].insert(n+1, 0)
D.insert(0,[0 for _ in range(n + 2)])
D.insert(n + 2, [0 for _ in range(n + 2)])
print(D)
"""

#E
s = input()
bf = s[0]
ans = 0
for i in range(1,len(s)):
    if bf != s[i]:
        ans += 1
        bf = s[i]
print(ans)

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> num(N);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    num.at(a-1)++;
    num.at(b-1)++;
  }
  for(int i=0; i<N; i++){
    cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int F(int v)
{
	int r=v/500;
	r+=(v%=500)/100;
	r+=(v%=100)/50;
	r+=(v%=50)/10;
	return r;
}
int main()
{
	int a,b,c,d,i,j,k,l,p,q,r,s,u,v,w,m,x=0;;
	while(scanf("%d",&v),v)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		m=999;
		for(l=0;l<=d;++l)for(k=0;k<=c;++k)for(j=0;j<=b;++j)for(i=0;i<=a;++i)
		{
			u=i*10+j*50+k*100+l*500;
			if(u>=v)
			{
				w=F(u-v);
				if(m > a+b+c+d-i-j-k-l+w)
				{
					m=a+b+c+d-i-j-k-l+w;
					p=i;
					q=j;
					r=k;
					s=l;
				}
			}
		}
		if(x++)puts("");
		if(p)printf("10 %d\n",p);
		if(q)printf("50 %d\n",q);
		if(r)printf("100 %d\n",r);
		if(s)printf("500 %d\n",s);
	}
	return 0;
}

Measured memory_bytes: 768
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp()
{
	ll i,j,k,n,m;
	string s;
	cin>>k>>n;
	vector<ll>v1;
	fl(i,n)
	{
		cin>>j;
		v1.pb(j);
	}
	sort(all(v1));
	vector<ll>v2;
	fl(i,n-1)
	{
		v2.pb(v1[i+1]-v1[i]);
	}
	v2.pb(k-v1[n-1]+v1[0]);
	sort(v2.begin(),v2.end());
	ll ans=0;
	fl(i,v2.size()-1)
	{
		ans+=v2[i];
	}
	cout<<ans<<endl;
}

int main()
{
    speedup;
    ll i=0,t;
    ll n;
    //cin>>t;
    t=1;
	while(t--)
    {
        comp();
    }
    return 0;
}


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

const int INI = -1;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int h, w, dist[22][22];
char maze[22][22];

int bfs(int sy, int sx){
  rep(i, h) rep(j, w) dist[i][j] = INI;
  dist[sy][sx] = 0;
  
  queue<P> que;
  que.push(P(sy, sx));
  while(que.size()){
    P p = que.front(); que.pop();
    rep(i, 4){
      int nx = p.second + dx[i], ny = p.first + dy[i];
      if(0 <= nx && 0 <= ny && nx < w && ny < h && maze[ny][nx] != '#' && dist[ny][nx] == INI){
        dist[ny][nx] = dist[p.first][p.second] + 1;
        que.push(P(ny, nx));
      }
    }
  }
  
  int ret = 0;
  rep(i, h) rep(j, w) ret = max(dist[i][j], ret);
  return ret;
}

int main(){
  cin >> h >> w;
  rep(i, h) rep (j, w) cin >> maze[i][j];
  
  int res = 0;
  rep(i, h){
    rep(j, w){
      if(maze[i][j] != '#')
        res = max(res, bfs(i, j));
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

bool ok(const string& s, const int& i) {
    return s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T';
}

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int r = i;
        while (r < n && ok(s, r)) r++;
        ans = max(ans, r - i);
        i = r;
    }
    cout << ans << endl;
}

Measured memory_bytes: 760
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// minFactor[i]: iを割り切る最小の素数。存在しない場合は-1。
void prime_int_table(const int n, std::vector<int> &table) {
  int size = n + 1;
  for (int i = 2; i < size; i++) {
    if (table[i] != -1)
      continue;
    table[i] = i;
    for (int k = 2; i * k < size; k++) {
      if (table[i * k] == -1) {
        table[i * k] = i;
      }
    }
  }
}

string solve(int N, const std::vector<long long> &A) {
  // TODO: edit here
  vi table(1e6 + 1, -1);
  prime_int_table(1e6, table);

  int g = A[0];
  REP(i, N - 1) { g = gcd(g, A[i + 1]); }
  bool isSetWise = g == 1;

  set<int> s;
  int tmp = 0;
  REP(i, N) {
    tmp = A[i];
    int p = table[tmp];
    while (true) {
      p = table[tmp];
      if (p == -1)
        break;
      if (s.count(p)) {
        return isSetWise ? "setwise coprime" : "not coprime";
      }
      s.insert(p);
      while (tmp % p == 0) {
        tmp /= p;
      }
    }
  }
  return "pairwise coprime";
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  string ans = solve(N, A);
  // failed to analyze output format
  // TODO: edit here
  std::cout << ans << std::endl;
  return 0;
}


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

int main(){
	long long i, j;
	char s;
	cin >> i >> s >> j;
	if(s == '+') cout << i + j << endl;
	else cout << i - j << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

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

    int A = inputValue();
    int B = inputValue();

    if(A<B || A<2*B){
        cout << 0 << endl;
    }else{
        cout << A-2*B << endl;
    }

    return 0;
}

Measured memory_bytes: 256