akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,k;cin>>n>>k;
  vector<int> h(n);rep(i,n)cin>>h[i];
  int ans = 0;
  rep(i,n){
    ans += h[i] >= k;
  }
  print(ans);
  return 0;
} 

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

using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a, b;
	cin >> a >> b;

	int sum = max(a, b) + min(a, b);
	if(sum % 2 == 0){
		cout << sum / 2;
	} else {
		cout << "IMPOSSIBLE";
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = 998244353;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

bool check(string s) {
	int a = 0, b = s.size() - 1;
	while (a < b) {
		if (s[a] != s[b]) {
			return false;
		}
		a++;	b--;
	}
	return true;
}

int main() {
	string s;	cin >> s;
	int n = s.size();
	string t = "";
	rep(i, n)	if (s[i] != 'x')	t += s[i];
	if (!check(t)) {
		cout << -1 << endl;
	}
	else {
		int a = 0, b = s.size() - 1;
		int ret = 0;
		while (a < b) {
			if (s[a] == 'x'&&s[b] != 'x') {
				ret++;
				a++;
			}
			else if (s[a] != 'x'&&s[b] == 'x') {
				ret++;
				b--;
			}
			else if (s[a] == s[b]) {
				a++;	b--;
			}
			else {
				cout << -1 << endl;
				break;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){

  Q[tail]=x;
  tail++;
  if(tail==LEN+1)tail=0;
}

P dequeue(){
  head++;
  if(head==LEN+1)head=0;
  return Q[head];
}



int main(){
  int elaps = 0, c;
  int i, q, t;
  int time=0;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);

  }
  
  
  while(head - tail != 0){
    if(Q[head].t > q){
      Q[head].t = Q[head].t - q;
      time += q;
      enqueue(Q[head]);
      dequeue();
    }else{
      time+=Q[head].t;
      Q[head].t=time;
      printf("%s %d\n",Q[head].name, Q[head].t);
      dequeue();
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e15;
ll mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ld pi = acos(-1);

int main()
{
    //freopen("telecow.in", "r", stdin), freopen("telecow.out", "w", stdout);
    fast_io;
    ll a;
    cin >> a;
    cout << fixed << setprecision(20) << (ld)a * 2 * pi;
    return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	string s;
	cin>>s;
	int i;
	for(i=1;i<4;i++)
		if(s[i]==s[i-1])
			break;
	if(i==4)
		cout<<"Good\n";
	else
		cout<<"Bad\n";
}
	

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

int N;
int dx[4] = {0,1,0,-1},dy[4] = {-1,0,1,0};
int main(){
    while(cin >> N && N){
        vector<int> X(N+1,0),Y(N+1,0);
        int n,d;
        for(int i=1;i<=N-1;i++){
            cin >> n >> d;
            X[i] = X[n]+dx[d];
            Y[i] = Y[n]+dy[d];
        }
        int xmin = 1e9,xmax = -1e9,ymin = 1e9,ymax = -1e9;
        for(int i=0;i<=N-1;i++){
            xmin = min(xmin,X[i]);
            xmax = max(xmax,X[i]);
            ymin = min(ymin,Y[i]);
            ymax = max(ymax,Y[i]);
        }
        cout << ymax-ymin+1 << " " << xmax-xmin+1 << endl;
    }
}


Measured memory_bytes: 3004
#include <iostream>

using namespace std;

bool judge(int a, int b) {
  return (a <= 8 && b <= 8);
}

int main() {
  int A, B;
  cin >> A >> B;

  if (judge(A, B)) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0),cout<<fixed<<setprecision(20);
#define rep(i,n)    for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
	int a,b,m,n,t;
	cin>>a>>m>>b>>n>>t;
	a=abs(a-b);m-=n;
	if(m<=0)cout<<"NO";
	else if((a+m-1)/m<=t)cout<<"YES";
	else cout<<"NO";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,q,m,k,x,y;

vector<ll> A;

ll gcd(ll i, ll j){
if(j == 0)return i;
return gcd(j,i%j);
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll c1,c2,c3,c4,c5;
    ll a,b,c;

    cin >> n;
    ll sum = 0;
    ll nodds = 0;
    ll ones = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
        sum += a;
        nodds += a%2;
        ones += (A[c1]==1);
    }

    if(n == 1){
        cout << "Second\n";
    }
    if(n == 2){
        if(nodds == 1){
            cout << "First\n";
        }
        else{
            cout << "Second\n";
        }
    }
    if(n > 2){

        if((sum-n)%2 == 1){
            cout << "First\n";
        }
        else{

            if(nodds > 1 || ones != 0){
                cout << "Second\n";
            }
            else{
                ll par = 0;
                while(1 == 1){

                    for(c1 = 0; c1 < n; c1++){
                        A[c1] -= A[c1]%2;
                    }
                    ll g = A[0];

                    for(c1 = 0; c1 < n; c1++){
                        g = gcd(g , A[c1]);
                    }
                    nodds = 0;
                    sum = 0;
                    ones = 0;
                    for(c1 = 0; c1 < n; c1++){
                        A[c1] /= g;
                        nodds += A[c1]%2;
                        sum += A[c1];
                        ones += (A[c1]==1);
                    }
                    par ^= 1;

                    if((sum-n)%2 == 1){
                        if(par == 1){
                            cout << "Second\n";
                        }
                        else{
                            cout << "First\n";
                        }
                        break;
                    }
                    else{
                        if(nodds > 1 || ones != 0){
                            if(par == 0){
                                cout << "Second\n";
                            }
                            else{
                                cout << "First\n";
                            }
                            break;
                        }
                    }
                }


            }
        }

    }
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

void solve(int m, int n){
	// h[r] := 余り r となる計算結果が前にあったかどうか
	map<int,int> h;
	// 循環する位置
	int a=0, b=0;
	// 計算結果を入れる
	string s;
	// 循環するかどうか
	bool flag = false;
	
	// 商
	int q = m / n;
	// 余り
	int r = m % n;
	
	h[r] = 0;
	//s.push_back( (char)q+'0' );
	m = r * 10;
	
	for(int i=0 ;  ; i++ ){
		// 商
		int q = m / n;
		// 余り
		int r = m % n;
		
		// 商		
		s.push_back( (char)q+'0' );
		m = r * 10;
		
		// 割り切れたとき
		if( r == 0 ) break;
		
		// 循環するとき
		if( h.count(r) ){
			a = h[r];
			b = i;
			flag = true;
			break;
		}
		h[r] = i+1;
	}
	cout << s << endl;
	if( flag ){
		for(int i=0 ; i < s.size() ; i++ ){
			if( a <= i && i <= b ){
				cout << "^";
			}else{
				cout << " ";
			}
		}
		cout << endl;
	}
}

int main(){
	int p, q;
	while( cin >> p >> q ){
		solve( p , q );
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<ll>sticks(n);
  for(int i=0;i<n;i++){
  	cin>>sticks[i];
  }
  sort(sticks.begin(),sticks.end());
  vector<ll>pos;
  for(int i=0;i<n-1;i++){
  	if(sticks[i]==sticks[i+1]){
  		pos.push_back(sticks[i]);
  		i++;
  	}
  }
  if(pos.size()>=2){
  	cout<<pos[pos.size()-1]*pos[pos.size()-2]<<endl;
  }else{
  	cout<<0<<endl;
  }
}



Measured memory_bytes: 1660
#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

#[allow(unused_macros)]
macro_rules ! for_ { ( $ init : stmt ; $ cond : expr ; $ incr : expr , $ body : block ) => ( { $ init ; while $ cond { $ body $ incr ; } } ) ; }

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let mut hmap = HashMap::new();

    for i in 1..(n+1) {
        let tmp = prime_factors(i as u64);
        for (key, value) in tmp.iter() {
            *hmap.entry(key.clone()).or_insert(0) += value.clone();
            *hmap.entry(key.clone()).or_insert(0) %= M;
        }
    }

    let mut ret = 1u64;
    for (_, value) in hmap.iter() {
        ret *= value + 1;
        ret %= M;
    }

    println!("{}", ret);
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn is_prime(n: u64) -> bool {
    for_ ! ( let mut i = 2 ; i * i <= n ; i += 1 , { if n % i == 0 { return false ; } } );
    n != 1
}
#[doc = " n>=1"]
#[allow(dead_code)]
fn divisors(n: u64) -> Vec<u64> {
    let mut ret = vec![];
    for_ ! ( let mut i = 1 ; i * i <= n ; i += 1 , { if n % i == 0 { ret . push ( i ) ; if i != n / i { ret . push ( n / i ) ; } } } );
    ret
}
#[allow(dead_code)]
use std::collections::HashMap;
#[doc = " n>=1"]
#[allow(dead_code)]
fn prime_factors(mut n: u64) -> HashMap<u64, u64> {
    let mut ret = HashMap::new();
    for_ ! ( let mut i = 2 ; i * i <= n ; i += 1 , { while n % i == 0 { * ret . entry ( i ) . or_insert ( 0 ) += 1 ; n /= i ; } } );
    if n != 1 {
        ret.insert(n, 1);
    }
    ret
}
#[doc = " return: (primes, is_prime)"]
#[allow(dead_code)]
fn sieve(n: usize) -> (Vec<usize>, Vec<bool>) {
    let mut primes = vec![];
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n + 1 {
        if is_prime[i] {
            primes.push(i);
            for_ ! ( let mut j = 2 * i ; j <= n ; j += i , { is_prime [ j ] = false ; } )
        }
    }
    (primes, is_prime)
}

Measured memory_bytes: 4352
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h,w,k = LI()
    aa = [[c == '#' for c in S()] for _ in range(h)]

    t = [(i,j) for j in range(w) for i in range(h) if aa[i][j]]

    r = 0
    for ii in range(2**h):
        ia = [((ii >> i) & 1) == 0 for i in range(h)]
        u = [v[1] for v in t if ia[v[0]]]
        if len(u) < k:
            continue

        for jj in range(2**w):
            ja = [((jj >> j) & 1) == 0 for j in range(w)]
            if sum(1 for v in u if ja[v]) == k:
                r += 1

    return r


print(main())




Measured memory_bytes: 10924
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int xx = x1 - x2;
	int yy = y1 - y2;
	int x3 = x2 + yy;
	int y3 = y2 - xx;
	int x4 = x1 + yy;
	int y4 = y1 - xx;
	cout << x3 << " " << y3 <<  " " << x4 << " " << y4 << endl;
}



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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d
		|| abs(a - b) <= d && abs(c - b) <= d) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
date = list(map(int,input().split("/")))

if date[0] < 2019:
    print("Heisei")
elif date[0] == 2019 and date[1] < 4:
    print("Heisei")
elif date[0] == 2019 and date[1] == 4 and date[2] <= 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b,f,r,v,i,j,k;
  int s[4][3][10]={};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    s[b-1][f-1][r-1] += v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
          cout << " " <<s[i][j][k];
      }
      cout << endl;
    }
    if(i!=3){
      cout << "####################" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <unordered_map>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod=1000000007;

int D, G, p[10], c[10], res;
int main() {
	res = intmax;
	cin >> D >> G;
	for (int i = 0; i != D; ++i)
		cin >> p[i] >> c[i];
	for (int i = 0; i != (1 << D); ++i) {
		int sum = 0, cnt = 0;
		for (int j = 0; j != D; ++j) {
			if (i&(1 << j)) {
				sum += 100 * (j + 1)*p[j] + c[j];
				cnt += p[j];
			}
		}
		if (sum >= G)
			res = min(res, cnt);
		else {
			for (int j = D - 1; j != -1; --j) {
				if (!(i&(1 << j))) {
					if (sum + 100 * (j + 1)*p[j] >= G) {
						res = min(res, cnt + (G - sum - 1) / (100 * (j + 1)) + 1);
						break;
					}
					else break;
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ll a, b, cnt=0;
  cin >> a>>b;
  rep(i,b-a)
    cnt += i;
  cout << cnt -a << endl;
  return 0;
}

Measured memory_bytes: 256
// failed to generate code

#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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#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 SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	string S;
	cin >> S;
	reverse(S.begin(), S.end());

	LL i = 0;
	while (i < SZ(S) && S[i] != 'W') {
		i++;
	}
	LL nw = 0, nb = 0;
	LL sum = 0;
	while (i < SZ(S)) {
		while (i < SZ(S) && S[i] == 'W') {
			i++;
			nw++;
		}
		nb = 0;
		while (i < SZ(S) && S[i] == 'B') {
			i++;
			nb++;
		}
		sum += nw * nb;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define rep(i,n) for(int i=0; i<n; i++)

int f(int A, int B, int C, int K, int i){
    if(i>K) return 0;

    if(B > A && C > B) return 1;

    i++;
    A*=2;
    if(f(A,B,C,K,i)) return 1;
    A/=2;

    B*=2;
    if(f(A,B,C,K,i)) return 1;
    B/=2;

    C*=2;
    if(f(A,B,C,K,i)) return 1;
    C/=2;

    return 0;
}

int main(void){
    int A, B, C;
    int K;
    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);

    if(f(A,B,C,K,0)) printf("Yes\n");
    else printf("No\n");

    return 0;
}

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

int a[101][101];
int dp[101][101];

int main()
{
    int n;
    cin >> n;
    int ans = numeric_limits<int>::min();
    
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            cin >> a[i][j];
            dp[i][j] = a[i][j] + dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
        }
    }
    
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            for(int x = 1; x <= j; ++x){
                for(int y = 1; y <= i; ++y){
                    ans = max(ans, dp[i][j] - dp[i][x-1] - dp[y-1][j] + dp[y-1][x-1]);
                }
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int n, a[10], ans = 1, p = 2;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ans *= a[i];
	}
	int flag;
	while (p < 1000) {
		flag = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % p == 0) {
				a[i] /= p;
				ans /= p;
				flag++;
			}
		}
		if (flag >= 2) {
			ans *= p;
			continue;
		}
		else if (flag == 1) {
			ans *= p;
		}
		p++;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 2720
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  map<int, int> MAP;
  FOR(i,0,n){
      int a;cin>>a;
      for(int j = 1; j * j <= a; j++){
          if(a % j == 0) {
              MAP[j]++;
              if(j != a / j) MAP[a/j]++;
          }
      }
  }
  for(auto m : MAP){
      if(m.second > 1) {
          cout << m.first << endl;
      }
  }
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int flag=0;
    string s;
    cin>>s;
    for(ll int i=0;i<s.length();i++)
    {
      if(s[i]=='7')
      {
        flag=1;
        break;
      }
    }
      if(flag==1)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if a == "H" {
		if b == "H" {
			fmt.Println("H")
		} else {
			fmt.Println("D")
		}
	} else {
		if b == "H" {
			fmt.Println("D")
		} else {
			fmt.Println("H")
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007
#define pb push_back
int dp[1001][1001];

int ways(int i,int j,int n,int m,vector<vector<char>> &v)
{
    if(v[i][j]=='#')
   {
            return dp[i][j]=0; 
            // vahan se koi path available nhi hai...
   }
   else
   {
    if( (i==n && j==m-1) || (i==n-1 && j==m))
    {
        return dp[i][j]=1;
    }
    else
    {
        if(dp[i][j]!=-1)
        {
            return dp[i][j];
        }
        
        
        else
        {
            int right=(j+1<=m?ways(i,j+1,n,m,v):0);
            int down=(i+1<=n?ways(i+1,j,n,m,v):0);
            
            return dp[i][j]=(right%p+down%p)%p;
        }
    }
   }
}

int solve(int n,int m,vector<vector<char>> &v)
{
    memset(dp,-1,sizeof(dp));
    return ways(1,1,n,m,v);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,m;
    cin>>n>>m;
    // 2-d array ko vector ke ander vector ke form mei reprsent kr sakte hain...
    vector<vector<char>> v(n+1,vector<char>(m+1));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>v[i].at(j);
        }
    }
    cout<<solve(n,m,v);
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    vector<set<int>> graph(N);
    vector<int> deg(N);
    rep(i,0,N-1){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    vector<bool> used(N);
    queue<int> que;
    rep(i,0,N) if(graph[i].size()==1) que.push(i);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        if(used[u]) continue;
        used[u]=true;
        if(graph[u].empty()){
            cout << "First" << endl;
            return;
        }
        int v=*graph[u].begin();
        used[v]=true;
        for(int w:graph[v]){
            graph[w].erase(v);
            if(graph[w].size()==1) que.push(w);
        }
    }
    cout << "Second" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 14976
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/22/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,M; cin>>N>>M;
  int ans = (N>0?N*(N-1)/2:0) + (M>0?M*(M-1)/2:0);
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int N;
int arr[54];

int main(){
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%d", arr + i);
    for(int i = 1; i <= N; ++i){
        for(int j = i; j <= N; ++j){
            swap(arr[i], arr[j]);
            int f = 1;
            for(int x = 1; x <= N; ++x){
                if(arr[x] != x){
                    f = 0; break;
                }
            }
            if(f){
                puts("YES"); return 0;
            }
            swap(arr[i], arr[j]);
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];

        IntStream.range(0,N).forEach(i -> a[i] =  rateToColor(sc.nextInt()) );

        int color_unknown = (int)Arrays.stream(a).filter(i -> i == 9).count();
        int colors = (int)Arrays.stream(a).filter(i -> i != 9).distinct().count();

        if(color_unknown == 0){
            System.out.print(colors);
            System.out.print(" ");
            System.out.print(colors);
            return;
        }

        int max;
        //max
        max = colors + color_unknown;

        int min = Math.max(1,colors);

        System.out.print(min);
        System.out.print(" ");
        System.out.print(max);
    }

    private static int rateToColor(int rate){
//        レート 1-399：灰色 1
//        レート 400-799：茶色 2
//        レート 800-1199：緑色 3
//        レート 1200-1599：水色 4
//        レート 1600-1999：青色 5
//        レート 2000-2399：黄色 6
//        レート 2400-2799：橙色 7
//        レート 2800-3199：赤色 8
           //9
        if(rate >= 3200){ return 9; }
        if(rate >= 2800){ return 8; }
        if(rate >= 2400){ return 7; }
        if(rate >= 2000){ return 6; }
        if(rate >= 1600){ return 5; }
        if(rate >= 1200){ return 4; }
        if(rate >= 800 ){ return 3; }
        if(rate >= 400 ){ return 2; }
        return 1;
    }
}

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

int main(){
    int n;
    cin >> n;
    double ans=0.0;
    vector<double> x(n);
    vector<string> u(n);
    rp(i,n) cin >> x.at(i) >> u.at(i);
    rp(i,n){
        if(u.at(i)=="JPY"){
            ans+=x.at(i);
        }
        else{
            double yen;
            yen = x.at(i)*380000.000;
            ans += yen;
        }
        
    }
    cout << fixed << setprecision(5) << ans << endl;
    return 0;
}

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

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

ll lsone(ll p){return(p & -p);}

struct path{
    ll l;
    ll r;
    ll c;
};

bool compareTwoPath(path a, path b){
    if (a.l != b.l){
        return a.l < b.l;
    }
    else if (a.r != b.r){
        return a.r < b.r;
    }
    else return a.c < b.c;
}

int main(){
    std::ios::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll n, m, l, r, c;
    vector<ll> line;
    vector<path> pathes;
    cin >> n >> m;
    for (int i=0;i<n;i++){
        line.push_back(-1);
    }
    for (int i=0;i<m;i++){
        cin >> l >> r >> c;
        path p;
        p.l = l-1;
        p.r = r-1;
        p.c = c;
        pathes.push_back(p);
    }
    sort(pathes.begin(), pathes.end(), compareTwoPath);
    line[0] = 0;
    for (int i=0;i<pathes.size();i++){
        path p = pathes[i];
        if (line[p.l] == -1){
            cout << -1;
            return 0;
        }
        else {
            if (line[p.r] == -1 || line[p.l] + p.c < line[p.r]) {
                line[p.r] = line[p.l] + p.c;
                int j = p.r - 1;
                while (j > p.l && (line[j] == -1 || line[j] > line[p.r])) {
                    line[j] = line[p.r];
                    j -= 1;
                }
            }
        }
    }
    cout << line[n-1];
}

Measured memory_bytes: 6256
#include <stdio.h>
#define p1 0
#define p2 1
#define p3 2
#define inf 2000000
#define MAX 100
void dijkstra();

int n,A[MAX][MAX];

int main()
{
  int i,j,k,a,b,c;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      for(j = 0; j < n;j++)
	{
	  A[i][j] = inf;
	}
    }
  for(i = 0;i < n;i++)
    {
      scanf("%d %d",&a,&k);
      for(j = 0;j < k;j++)
	{
	  scanf("%d %d",&b,&c);
	  A[a][b] = c;
	}
    }
  /*for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  printf("%d\n",A[i][j]);
	}
	}*/
  dijkstra();
  return 0;
}
void dijkstra()
{
  int a = -1,i,min,b;
  int d[MAX],c[MAX];
  for(i = 0;i < n;i++)
    {
      c[i] = p1;
      d[i] = inf;
    }
  d[0] = 0;
  while(1)
    {
      min = inf;
      for(i = 0;i < n;i++)
	{
	  if(c[i] != p3 && d[i] < min)
	    {
	      a = i;
	      min = d[i];
	    }
	}
      if(min == inf) break;

      c[a] = p3;

      for(b = 0;b < n;b++)
	{
	  if(c[b] != p3 && A[a][b] != inf)
	    {
	      if(d[a] + A[a][b] < d[b])
		{
		  d[b] = d[a] + A[a][b];
		  c[b] = p2;
		}
	    }
	}
    }
  for(i = 0;i < n;i++)
    {
      printf("%d ",i);
      if(d[i] == inf) printf("-1\n");
      else printf("%d\n",d[i]);
    }
}
      



Measured memory_bytes: 2108
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
puts N%K

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
	int H,W,i,j;
	
	while(1)
	{
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)
		{
			break;
		}
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if((i+j)%2 == 0)
				{
					printf("#");
				}else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
d = map(int,raw_input().split())
#m = {"E":[4,2,1,6,5,3],"N":[2,6,3,4,1,5],"W":[3,2,6,1,5,4],"S":[5,1,3,4,6,2]}
m = {"E":[3,1,0,5,4,2],"N":[1,5,2,3,0,4],"W":[2,1,5,0,4,3],"S":[4,0,2,3,5,1]}

nd = [0]*6
for x in raw_input():
    for j in range(6):
        nd[j] = d[m[x][j]]
    d = list(nd)
print d[0]

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=105;

int n,m;
char s[sz][sz];
int dp[sz][sz][2];

int fnc(int x, int y, int f)
{
    if(dp[x][y][f]!=-1) return dp[x][y][f];

    int h = s[x][y]=='#', nf;
    if(h && f) h = 0, nf = 1;
    else if(h && !f) h = 1, nf = 1;
    else h = 0, nf = 0;

    if(x==n-1 && y==m-1) return h;

    int now = sz;
    if(x<n-1) now = min(now, fnc(x+1, y, nf));
    if(y<m-1) now = min(now, fnc(x, y+1, nf));
    return dp[x][y][f] = h + now;
}

int main()
{
    cin >> n >> m;
    for(int i=0; i<n; i++) scanf("%s", s[i]);
    memset(dp, -1, sizeof(dp));
    cout << fnc(0,0,0) << endl;
}


Measured memory_bytes: 384
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

ll MAX_A = 1001000;
// ll MAX_A = 20;

int main(){
    ll N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    vector<bool> dp(MAX_A, true);
    ll ans = 0;
    rep(i, N){
        if(!dp[a[i]]) continue;
        for(ll j = a[i]; j < MAX_A; j += a[i]){
            dp[j] = false;
        }
        if (i < N - 1 && a[i] == a[i + 1]) continue;
        ans++;
    }
    pt(ans);
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    vector<ll> T(N);
    ll LCM;
    rep(i, N) {
        cin >> T.at(i);
        if (i == 0) LCM = T[i];
        else {
            ll g = __gcd(LCM, T[i]);
            ll L = (LCM / g) * T[i];
            LCM = L;
        }
    }
    cout << LCM << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



  int a;
  string ans = "No";
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	cin >> a;
    int i = 0;
    
    for(int i = 1; i<=9; i++){
		if(a/i <= 9 && a%i == 0){
			ans = "Yes";
		}
	}
    cout << ans;
    
	}

	
	


	



Measured memory_bytes: 3648
#include <stdio.h>

   typedef struct{
       char mark;
       int  num;
   }card;
   
   int main(void)
   {
    int N,i,j,min,x;
    char t;
    card a[36],b[36],change;

    scanf("%d\n",&N);

    for(i=0;i<N-1;i++){
     scanf("%c%d",&a[i].mark,&a[i].num);
     scanf("%c",&t);
    }
    scanf("%c%d",&a[N-1].mark,&a[N-1].num);
    
    for(i=0;i<N;i++)
     b[i]=a[i];

    for(i=0;i<N;i++){
     for(j=N-1;j>i;j--){
      if(a[j].num<a[j-1].num){
        change=a[j];
        a[j]=a[j-1];
        a[j-1]=change;
      }
     }
    }

    for(i=0;i<N-1;i++){
     printf("%c%d ",a[i].mark,a[i].num);
    }
    printf("%c%d\n",a[N-1].mark,a[N-1].num);
    printf("Stable\n");

    for(i=0;i<N;i++){

     min=i;
     for(j=i;j<N;j++){

      if(b[j].num<b[min].num){
       min=j;
      }
     }
     change=b[i];
     b[i]=b[min];
     b[min]=change;
    }

    for(i=0;i<N-1;i++){
     printf("%c%d ",b[i].mark,b[i].num);
    }
    printf("%c%d\n",b[N-1].mark,b[N-1].num);

    x=1;
    for(i=0;i<N;i++){
     if(a[i].mark!=b[i].mark){
      x=0;
     }
    }
     if(x==0){
      printf("Not stable\n");
     }else{
      printf("Stable\n");
     }

    return 0;

   }

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

using namespace std;
int main()
{
   int a,b,c,d,e;
   cin>>a>>b>>c;
   d=b-a;
   e=c-b;
   if(d==e){
    cout<<"YES"<<endl;
   }
   else cout<<"NO"<<endl;
   return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    string t = s;
    int anss = 0;
    int anst = 1;
    FOR(i,1,s.length()){
        if(s[i-1]==s[i]){
            if(s[i-1]=='1') s[i] = '0';
            else s[i] = '1';
            anss++;
        }
    }

    if(t[0]=='0') t[0]='1';
    else t[0] = '0';

    FOR(i,1,t.length()){
        if(t[i-1]==t[i]){
            if(t[i-1]=='1') t[i] = '0';
            else t[i] = '1';
            anst++;
        }
    }
    int ans = min(anst,anss);
    print(ans);
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    int ans = 1;
    for (int i = 1; (1 << i) <= n;i++){
        ans = (1 << i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int triplets(int x){
    int cnt = 0;
    for(int i = 1; i <= (int)(1e2); i++){
        for(int j = 1; j <= (int)(1e2); j++){
            for(int k = 1; k <= (int)(1e2); k++){
                if(i * i + j * j + k * k + i * j + j * k + k * i > x)break;
                if(i * i + j * j + k * k + i * j + j * k + k * i == x)cnt++;
            }
        }
    }
    return cnt;
}



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

    for(int i = 1; i <= n; i++){
        cout << triplets(i) << endl;

    }


}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;

long long cp(pll a, pll b) {
	return a.first * b.second - a.second * b.first;
}

long long Calc(pll a, pll b, pll c) {
	return abs(cp(a, b) + cp(b, c) + cp(c, a));
}

int main()
{
	long long S;
	cin >> S;
	
	long long x = (S + 999999999LL) / 1000000000LL;
	
	pll a = {0LL, 0LL};
	pll b = {x, 1LL};
	pll c = {x * 1000000000LL - S, 1000000000LL};
	
	cout << a.first << " " << a.second << " ";
	cout << b.first << " " << b.second << " ";
	cout << c.first << " " << c.second << "\n";
	
	//cout << Calc(a, b, c) << endl;
}


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

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N, T;
	long A[100010];
	long i, j;
	long m = INF;
	long min_list[100010];
	long sale_list[100010];
	long ans = 0;
	
	sl(N); sl(T);
	for(i=0;i<N;i++) {
		sl(A[i]);
		m = min(m, A[i]);
		sale_list[i] = (A[i] - m) * (T / 2);
	}
	
	m = sale_list[0];
	for(i=1;i<N;i++) {
		m = max(m, sale_list[i]);
	}
	
	for(i=0;i<N;i++) {
		if(m == sale_list[i]) ans++;
	}
	
	pl(ans);
	
	return 0;
}

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

using namespace std;

long long myatoll(char c) {
    return (long long)atoi(&c);
}

long long P_is_not_2_5(long long N, long long P, const string& S) {
    map<long long, long long> residual;
    residual.insert(make_pair(0LL, 1LL));
    long long pow10 = 1;
    long long curr = 0LL;
    for (long long i = N - 1; i >= 0; --i) {
        //int s = atoi(S.substr(i, 1).c_str());
        //int m = (s * pow10 + curr) % P;
        //if (residual.count(m) == 0) {
        //    residual.insert(make_pair(m, 0LL));
        //}
        //residual[m] += 1;
        //curr = m;
        long long x = (curr + pow10 * myatoll(S[i])) % P;
        if (residual.count(curr) == 0) {
            residual.insert(make_pair(curr, 0LL));
        }
        residual[x] += 1;
        curr = x;
        pow10 *= 10;
        pow10 %= P;
    }
    long long ans = 0;
    for (auto it : residual) {
        long long n = it.second;
        if (n >= 2) {
            ans += n * (n - 1) / 2;
        }
    }
    return ans;
}

long long P_is_2_or_5(long long N, long long P, const string& S) {
    long long ans = 0LL;
    for (long long i = 0; i < N; ++i) {
        long long c = myatoll(S[i]);
        if (c % P == 0) {
            ans += i + 1;
        }
    }
    return ans;
}

void Main() {
    long long N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    long long ans = 0LL;
    if (P == 2LL || P == 5LL) {
        ans = P_is_2_or_5(N, P, S);
    }
    else {
        ans = P_is_not_2_5(N, P, S);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1028
//$ node B.js < B.txt
function Main(input) {
  input = input.split('\n') // 1行目がinput[0], 2行目がinput[1], …に入る
  for(var i=0;i<input.length;i++){
    var tmp = input[i].split(' ')
    input[i] = []
    for(var ii=0;ii<tmp.length;ii++){
      input[i].push(tmp[ii])
    }
  }
  var ans = 0

  var A = input[0][0]
  var B = input[0][1]
  var C = input[0][2]

  ans = C- (A-B)
  console.log(0<ans?ans:0)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const int maxn = 1e6;

int n;
int p[maxn + 10];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }


    cin >> n;
    for (int i = 2; i * i <= n; ++i)
        if (!p[i])
            for (int j = 1; i * j <= n; ++j)
                if (!p[i * j]) p[i * j] = i;
    for (int i = 2; i <= n; ++i)
        if (!p[i]) p[i] = i;
    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        int temp = n - i;
        int hold1 = p[temp], hold2 = p[temp], c = 0;
        int pans = 1;
        while (temp > 1)
        {
            hold1 = p[temp];    temp /= p[temp];
            if (hold1 == hold2) ++c;
            else
            {
                pans *= c + 1;
                c = 1;
            }
            hold2 = hold1;
        }
        pans *= c + 1;
        ans += pans;
    }
    cout << ans;


}



Measured memory_bytes: 11380
prime_num = [1 for i in range(300000)]
prime_num[0] = 0
prime_num[1] = 0
i = 2
j = 0
while i < len(prime_num):
    if prime_num[i]:
        j = i * 2
        while j < len(prime_num):
            prime_num[j] = 0
            j += i
    i += 1


ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    ans = 0
    for i in range(n + 1, 2 * n + 1):
        if prime_num[i]:
            ans += 1
    ans_list.append(ans)

for i in ans_list:
    print(i)


Measured memory_bytes: 8052