akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class ABlackjack {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int a,b,c;cin >> a >> b >> c;
        if(a+b+c >=22)cout << "bust" << endl;else cout << "win" << endl;
    }
};

int main() {
	ABlackjack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
int i;
int N;
int A;
int iMin;
int iCnt;

	iMin = 100000000;
	cin >> N;
	for( i = 0; i < N; i++ )
	{
		cin >> A;
		iCnt = 0;
		while( A > 0 && A % 2 == 0 )
		{
			iCnt++;
			A /= 2;
		}

		if( iMin > iCnt ) iMin = iCnt;
		if( iMin == 0 ) break;
	}

	cout << iMin << endl;

	return 0;
}

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

int64_t Len[51], Pat[51];

int64_t rec(int64_t k, int64_t x){
    // バーガー全部なら前計算の結果を返す
    if(x == Len[k]) return Pat[k];
    
    int64_t ans = 0;

    // 下のバン
    x--;

    // 下のk-1バーガー
    if(x > 0){
        int64_t l = min(x, Len[k-1]);
        ans += rec(k-1, l);
        x -= l;
    }

    // 真ん中のパティ
    if(x > 0){
        ans++;
        x--;
    }

    // 上のk-1バーガー
    if(x > 0){
        int64_t l = min(x, Len[k-1]);
        ans += rec(k-1, l);
        x -= l;
    }

    return ans;
}

int main(){
    int64_t N, X;
    cin >> N >> X;
    
    Len[0] = Pat[0] = 1;
    for(int i=1; i<=N; i++){
        Len[i] = Len[i-1] * 2 + 3;
        Pat[i] = Pat[i-1] * 2 + 1;
    }

    cout << rec(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String S1 = S.replace("0","");
		int n1 = S1.length();
		int n0 = S.length() - n1;
		int min = Math.min(n1,n0);
			System.out.println( 2 * min);

	}

}

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

int a[200001];

int main(){
    int n; cin >> n;
    for(int i=1;i<n;i++){
        int b; cin >> b;
        a[b-1]++;
    }
    for(int i=0;i<n;i++) cout << a[i] <<  endl;
    
    return 0;
}

Measured memory_bytes: 4300
s = input()
a = []

for i in range(len(s)):
  a.append(s[i])
  
a = list(map(int, a))

if len(a) == 1:
  print('0')
elif len(a) == 2:
  if a[0] == a[1]:
    print('1')
  else:
    print('0')
else:
  cnt = 0
  i = 0
  while True:
    if a[i] == a[i+1] and a[i+1] == a[i+2]:
      if a[i+1] == 0:
        a[i+1] = 1
      else:
        a[i+1] = 0
      i += 1
      cnt += 1
    elif a[i] == a[i+1]:
      if a[i+1] == 0:
        a[i+1] = 1
      else:
        a[i+1] = 0
      i += 1
      cnt += 1
    else:
      i += 1
      
    if i + 2 > len(a) - 1:
      break
      
  if a[i] == a[i+1]:
    if a[i+1] == 0:
      a[i+1] = 1
    else:
      a[i+1] = 0
    cnt += 1

  print(cnt)

Measured memory_bytes: 4860
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)&&(a||b||c)){

        for(int k=1;k*k<=a;k++){
            if (a%k) continue;
            auto p=a/k,r=k;
            if (!c){
                int dx[]={b/p,0},dy[]={0,b/r};
                for(int i=0;i<2;i++){
                    auto q=dy[i],s=dx[i];
                    if (p*s+q*r!=b) continue;
                    if (p==r&&q<s) continue;
                    printf("%d %d %d %d\n",p,q,r,s);
                    goto end;
                }
                
                continue;
            }

            for(int k=1;k*k<=abs(c);k++){
                if (c%k) continue;
                auto fst=k,snd=c/k;
                int cx[]={fst,-fst,snd,-snd}
                ,cy[]={snd,-snd,fst,-fst};

                for (int i=0;i<4;i++){
                    auto q=cx[i],s=cy[i];
                    if (p==r&&q<s) continue;
                    if (p*s+q*r==b){
                        printf("%d %d %d %d\n",p,q,r,s);
                        goto end;
                    }
                }
            }
            

        }

        puts("Impossible");
        end:
        ;
    }

    return 0;
}


