akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define mp make_pair
#define sz size()
#define pb push_back
using ll = long long;
using pii = pair<int, int>;

const int N = 2e3 + 5;
int n;
std::vector<int> g[N];
int ans[N];

void bfs(int s){
  std::vector<int> d(n, 0), vis(n, 0);
  queue<int> Q;
  Q.push(s);

  d[s] = 0;
  vis[s] = 1;
  while(!Q.empty()){
    int u = Q.front(); Q.pop();

    for(int v : g[u]){
      if(vis[v])continue;
      d[v] = d[u] + 1;
      vis[v] = 1;
      Q.push(v);
    }
  }
  for(int i = 0; i < n; i++)ans[d[i]]++;
}

int main() {

  int x, y;
  cin >> n >> x >> y;
  for(int i = 0; i < n - 1; i++){
    g[i].pb(i + 1);
    g[i + 1].pb(i);
  }
  x--, y--;
  g[x].pb(y); g[y].pb(x);

  for(int i = 0; i < n; i++){
    bfs(i);
  }

  for(int i = 1; i < n; i++)cout << ans[i] / 2<< '\n';

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
  int m,f,r,sum;
  while(1) {
    scanf("%d%d%d\n",&m,&f,&r);
    if(m==-1 && f==-1 && r==-1) break;
    else if(m==-1 || f==-1) printf("%c\n",'F');
    else if(m+f >= 80) printf("%c\n",'A');
    else if(m+f < 80 && m+f >= 65) printf("%c\n",'B');
    else if(m+f < 65 && m+f >= 50) printf("%c\n",'C');
    else if(m+f < 50 && m+f >= 30) {
      if(r >= 50) {
        printf("%c\n",'C');
      }else printf("%c\n",'D');
    } 
    else if(m+f < 30) printf("%c\n",'F');
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n)cin >> p[i];
  int dif = 0;
  rep(i,n) if(p[i] != i + 1)++dif;
  if(dif <= 2)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
} 


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

//#define FILEIO

using namespace std;

const int SZ = 52;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
     return (a > b);
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    long long int n, k, ans, x;

    cin >> n >> k;
    n = n % k;
    x = abs(k - n);
    ans = MIN(n, x);
    cout << ans << endl;

    return 0;
}



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

using namespace std;
const long mod = 1000000007;

