akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int v = x / 500;
	int t = (x - v * 500)/5;

	LL ans = v * 1000 + t * 5;
	cout << ans << endl;

	return 0;
}

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

int c[1000006];
vector<int> V;
set<int> S;
multiset<int> T;

int N, A[200005];

int dp[200005];

int num[1000006];

int main(void) {
	cin >> N;
	int Am = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
		S.insert(A[i]);
		T.insert(A[i]);
		Am = max(Am, A[i]);
		num[A[i]]++;
	}

	//sort(V.begin(), V.end());

	

	for(auto y: V){
		if (c[y] >= 1) { c[y] = 2; }
		else if (c[y] >= 0) { c[y]++;
		for (long long int j = y*2; j <= Am; j+=y) {
			c[(int) j] = -1;
		}
		}
	}

	int ans = 0;

	for (int i = 1; i <= N;i++) {
		int u = A[i];
		if (T.count(u) >= 2) { /*continue;*/ }
		//else  if (c[u] == 1) { ans++; } 
	}

	
	
	for (int i = 1; i <= N; i++) {
		//if (T.count(A[i]) >= 2) { continue; }
		if (c[A[i]] == 1) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 30348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,q,a[100005],s[100005],as[100005];
bool ch(ll m,ll x){
    ll p=lower_bound(a,a+n,2*x-a[m])-a;
    return m-p>=n-m-1;
}
int main(void){
    scanf("%lld%lld",&n,&q);
    for(int i=0;i<n;i++)scanf("%lld",a+i),s[i]=a[i],as[i]=a[i];
    for(int i=0;i+2<n;i++)s[i+2]+=s[i];
    for(int i=0;i+1<n;i++)as[i+1]+=as[i];
    while(q--){
        ll x,ans=0;
        scanf("%lld",&x);
        ll l=-1,r=n;
        while(r-l>1){
            ll m=(l+r)/2;
            if(ch(m,x))r=m;
            else l=m;
        }
        if(r==0){
            printf("%lld\n",as[n-1]);
            continue;
        }
        ans+=(as[n-1]-as[r-1]);
        ll p=lower_bound(a,a+n,2*x-a[r])-a;
        p=r-(n-r);
        if(p-1>=0){
            ans+=s[p-1];
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  ll ans = 0;
  for(int i=0;i<K;i++){
    string s="";
    for(int j=0;i+j<N;j+=K){
      s+=T[i+j];
    }
    //cout << s << endl;
    bool flag = false;
    ll add = 0;
    char hand='a';
    ll cnt = 1;
    rep(j,sz(s)){
      if(s[j]!=hand){
        if(hand=='r') ans += (cnt+1)/2*P;
        if(hand=='s') ans += (cnt+1)/2*R;
        if(hand=='p') ans += (cnt+1)/2*S;
        hand = s[j];
        cnt = 1;
      }
      else{
        cnt++;
      }
    }
    if(hand=='r') ans += (cnt+1)/2*P;
    if(hand=='s') ans += (cnt+1)/2*R;
    if(hand=='p') ans += (cnt+1)/2*S;
    ans += add;
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
    
int main() {
  int n;
  cin>>n;
  int a[200010],b[200010];
  for (int i=0; i<n; i++) {
    scanf("%d",a+i);
  }
  for (int i=0; i<n/2; i++) {
    b[i]=a[n-1-i*2];
    b[n-1-i]=a[n-2-i*2];
  }
  if (n%2==1) b[n/2]=a[0];
  

  for (int i=0; i<n; i++) {
    printf("%d ",b[i]);
  }
  printf("\n");
  return 0;
}

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

int N;
double T,A;
double H[2000];
double AT[2000];
double ans = 1000000;
int num;

int main(){
    cin >> N;
    cin >> T >> A;
    for(int i = 0; i < N; i++){
        cin >> H[i];
        AT[i] = T - H[i]*0.006;
    }
    
    for(int i = 0; i < N; i++){
        if(ans > abs(AT[i]-A)){
            ans = abs(AT[i]-A);
            num = i;
        }
    }
    
    cout << num + 1 << endl;
    
}

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

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    long long ans=0;

    for(int i=1;i<n;i++){
        ans+=min((x[i]-x[i-1])*a,b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int i,n,d[10005]={};
  d[0]=1;
  for(i=0;i<10000;i++) d[i+1]=d[i]+i+1;
  while(cin>>n)
    cout << d[n] << endl;
  return 0;
}

Measured memory_bytes: 1204
n = int(input())
first = 0
second = 0
x1 = 0
for i in range(n):
  a = int(input())
  if a > second:
    if a > first:
      second = first
      first = a
      x1 = i
    else:
      second = a
for i in range(x1):
  print(first)
print(second)
for i in range(x1+1,n):
  print(first)

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

double p[10], q[10];

double cal(double mid) {
	double ans = 0;
	for (int i = 0; i < 6; i++)
		ans += max(p[i] * mid / 100, q[i] * (1 - mid) / 100);
	return ans;
}

int main() {
	for (int i = 0; i < 6; i++) scanf("%lf", &p[i]);
	for (int i = 0; i < 6; i++) scanf("%lf", &q[i]);
	double l = 0, r = 1;
	for (int i = 0; i < 100; i++) {
		double ml = (l * 2 + r) / 3;
		double mr = (l + r * 2) / 3;
		if (cal(ml) > cal(mr)) l = ml;
		else r = mr;
	}
	printf("%.12f\n", cal(l));
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <string,string> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int tx[4],ty[4];

int dfs(int stage,int c){	
	if(c==8) return 1;	

	int res = 0;
	int sx = -1;
	int sy = -1;
	for(int y=0;y<4;y++){
		for(int x=0;x<4;x++){
			if(~stage & (1<<(y*4+x))){	
				sx = x;
				sy = y;
				goto found;
			}
		}
	}
found:;


	if(sx == -1) return 0;

	for(int i=0;i<4;i++){
		int dx = sx + tx[i];
		int dy = sy + ty[i];
		if(dx < 0 || dx >= 4 || dy < 0 || dy >= 4) continue;
		if(stage & (1<<(dy*4+dx))) continue;

		stage |= (1<<(dy*4+dx));
		stage |= (1<<(sy*4+sx));
		res += dfs(stage,c+1);
		stage &= ~(1<<(dy*4+dx));
		stage &= ~(1<<(sy*4+sx));
	}

	return res;
}

int main(){

	while(~scanf("%d",tx+0)){
		if(tx[0] >= 5) break; 
		scanf("%d %d %d %d %d %d %d",ty+0,tx+1,ty+1,tx+2,ty+2,tx+3,ty+3);
		printf("%d\n",dfs(0,0));
	}
}

Measured memory_bytes: 0
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)

ac=0
wa=0
for i in range(n):
    a1=0
    a2=0
    for j in range(len(aa[i])):
        if aa[i][j]=="WA":
            a1+=1
        else:
            a2+=1
            break
    if a2==1:
        wa+=a1
        ac+=1
print(str(ac)+" "+str(wa))
        

Measured memory_bytes: 25468
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

//#define LOCAL
vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#ifdef LOCAL
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 6660999
#endif

void absinthe() {
    ll n, m, q, l, r; 
    cin >> n >> m >> q;
    vector<vector<ll>>a(n+3, vector<ll>(n+3));
    rep(i, 0, m) { cin >> l >> r; a[l][r]++; }
    rep(i, 1, n+1) rep(j, 1, n+1) a[i][j] += a[i][j-1];
    rep(j, 1, n+1) rep(i, 1, n+1) a[i][j] += a[i-1][j];
    while(q--) { cin >> l >> r; cout << a[r][r] + a[l-1][l-1] - a[l-1][r] - a[r][l-1] << NL; }
}
 
int main(){
  _fastIO();
  int tx = 1; 
  //cin >> tx;
  while(tx--) absinthe();
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
int a[200005];
vector<pair<int,int> >v[200];
int main()
{
    fastread;
    int n,i,j,k,l,m;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>k;
		for(j=1;j<=k;j++)
		{
			cin>>l>>m;
			v[i].pb({l,m});
		}
	}
	ll test=(1<<n)-1;
	int co=0;
	int maxi=0;
	for(i=0;i<=test;i++)
	{
		int flag=0;
		co=0;
	//	cout<<endl;
		for(j=1;j<=n;j++)
		{
			ll sz=v[j].size();
			//cout<<(i&(1<<(j-1)));
			//flag=0;
			if((i&(1<<(j-1)))!=0)
			{
			   //cout<<"udig";
			   co++;}
			for(k=0;k<sz;k++)
			{
				if((i&(1<<(j-1)))!=0)
				{
					if((i&(1<<(v[j][k].fi-1)))!=0&&v[j][k].se==0)
					{
						//co=0;
						flag=1;
						break;
					}
					else if((i&(1<<(v[j][k].fi-1)))==0&&v[j][k].se!=0)
					{
						//co=0;
						flag=1;
						break;
					}
				}
				/*else
				{
					if((i&(1<<(v[j][k].fi-1)))==0&&v[j][k].se==0)
					{
						//co=0;
						flag=1;
						break;
					}
					else if((i&(1<<(v[j][k].fi-1)))!=0&&v[j][k].se!=0)
					{
						//co=0;
						flag=1;
						break;
					}
				}*/
			}
			if(flag==1)
			break;
		}
		//cout<<co<<endl;
		if(flag==0)
		maxi=max(maxi,co);
    }
	cout<<maxi;
	return 0;	 
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int n, k;
bool su[101];

int main(){
    cin >> n >> k;
    int ans=0;
    REP(i,k){
        int d=0;
        cin >> d;
        REP(j,d)
        {
            int a;
            cin >> a;
            su[a-1]=true;
        }
    }
    REP(i,n)
    {
        if(!su[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x[5] = {};
	int i = 0, j = 0,k = 0;//ループ用配列
	
	int n;
	int count = 0;
	int ans = 0;


	rep(i, 5) {
		cin >> x[i];
	}

	rep(i, 5) {
		if (x[i] == 0)ans = i+1;
	
	}

	cout << ans << "\n";
}


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

typedef long long ll;
typedef pair<int, int> pi;
const int inf = 0x3f3f3f3f;

template <class T> inline void chmax(T& x, T y) {if (x < y) x = y;}
template <class T> inline void chmin(T& x, T y) {if (x > y) x = y;}
inline int LSB(int i) {return (i & -i);}

const int maxn = 1e5+5;

struct suffix{
    int idx, r[2];

    bool operator <(const suffix& s) const{
        return (r[0] != s.r[0] ? r[0] < s.r[0] : r[1] < s.r[1]);
    }
} sa[maxn];

int n, k, a[20][maxn], lcp[maxn];
string s;

void buildSA(){
    for (int i = 0; i < n; i++) a[0][i] = s[i] - 'a';
    for (int cnt = 1, step = 1; cnt < n; cnt <<= 1, step++){
        for (int i = 0; i < n; i++){
            sa[i].r[0] = a[step - 1][i];
            sa[i].r[1] = i + cnt < n ? a[step - 1][i + cnt] : -1;
            sa[i].idx = i;
        }

        sort(sa, sa + n);

        a[step][sa[0].idx] = 0;
        for (int i = 1, curRank = 0; i < n; i++){
            if (sa[i].r[0] != sa[i - 1].r[0] || sa[i].r[1] != sa[i - 1].r[1]) curRank++;
            a[step][sa[i].idx] = curRank;
        }
    }

    //for (int i = 0; i < n; i++) cout << sa[i].idx << " ";
}

void buildLCP(){
    int inv[maxn];
    for (int i = 0; i < n; i++) inv[sa[i].idx] = i;
    for (int i = 0, k = 0; i < n; i++, k ? k-- : 0){
        if (inv[i] == n - 1){
            k = 0;
            continue;
        }

        int j = sa[inv[i] + 1].idx;
        while (i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
        lcp[inv[i]] = k;
    }

    //for (int i = 0; i < n; i++) cout << lcp[i] << " ";
}

void solve(){
    int cur = n - sa[0].idx;
    if (k <= cur){
        for (int i = sa[0].idx; i < sa[0].idx + k; i++) cout << s[i];
        cout << endl;
        return;
    }

    int p = cur;
    for (int i = 1; i < n; i++){
        p = cur;
        cur += n - sa[i].idx - lcp[i - 1];
        if (k <= cur){
            //cout << i << " " << p << endl;
            for (int j = sa[i].idx; j < sa[i].idx + lcp[i - 1] + k - p; j++) cout << s[j];
            cout << endl;
            return;
        }
    }
}

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

    cin >> s >> k;
    n = s.length();

    buildSA();
    buildLCP();
    solve();
	return 0;
}


Measured memory_bytes: 4608
N,X = map(int,input().split())
L = [int(i) for i in input().split()]
#print(L)
cnt=0
D = [0]
for i in range(N):
  tmp = D[i]+L[i]
  D.append(tmp)
  if tmp <= X:
    cnt += 1
print(cnt+1)
#初期値の0を追加

Measured memory_bytes: 3060
S = str(input())

left_s = S[:2]
right_s = S[2:]
# print(left_s, right_s)


YYMM = False
MMYY = False
# どちらもTrueになってたらAMBIGUOUSを出力

if int(left_s) >= 0 and 99 >= int(left_s) and int(right_s) > 0 and 12 >= int(right_s):
    YYMM = True

if int(left_s) > 0 and 12 >= int(left_s) and int(right_s) >= 0 and 99 >= int(right_s):
    MMYY = True

if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')


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

using i64 = int64_t;

constexpr i64 MAXIMUM = 1e7;

bool arr[MAXIMUM+1]={0};

i64 solve(i64 m, i64 n){
    for(i64 i=m;i<=MAXIMUM;++i)arr[i] = true;
    i64 cnt = 0;
    i64 i = m;
    for(;i<=MAXIMUM;++i){
        if(!arr[i])continue;
        cnt++;
        for(i64 j=2;i*j<=MAXIMUM;++j)arr[i*j] = false;
        if(cnt >= n)break;
    }
    for(i=i+1;i<=MAXIMUM;++i){
        if(arr[i])return i;
    }
    return -1;
}

int main(){
    int m, n;
    while(cin >> m >> n, m != 0){
        cout << solve(m, n) << endl;
    }

    return 0;
}



Measured memory_bytes: 12840
s = input()

str_max = ""
int_max = 0
str_temp = ""
int_temp = 0

for i in s:
    if i == "A"or i == "C"or i == "G"or i == "T":
        str_temp += i
        int_temp += 1
        # print("OK", i)
    else:
        str_temp = ""
        int_temp = 0
        # print("NG", i)

    if int_max < int_temp:
        int_max = int_temp
        str_max = str_temp

print(int_max)


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	static int A[1000010] = {};
	rep(i, 0, N)A[a[i]] += a[i];
	rep(i, 1, 1000010)A[i] += A[i - 1];

	rep(i, 0, M) {
		int p = A[b[i]];
		if (p >= c[i])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 17548
a_list = ['z'] + [chr(ord('a') + i) for i in range(25)]

def get_alphabet(c: int, s: str) -> str:
    s += a_list[c % 26]
    if c / 26 <= 1:
        return s
    else:
        c = (c - 1) // 26 if c / 26 >= 1 else c // 26
        return get_alphabet(c, s)

n = int(input())

ans = get_alphabet(n, '')

print(''.join(reversed(ans)))


Measured memory_bytes: 9180
n,m=map(int,raw_input().split())
x=map(int,raw_input().split())
y=map(int,raw_input().split())
mod=10**9+7
xx=0
yy=0
for i in xrange(n-1):
    xx+=(i+1)*(n-1-i)*(x[i+1]-x[i])%mod
for i in xrange(m-1):
    yy+=(i+1)*(m-1-i)*(y[i+1]-y[i])%mod
print xx*yy%mod


Measured memory_bytes: 14496
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

string parse(string s){
  stack<char> st;

  for(int i=0;i<s.size();i++){
    if(s[i] == '+' || s[i] == '-' || s[i] == '['){
      st.push(s[i]);
    }else if(s[i] == ']'){
      string t;
      while(st.top() != '['){
        t += st.top();
        st.pop();
      }
      st.pop();
      for(int i=0;i<t.size();i++) st.push(t[i]);
    }else{
      while(st.size() && (st.top() == '-' || st.top() == '+')){
        char c = st.top(); st.pop();
        if(c == '-') s[i] = (s[i] - 'A' + 25)%26 + 'A';
        else s[i] = (s[i] - 'A' + 1)%26 + 'A';
      }
      st.push(s[i]);
    }
  }

  string ans = "";
  while(st.size()){
    ans = st.top() + ans;
    st.pop();
  }

  return ans;
}

bool solve(){
  string s, ans;
  cin >> s;

  if(s == ".") return false;

  for(int i=0;i<s.size();i++) ans += 'Z';
  
  for(int i=0;i<26*26*26;i++){
    int k = 1;
    string t;
    for(int j=0;j<s.size();j++){
      if(s[j] != '?'){
        t += s[j];
      }else{
        t += (i/k)%26 + 'A';
        k *= 26;
      }
    }
    ans = min(ans, parse(t));
  }

  cout << ans << endl;

  return true;
}

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



Measured memory_bytes: 3192
def f(r, a):
    if r[a] != a:
        r[a] = f(r, r[a])
    return r[a]


def union(r, x, y):
    a = f(r, x)
    b = f(r, y)
    if a != b:
        r[a] = b


n, m = list(map(int, input().split()))
p = list(map(int, input().split()))
r = [i for i in range(n)]

for i in range(m):
    x, y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    union(r, x, y)


c = 0
for i in range(n):
    if f(r, i) == f(r, p[i] - 1):
        c += 1

print(c)


Measured memory_bytes: 14452
#include <iostream>
#include <cctype>
#include <stdio.h>
using namespace std;

int main() {
    char a;
    while(1) {
        
        scanf("%c", &a);
        if(a == '\n') break;
        if(islower(a)){
            printf("%c", toupper(a));
        }
        else if (isupper(a)) {
            printf("%c", tolower(a));
        }
        else {
            printf("%c",a);
        }
        
    }
    cout << endl;
    
   
}



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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a+b==4) cout<<2;
    else if(a+b==3) cout<<3;
    else cout<<1;
}


Measured memory_bytes: 892
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

def main():
    ans = 0
    for i in range(N-1):
        if A[i + 1] == A[i] + 1:
            ans += C[A[i] - 1]
        ans += B[A[i]-1]
    ans += B[A[-1]-1]
    print(ans)
    return
main()


Measured memory_bytes: 3060
import fractions
a,b,c,d=map(int, input().split()) 

i = b//c- (a-1)//c
j = b//d- (a-1)//d

f=fractions.gcd(c,d)
f2= int(c * d / f)
k = b//f2 - (a-1)//f2

pot = i + j - k

print(b-(a-1)-pot)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    arep(i, a) cin >> i;

    cout << (n + k - 3) / (k - 1) << '\n';
    return 0;
}

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

void Main() {
    // input
    int N, K;
    cin >> N >> K;
    int A[N+1]; // 添字は -1 しなくてもいいことに注意
    // 配列の初期化
    for (int i = 0; i <= N; i++) {
        A[i] = 0;
    }

    for (int i = 0; i< K; i++) {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            A[a]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i] == 0) {
            ans++;
        }
    }

    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    vector<int> aa(3);
    cin>> aa[0] >> aa[1] >> aa[2];
    sort(all(aa));
    reverse(all(aa));
    cout << aa[0]*10+aa[1]+aa[2];
    return 0;
}


Measured memory_bytes: 3620
import queue

def main():
    A = list(map(int,input().split()))
    pt = list(map(int,input().split()))
    qt = list(map(int,input().split()))
    rt = list(map(int,input().split()))

    ans = 0

    pt.sort(reverse=True)
    qt.sort(reverse=True)
    rt.sort()

    p = queue.LifoQueue()
    q = queue.LifoQueue()
    r = queue.LifoQueue()

    for i in range(A[0]):
        ans += pt[i]
        p.put(pt[i])
    for i in range(A[1]):
        ans += qt[i]
        q.put(qt[i])
    for i in range(A[4]):
        r.put(rt[i])

    while (not p.empty() or not q.empty()) and not r.empty():
        items = [10**9+1,10**9+1,0]
        if not p.empty():
            items[0] = p.get()
        if not q.empty():
            items[1] = q.get()
        items[2] = r.get()

        mini = items.index(min(items))

        if mini == 0:
            ans = ans - items[0] + items[2]
            q.put(items[1])
        elif mini == 1:
            ans = ans - items[1] + items[2]
            p.put(items[0])
        else:
            break

    print(ans)

main()

Measured memory_bytes: 114380
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll X,K,D; cin>>X>>K>>D;
	X=abs(X);
	ll cur=min(X/D,K);
	X-=D*cur; K-=cur;
	if(K%2) X-=D;
	cout<<abs(X)<<"\n";
	return 0;
}

Measured memory_bytes: 3644
import math
a, b, h, m = tuple(map(int, input().split()))

h2 = (h+(m/60)) * 30
m2 = m * 6
x = abs(h2 - m2)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(x)))
print(ans)


Measured memory_bytes: 9504
#include <iostream>
#include <algorithm>
using namespace std;
int ar[100];
int main() {
    int n,sum;
    scanf("%d%d",&n,&sum);
    for(int i = 0;i < n;i ++) {
        scanf("%d",&ar[i]);
    }
    sort(ar,ar + n);
    int i = 0;
    while(i < n && sum >= ar[i]) {
        sum -= ar[i ++];
    }
    if(sum && i == n) {
        i --;
    }
    printf("%d",i);
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a,b,c,d,s1,s2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	s1=a*b;
	s2=c*d;
	if(s1>s2)
	{
		printf("%d\n",s1);
	}
	else
	{
		printf("%d\n",s2);
	}
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, N):
        self.node = [-1 for i in range(N)]

    def find(self, i):
        if self.node[i] < 0:
            return i
        else:
            return self.find(self.node[i])

    def size(self, i):
        return -self.node[self.find(i)]
        
    def unite(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j: return False

        if self.size(i) < self.size(j):
            i, j = j, i

        self.node[i] += self.node[j]
        self.node[j] = i
        return True

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        a, b = map(int, input().split())
        uf.unite(a-1, b-1)

    ans = 0
    for i in range(N):
        ans = max(ans, uf.size(i))
    print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 14908
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,m; cin >> n >> m;
  vector<vector<int>> G(n+m);
  for(int i = 0; i < n; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int l; cin >> l;
      l--;
      G[n+l].push_back(i);
      G[i].push_back(n+l);
    }
  }

  vector<int> visited(n+m,0);
  function< void(int,int) > dfs =
  [&](int u,int pre){
    if(visited[u]) return;
    visited[u] = 1;
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
    }
  };
  dfs(0,-1);

  for(int i = 0; i < n; i++){
    if(!visited[i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;
        vector<ll> a(n); cin >> a;
        sort(all(a));
        priority_queue<pair<int,int>> pq;
        int x = a.back(); a.pop_back();
        int y = a.back(); a.pop_back();
        pq.emplace(y, x);
        pq.emplace(y, x);
        ll ans = x;
        while (a.size()) {
                tie(x, y) = pq.top(); pq.pop();
                auto cur = a.back(); a.pop_back();
                pq.emplace(cur, x);
                pq.emplace(cur, y);
                ans += x;
//                cout << cur << " [" << x << ' ' << y << "]\n";
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 41, Mod = 1e9 + 7, All = (1 << 17) - 1;

int dp[N][All + 1];
bitset<All + 1> ban;

inline int Up(int val, int pos) {
	return val | (1 << (pos - 1));
}

int main() {

	File();

	int n = read(), X = read(), Y = read(), Z = read(), tmp = Up(Up(Up(0, Z), Y + Z), X + Y + Z);

	For (i, 0, All)
		ban[i] = (i | tmp) == i;

	dp[0][0] = 1;
	For (i, 0, n - 1) For (j, 0, All) 
		if (!ban[j] && dp[i][j])
			For (dig, 1, 10)
				(dp[i + 1][All & Up(j << dig, dig)] += dp[i][j]) %= Mod;

	int ans = 0;
	For (i, 1, All) if (!ban[i])
		(ans += dp[n][i]) %= Mod;

	int fac = 1;
	For (i, 1, n)
		fac = fac * 10ll % Mod;

	printf ("%d\n", (fac - ans + Mod) % Mod);
	
#ifdef zjp_shadow
	cerr << (double)clock () / CLOCKS_PER_SEC << endl;
#endif

    return 0;

}


Measured memory_bytes: 19328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=605,p=1000000007,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,a[N],h[N],s[N],inv[N],f[N][N],g[N][N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
int main(){
	n=read()*2;
	for (int i=0;i<n;i++) a[i]=read();
	for (int i=0;i<n;i++)
	if (a[i]>0) h[a[i]]=(a[i^1]>0) ? 2 : 1;
	for (int i=1;i<=n;i++) inv[i]=qpow(i,p-2),s[i]=s[i-1]+(h[i]==1);
	f[0][0]=1;
	for (int i=n;i;i--)
	if (h[i]<2){
		memset(g,0,sizeof(g));
		for (int x=0;x<=n-i;x++)
		for (int y=0;x+y<=n-i;y++)
		if (f[x][y]){
			if (h[i]==1) check(g[x+1][y],f[x][y]);
			else check(g[x][y+1],f[x][y]);
			if (x&&(h[i]!=1)) check(g[x-1][y],(ll)f[x][y]*x%p);
			if (y&&(h[i]==1)) check(g[x][y-1],f[x][y]);
			else check(g[x][y-1],f[x][y]);
		}
		memcpy(f,g,sizeof(g));
	}
	int ans=f[0][0],t=0;
	for (int i=0;i<n;i+=2)
	if (a[i]+a[i^1]==-2) ans=(ll)ans*(++t)%p;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3072
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x,vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout <<#x<<" "<< x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a,b,c) min(a,min(b,c))
#define max(a,b,c) max(a,max(b,c))
vector<ll> v[2*100000+1];
ll val[2*100000+1]={0};
void dfs(int u,int p)
{
    if(p!=-1)
    val[u]+=val[p];
    for(auto x:v[u])
    {
        if(x!=p)
        dfs(x,u);
    }
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	ll q;
	cin>>n;
	cin>>q;
	ll a,b;
	for(int i=0;i<n-1;i++)
	{
	    cin>>a>>b;
	    v[a].pb(b);
	    v[b].pb(a);
	}
	while(q--)
	{
	    ll ver,a;
	    cin>>ver>>a;
	    val[ver]+=a;
	}
	dfs(1,-1);
	for(int i=1;i<=n;i++)
	cout<<val[i]<<" ";
}
	

Measured memory_bytes: 24320
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <deque>
#include <stack>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

bool isAtgc(char c) {
    return (c == 'A') or (c == 'T') or (c == 'G') or (c == 'C');
}

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    
    int res = 0;
    int curr = 0;
    REP(i, s.size()) {
        if (isAtgc(s[i])) {
            curr += 1;
            res = max(res, curr);
        } else {
            curr = 0;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = [S[0]]
for i in range(1, N-1):
    if  i == 1 and ans[0] != S[i]:
        ans.append(S[i])
    elif ans[-1] != S[i]:
        ans.append(S[i])
if ans[-1] != S[-1]:
    ans.append(S[-1])
print(len(ans))

Measured memory_bytes: 4648
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  map<int, int> mp; 
  rep(i ,n) mp[d[i]];
  cout << mp.size() << endl;
  return 0;
}

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

using namespace std;

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

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

    size_t N;
    cin >> N;

    int small = 0;
    intmax_t sum = 0, minv = LLONG_MAX;
    for (size_t i = 0; i < N; ++i) {
        intmax_t a; cin >> a;
        small += (a < 0);
        a = abs(a);
        sum += a;
        minv = min(minv, a);
    }

    if (small % 2) {
        sum -= 2 * minv;
    }

    cout << sum << "\n";

    return 0;
}


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

class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var words = new HashSet<string>();
            string previousWord = null;
          	var output = "Yes";
            for (int i = 0; i < n; i++)
            {
                var word = Console.ReadLine();
                if (!words.Add(word))
                  	output = "No";
              	if(previousWord != null && previousWord.Last() != word.First())
                  	output = "No";
              
              	previousWord = word;
            }
          	Console.WriteLine(output);
        }
    }


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

  int b1 = 0, b2 = 0;
  REP(i, n){
    if(i % 2){
      if(s[i] == '0')
        b1++;
      else
        b2++;
    } else {
      if(s[i] == '1')
        b1++;
      else
        b2++;
    }
  }

  cout << min(b1, b2) << endl;

  return 0;
}


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

int d[1000];
int memo[10][10][10][105];
int n,m;

int solve(int a, int b, int c, int i){

  if(memo[a][b][c][i]) return memo[a][b][c][i];
  if(a == b && b == c) return 0;
  if(d[i] != 0 && d[i] != c) return 0;
  if(i > n) return 0;

  if(i == n) return 1;

  return memo[a][b][c][i] = (solve(b,c,1,i+1) + solve(b,c,2,i+1) + solve(b,c,3,i+1))%10000;
}

int main(){

  int a,b;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    d[a] = b;
  }

  int ans = (solve(0,0,1,1) + solve(0,0,2,1) + solve(0,0,3,1))%10000;

  cout << ans << endl;

}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100;

LL gi() {
	LL w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

//树高为i的树的sg为lowbit(i)
int lc[N],rc[N];bool die[N];
LL sg;
inline void dfs(int k,LL L) {
	if (!k) sg^=L&-L;
	else {
		if (die[k]) return;
		dfs(lc[k],L-1);
		dfs(rc[k],L-1);
	}
}
int main()
{
	int n=gi(),k,tot=1;char c;LL L=gi();
	while (n--) {
		while ((c=getchar())!='0'&&c!='1');
		for (k=1;c=='0'||c=='1';c=getchar())
			if (c=='0') {
				if (!lc[k]) lc[k]=++tot;
				k=lc[k];
			} else {
				if (!rc[k]) rc[k]=++tot;
				k=rc[k];
			}
		die[k]=true;
	}
	dfs(1,L+1);
	puts(sg?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
string s;
map < string , int > mp;
int mx;
int main(){
    TIME
    int n;
    cin >> n;
    for(int i = 1; i <= n ; i ++){
        cin >> s;
        mp[s] ++;
        mx = max(mx , mp[s]);
    }
    for(auto i: mp){
        if(i.sc == mx)
            cout << i.fr << "\n";
    }
}
///...


Measured memory_bytes: 23808
function main()
  
  N = parse(Int,readline())
  H = map(x -> parse(Int,x), split(readline()))
  
  check = true
 
  for i in 1:N-1
    
    if H[i] > H[i+1] || H[i] > H[end]
      H[i] -= 1
    end
    
  end
  
  for i in 1:N-1
    
    if H[i] > H[i+1]
      check = false
    end
    
  end
  
  if check
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 136048
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

class Dis{
  public:
  vector<int> rank,p;
  
  Dis(int s){
    rank.resize(s,0);
    p.resize(s,0);
    rep(i,s) makeSet(i);
  }
  
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
  
  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
  
  void link(int x,int y){
    if(rank[x]>rank[y]) p[y]=x;
    else{
      p[x]=y;
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  
  int findSet(int x){
    if(x != p[x]) p[x]=findSet(p[x]);
    return p[x];
  }

};


int main(){
  int n,q;
  cin>>n>>q;
  
  Dis ds=Dis(n);
  
  int c,a,b;
  for(int i=1;i<=q;i++){
    cin>>c>>a>>b;
    if(c==0) ds.unite(a,b);
    else if(c==1){
      if(ds.same(a,b)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int n, k;
    cin >> n; cin >> k;
    double p = 0.0;
    for (int i=1; i <= n ; i++) {
        int val = i;
        double q = (double)1/n;
        while (val < k) {
            val *= 2;
            q   *= 0.5;
        }
        p += q;
    }
    printf("%.12f\n",p);
}



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

using namespace std;

int main(void) {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			ans++;
		}
	}
	cout << min(ans + 2 * k, n - 1) << endl;
}

Measured memory_bytes: 512
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    P = list(map(int, input().split()))
    result = 0
    for i in range(N - 2):
        tmp = sorted(P[i:i + 3])
        if tmp[0] < tmp[1] < tmp[2] and tmp[1] == P[i + 1]:
            result += 1
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int n,flag = 0;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        
    }
    for(int i = 0; i<n ; i++){
        if(a[i]% 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                printf("DENIED\n");
                return 0;
            }
    }
    }

    printf("APPROVED\n");

    return 0;
}



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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

int di[] = {-1,1,0,0}, dj[] = {0,0,-1,1};

void dfs(int i, int j, vector<string>& grid, vector<vector<bool>>& visited){
	if(grid[i][j]!='#')
		visited[i][j]=true;
	else
		return;
	for(int d=0;d<4;d++){
		int ni=i+di[d],nj=j+dj[d];
		if(ni>=0&&nj>=0&&ni<grid.size()&&nj<grid[0].size()&&grid[ni][nj]!='#'&&!visited[ni][nj]){
			visited[ni][nj]=true;
			dfs(ni,nj,grid,visited);
		}
	}
}



void solveTest(){
}

int main(){
	fastio();
	//input();

	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}*/

	int n,A,B;
	cin>>n>>A>>B;
	string s;
	cin>>s;
	int l = s.length();
	int a=0,b=0;
	for(int i=0;i<l;i++){
		if(s[i]=='a'){
			if(A+B>a+b){
				cout<<"Yes"<<endl;
				a++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		else if(s[i]=='b'){
			if((A+B>b+a)&&(b+1<=B||b==0)){
				cout<<"Yes"<<endl;
				b++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		else{
			cout<<"No"<<endl;
		}
		//cout<<a<<" "<<b<<endl;

	}



	return 0;
}
     

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

#define int long long
int red[4001],blue[4001],green[4001];

signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<n;i++){
    red[i+1]=red[i]+(s[i]=='R');
    blue[i+1]=blue[i]+(s[i]=='B');
    green[i+1]=green[i]+(s[i]=='G');
  }
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      ans+=red[i]*(green[n]-green[i+1]);
      ans+=green[i]*(red[n]-red[i+1]);
    }
    if(s[i]=='G'){
      ans+=red[i]*(blue[n]-blue[i+1]);
      ans+=blue[i]*(red[n]-red[i+1]);
    }
    if(s[i]=='R'){
      ans+=blue[i]*(green[n]-green[i+1]);
      ans+=green[i]*(blue[n]-blue[i+1]);
    }
    for(int j=1;i-j>=0&&i+j<n;j++)
      if(s[i-j]+s[i]+s[i+j]=='R'+'G'+'B')ans--;
  }
  cout<<ans<<endl;
}


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

int main(void) {
    int N, K;
    cin >> N >> K;

    long double expected_to_win = 0;
    for (int i = 1; i <= N; i++) {
        int score = i;
        long double coin = 1;
        while (1 <= score && score <= K-1) {
            score *= 2;
            coin /= 2;
        }
        expected_to_win += coin / N;
    }

    cout << setprecision(12) << expected_to_win << endl;
}

Measured memory_bytes: 256