Measured memory_bytes: 2568
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) rec(T[u].r, p);
	if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main(){
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) r = i;
	}

	rec(r, 0);

	for (i = 0; i < n; i++) print(i);

    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;

//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//main
//------------------------------------------

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A==B){
    if(B==C){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
      cout << "No" << endl;
    }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, p, q, a, b, c, d[444][444] = {}, z = 890328;
    cin >> n >> p >> q;
    fr(444) for (int j = 0; j < 444; j++) d[i][j] = 890328;
    d[0][0] = 0;
    while (n--) {
        cin >> a >> b >> c;
        for (int i = 404; i >= a; i--) for (int j = 404; j >= b; j--) d[i][j] = min(d[i][j], d[i - a][j - b] + c);
    }
    for (int i = 1; i * p < 404 && i * q < 404; i++) z = min(z, d[i * p][i * q]);
    if (z == 890328) cout << -1;
    else cout << z;
}


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

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

    int ans=0;
    for(int i=1;i<=N;i++){
        int cnt=0,n=i;
        while(n){
            if(n%2==0) cnt++;
            n/=2;
        }
        ans=max(ans,cnt);
    }
    cout<<(1<<ans)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c>>k;
    ans=a-b;
    if(k%2==0)Cout(ans);
    else Cout(ans*-1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int H, W;
  cin >> H >> W;


  int a = (W + 1) / 2;
  int b = W - a;

  int c = (H + 1) / 2;
  int d = H - c;

  int ans = a * c + b * d;

  if (H == 1 || W == 1)
    ans = 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <utility>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define C2(a) ((((ll)(a) * (ll)((a)-1)) / 2LL) + (ll)(a))

int n;
int c[200005];
vector<int> graph[200005];
ll anscomp[200005];
int curfreq[200005];

int cglobal = 0;

void dfs(int node, int parent)
{
    int old_prt_freq = curfreq[c[parent]] + cglobal;
    /*for (int i = 1; i <= n; i++) {
        if (i != c[node]) curfreq[i]++;
    }*/
    cglobal++; curfreq[c[node]]--;
    for (int i = 0; i < graph[node].size(); i++) {
        int child = graph[node][i];
        if (child == parent) continue;
        dfs(child, node);
    }
    anscomp[c[parent]] += C2(curfreq[c[parent]] + cglobal - old_prt_freq);
    curfreq[c[parent]] = old_prt_freq - cglobal;
    if (parent == 0) {
        for (int i = 1; i <= n; i++) {
            anscomp[i] += C2(curfreq[i] + cglobal);
        }
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", c + i);
    for (int i = 1; i < n; i++) {
        int a, b; scanf("%d%d", &a, &b);
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1, 0);
    ll base = C2(n);
    for (int i = 1; i <= n; i++) {
        printf("%lld\n", base - anscomp[i]);
    }
    return 0;
}


Measured memory_bytes: 33500
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 3005;
int dp[N][N];
int prv[N][N];// 0 : up-left,1 : left,2 : up
string ans;
string s,t;

void path(int i,int j){
	if(i < 1 || j < 1)	return;
	if(prv[i][j] == 0){
		ans += s[i-1];	path(i-1,j-1);
	}
	else if(prv[i][j] == 1)	path(i,j-1);
	else					path(i-1,j);
}

signed main(){
	IOS
	cin >> s >> t;
	rep(i,SZ(s)){
		rep(j,SZ(t)){
			if(s[i] == t[j])	dp[i+1][j+1] = dp[i][j] + 1,prv[i+1][j+1] = 0;
			else if(dp[i+1][j] > dp[i][j+1]){
				dp[i+1][j+1] = dp[i+1][j],prv[i+1][j+1] = 1;
			}
			else{
				dp[i+1][j+1] = dp[i][j+1],prv[i+1][j+1] = 2;
			}
		}
	}
	int S = SZ(s),T = SZ(t);
	path(S,T);
	rep(i,SZ(ans))	cout << ans[dp[S][T] - i - 1];

}


Measured memory_bytes: 141312
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b))
        cout<<"B"<<endl;
    else cout<<"A"<<endl;
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  vector<pair<int,int>> x;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    x.push_back(make_pair(t, i));
  }

  sort(x.begin(), x.end());

  int mid_left = n / 2 - 1;
  int mid_right = n / 2;
  int ans[max_n + 1];

  for(int i = 0; i < n; i++){
    if(i <= mid_left) ans[x[i].second] = x[mid_right].first;
    else ans[x[i].second] = x[mid_left].first;
  }
  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 5568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define LL long long

