akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define LL long long
#define MAXN 100005
 
struct P{
    LL index;
    LL dis;
    P(LL a = 0,LL b = 0):index(a),dis(b){;}
};
 
P line[MAXN];
 
LL root(LL &a){
    LL ret_val = 0;
    while(line[a].index != a){
        ret_val += line[a].dis;
        a = line[a].index;
    }
    return ret_val;
}
 
int main()
{
    int N,M;
    cin >> N >> M;
    _for(i,1,N+1){
        line[i] = P(i,0);
    }
    bool failed = false;
    _for(i,0,M){
        LL l,r,d;
        cin >> l >> r >> d;
        LL d1 = root(l);
        LL d2 = root(r);
        if(l != r){
            if(d1 + d > d2){
                line[r].index = l;
                line[r].dis = d1+d-d2;
            }
            else{
                line[l].index = r;
                line[l].dis = d2-d1-d;
            }
        }
        else if(l == r){
            if(d2 - d1 != d){
                failed = true;
                break;
            }
        }
    }
    if(failed) printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

const long long MOD = 1000000007;

using namespace std;

long long min_sum(long long num) {
    long long sum;

    sum = ((0 + (num - 1)) * num) / 2;

    return sum;
}

long long max_sum(long long num, long long dec) {
    long long i;
    long long sum = 0;

    for (i = 0; i < dec; i++) {
        sum += num;
        num--;
    }

    return sum;
}

int main(void) {

    long long i, j;
    long long n, k;
    long long sum = 0;
    long long temp;
    long long min, max;
    vector<long long> a;
    vector<long long> ans;

    cin >> n >> k;


    for (i = k; i <= n + 1; i++) {
        if (i == k) {
            min = min_sum(i);
            max = max_sum(n, i);
        }else{
            min += i - 1;
            max += n - i + 1;
        }


        sum += max - min + 1;
    }

    cout << sum % MOD << endl;

    return 0;
}

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

int main(){
  int a,b,c,m,ans=0,z;
  cin>>a>>b>>c;
  m=max(a,b);
  m=max(m,c);
  ans+=(m-a)/2+(m-b)/2+(m-c)/2;

  z=(m-a)%2+(m-b)%2+(m-c)%2;
  if(z==2) ans++;
  if(z==1) ans+=2;

  cout<<ans<<endl;
  return 0;
}


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

int main() {
  long long n, a, b;
  std::cin >> n >> a >> b;

  long long cnt = 0;

  cnt += (n / (a + b)) * a;
  cnt += std::min(n % (a + b), a);

  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int a[maxn],n,vis[maxn],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!vis[a[i]]) vis[a[i]]++,ans++;	
	}
	if(ans%2) cout<<ans;
	else cout<<ans-1;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;
#define mod (llint)1000000007
#define int_max 2147483647
#define ll_max (llint)9223372036854775807

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aのb乗を求める(1000000007で割った余りやで)
llint modpow(llint a, llint b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	llint tmp = modpow(a, b / 2);
	tmp %= mod;
	tmp = tmp * tmp % mod;
	if (b % 2)return tmp * a % mod;
	else return tmp;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= mod;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, mod);
		ans %= mod;
	}
	return ans;
}