int main() {

	long A, B, C; cin >> A >> B >> C;

	cout << max((long)0, C - (A - B)) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a[3][3];
bool b[3][3];
int main(){
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(a[j][k]==x)b[j][k]=1;
	}
	bool flg=0;
	for(int i=0;i<3;i++)if(b[i][0]&&b[i][1]&&b[i][2])flg=1;
	for(int i=0;i<3;i++)if(b[0][i]&&b[1][i]&&b[2][i])flg=1;
	if(b[0][0]&&b[1][1]&&b[2][2])flg=1;
	if(b[0][2]&&b[1][1]&&b[2][0])flg=1;
	cout<<(flg?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
//2019.5.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=5e3+10;
namespace MAIN {
    int n,A,B,pos[N];
    LL dp[2][N],ans=inf;
    inline void MAIN(){
        n=read(),A=read(),B=read();
        for(res i=1;i<=n;i++)pos[read()]=i,dp[0][i]=inf;
        res cur=0;
        for(res i=1;i<=n;i++){
            for(res j=0;j<=i;j++)dp[cur^1][j]=inf;
            for(res j=0;j<i;j++){
                RG LL DP=dp[cur][j];
                if(DP!=inf){
                    if(pos[i]>pos[j])dp[cur^1][i]=min(dp[cur^1][i],DP),dp[cur^1][j]=min(dp[cur^1][j],DP+B);
                    else dp[cur^1][j]=min(dp[cur^1][j],DP+A);
                }
            }
            cur^=1;
        }
        for(res i=1;i<=n;i++)ans=min(ans,dp[cur][i]);
        printf("%lld\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N;
ll x[MAX_N], y[MAX_N];

bool used[MAX_N];

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

  cin >> N;
  rep(i, N) cin >> x[i] >> y[i];

  set<Pll> st;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      st.insert(Pll(x[i]-x[j], y[i]-y[j]));
      st.insert(Pll(x[j]-x[i], y[j]-y[i]));
    }
  }

  ll ans = 0;
  for (Pll pll : st) {
    ll p = pll.fi, q = pll.sc;
    memset(used, false, sizeof(used));
    ll tmp = 0;
    for (int i = 0; i < N; ++i) {
      if (used[i]) continue;
      for (int j = 0; j < N; ++j) {
        if (i == j) continue;
        if (x[j]-x[i] == p && y[j]-y[i] == q)  {
          ++tmp; used[i] = true;
          break;
        }
      }
    }
    ans = max(ans, tmp);
  }

  ans = N - ans;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
//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

bool dp[110000];

int main() {

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

	for (int i = 1; i < k+1; i++) {
		for (int j = 0; j < n; j++) {
			//a[j]個とって、相手に負けを押し付けられるなら勝ち
			if (i - a[j] >= 0)dp[i] |= !dp[i - a[j]];
		}
	}

	if (dp[k])cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL N;
int main(){
	cin>>N;
	LL M=N;
	int a;
	while(N!=0){
		a+=N%10;
		N/=10;
	}
	int c=0;
	while(M>=10){
		c+=9;
		M/=10;
	}
	M--;
	cout<<max(LL(a),M+c)<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $r = [];
  for ($i=2; $i<=$n; $i++) {
    $p = factorize($i);
    foreach($p as $key => $value){
      if(!isset($r[$key])) $r[$key] = 0;
      $r[$key] += $value;
    }
  }

  //var_dump($r);

  $above75 = 0;
  $above25 = 0;
  $above15 = 0;
  $above5 = 0;
  $above3 = 0;
  foreach($r as $key => $value){
    if($value+1 >= 75){
      $above75++;
      $above25++;
      $above15++;
      $above5++;
      $above3++;
    }
    else if($value+1 >= 25){
      $above25++;
      $above15++;
      $above5++;
      $above3++;
    }
    else if($value+1 >= 15){
      $above15++;
      $above5++;
      $above3++;
    }
    else if($value+1 >= 5){
      $above5++;
      $above3++;
    }
    else if($value+1 >= 3){
      $above3++;
    }
  }

  if($above5 < 2 || $above3 < 3){
    echo "0";
    exit;
  }
  // 75
  $ans1 = $above75;
  // 25 3
  $ans2 = $above25*($above3-1);
  // 15 5
  $ans3 = $above15*($above5-1);
  // 5 5 3
  $ans4 = ($above5*($above5-1))/2*($above3-2);

  echo $ans1+$ans2+$ans3+$ans4;

function factorize($n){
  $res = [];
  for($i=2; $i*$i<=$n; $i++){
    if($n % $i != 0) continue;
    $res[$i]=0;
    while($n % $i == 0){      
      $res[$i]++;
      $n /= $i;
    }
  }
  if($n != 1){
    $res[$n]=1;
  }
  return $res;
}

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

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

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

    int ans = 0, j = 0;
    for (int i = min(a, b); i > 0; i--) {
        if (!(a % i) && !(b % i)) {
            j++;

            if (k == j)
                ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string ALP = "abcdefghijklmnopqrstuvwxyz";
#define PB push_back
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  string s;
  cin >> s;
  for(int i=1;i<s.length();i++){
    string t = s.substr(0, s.length()-i);
    if(t.length()%2==0){
      if(t.substr(0,t.length()/2)== t.substr(t.length()/2,t.length()/2)){
        cout << t.length();
        break;
      }
    }
  }
  cout << endl;
  return 0;
}

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

bool light[15][15];

int main(){
    //printf( "%d\n" , (int)light[5][5] );
    int n,m,p[15],c[15];
    scanf( "%d%d" , &n , &m );
    for( int i=0 ; i<m ; i++ ){
        int k;
        scanf( "%d" , &k );
        for( int j=0 ; j<k ; j++ ){
            int x;
            scanf( "%d" , &x );
            light[i][x] = true;
        }
    }
    for( int i=0 ; i<m ; i++ ){
        scanf( "%d" , &p[i] );
    }
    int ans = 0;
    for( int i=0 ; i<(1<<n) ; i++ ){
        for( int j=0 ; j<m ; j++ ){
            c[j] = 0;
        }
        bool ok = true; int t = i;
        for( int j=0 ; j<n ; j++ ){
            int tmp = t%2; t /= 2;
            for( int k=0 ; k<m ; k++ ){
                if( light[k][j+1]&&tmp ) c[k] = (c[k]+1)%2;
            }
        }
        for( int j=0 ; j<m ; j++ ){
            if( c[j]!=p[j] ) ok = false;
        }
        if( ok ) ans++;
    }
    printf( "%d\n" , ans );
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m, k;
ll a[10000];
bool arr[10000];
bool solve(int x) {
  if(n-1<x)return true;
  if(x < 0) return false;
  rep(i, 10000){arr[i]=false;}
  arr[0] = true;
  bool flg=false;
  ll mx = 0;
  rep(i, n) {
    if(i == x) continue;
    for(int j=k; j >= 0; j--){
      if(arr[j]) {
        mx = max(mx, j+a[i]);
        if(j+a[i] < k) {
          arr[j+a[i]] = true;
        }
      }
    }
  }
  if(mx + a[x] < k)return false;
  ll s = k > a[x] ? k-a[x] : 0;
  reps(i, s, k) {
    if(arr[i])return true;
  }
  return false;
}

int main(){

  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
  }
  sort(a, a+n);

  ll r=1LL<<31;
  ll ans = r-1;
  while(r) {
    if(solve(ans-r)) {
      ans -= r;
    }
    r /= 2;
    //cerr<<ans<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    string s;
    cin>>s;
    ll x = s.len()-1;
    ll y = 0;
    ll ans = 0;
    while(x > y){
        if(s[y] != s[x]) ans++;
        x--, y++;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[101];
int main(){
  int n;
  while(cin>>n,n){
    int sum=0;
    for(int i=0;i<n;++i) cin>>s[i];
    sort(s,s+n);
    for(int i=1;i<n-1;++i) sum+=s[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  if(n<=k){
    COUT("unsafe");
  }
  else COUT("safe");
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int a;
  cin >> a;
  int b = a % 10;
  if(b == 2 || b == 4 || b == 5 || b == 7 || b == 9){
    cout << "hon" << endl;
  }
  else if(b == 0 || b == 1 || b == 6 || b == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3640
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-17 00:12:29
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-18 00:46:34
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int maxn =200000;
int f[maxn+10];
int find(int x)
{
    if(f[x]==x) return x;
    else
    {
        f[x]=find(f[x]);
        return f[x];
    } 
}
int N;
ll M;
ll Q;
vector<pii> p1;
vector<pii> p2;
signed main()
{
    for(int i=0;i<=maxn;i++)
    f[i]=i;
    read(N),read(M),read(Q);
    ll pos=0;
    for(int i=1;i<=Q;i++)
    {
        int x,y,k;
        read(x),read(y),read(k);
        if(k==0) p1.push_back(make_pair(x,y));else p2.push_back(make_pair(x,y));
        if(k==0){
        int f1=find(x);
        int f2=find(y);
        if(f1!=f2) {
        pos++;
        f[f1]=f2;}
        }
    }
    ll cnt=0;
    if(M==N-1)
    {
        if(p2.size()!=0){
        cout<<"No";return 0;}
        else {cout<<"Yes";return 0;}
    }
    for(int i=0;i<N;i++)
    if(find(i)==i) cnt++;
    ll que=0;
    for(auto p:p2)
    {
        if(find(p.second)==find(p.first))
        {
            cout<<"No";
            return 0;
        }
    }
    if(cnt<=2)
    {
        
        if(p2.size()!=0)
        {
            cout<<"No";
            return 0;
        }
        else
        {
            cout<<"No";
            return 0;
        }
    }
    else
    {
        ll ans=(1ll*cnt*(cnt-1))/2;
        
        if(((M-1ll*pos)>ans))
        {
            cout<<"No";
            return 0;
        }
        else
        {
            cout<<"Yes";
            return 0;
        }
        
    }
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : b;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	rep(i, s.size()){
		char c = s[i];
		c += (char)n;
		if('Z' < c) c = c - 'Z' + 'A' - 1;
		s[i] = c;
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long x,y,z;
	long long x3,y3,z3;
	long long max;
	while(1) {
		scanf("%lld",&z);
		if(z==0)break;
		z3=z*z*z;
		max=0;
		for(x=1;x<z;x++) {
			x3=x*x*x;
			for(y=1;y<z;y++) {
				y3=y*y*y;
				if(x3+y3<=z3) {
					if(max<x3+y3)max=x3+y3;
				} else break;
			}
		}
		printf("%lld\n",z3-max);
	}
	return 0;
}

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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  llint ans = 0;
  for (llint i = 1; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
    int n,sum=0;
    cin >> n;
    if(n>=500)
    {
        sum = 1000 * (n / 500);
        n %= 500;
    }
    sum += 5 * (n / 5);
    cout << sum << endl;
    return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < min(k, 50); i++){
    vector<int> imos(n);	 //I'll begin the imos method
    for(int j = 0; j < n; j++){
      int l = max(0, j-a[j]);
      int r = min(n-1, j+a[j]);
      imos[l]++;
      if(r+1 <= n-1){
      	imos[r+1]--;
      }
    }
    for(int k = 0; k < n; k++){
      if(k > 0){
        imos[k] += imos[k-1];
      }
    }
    /*for(int l = 0; l < n; l++){
      a[l] = imos[l];
    }*/
    a = imos;
  }
  
  for(int i = 0; i < n; i++){
    cout << a[i] << " ";
  }
}

Measured memory_bytes: 4824
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    for bit in range(1<<n):
        books_set = [0] * (m + 1)
        for i in range(n):
            mask = 1 << i
            if bit & mask:
                for i2 in range(m + 1):
                    books_set[i2] += books[i][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 11340
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    char b;
    cin >> b;

    if(b == 'A'){
        cout << 'T' << endl;
    }else if(b == 'T'){
        cout << 'A' << endl;
    }else if(b == 'C'){
        cout << 'G' << endl;
    }else{
        cout << 'C' << endl;
    }

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

const int maxn = 200, maxm = 1e7;
int n, m, k, p[maxm / 10 + 3], a[maxn + 3], mat[maxn + 3];
map<int, bool> M;
bool b[maxm + 3], vis[maxn + 3];
vector<int> G[maxn + 3];

void prework(int n) {
	for (int i = 2; i <= n; i++) {
		if (!b[i]) p[++k] = i;
		for (int j = 1; j <= k && i * p[j] <= n; j++) {
			b[i * p[j]] = true;
			if (i % p[j] == 0) break;
		}
	}
	b[1] = b[2] = true;
}

bool dfs(int u) {
	for (int i = 0, v; i < G[u].size(); i++) {
		if (!vis[v = G[u][i]]) {
			vis[v] = true;
			if (!mat[v] || dfs(mat[v])) {
				mat[v] = u, mat[u] = v;
				return true;
			}
		}
	}
	return false;
}

int main() {
	prework(maxm);
	scanf("%d", &n);
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		M[x] ^= 1, M[x + 1] ^= 1;
	}
	for (map<int, bool>::iterator it = M.begin(); it != M.end(); it++) {
		if (it -> se) a[++m] = it -> fi;
	}
	for (int i = 1; i <= m; i++) {
		for (int j = i + 1; j <= m; j++) {
			if (!b[a[j] - a[i]]) {
				G[i].push_back(j), G[j].push_back(i);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) if (a[i] % 2 && !mat[i]) {
		fill(vis + 1, vis + m + 1, false), ans += dfs(i);
	}
	int odd = 0, even = 0;
	for (int i = 1; i <= m; i++) if (!mat[i]) {
		if (a[i] % 2) {
			if (odd) odd = 0, ans += 2;
			else odd = 1;
		} else {
			if (even) even = 0, ans += 2;
			else even = 1;
		}
	}
	if (odd && even) ans += 3;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 12672
N=int(input())
a=list(map(int,input().split()))
I=[i for i in range (1,N+1)]
b=[]
for i in range(N):
    b.append([a[i],I[i]])
count=0
for i in range(N):
    if b[i][0]==b[b[i][0]-1][1] and b[i][1]==b[b[i][0]-1][0]:
        count+=1
print(count//2)

Measured memory_bytes: 94644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  char tmp;
  ll num;
  while(cin >> tmp)
    {
 
      int n = (int)tmp - 48;
      num += n;
    }
  if(num%9 == 0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  cin.clear();
}


Measured memory_bytes: 3564
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b, c = map(int, readline().split())
        G[a - 1].append((b - 1, c))
        G[b - 1].append((a - 1, c))

    Q, K, *XY = map(int, read().split())
    K -= 1

    hq = [(0, K)]
    dist = [INF] * N
    dist[K] = 0
    while hq:
        d, v = heappop(hq)
        if dist[v] < d:
            continue
        for nv, cost in G[v]:
            if dist[nv] > d + cost:
                dist[nv] = d + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * Q
    for i, (x, y) in enumerate(zip(*[iter(XY)] * 2)):
        ans[i] = dist[x - 1] + dist[y - 1]

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int n,l;
    cin>>n>>l;
    vector<int> v(n);
    int sum = 0;
    for(int i=0;i<n;++i){
        v[i] = i+l;
        sum += v[i];
    }
    sort(v.begin(),v.end());
    auto it = lower_bound(v.begin(),v.end(),0);
    if(it == v.end()) it--;
    cout << sum - *it << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		Scanner1 sc = new Scanner1();
		
		char[] line=sc.next().toCharArray();
		int sum=0;
		for (char c:line)		
		{ 
			sum+=c-'0';
		}
		
		System.out.println(sum%9==0?"Yes":"No");

	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;//shuffle, then sort 
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class Scanner1 {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

}

Measured memory_bytes: 37120
import sys
import math
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    X = II()
    i = 0
    M = 100
    
    while True:
        i += 1
        M = M + math.floor(M * 0.01)
        if M>=X:
            break
    
    print(i)



if __name__ == "__main__":
	main()

Measured memory_bytes: 63520
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (a, b, k): (usize, usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        let c = ws.next().unwrap().parse().unwrap();
        (a, b, c)
    };

    if k <= a {
        println!("{} {}", a - k, b);
    } else if k <= a + b {
        println!("{} {}", 0, a + b - k);
    } else {
        println!("0 0");
    }
}


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

int main ()
{
    string S;
    std::cin >> S;
    
    int count=0;
    for (int i = 0; i < sizeof(S); i++) 
    {
        if (S[i] == '+')
        {
            count++;
        }
        else if (S[i] == '-')
        {
            count--;
        }
    }
    
    std::cout << count << std::endl;
    
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 3030
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define elif else if
#define lld long double
#define r0 return 0
#define EPS 1e-7
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
const ll mods[2] = {1000000009ll, 1000000007ll};
const ll p[2] = {31, 53};
 
using namespace std;
using namespace __gnu_pbds;

ll dp[N][N][5];
ll a[N][N];

int main()
{
	barnarnar
	int r, c, k123123;
	cin >> r >> c >> k123123;
	forn(i, k123123)
	{
		ll p1, p2, t;
		cin >> p1 >> p2 >> t;
		a[p1][p2] = t;
	}
	forn1(i, r)
	{
		forn1(j, c)
		{
			forn(k, 4)
			{
				if(k == 0)	forn(k1, 4)	dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k1]);
				if(a[i][j] != 0 && k > 0)
				{
					ll alternate = -1ll;
					if(k == 1)	forn(k1, 4)	alternate = max(alternate, dp[i - 1][j][k1]);
					dp[i][j][k] = max(dp[i][j][k], max(dp[i][j - 1][k - 1], alternate) + a[i][j]);
				}
				dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
			}
		}
	}
	/*
	forn1(i, r)
	{
		forn1(j, c)
		{
			cout << a[i][j] << ' ';
		}
		cout << endl;
	}
	cout << endl;
	forn1(i, r)
	{
		forn1(j, c)
		{
			forn(k, 4)	cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
		}
	}
	*/
	ll anss = 0;
	forn(i, 4)	anss = max(anss, dp[r][c][i]);
	cout << anss;
}	
// # pog-unlimitation

/*
Merami isn't so great?
Are you kidding me?
When was the last time you saw a player with such aim ability and movement with a tablet?
Merami puts the game in another level, and we will be blessed if we ever see a player with his skill and passion for the game again.
Whitecat breaks records.
Vaxei breaks records.
Merami breaks the rules.
You can keep your statistics.
I prefer the magic.
*/

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;

  int l[n] = {};
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  
  int64_t count = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i;j<n-1;j++){
      for(int k=j;k<n;k++){
        if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k]) continue;
        if(l[i]>=l[j]+l[k]||l[j]>=l[i]+l[k]||l[k]>=l[i]+l[j])continue;
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3700
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <numeric>

using namespace std;

int main()
{
    int N, M, X;

    cin >> N >> M >> X;
    
    int l = 0;
    int r = 0;
    for (int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        if(a > X)
        {
            r++;
        }
        else
        {
            l++;
        }
    }

    cout << min(r, l) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  vector<int> cnt(26, 0), masks;
  for (char c : s) {
    ++cnt[c - 'a'];
    int m = 0;
    for (int i = 0; i < 26; i++) {
      m |= (cnt[i] & 1) << i;
    }
    masks.push_back(m);
  }
  vector<int> mask_set = masks;
  mask_set.push_back(0);
  sort(mask_set.begin(), mask_set.end());
  mask_set.erase(unique(mask_set.begin(), mask_set.end()), mask_set.end());
  vector<int> dp(mask_set.size(), s.size());
  dp[0] = 0;
  for (int i = 0; i < s.size(); i++) {
    int m = lower_bound(mask_set.begin(), mask_set.end(), masks[i]) -
            mask_set.begin();
    for (int j = 0; j < 26; j++) {
      int x = masks[i] ^ (1 << j);
      int om =
          lower_bound(mask_set.begin(), mask_set.end(), x) - mask_set.begin();
      if (om < mask_set.size() && mask_set[om] == x) {
        dp[m] = min(dp[m], dp[om] + 1);
      }
    }
    if (i == s.size() - 1) {
      cout << max(dp[m], 1) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

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

    vector<vector<int>> vec(M);

    for (int i = 0; i < M; ++i)
    {
        int k;
        cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; ++j)
        {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; ++i)
        cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << N); ++i)
    {
        bool ok = true;
        for (int j = 0; j < M; ++j)
        {
            int c = 0;
            for (int id : vec[j])
            {
                if ((i >> id) & 1)
                {
                    ++c;
                }
            }
            c %= 2;
            if (c != p[j])
            {
                ok = false;
            }
        }
        if (ok)
        {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CColoringColorfully solver = new CColoringColorfully();
        solver.solve(1, in, out);
        out.close();
    }

    static class CColoringColorfully {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();

            int n = s.length();

            int[] c = new int[n];
            for (int i = 0; i < n; i++) {
                c[i] = s.charAt(i) - '0';
            }

            int ans = Integer.MAX_VALUE;

            for (int parity = 0; parity <= 1; parity++) {
                int score = 0;

                for (int i = 0; i < n; i++) {
                    score += (c[i] + i + parity) % 2;
                }

                ans = Math.min(ans, score);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;
int main() {
	string s;
	cin >> s;
	stack<char> st;
	for (int i = 0; i < s.size(); i++){
		if (st.empty()) st.push(s[i]);
		else if (s[i] == 'T' and st.top() == 'S') st.pop();
		else st.push(s[i]);
	}

	cout << st.size() << endl;


}


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

int main(){
   int N,M,sum_a,count;
   cin>>N>>M;
   vector<int> vec(N);
  sum_a=0;
  count=0;
  
   for(int i=0;i<N;i++){
     int a;
     cin>>a;
     vec.at(i)=a;
     sum_a+=a;
   }
   
   double W=(double)sum_a/(4*M);
   for(int x:vec){
      if(x>=W){
      count++;
      }
   }
 
   if(count>=M){
   cout<<"Yes"<<endl;
   }
   if(count<M){
   cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
module Main where

toInt :: String -> Int
toInt s = read s :: Int

strToIntList :: String -> [Int]
strToIntList = map toInt . words

getIntList :: IO [Int]
getIntList = getLine >>= return . strToIntList

main :: IO ()
main = do
  a <- getLine
  b <- getLine
  c <- getLine
  x <- getLine
  let (n500, n100, n50, sum) = (toInt a, toInt b, toInt c, toInt x)
  print $ length
    [ (c500, c100, c50)
    | c500 <- [0 .. n500]
    , c100 <- [0 .. n100]
    , c50  <- [0 .. n50]
    , c500 * 500 + c100 * 100 + c50 * 50 == sum
    ]


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int main(){
long long n,m;cin>>n>>m;
vector<pair<bool,int>> v(n,make_pair(false,0));
long long a=0,b=0;
for(int i=0;i<m;i++){
    int c;string s;cin>>c>>s;
    if(v[c-1].first==false && s=="WA")v[c-1].second++;
    else if(v[c-1].first==false&&s=="AC" ){v[c-1].first=true;}
}
for(int i=0;i<n;i++){
    if(v[i].first==true){
        a++;
        b+=v[i].second;
    }
}
cout<<a<<' '<<b;

}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"    [";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<int> cnt(100001, 0);
    for (int i = 0; i < N; ++i) {
        cnt[A[i]]++;
    }
    int e = 0;
    for (int i = 0; i < 100001; ++i) {
        while(cnt[i] >= 3) cnt[i] -= 2;
        if (cnt[i] == 2) {e++; cnt[i] = 1;}
    }
    int ans = 0;
    for (int i = 0; i < 100001; ++i) {
        if (cnt[i] == 1) ans++;        
    }
    cout << ans - ((e % 2) == 1) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"
#define MAX  1000001
#define ff first
#define ss second
ll mod = 1e9 + 7;
ll maxi = 3e5 + 1;

ll h,w,m;
vll x,y;
set<pll> s;
void solve(){
    cin >> h >> w >> m;
    x.assign(h + 1,0);
    y.assign(w + 1,0);
    ll maxx=1,maxy=1;
    rep(i,0,m){
        ll x0,y0;
        cin >> x0 >> y0;
        x[x0]++;
        y[y0]++;  
        maxx = max(maxx,x[x0]);
        maxy = max(maxy,y[y0]);
        s.insert({x0,y0});
    }
    vll vx,vy;
    rep(i,0,h + 1){
        if(x[i] == maxx) vx.pb(i);
    }
    rep(i,0,w + 1){
        if(y[i] == maxy) vy.pb(i);
    }
    ll ans = maxx + maxy - 1;
    for(auto i:vx){
        for(auto j:vy){
            if(s.find({i,j}) == s.end()){ 
                cout << x[i] + y[j];
                return;
            }

        }
    }
    cout << ans;




}
	
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  
 
    ll t = 1;
    // cin >> t;
    rep(i,0,t){
        solve();
    }
 
}	


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n,cnt=0,minh=0;
    cin >> n;
    vector<int>masu(n);
    rep(i, n)cin >> masu[i];
    for (int i = n - 1; i >= 1; i--) {
        if (masu[i] <= masu[i - 1])cnt++;
        else {
            minh = max(minh, cnt);
            cnt = 0;
        }
    }
    cout << max(minh, cnt) << endl;
    return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int> dp1(3);
    for(int i=0; i<n; ++i){
        vector<int> dp2(3,0);
        vector<int> c(3);
        cin>>c[0]>>c[1]>>c[2];
        for(int j=0; j<3; ++j){
            for(int k=0; k<3; ++k){
                if(j!=k)
                    dp2[k] = max(dp2[k], dp1[j]+c[j]);
            }
        }
        dp1 = dp2;
    }
    cout<<max({dp1[0], dp1[1], dp1[2]});
    return 0;
}


Measured memory_bytes: 256