LL read() {
    LL x = 0, f = 1; char c = getchar();
    while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
    while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
    return x * f;
}

int main() {
    LL l = read(), orgl = l, r = read(), orgr = r, tr = r, ans;
    
    for(int i = 59; i >= 0; i--)
        if((l>>i)^(r>>i)) {
            l |= 1ll << i;
            int tmp = i;
            for(tmp--; tmp >= 0; tmp--) tr |= 1ll << tmp;
            for(i--; i >= 0 && !(r >> i & 1); i--) ;
            for(i; i >= 0; i--) r |= 1ll << i;
            break;
        }
    if(r >= l) return printf("%lld\n", tr - orgl + 1), 0;
    ans = r - orgl + 1 + tr - l + 1;
    
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define x first
#define y second

const ll inf=2147483647;

//

ll read()
{
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

void print(ll x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(ll i=sz-1; i>=0; i--)putchar('0'+a[i]);
}

ll n;
ll m;
vector<ll> adj[111111];
vector<ll> cc[111111];
ll vis[111111];
ll cnt;
ll w[111111];
ll used[111111];
ll ind[111111];

bool cmp(ll aa,ll bb){return w[aa]<w[bb];}

void dfs(ll x){
	cc[cnt].pb(x);
	for(ll i=0;i<adj[x].size();i++){
		ll v=adj[x][i];
		if(!vis[v]){
			vis[v]=cnt;
			dfs(v);
		}
	}
}

ll ans;

int main(){
	n=read(),m=read();
	for(ll i=1;i<=n;i++) w[i]=read(),ind[i]=i;
	for(ll i=1;i<=m;i++){
		ll x=read(),y=read();
		x++;
		y++;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			cnt++;
			vis[i]=cnt;
			dfs(i);
			sort(cc[cnt].begin(),cc[cnt].end(),cmp);
		}
	}
	
	if(n<(cnt-1)*2){
		cout<<"Impossible"<<endl;
		return 0;
	}
	if(cnt==1){
		cout<<0<<endl;
		return 0;
	}
//	cout<<cnt<<endl;
	for(ll i=1;i<=cnt;i++){
		used[cc[i][0]]=1;
		ans+=w[cc[i][0]];
	}
//	cout<<ans<<endl;
	sort(ind+1,ind+n+1,cmp);
	ll nw=cnt;
	if(cnt==2){
		cout<<ans<<endl;
		return 0;
	}
	for(ll i=1;i<=n;i++){
		if(!used[ind[i]]){
			nw++;
			ans+=w[ind[i]];
			if(nw==(cnt-1)*2){
				break;
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

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

    ll n, k;
    cin >> n >> k;

    if(k == 0){
        cout << n*n << endl;
        return 0;
    }
    
    ll res = 0;
    for(ll i = k+1; i <= n; ++i){
        res += ((n+1)/i)*(i-k) + max(0LL, ((n+1)%i - k));
        if(k==0) res -= (n+1)/i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define ll long long
typedef pair<ll,ll> pll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define coutif(a,b,c) cout<<(a?b:c)

int main(){
    ll n,m,j,k=0,ans=0,t,x,y,i;
    string s;
    cin>>s;
    for(i=1;i<s.size();i++){
        if(s[i]==s[i-1] && k==0){
            i++;
            k=1;
        }
        else k=0;
        ans++;
        //cout<<ans<<" "<<i<<" "<<k<<endl;
    }
    if(i==s.size()) ans++;
    cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

#define PI 3.14159265358979
double torad(double deg){
	return deg/360.*2*PI;
}
signed main(){
	int A,B,H,M;cin>>A>>B>>H>>M;
	double deg1=360./720*(H*60+M);
	double deg2=360./60*M;
	double xa=cos(torad(deg1))*A,ya=sin(torad(deg1))*A;
	double xb=cos(torad(deg2))*B,yb=sin(torad(deg2))*B;
	double x=abs(xa-xb),y=abs(ya-yb);
	printf("%.12lf\n",sqrt(x*x+y*y));
}


Measured memory_bytes: 4096
character(10) a,b,c
read*,a,b,c
if (a(len_trim(a):len_trim(a))==b(1:1).and.b(len_trim(b):len_trim(b))==c(1:1))then
	print"(A)","YES"
else
	print"(A)","NO"
endif
end

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  int n = s.size();
  int cnt = 0;
  vector<bool> dir(4, false);
  int nowdir = 0;
  bool ok = false;
  REP(i, n) {
    int next = 0;
    if(s[i] == 'R') next = 1;
    else next = -1;

    if(nowdir == 0 && next == 1) {
      ok = true;
    } else if(nowdir == 1 && next == -1) {
      ok = false;
    } else if(nowdir == 3 && next == 1 && ok) {
      ok = false;
      cnt++;
    }
    nowdir += next;
    nowdir %= 4;
  }

  cout << cnt << endl;
}



Measured memory_bytes: 3216
import * as fs from "fs"

// ############################################################ //

// 2次元配列の行と列を入れ替える
const transpose = <T>(a: Array<Array<T>>) =>
  a[0].map((_, c) => a.map((r) => r[c]))

// 配列を作成して指定された値で初期化する
const createArray = <T>(length: number, initialValue: T): T[] => {
  const ary = []
  for (let i = 0; i < length; i++) {
    ary.push(initialValue)
  }
  return ary
}

// 配列の初期化などで使える、整数値の上限下限（これ同士を足してもオーバーフローしない）
const NUMBER_MAX = Math.floor(Number.MAX_SAFE_INTEGER / 2)
const NUMBER_MIN = Math.ceil(Number.MIN_SAFE_INTEGER / 2)

// ############################################################ //

const process = (n: number, a: number[], b: number[], c: number[]): string => {
  // 最後に各行動を選んだときの幸福度
  let ha = 0
  let hb = 0
  let hc = 0

  for (let i = 0; i < n; i++) {
    // 一時変数を使わないと、足された後の数で計算されてしまう
    let tempA = 0
    let tempB = 0
    let tempC = 0

    // ha
    // 行動 A は選べない
    if (hb > hc) {
      tempA += a[i] + hb
    } else {
      tempA += a[i] + hc
    }

    // hb
    if (ha > hc) {
      tempB += b[i] + ha
    } else {
      tempB += b[i] + hc
    }

    // hc
    if (ha > hb) {
      tempC += c[i] + ha
    } else {
      tempC += c[i] + hb
    }

    // 対比していた今回の幸福度を足す
    ha = tempA
    hb = tempB
    hc = tempC
  }

  // 一番幸福度が大きいものを返す
  if (ha > hb && ha > hc) {
    return ha + ""
  } else if (hb > ha && hb > hc) {
    return hb + ""
  }
  return hc + ""
}

const Main = (input: string): string => {
  const aa: string[][] = input.split("\n").map((e) => e.split(" "))
  const n: number = parseInt(aa[0][0])
  const abc = transpose(aa.slice(1).map((e) => e.map((e2) => parseInt(e2))))

  const res = process(n, abc[0], abc[1], abc[2]) + ""
  console.log(res)
  return res
}
 Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 68260
#include <stdio.h>
#include <string.h>
 
int main(void) {
    char S[110];
    char T[110];
    char *ANS;
    int a;
    int i;
    scanf("%d",&a);
    scanf("%s %s",S,T);
    
    for(i=0; i < a;i++) {
      printf("%c",S[i]);
      printf("%c",T[i]);
      
    }
  printf("\n");
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
long long int gcd(long long int x,long long int  y){
   if(y==0)return x;
   return gcd(y,x%y);
}
long long exp(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = exp(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int prime(long long x){
if(x%2==0)

    return 0;
else{
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)
            return 0;
    }
}
return 1;
}
//main
int main() {
IOS;
int n;
ll coun=0;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++)cin>>v[i];
sort(v.begin(),v.end());
for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
        for(int k=j+1;k<n;k++){
            if(v[k]<v[i]+v[j]&&v[i]!=v[j]&&v[j]!=v[k])
            coun++;
        }
    }
}
cout<<coun<<"\n";
return 0;
}


Measured memory_bytes: 3576
x, n = gets.split.map &:to_i
ps = gets.split.map &:to_i

min_y = -1
min_d = 1e1000

unless ps.include? x
	p x
	exit
end

y1 = x - 1
y2 = x + 1
y = nil

loop do
	y = y1
	break unless ps.include? y1
	y1 -= 1
	y = y2
	break unless ps.include? y2
	y2 += 1
end

p y

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, X, T;
  cin >> N >> X >> T;

  cout << (N / X + (N % X > 0)) * T << endl;

  return 0;
}

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


// problem: C
//int main(){
//	int N;
//	cin >> N;
//	int A[100010] = {0};
//	for(int n=1; n<=N; ++n) cin >> A[n];
//	int sum;	
//	for(int i=1; i<=N+1; ++i){
//		sum += abs(A[i]-A[i-1]);
//	}
//	for(int i=1; i<=N; ++i){
//		int diff, add, tmpSum;
//		tmpSum = sum;
//		diff = abs(A[i] - A[i-1])+abs(A[i+1]-A[i]);
//		add = abs(A[i+1]-A[i-1]);
//		tmpSum -= diff;
//		tmpSum += add;
//		cout << tmpSum << endl
//	}
//}

// problem:D
int main(){
	int A, B;
	cin >> A >> B;
	string grid[10010];
	for(int i=0; i<10000; ++i){
		if(i < 5000){
		grid[i] = "#";
		}else{
		grid[i] = ".";
		}
	}
	int a, b;
	a = A - 1;
	b = B - 1;
	for(int i=0; i<a; ++i){
		if(i%100<50){
		grid[2*i] = ".";
		}else{
		grid[2*i+1000] = ".";
		}
	}
	for(int i=0; i<b; ++i){
		if(i%100<50){
		grid[6000 + 2*i] = "#";
		}else{
		grid[6000 + 2*i+1000] = "#";
		}
	}
	cout << "100 100"<<endl;
	for(int i=0; i<10000; ++i){
		cout << grid[i];
		if (i%100 == 99){
		cout << endl;
		}
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

string s;
vs ord(3);
int p;

ll op0();

ll num()
{
	ll res = 0;
	while (isdigit(s[p]))
	{
		res *= 10;
		res += s[p] - '0';
		p++;
	}
	return res;
}

ll unit()
{
	ll res;
	if (s[p] == '(')
	{
		p++;
		res = op0();
		p++;
	}
	else
	{
		res = num();
	}
	return res;
}

ll op2()
{
	ll res = unit();
	while (ord[2].find(s[p]) != -1)
	{
		if (s[p] == '+')
		{
			p++;
			ll rhs = unit();
			res += rhs;
			continue;
		}
		if (s[p] == '-')
		{
			p++;
			ll rhs = unit();
			res -= rhs;
			continue;
		}
		if (s[p] == '*')
		{
			p++;
			ll rhs = unit();
			res *= rhs;
			continue;
		}
	}
	return res;
}

ll op1()
{
	ll res = op2();
	while (ord[1].find(s[p]) != -1)
	{
		if (s[p] == '+')
		{
			p++;
			ll rhs = op2();
			res += rhs;
			continue;
		}
		if (s[p] == '-')
		{
			p++;
			ll rhs = op2();
			res -= rhs;
			continue;
		}
		if (s[p] == '*')
		{
			p++;
			ll rhs = op2();
			res *= rhs;
			continue;
		}
	}
	return res;
}

ll op0()
{
	ll res = op1();
	while (ord[0].find(s[p]) != -1)
	{
		if (s[p] == '+')
		{
			p++;
			ll rhs = op1();
			res += rhs;
			continue;
		}
		if (s[p] == '-')
		{
			p++;
			ll rhs = op1();
			res -= rhs;
			continue;
		}
		if (s[p] == '*')
		{
			p++;
			ll rhs = op1();
			res *= rhs;
			continue;
		}
	}
	return res;
}

ll parse() //+-*
{
	p = 0;
	return op0();
}

int main()
{
	cin >> s;
	ll ans = LLONG_MIN;
	REP(i, 3)REP(j, 3)REP(k, 3)
	{
		ord.clear();
		ord.resize(3);
		ord[i] += '+';
		ord[j] += '-';
		ord[k] += '*';
		ll res = parse();
		chmax(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

set<char> l = {'q', 'w', 'e', 'r', 't', 'a', 's', 'd',
               'f', 'g', 'z', 'x', 'c', 'v', 'b'};

bool solve() {
    string s;
    cin >> s;
    if(s == "#") {
        return 0;
    }
    int ans = 0;
    int now;
    for(int i = 0; i < s.size(); i++) {
        if(i == 0) {
            now = l.count(s[i]);
        } else {
            int next = l.count(s[i]);
            if(now != next) {
                ans++;
                now = next;
            }
        }
    }
    cout << ans << endl;
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        if(!solve()) {
            break;
        }
    }
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,x = 0;
    cin >> n;
    rep0(i, n){
        ll a;
        cin >> a;
        x ^= a;
    }
    if(x == 0)pf("Yes");
    else pf("No");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N-1];
		for(int i = 0;i < N;i++){
			A[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0;i < N;i++){
			B[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0;i < N-1;i++){
			C[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int ans = 0;
		for(int i = 0;i < N;i++){
			ans += B[A[i]-1];
			if(i > 0&& A[i] - A[i-1]==1){
				ans += C[A[i-1]-1];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    int a = 0, b = 0, ab = 0;
    for(int i = 0; i < n; i++)
    {
        string s; cin >> s;
        for(int j = 0; j < s.size() - 1; j++)
        {
            string t = s.substr(j, 2);
            if(t == "AB") ans++;
        }
        if(s[0] == 'B' && s.back() == 'A') ab++;
        else if(s[0] == 'B') b++;
        else if(s.back() == 'A') a++;
    }
    if(ab >= 2)
    {
        ans += ab - 1;
        ab = 1;
    }
    ans += min(a, b);
    a -= min(a, b);
    b -= min(a, b);
    if(a > 0) ans += min(a, ab);
    else if(b > 0) ans += min(b, ab);
    cout << ans << endl;
    return 0;
}



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

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

    int N;
    cin >> N;
    vector<int> X;
    vector<int> XSort;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        X.push_back(x);
        XSort.push_back(x);
    }
    sort(XSort.begin(), XSort.end());
    int mid1 = XSort[XSort.size() / 2 - 1];
    int mid2 = XSort[XSort.size() / 2];
    for (auto i : X) {
        if (i <= mid1) {
            cout << mid2 << endl;
        } else if (i >= mid2) {
            cout << mid1 << endl;
        }
    }
}

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

using namespace std;

const int MaxN = (int)3e5;
int H, W, N;
int sr, sc;
string S, T;
int cntS[MaxN][4];
int cntT[MaxN][4];

const int LEFT = 0;
const int RIGHT = 1;
const int UP = 2;
const int DOWN = 3;
int char2int(char ch)
{
    if(ch == 'L')
        return LEFT;
    if(ch == 'R')
        return RIGHT;
    if(ch == 'U')
        return UP;
    if(ch == 'D')
        return DOWN;
}
char int2char(int x)
{
    if(x == LEFT)
        return 'L';
    if(x == RIGHT)
        return 'R';
    if(x == UP)
        return 'U';
    if(x == DOWN)
        return 'D';
}

bool fall_off(int s_ch, int t_ch, int pos, int limit)
{
    for(int i = 0; i < N; i++)
    {
        if(S[i] == s_ch)
            pos++;
        if(pos > limit)
            return true;
        if(T[i] == t_ch)
            if(pos > 1)
                pos--;
    }
    return false;
}

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

    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> S;
    cin >> T;

    if(fall_off('U', 'D', H + 1 - sr, H) || fall_off('D', 'U', sr, H) || 
        fall_off('L', 'R', W + 1 - sc, W) || fall_off('R', 'L', sc, W))
        cout << "NO";
    else
        cout << "YES";
    // system("PAUSE");
    return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    int ans = 0;
    REP(i,n-1) {
        if (v[i] == i+1) {
            swap(v[i],v[i+1]);
            ans++;
        }
    }
    if (v.back() == v.size()) {
        swap(v[n-1],v[n-2]);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
long long n;
std::vector<long long> inp(n,0);
std::vector<std::vector<long long>> dp;
std::vector<std::vector<bool>> b;
long long f(long long s, long long e)
{
	//cout<<s<<" "<<e<<" \n";
	if(b[s][e]){return dp[s][e];}
	if(s==e)
	{
		b[s][e]=1;
		dp[s][e]=inp[s];
		return dp[s][e];
	}
	b[s][e]=1;
	dp[s][e]=(inp[s]-f(s+1,e));
	dp[s][e]=MAX(dp[s][e],(inp[e]-f(s,e-1)));
	return dp[s][e];
}
int main(){
	cin>>n;
	inp.resize(n,0);
	dp.resize(n+1,std::vector<long long>(n+1,0));
	b.resize(n+1,std::vector<bool>(n+1,0));
	REP(i,0,n-1){cin>>inp[i];}
	cout<<f(0,n-1)<<"\n";
}

Measured memory_bytes: 72192
#include <iostream>

using namespace std;
template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}

class XorWorld {
    uint64_t const A;
    uint64_t const B;
    uint64_t const diff;

    static uint64_t constexpr period = 4; // = 100b
    static uint64_t constexpr periodicMask = period - 1; // = 011b

    uint64_t GetXor () const {
        uint64_t ret;
        for (uint64_t i = A; i <=B; i++) {
            if (i == A) ret = i;
            else ret ^= i;
        }
        return ret;
    }

    uint64_t GetShortenA() const {
        uint64_t newDiff = (diff & periodicMask);
        if (newDiff == 0) newDiff = 4;
        return B - newDiff + 1;
    }

public : 
    XorWorld(uint64_t A_p, uint64_t B_p) : A(min(A_p, B_p)), B(max(A_p,B_p)), diff(B - A + 1) {}

    uint64_t Calculate() const {

        // When the size is too small, no problem even calculate greedly
        if (diff < (period + 1)) return GetXor();
       
        // Otherwise retry calculating after getting new A
        // If the A is even number.
        // Shorten A to (B - 1), (B - 2), (B - 3).            
        //return subWorld.Calculate();
        if ((A & 1) == 0) return XorWorld(GetShortenA(), B).GetXor();

        // Otherwise A is odd number and size is very large.
        // Separate numbers to A and then after((A + 1)(must be even number) to B)
        // Then calculate recursively.
        return A ^ XorWorld(A + 1, B).Calculate();
    }
};
int main() {
    uint64_t A(in<uint64_t>()), B(in<uint64_t>());
    XorWorld const world(A, B);
    cout << world.Calculate() << endl;
    return 0;
}




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

int main() {

	int L[100];
	for (int i = 0; i < 5; i++) {
		cin >> L[i];
	}
	sort(L, L + 5);

	int k;
	cin >> k;

	if (L[4] - L[0] > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  long long n;
  cin >> n;
  long long ans;
  cin >> ans;
  bool x = false;
  
  rep(i, n-1){    
    long long j;
    cin >> j;
    if(ans ==0)break;
    if(1000000000000000000/ans >= j){
       ans = ans*j;
    }
    else{
      ans = 1;
      x = true;
    }
  }
  
  if(x){
    if(ans == 0) cout << ans << endl;
    else cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
  
  
}
  
  

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

using namespace std;

int N, M, L, F[9];
double B[11], H[11], X[9];

double beet[13];

void put(int x, double &v, int l, int r)
{
  if(r - l >= 2) {
    int mx = l + 1;
    for(int i = l + 2; i < r; i++) if(H[i] > H[mx]) mx = i;
    if(x < mx) {
      put(x, v, l, mx);
      put(x, v, mx, r);
    } else {
      put(x, v, mx, r);
      put(x, v, l, mx);
    }
  }
  double w = B[r] - B[l], u = min(H[l], H[r]);
  double dh = v / w;

  if(beet[l] + dh < u) {
    v = 0;
    for(int i = l; i < r; i++) beet[i] += dh;
  } else {
    v -= (u - beet[l]) * w;
    for(int i = l; i < r; i++) beet[i] = u;
  }
}

int main()
{
  int D;
  cin >> D;
  while(D--) {
    cin >> N;
    ++N;
    for(int i = 1; i < N; i++) cin >> B[i] >> H[i];
    B[0] = 0, H[0] = 50;
    B[N] = 100, H[N] = 50;

    cin >> M;
    for(int i = 0; i < M; i++) {
      cin >> F[i] >> X[i];
      X[i] /= 30;
      F[i] = lower_bound(B, B + N, F[i]) - B-1;
    }
    cin >> L;
    while(L--) {
      int P, T;
      cin >> P >> T;
      memset(beet, 0, sizeof(beet));
      for(int i = 0; i < M; i++) {
        double cup = X[i] * T;
        put(F[i], cup, 0, N);
      }
      cout << fixed << setprecision(10) << beet[lower_bound(B, B + N, P) - B - 1] << endl;
    }
  }
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	string s;cin>>s;
	int cnt=0,ma=0;
	for(char c: s){
		if(c=='R'){
			cnt++;
			ma = max(cnt,ma);
		}
		else{
		
			cnt=0;
		}
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
alist = list(map(int, input().split()))
boxList = [0] * (n + 1)

m = 0
resultList = []

for i in range(1, n+1)[::-1]:
    sums = 0
    for j in range(1, n // i):
        sums += boxList[(j+1) * i]
    if sums % 2 != alist[i - 1]:
        boxList[i] = 1
        m+= 1
        resultList.append(i)

print(m)
if m != 0:
    print(' '.join(map(str, resultList)))

Measured memory_bytes: 19876
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


H, W = inpl()
S = ["#" + input().strip() + "#" for _ in range(H)]
S = ["#" * (W + 2)] + S + ["#" * (W + 2)]
sharp = sum(len(list(filter(lambda x: x == "#", s))) for s in S)
sharp -= 2 * H + (W + 2) * 2

mp = [[-1] * (W + 2) for i in range(H + 2)]
mp[1][1] = 0
Q = deque()
Q.append((1, 1))
dhw = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while Q:
    h, w = Q.popleft()
    for dh, dw in dhw:
        if S[h + dh][w + dw] == "#":
            continue
        elif mp[h + dh][w + dw] != -1:
            continue
        mp[h + dh][w + dw] = mp[h][w] + 1
        Q.append((h + dh, w + dw))

if mp[H][W] == -1:
    print(-1)
else:
    print(H * W - mp[H][W] - 1 - sharp)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().trim().split(" ");
        long n = Long.parseLong(s[0]);
        long m = Long.parseLong(s[1]);
        long c = (n-2)*(m-2);
        if(m==1 && n==1) {
            c = 1;
        } else if(n==1) {
            c = m-2;
        } else if(m==1) {
            c = n-2;
        } else if(n==2 || m==2) c = 0;
        System.out.println(c<0?0:c);
    }
}

Measured memory_bytes: 21332
A = [int(input()) for i in range(5)]
k = int(input())
ans = 0
for i in range(5):
    for x in range(i,5):
        if A[x] - A[i] > k:
            ans = ans + 1
if ans > 0:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main (){
	int N,L;
  int sum=0;
  cin >> N >> L;
  int min_index;
  int mi=abs(L);
  for (int i=0;i<N;i++){
  	sum += L+i;
    if (mi > abs (L +i)){
    	mi  = abs(L+i);
      	min_index =i;
    }
  }
  
  cout << sum - (L + min_index);
  

  
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int M, D;
	std::cin >> M >> D;

	int result = 0;
	for (int m = 1; m <= M; ++m) {
		for (int d = 22; d <= D; ++d) {
			if (d%10 < 2)
				continue;
			int d10 = d/10;
			int d1 = d%10;
			if (m == d1 * d10) {
				++result;
			}
		}
	}
	std::cout << result << "\n";
}


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

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

    // 初期化
    int A[100][100];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    int b[100];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    int c[100];
    for (int i = 0; i < n; i++) {
        c[i] = 0;
        for (int j = 0; j < m; j++) {
            c[i] += A[i][j] * b[j];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << c[i] << endl;
    }
}



Measured memory_bytes: 3092