int main() {
	char a, b;
	cin >> a >> b;
	if (a < b)cout << "<" << endl;
	else if (a > b)cout << ">" << endl;
	else cout << "=" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long
#define float double
const int INF = 10000000000000;
const float F_INF = 10000000000000.0;

signed main(void){
  int h,w;
  int ret = INF;
  int max_,min_;
  int h_,w_;
  float fh,fw;

  cin >> h >> w;
  fh = (float)h;
  fw = (float)w;
  h_ = h;w_ = w;

  max_ = 0;min_ = INF;
  h = h_; w = w_;
  max_ = max(max_, h*(w/3));
  min_ = min(min_, h*(w/3));
  w -= (w/3);
  max_ = max(max_, h*(w/2));
  min_ = min(min_, h*(w/2));
  max_ = max(max_, h*(w-w/2));
  min_ = min(min_, h*(w-w/2));
  ret = min(max_-min_, ret);

      max_ = 0;min_ = INF;
      h = h_; w = w_;
  max_ = max(max_, h*(w/3+1));
  min_ = min(min_, h*(w/3+1));
  w -= (w/3+1);
  max_ = max(max_, h*(w/2));
  min_ = min(min_, h*(w/2));
  max_ = max(max_, h*(w-w/2));
  min_ = min(min_, h*(w-w/2));
  ret = min(max_-min_, ret);

      max_ = 0;min_ = INF;
      h = h_; w = w_;
  max_ = max(max_, (h/3)*w);
  min_ = min(min_, (h/3)*w);
  h -= (h/3);
  max_ = max(max_, h*(w/2));
  min_ = min(min_, h*(w/2));
  max_ = max(max_, h*(w-w/2));
  min_ = min(min_, h*(w-w/2));
  ret = min(max_-min_, ret);


      max_ = 0;min_ = INF;
      h = h_; w = w_;
  max_ = max(max_, (h/3+1)*w);
  min_ = min(min_, (h/3+1)*w);
  h -= (h/3+1);
  max_ = max(max_, h*(w/2));
  min_ = min(min_, h*(w/2));
  max_ = max(max_, h*(w-w/2));
  min_ = min(min_, h*(w-w/2));
  ret = min(max_-min_, ret);


      max_ = 0;min_ = INF;
      h = h_; w = w_;
    max_ = max(max_, h*(w/3));
    min_ = min(min_, h*(w/3));
    w -= (w/3);
      max_ = max(max_, (h/2)*w);
      min_ = min(min_, (h/2)*w);
      max_ = max(max_, (h-h/2)*w);
      min_ = min(min_, (h-h/2)*w);
    ret = min(max_-min_, ret);

        max_ = 0;min_ = INF;
        h = h_; w = w_;
    max_ = max(max_, h*(w/3+1));
    min_ = min(min_, h*(w/3+1));
    w -= (w/3+1);
      max_ = max(max_, (h/2)*w);
      min_ = min(min_, (h/2)*w);
      max_ = max(max_, (h-h/2)*w);
      min_ = min(min_, (h-h/2)*w);
    ret = min(max_-min_, ret);

        max_ = 0;min_ = INF;
        h = h_; w = w_;
    max_ = max(max_, (h/3)*w);
    min_ = min(min_, (h/3)*w);
    h -= (h/3);
      max_ = max(max_, (h/2)*w);
      min_ = min(min_, (h/2)*w);
      max_ = max(max_, (h-h/2)*w);
      min_ = min(min_, (h-h/2)*w);
    ret = min(max_-min_, ret);


    max_ = 0;min_ = INF;
    h = h_; w = w_;
    max_ = max(max_, (h/3+1)*w);
    min_ = min(min_, (h/3+1)*w);
    h -= (h/3+1);
      max_ = max(max_, (h/2)*w);
      min_ = min(min_, (h/2)*w);
      max_ = max(max_, (h-h/2)*w);
      min_ = min(min_, (h-h/2)*w);
    ret = min(max_-min_, ret);

  cout << ret << "\r\n";
}


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

using namespace std;

int main()
{
  string S; cin >> S;

  int ans = 9999;
  for (int i = 0, len = S.size(); i < len-2; ++i) {
    ans = min(abs(stoi(S.substr(i, 3)) - 753), ans);
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t dfs(const vector<vector<int64_t>>& c, const vector<int64_t>& x, int64_t v) {
  int64_t s = 0, sy = 0;
  bitset<5001> bs;
  bs.set(0);
  for (auto i : irange(0uL, c[v].size())) {
    int64_t xx = x[c[v][i]];
    int64_t yy = dfs(c, x, c[v][i]);
    if (yy < 0) {
      return -1;
    }
    if (yy < xx) {
      swap(xx, yy);
    }
    yy -= xx;
    bs |= (bs << yy);
    s += xx;
    sy += yy;
  }
  if (s > x[v]) {
    return -1;
  }
  for (int64_t i = x[v] - s; i >= 0; --i) {
    if (bs[i]) {
      return sy - i;
    }
  }
  return -1;
}

main() {
  int64_t n;
  cin >> n;
  
  vector<int64_t> p(n, -1);
  vector<vector<int64_t>> c(n);
  for (auto i : irange(1L, n)) {
    cin >> p[i];
    --p[i];
    c[p[i]].push_back(i);
  }
  
  vector<int64_t> x(n);
  for (auto&& xx : x) {
    cin >> xx;
  }
  
  if (dfs(c, x, 0) >= 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
string alice, bob, charlie;
void alic();
void bo();
void cha();
int main() {

    cin >> alice >> bob >> charlie;
    alic();
    return 0;
}
void alic() {
    if(alice.empty()) cout << "A" << endl;
    else if (alice[0] == 'a') {
        alice.erase(0, 1);
        alic();
    } else if (alice[0] == 'b') {
        alice.erase(0, 1);
        bo();
    } else if (alice[0] == 'c') {
        alice.erase(0, 1);
        cha();
    }
}
void bo() {
    if(bob.empty()) cout << "B" << endl;
    else if (bob[0] == 'a') {
        bob.erase(0, 1);
        alic();
    } else if (bob[0] == 'b') {
        bob.erase(0, 1);
        bo();
    } else if (bob[0] == 'c') {
        bob.erase(0, 1);
        cha();
    }
}
void cha() {
    if(charlie.empty()) cout << "C" << endl;
    else if (charlie[0] == 'a') {
        charlie.erase(0, 1);
        alic();
    } else if (charlie[0] == 'b') {
        charlie.erase(0, 1);
        bo();
    } else if (charlie[0] == 'c') {
        charlie.erase(0, 1);
        cha();
    }
}

Measured memory_bytes: 256
function Main(input){
    input = parseInt(input);
    var i = Math.sqrt(input);

    var array = [];
    for (var index = 1; index <= i; index++) {
        if(input%index == 0){
            array.push(input/index+index);
        }
    }
    console.log(array.reduce((a,b)=>Math.min(a,b))-2);
}

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

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

using namespace std;

int main(){
    int a,b,c,n;
    cin >> n;
    a = n/100;
    b = (n%100)/10;
    c = (n%10);

    if(a==7||b==7||c==7){
        cout << "Yes" <<endl;
    }else {
        cout << "No";
    }

}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int H, W, A, B; cin >> H >> W >> A >> B;
  int r[H][W]; rep(i,H) rep(j,W) r[i][j] = (i<B)^(j<A);
  rep(i,H) { rep(j,W) cout << r[i][j]; cout << endl; };
  return 0;
}

Measured memory_bytes: 5120
n = int(input())
a = []
for i in range(n):
  si = str(input())
  a.append(si)
a.sort()
mx = 1
w = []
j = 1
for i in range(1,n):
  if a[i] == a[i-1]:
    j += 1
  else:
    if j > mx:
      w = [a[i-1]]
      mx = j
    elif j == mx:
      w.append(a[i-1])
    j = 1
if j > mx:
  w = [a[n-1]]
elif j == mx:
  w.append(a[n-1])
for wi in w:
  print(wi)
    
    
  

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

typedef long long LL;

const int N = 1e5;
const LL MOD = 1e9+7;

int n;
vector<int> adj[N+5];
vector<int> tadj[N+5];

void dfs(int x=1, int y=-1){
   for(int i=0;i<adj[x].size();i++){
      int now = adj[x][i];
      if(now == y) continue;
      tadj[x].push_back(now);
      dfs(now,x);
   }
   return;
}

LL memo[N+5][3];

LL dp(int node, int col){
   if(tadj[node].size() == 0){
      if(col == 0) return 2LL;
      else return 1LL;
   }
   LL &ret = memo[node][col];
   if(ret!=-1) return ret;
   ret = 0;
   if(col == 0){//hitam
      LL tmp = 1LL;
      for(int i=0;i<tadj[node].size();i++){
         tmp*=dp(tadj[node][i],1);
         tmp%=MOD;
      }
      ret+=tmp;
      ret%=MOD;
   }
   LL tmp = 1LL;
   for(int i=0;i<tadj[node].size();i++){
      tmp*=dp(tadj[node][i],0);
      tmp%=MOD;
   }
   ret+=tmp;
   ret%=MOD;
   return ret;
}


int main(){
   memset(memo,-1,sizeof(memo));
   scanf("%d",&n);
   for(int i=1;i<n;i++){
      int u,v;
      scanf("%d%d",&u,&v);
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   dfs();
//   cout << "DONE\n";
   LL ans = dp(1,0);
   printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 20480
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

bool sheep[100010] = {};

bool check(string s, int n) {
  for (int i = 0; i < n; i++) {
    int nx = (i + 1) % n;
    int nx2 = (i + 2) % n;

    if (i >= n - 2) {
      if (sheep[nx]) {
        if (s[nx] == 'o') {
          if (sheep[i] != sheep[nx2]) return false;
        } else {
          if (sheep[i] == sheep[nx2]) return false;
        }
      } else {
        if (s[nx] == 'o') {
          if (sheep[i] == sheep[nx2]) return false;
        } else {
          if (sheep[i] != sheep[nx2]) return false;
        }
      }

    } else {
      if (sheep[nx]) {
        sheep[nx2] = s[nx] == 'o' ? sheep[i] : !sheep[i];
      } else {
        sheep[nx2] = s[nx] == 'o' ? !sheep[i] : sheep[i];
      }
    }
  }
  return true;
}

void output(int n) {
  REP(i, n) {
    if (sheep[i]) {
      cout << "S";
    } else {
      cout << "W";
    }
  }
  cout << endl;
}

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

  int N;
  cin >> N;

  string s;
  cin >> s;

  sheep[0] = true;
  sheep[1] = true;
  if (check(s, N)) {
    output(N);
    return 0;
  }

  sheep[0] = true;
  sheep[1] = false;
  if (check(s, N)) {
    output(N);
    return 0;
  }

  sheep[0] = false;
  sheep[1] = false;
  if (check(s, N)) {
    output(N);
    return 0;
  }

  sheep[0] = false;
  sheep[1] = true;
  if (check(s, N)) {
    output(N);
    return 0;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    vector<int> A(N);

    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }

    long long ans = 0;
    int a = 0;
    int j = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( ; j < N && (a&A[j]) == 0; j++ ) { a |= A[j]; }
        ans += j-i;
        a ^= A[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

using namespace std;
using ll = long long;


int main() {
    int n, k; cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    ll ans = 1ll << 60;
    for (int i = 0; i + k - 1 < n; ++i) {
        ll left = x[i], right = x[i + k - 1];
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)

ll n,m,a=0;

int main() {
    cin>>n;
    rep(i,n){
        cin>>m;
        a^=m;
    }
    if(a==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,M;
cin >> N >> M;
vector<vector<int>> vec(N,vector<int>(M+1));
for (int i = 0;i < N;i++) {
    int K;
    cin >> K;
    for (int j = 0;j < K;j++) {
        int a;
        cin >> a;
        vec.at(i).at(a) = a;
    }
}
int cnt = 0;
for (int i = 1;i <= M;i++) {
    bool ans = true;
    for (int j = 0;j < N;j++) {
        if (vec.at(j).at(i) != i) ans = false;
    }
    if (ans == true) cnt++;
}
cout << cnt << endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n*3),mx(n*3),mi(n*3);
    rep(i,n*3) cin >> a[i];
    priority_queue<ll> nmi;
    ll sum = 0;
    for(int i = n*3-1; i >= n*2; i--) {
        nmi.push(a[i]);
        sum += a[i];
    }
    mi[n*2] = sum;
    for(int i = n*2-1; i >= n; i--) {
        sum += a[i];
        nmi.push(a[i]);
        sum -= nmi.top();
        nmi.pop();
        mi[i] = sum;
    }
    priority_queue<ll,vector<ll>,greater<>> nmx;
    sum = 0;
    rep(i,n) {
        nmx.push(a[i]);
        sum += a[i];
    }
    mx[n-1] = sum;
    rep2(i,n,n*2) {
        sum += a[i];
        nmx.push(a[i]);
        sum -= nmx.top();
        nmx.pop();
        mx[i] = sum;
    }
    ll ans = -1001001001001001;
    rep2(i,n-1,n*2) {
        chmax(ans,mx[i]-mi[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9588
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

t = ['Sunny', 'Cloudy', 'Rainy']
s = input()
print(t[t.index(s)+1] if t.index(s)<2 else t[0])

Measured memory_bytes: 3060
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"sort"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
 
func nextString() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var N, ANS int
func main() {
	N = nextInt()
	m := make(map[string]int, N)
	for i := 0; i < N; i++ {
		s := SortString(nextString())
		m[s] = m[s] + 1
	}
	for _, v :=  range m {
		ANS += patternCount(v)
	}
	fmt.Println(ANS)
}

func SortString(w string) string {
    s := strings.Split(w, "")
    sort.Strings(s)
    return strings.Join(s, "")
}

func patternCount(n int) int {
	return (n * n - n) / 2
}

func max(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 16012
#include <stdio.h>

int check(int,int);

int S[100000];

int main(void){
  int n,q,key,i,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(check(key,n)==1)count++;
  }
  printf("%d\n",count);
  return 0;
}

int check(int key,int n){
  int left,right,mid;
  left=0;
  right=n;
  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==key)return 1;
    else if(S[mid]<key)left=mid+1;
    else right=mid;
  }
  return 2;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)
LL N;

void solve()
{
    cin >> N;

    for (LL a = 1; a <= 3500; a++)
    {
        for (LL b = a; b <= 3500; b++)
        {
            LL denom = 4 * a * b - N * (a + b);

            if (denom >= 1 and (a * b * N) % (denom) == 0)
            {
                std::cout << a << " " << b << " ";
                std::cout << (a * b * N) / denom << endl;
                return;
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 112000000012345L

template<typename T>
class MaximumFlow{
private:
  struct edge{int to; T cap; int rev;};
  vector<vector<edge> > Graph;
  vector<int> level, iter; //sからの距離,どこまで調べたか
  void bfs(int s){
    fill(all(level), -1);
    queue<int> q;
    level[s]=0;
    q.push(s);
    while(!q.empty()){
      int v=q.front(); q.pop();
      for(auto e : Graph[v]){
        if(e.cap>0 && level[e.to]<0){
          level[e.to] = level[v]+1;
          q.push(e.to);
        }
      }
    }
  }
  T dfs(int v, int t, T f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)Graph[v].size(); i++){
      auto &e = Graph[v][i];
      if(e.cap>0 && level[v]<level[e.to]){
        T d = dfs(e.to, t, min(f, e.cap));
        if(d>0){
          e.cap -= d;
          Graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
public:
  MaximumFlow(int n){
    Graph = vector<vector<edge> >(n, vector<edge>());
    level = vector<int>(n);
    iter = vector<int>(n);
  }
  T max_flow(int s, int t){
    T flow=0;
    while(true){
      bfs(s);
      if(level[t] < 0) break;
      fill(all(iter), 0);
      T f;
      while( (f=dfs(s,t,INF)) > 0){
        flow += f;
      }
    }
    return flow;
  }
  void add_edge(int from, int to, T cap){
    int tos = Graph[to].size(), froms = Graph[from].size();
    Graph[from].pb(((edge){to, cap, tos}));
    Graph[to].pb(((edge){from, 0, froms}));
  }
};

int main(){
  int n;
  cin>>n;
  vector<long> v(n);
  rep(i,n) cin>>v[i];

  MaximumFlow<long> flow(n+2);
  int s = 0, t = n+1;
  long acc = 0;
  // rep(i,n){
  //   flow.add_edge(s, i+1, max(0L, -v[i]));
  //   flow.add_edge(i+1, t, max(0L, v[i]));
  //   for(int x = i; x>0; x--) if((i+1)%x==0) flow.add_edge(x, i+1, INF);
  //   acc += max(0L, v[i]);
  // }
  rep(i,n){
    int x = i+1;
    flow.add_edge(s, x, max(0L, v[i]));
    flow.add_edge(x, t, max(0L, -v[i]));
    for(int y=x-1; y>0; y--) if(x%y==0) flow.add_edge(x, y, INF);
    acc += max(0L, v[i]);
  }

  cout << acc - flow.max_flow(s,t) << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$s.="R";
$ans=array_fill(0,$n,0);
$i=0;
$count=0;
$check=0;
while($i<$n){
  if($count%2==0){
    $lr=strpos($s,"L",$i);
    $d=$lr-$i;
    $ans[$lr-1]+=ceil($d/2);
    $ans[$lr]+=floor($d/2);
    $i+=$d;
  }else{
    $lr=strpos($s,"R",$i);
    $d=$lr-$i;
    $ans[$i-1]+=floor($d/2);
    $ans[$i]+=ceil($d/2);
    $i+=$d;
  }
  ++$count;
}
echo join(" ",$ans);

Measured memory_bytes: 35576
import sys
input = sys.stdin.readline

n = int(input())
prime = []
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
for i in range(2, 55556):
    if is_prime(i) and i % 5 == 1:
        prime.append(i)
print(*prime[:n])

Measured memory_bytes: 3060
#include <cstdio>

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

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d\n", a < b ? b + max(a, b - 1) : a + max(a - 1, b));
  return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int h1,m1;
int h2,m2;
int k;

bool compare() {
	if(h2 > h1) return true;
	if(h2 == h1) {
		if(m2 >= m1) return true;
		return false;
	}
	return false;
}

int main() {
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int totalMin;

	if(compare()) {
		totalMin = (h2 * 60 + m2) - (h1 * 60 + m1);
	} else {
		totalMin = 24 * 60 - ((h1 * 60 + m1) - (h2 * 60 + m2));
	}
	cout << max(0, totalMin - k) << endl;

	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner ss=new Scanner(System.in);
        long p,x,xx,c;
        p=ss.nextLong(); x=ss.nextLong(); xx=ss.nextLong();
        if(x>xx){
            c=xx;
            xx=x;
            x=c;
        }
        
        
        p+=x;
        xx-=p;
        if(xx<0) xx=0;
        System.out.println(xx);
    }
}

Measured memory_bytes: 21844
/* ABC069_B
    Stuartyg */

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


int main(void){
        char str[150]; //sのこと.これだけあれば安心
        int length; //sの間に入っている文字数を求めるための変数
        scanf("%s",str);//標準入力からの受取り

        length = strlen(str)-2; //strの間に入っている文字数
        printf("%c%d%c\n",str[0],length,str[length+1]); //0始まりなので終わりの文字は(length+1)番目
        return 0;
}



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

int main() {
  int K,A,B;
  cin>>K>>A>>B;
  for(int i=0; i<K; i++){
    if(A%K==0){
      cout<<"OK"<<endl;
      break;
    }
    A+=1;
    if(A>B){
      cout<<"NG"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3628
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int cardsSize = scan.nextInt();
		boolean isStable = true;
		boolean boubleFlag = true;
		String[] cards = new String[cardsSize];
		for(int i = 0; i < cardsSize; i++) {
			cards[i] = scan.next();
		}
		String[] boubleCards = Arrays.copyOf(cards , cardsSize);
		String[] selectionCards = Arrays.copyOf(cards , cardsSize);

		//bouble
		while(boubleFlag) {
			boubleFlag = false;
			for(int n = cardsSize - 1; n > 0 ; n--) {
			String tmp = boubleCards[n];
				if(boubleCards[n].charAt(1) < boubleCards[n-1].charAt(1)) {
					boubleCards[n] = boubleCards[n-1];
					boubleCards[n-1] = tmp;
					boubleFlag = true;
				}
			}
		}



		//selectionSort
		for(int n = 0; n < cardsSize; n++) {
			int point = 0;
			String min = selectionCards[n];
			for(int j = n + 1; j < cardsSize; j++) {
				if(selectionCards[j].charAt(1) < min.charAt(1)) {
					min = selectionCards[j];
					point = j;
				}
			}
			if(min != selectionCards[n]) {
				selectionCards[point] = selectionCards[n];
				selectionCards[n] = min;
			}
		}


		for(int i = 0 ; i < cardsSize; i++) {
			System.out.print(boubleCards[i]);
			if(i != cardsSize-1){
				System.out.print(" ");
			} else {
				System.out.println();
		    }
		}
		System.out.println("Stable");


		for(int i = 0 ; i < cardsSize; i++) {
			System.out.print(selectionCards[i]);
			if(!(boubleCards[i].equals(selectionCards[i]))){
				isStable = false;
			}
			if(i != cardsSize-1){
				System.out.print(" ");
			} else {
				System.out.println();
		    }
		}
		if(isStable) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
	    }
    }
}


Measured memory_bytes: 26364
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("\\s");
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a < b){
       System.out.println("a < b");
    }else if(a > b){
       System.out.println("a > b");
    }else{
       System.out.println("a == b");
    }  

       
   
  }

}

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

int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, pair<int, int>>> d;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n/2; i++) {
        d.push_back({i+1, {i, i*2+1}});
        d.push_back({i-n/2, {i+n/2, i*2}});
    }
    if (n & 1) {
        d.push_back({0, {n-1, n-1}});
    }
    sort(d.begin(), d.end());
    for (int i = 0; i < n; i++) {
        auto u = n+k+i;
        auto p = d[i].second.first + k;
        auto q = d[i].second.second + k + n*2;
        if (u > q-p) {
            cout << -1 << endl;
            return 0;
        }
        a[i] = p;
        b[i] = u;
        c[i] = q;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << " " << b[i] << " " << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4724
#include <stdio.h>
int n;
int ans;
char s[5001];
int x[5000];
int y;
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)x[j] = 0;
		for (int j = i; j < n; j++) {
			if (s[j] == s[j - i])x[j - i]++;
		}
		y = 0;
		for (int j = 0; j < n; j++) {
			if (x[j])y++;
			else y = 0;
			if (y <= i && y > ans)ans = y;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
'''
標準入力
4 4
1 9 3 5
'''

n,m=list(map(int, input().split()))
a=list(map(int, input().split()))
b=[-a[i] for i in range(n)]
#print(b) => [-1, -9, -3, -5]

import heapq
heapq.heapify(b)
#print(b) => [-9, -5, -3, -1]

for i in range(m):
	maximum=heapq.heappop(b)
#forなしでprint(maximum) => -9
	
	maximum=-(-maximum//2)
	heapq.heappush(b,maximum)
print((sum(b))*(-1))

Measured memory_bytes: 15020
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<queue<int> > a(n);
    queue<int> q;
    for(int i=0; i<n; ++i){
        q.push(i);
        for(int j=0; j<n-1; ++j){
            int tmp;
            cin >> tmp;
            -- tmp;
            a[i].push(tmp);
        }
    }

    vector<int> day(n, 0);
    int ans = 0;
    int rest = n * (n - 1) / 2;
    while(rest > 0 && !q.empty()){
        ++ ans;
        int m = q.size();
        while(--m >= 0){
            int x = q.front();
            q.pop();
            if(a[x].empty() || day[x] == ans)
                continue;

            int y = a[x].front();
            if(a[y].empty() || day[y] == ans)
                continue;

            if(a[y].front() == x){
                a[x].pop();
                a[y].pop();
                q.push(x);
                q.push(y);
                day[x] = day[y] = ans;
                -- rest;
            }
        }
    }

    for(int i=0; i<n; ++i){
        if(!a[i].empty()){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

// n の i ビット目と j ビット目を swap する
void swp(int &n, int i, int j) {
    if ((n >> i & 1) ^ (n >> j & 1) == 0) return;
    n ^= (1 << i);
    n ^= (1 << j);
}

// [0, n) ビット目を使って a を b にする
vector<int> dfs(int n, int a, int b) {
    if (n == 1) return {a, b};

    b ^= a;
    int msb = (b) ? 31 - __builtin_clz(b) : n - 1;
    swp(b, n - 1, msb);

    int onehot = 1 << (n - 1);
    int mask = onehot - 1;
    auto first = dfs(n - 1, 0, 1);
    auto second = dfs(n - 1, 1, b & mask);

    vector<int> res;
    for (auto x : first) res.push_back(x);
    for (auto x : second) res.push_back(x | onehot);

    for (auto& x : res) swp(x, n - 1, msb);
    for (auto& x : res) x ^= a;
    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (!__builtin_parity(a ^ b)) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    auto res = dfs(n, a, b);
    for (int i = 0; i < res.size(); i++) {
        cout << res[i] << ((i == res.size() - 1) ? "\n" : " ");
    }
}


Measured memory_bytes: 1628
#include<stdio.h>
int main(){
   long long int n;
    scanf("%lld",&n);
    long long int a[n];
    for(long long int i=0;i<n;i++)
    scanf("%lld",&a[i]);
   // printf("%d  ",a[0]);
    long long int sum=0;
    long long int d=0;
    for(long long int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            d=a[i-1]-a[i];
            sum=sum+d;
            a[i]=a[i-1];
        }
       // printf("i=%d d is %d     sum is %d\n",i,d,sum);
    }
    printf("%lld",sum);
}

Measured memory_bytes: 3216
#include <stdio.h>
int main(void){
	int a,b,c;
	a=1;
	for(a=1;a<10;a++){
		for(b=1;b<10;b++){
			c=a*b;
			printf("%dx%d=%d\n", a, b, c);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){

  string str;

  cin>>str;

  bool judge=1;

  if(str[0]!='A'||str[1]<'a'||str[str.length()-1]<'a'){
    judge=0;
  }else {

    int judge1=0;
    
    for(int i=2;i<str.length()-1;i++){

      
      if(str[i]=='C'){
	judge1++;
      }else if(str[i]<'a'){
	judge=0;
      }
    }

    if(judge1==0||judge1>1){
      judge=0;
    }
    

  }
  if(judge){

    cout<<"AC"<<endl;
  }else{

    cout<<"WA"<<endl;

  }

  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	vector<string> s(3);
	bool chk=true;
	for(int i=0;i<3;i++){
		cin >> s.at(i);
		if(i>0){
			if(s.at(i).at(0)!=s.at(i-1).at(s.at(i-1).size()-1))chk=false;
		}
	}
	if(chk){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

def main():
    if H % 3 == 0 or W % 3 == 0:
        return 0
    total = H * W
    ans = 10 ** 20
    for i in range(W):
        one = H * (i+1)
        two = (W-(i+1)) * (H//2)
        three = total - one - two
        ans = min(ans, max([one, two, three]) - min([one, two, three]))
        two = (W-(i+1))//2 * H
        three = total - one - two
        ans = min(ans, max([one, two, three]) - min([one, two, three]))
        two = (W-(i+1))//2 * H
    return ans

ret = main()
H, W = W, H
ret2 = main()
print(min(ret, ret2))


Measured memory_bytes: 73784
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int a,b,res=-10000000;
    scanf("%d %d\n",&a,&b);

    res=max(a+b,a-b);
    res=max(res,a*b);
    printf("%d\n",res);
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(std::string S, std::string T, long long A, long long B,
           std::string U) {
    if (U == S)
        A--;
    else
        B--;

    cout << A << " " << B << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    cin >> A;
    long long B;
    cin >> B;
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		string s; cin >> s;
		int len = s.size();
		vector<int> ans(len);
		for (int i = 0; i < 2; ++i) {
			int cnt = 0;
			for (int j = 0; j < len; ++j) {
				if (s[j] == 'R') {
					cnt++;
				} else {
					ans[j] += cnt / 2;
					ans[j - 1] += (cnt + 1) / 2;
					cnt = 0;
				}
			}
			reverse(all(s));
			reverse(all(ans));
			rep (j, len) {
				if (s[j] == 'L') s[j] = 'R';
				else s[j] = 'L';
			}
		}
		rep (i, len) {
			cout << ans[i] << endl;
		}
    return;
}

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



Measured memory_bytes: 1024
N, K = map(int, input().split())
H = list(map(int, input().split()))
for _ in range(K+2):
    H.append(10**9)
dp = [10**9] * (N+K+1)
dp[0] = 0
# ひっぱる
for i in range(1, N):
    tmp = 10 ** 9
    for j in range(1, K+1):
        # 最小の移動コストを計算
        tmp = min(tmp, dp[i-j] + abs(H[i]-H[i-j]))
    dp[i] = tmp
print(dp[N-1])



Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>



int main() {
	fastio;
    lli n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<"\n";
	return 0;
}


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

int main() {
  long a,b,x;
  cin>>a>>b>>x;
  long ans=0;
  ans = b/x;
  long res;
  if(a==0) res=-1;
  else res=(a-1)/x;
  cout << ans -res <<endl;
  }


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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for (int i = 0; i < n; i++)
    cin >> x[i];

  ll ans = 1e18;
  for (int i = 0; i <= n - k; i++) {
    int j = i + k - 1;
    if (x[j] <= 0) {
      ans = min(ans, abs(x[i]));
    } else if (x[i] <= 0 && x[j] >= 0) {
      ans = min(ans, abs(x[i]) + x[j] + min(abs(x[i]), x[j]));
    } else {
      ans = min(ans, x[j]);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  int sum;
  sum = N%10 + N/10%10 + N/100%10 + N/1000%10 + N/10000%10 + N/100000%10 + N/1000000%10 + N/10000000%10 + N/100000000%10;
  
  if (N%sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
    int n;
    ll sum = 0;
    cin >> n;

    for(int i = 1; i<n+1; i++) {
        int v = (n-1)/i;
        sum += v;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s, t;
int cont = 0;
int main(){
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]){
			cont++;
		}
	}
	cout << cont << endl;
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
using namespace std;
#define debug cout<<"OK"<<endl;
#define int long long
const int MAXN=500005;
int n;
string s;
bool a[MAXN];
int mn=0;
int ans=0;
int pre[MAXN],nex[MAXN];

signed main()

{
	ios::sync_with_stdio(false);
	cin>>s;
	int n=s.size();
	for (int i=0;i<n;i++)
		a[i+1]=s[i]=='<';
	a[0]=true;

	for (int i=1;i<=n;i++){
		if (a[i]) pre[i]=pre[i-1]+1;
		else pre[i]=0;
	}

	for (int i=n-1;i>=0;i--){
		if (!a[i+1]) nex[i]=nex[i+1]+1;
		else nex[i]=0;
	}

	for (int i=0;i<=n;i++){
		//cout<<pre[i]<<" "<<nex[i]<<endl;
		ans+=max(pre[i],nex[i]);
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9116
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 3e2 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k;
	cin >> n >> k;
	if (!k)
		f(1LL * n * n);
	ll ans = 0;
	lp(i,k+1,n)
	{
		ans += (i - k);
		ans += (1LL * ((n / i) - 1) * (i - k));
		int z = (n % i) - (k - 1);
		ans += max(0, z);
	}
	f(ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
Ps = [int(i) for i in input().split(" ")]
Qs = list(sorted(Ps))
cnt = 0
for i in range(N):
  if Ps[i] != Qs[i]:
    cnt += 1
if cnt == 0 or cnt == 2: print("YES")
else: print("NO")


Measured memory_bytes: 2940
#coding:utf-8

S = input()

candidate1 = []
candidate2 = []
for i in range(len(S)):
    candidate1.append(str(i%2))
    candidate2.append(str((i+1)%2))

dif1 = dif2 = 0
for enu, i in enumerate(S):
    if i!= candidate1[enu]:
        dif1 += 1
    if i!= candidate2[enu]:
        dif2 += 1
    
print(min(dif1, dif2))    


Measured memory_bytes: 15860
#include <stdio.h>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

void bubble_sort(const std::vector<std::string>& arr, std::vector<std::string>& sorting_arr)
{
  using std::swap;
  sorting_arr.resize(arr.size());
  std::copy(arr.begin(), arr.end(), sorting_arr.begin());
  for (int i = 0; i < sorting_arr.size(); i++) {
    for (int j = sorting_arr.size() - 1; j > i; j--) {
      if (sorting_arr[j][1] < sorting_arr[j - 1][1]) {
        swap(sorting_arr[j], sorting_arr[j - 1]);
      }
    }
  }
}

void selection_sort(const std::vector<std::string>& arr, std::vector<std::string>& sorting_arr)
{
  using std::swap;
  sorting_arr.resize(arr.size());
  std::copy(arr.begin(), arr.end(), sorting_arr.begin());
  for (int i = 0; i < sorting_arr.size() - 1; i++) {
    int minv = i;
    for (int j = i + 1; j < sorting_arr.size(); j++) {
      if (sorting_arr[minv][1] > sorting_arr[j][1]) {
        minv = j;
      }
    }
    if (i != minv) {
      swap(sorting_arr[i], sorting_arr[minv]);
    }
  }
}

bool is_stable(const std::vector<std::string>& arr, const std::vector<std::string>& stably_sorted_arr)
{
  return arr == stably_sorted_arr;
}

void output(const std::vector<std::string>& arr)
{
  for (int i = 0; i < arr.size(); i++) {
    if (i == arr.size() - 1) {
      printf("%s\n", arr[i].c_str());
    }
    else {
      printf("%s ", arr[i].c_str());
    }
  }
}

int main()
{
  int N;
  std::vector<std::string> arr;
  std::vector<std::string> bubble_sorted_arr;
  std::vector<std::string> selection_sorted_arr;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    char str[3];
    scanf("%s", str);
    arr.push_back(std::string(str));
  }

  bubble_sort(arr, bubble_sorted_arr);
  output(bubble_sorted_arr);
  puts("Stable");

  selection_sort(arr, selection_sorted_arr);
  output(selection_sorted_arr);
  if (is_stable(selection_sorted_arr, bubble_sorted_arr)) {
    puts("Stable");
  }
  else {
    puts("Not stable");
  }

  return 0;
}



Measured memory_bytes: 2844