akhauriyash/Code-Regression huggingface dataset:
pattern = input()

temp = [0] * len(pattern)
ans = []

while "LR" in pattern:
    pR = pattern.find("RL")
    pL = pattern.find("LR")
    temp = [0] * (pL+1)
    for i in range(pR-1):
        temp[i] = 0
    if (pL+1)%2 == 0:
        temp[pR] = int((pL+1)/2) 
        temp[pR+1] = int((pL+1)/2)
    else:
        if pR%2 == 0:
            temp[pR] = int(pL/2+1) 
            temp[pR+1] = int(pL/2)
        else:
            temp[pR+1] = int(pL/2+1) 
            temp[pR] = int(pL/2)
    ans += temp
    pattern = pattern[pattern.find("LR")+1:len(pattern)]

pR = pattern.find("RL")
pL = len(pattern)-1
temp = [0] * (pL+1)
for i in range(pR-1):
    temp[i] = 0
if (pL+1)%2 == 0:
    temp[pR] = int((pL+1)/2) 
    temp[pR+1] = int((pL+1)/2)
else:
    if pR%2 == 0:
        temp[pR] = int(pL/2+1) 
        temp[pR+1] = int(pL/2)
    else:
        temp[pR+1] = int(pL/2+1) 
        temp[pR] = int(pL/2)
ans += temp

print(" ".join(map(str,ans)))

Measured memory_bytes: 11876
using System;
using System.Linq;

namespace AtCoder20200404
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int N = int.Parse(inputs[0]);
            int M = int.Parse(inputs[1]);
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int total = A.Sum();
            Array.Sort(A);
            Array.Reverse(A);
            if(A[M-1] * 4 * M >= total)
            {
                Console.WriteLine("Yes");
            }
            else
            { 
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13396
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	S = input()
	T = input()
	N = len(S)
	ans = 0
	for i in range(N):
		if S[i] != T[i]:
			ans += 1


	print(ans)




if __name__ == '__main__':
	main()

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;
int A[100100];
int d[100100];

signed main() {
    cin >> N;
    int costN = 0;
    A[0] = 0;
    A[N + 1] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        d[i] = abs(A[i] - A[i - 1]);
        costN += d[i];
    }
    d[N + 1] = abs(A[N + 1] - A[N]);
    costN += d[N + 1];
    
    for (int i = 1; i <= N; ++i) {
        int cost = costN - d[i] - d[i + 1] + abs(A[i + 1] - A[i - 1]);
        cout << cost << endl;
    }
}

Measured memory_bytes: 2816
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int cnt = 0;
    Set<Integer> set = new TreeSet<>();

    for(int i = 1; i <= n; i+=2){
      int tmp = i;
      for(int j = 1; j <= Math.sqrt(tmp); j++){
        if(tmp % j == 0){
          set.add(tmp);
          set.add(j);
          set.add(tmp / j);
        }
      }
      if(set.size() == 8){
        cnt++;
      }
      set.clear();
    }

    System.out.println(cnt);

  }
}


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

#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5+7;

int n;
ll bit[N+9], res;
pii a[N];

ll get(int i)
{
    ll ans = 0;
    for (; i > 0; i -= (i&-i))
        ans = max(ans, bit[i]);
    return ans;
}

void Set(int i, ll val)
{
    for (; i <= n; i += (i&-i))
        bit[i] = max(val, bit[i]);
}

int main() 
{
	cin >> n;
	for (int i=1; i<=n; i++) 
	    cin >> a[i].fi;
	for (int i=1; i<=n; i++) 
	    cin >> a[i].se;
	
	for (int i=1; i<=n; i++)
	{
        ll cur = get(a[i].fi) + a[i].se;
        res = max(res, cur);
        Set(a[i].fi, cur);
	}
	cout << res;
	return 0;
}

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

namespace AtCoder
{
    class Abc169A
    {
        public static void Main()
        {
            var ab = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}


Measured memory_bytes: 28296
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,k=map(int,input().split())
    A=list(map(lambda x:int(x)-1,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]
        S[i+1]%=k

    C=defaultdict(int)
    ans=0
    for i in range(n+1):
        if(i-k>=0):
            C[S[i-k]]-=1
        ans+=C[S[i]]
        C[S[i]]+=1
    print(ans)
resolve()

Measured memory_bytes: 105704
def main():
    s = input()
    res = 0
    for i in range(len(s) + 1):
        for j in range(i + 1, len(s) + 1):
            ss = s[i:j]
            if not all(c in "ACGT" for c in ss):
                continue
            if len(ss) > res:
                res = len(ss)
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100010;
const ll MOD = 1e9+7;
ll fact[3*MAXN], rfact[3*MAXN];

// extgcd
ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}
// mod_inverse
ll mod_inverse(ll a, ll m = MOD) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m+x%m) % m;
}

ll nCr(int n, int r) {
    ll ret = fact[n];
    (ret *= rfact[r]) %= MOD;
    (ret *= rfact[n-r]) %= MOD;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact[0] = rfact[0] = 1;
    for (int i = 1; i < 3*MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = mod_inverse(fact[i]);
    }
    int N, M, K;
    cin >> N >> M >> K;
    ll ans = 0;
    int total = N+M+2*K;
    for (int i = 0; i <= K; i++) {
        int yoko = N+2*i;
        int tate = M+2*(K-i);
        ll y = nCr(yoko, i);
        if (i > 0) {
            (y -= nCr(yoko, i-1)) %= MOD;
            if (y < 0) y += MOD;
        }
        ll t = nCr(tate, (K-i));
        if (K-i > 0) {
            (t -= nCr(tate, (K-i)-1)) %= MOD;
            if (t < 0) t += MOD;
        }
        ll plus = (y*t)%MOD;
        (plus *= nCr(total, yoko)) %= MOD;
        ans += plus;
    }
    cout << ans%MOD << endl;
    return 0;
}

Measured memory_bytes: 5876
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
//#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000
#define N_max 100

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

long int check(long int sum, long int ans, vector<int> T, int N, bool pre_pm) {

    for(int i = 0; i < N; i ++) {
        if(pre_pm) {
            sum += T.at(i);
            //while (0 <= sum) {
            if (0 <= sum) {
                ans += (abs(sum) + 1);
                sum -= (abs(sum) + 1);
            }
            pre_pm = false;
        } else {
            sum += T.at(i);
            //while (sum <= 0 ) {
            if (sum <= 0) {
                ans += (abs(sum) + 1);
                sum += (abs(sum) + 1);
            }
            pre_pm = true;
        }
    }
    return ans;
}
 
int main()
{
    int N;
    vector<int> T;

    cin >> N;

    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        T.push_back(tmp);
    }

    long int ans = 0;   
    long int sum = 0;

    bool pre_pm;

    cout << min(check(sum, ans, T, N, true), check(sum, ans, T, N, false)) << endl;

    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    typedef bitset< 51 > bitset_t; 

    struct canvas_t: array< bitset_t, 52 > 
    {
        int H, W; 
    
        canvas_t()
        {
            string s; cin >> H >> W;  
    
            for( int i = 1; i <= H; i++ )
                cin >> s, at( i ) = bitset_t( s + '.', 0, W + 1, '.', '#' );
        }
        
        bool invalid( int i, int j ) const 
        {
            return !(*this)[ i - 1 ][ j ] &&
                   !(*this)[ i + 1 ][ j ] &&
                   !(*this)[ i ][ j - 1 ] &&
                   !(*this)[ i ][ j + 1 ];
        }
        
        bool paintable() const 
        {
            for( int i = 1; i <= H; i++ )
                for( int j = 1; j <= W; j++ )
                    if ( (*this)[ i ][ j ] && invalid( i, j ) )
                        return false;
            
            return true;            
        }
        
    } canvas;
    
    if ( canvas.paintable() )
        cout << "Yes";
    else
        cout << "No";
}


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

string s, t;
int c[2]['z' - 'a' + 1];

int main() {
	cin >> s >> t;

	for (int i = 0; i < s.length(); i++) {
		c[0][s[i] - 'a']++;
		//cout << "a" << endl;
	}
	for (int i = 0; i < t.length(); i++) {
		c[1][t[i] - 'a']++;
	}

	/*cout << "S" << endl;
	for (int i = 0; i < 'z' - 'a' + 1; i++) {
		cout << (char)(i + 'a') << ":" << c[0][i] << endl;
	}
	cout << "T" << endl;
	for (int i = 0; i < 'z' - 'a' + 1; i++) {
		cout << (char)(i + 'a') << ":" << c[1][i] << endl;
	}*/

	int j = 0;
	for (int i = 0; i < 'z'-'a'+1; i++) {
		if (c[0][i] > 0) {
			c[0][i]--;
			s[j] = i + 'a';
			i--;
			j++;
		}
	}

	j = 0;
	for (int i = 'z' - 'a';i >= 0; i--) {
		if (c[1][i] > 0) {
			c[1][i]--;
			t[j] = i + 'a';
			i++;
			j++;
		}
	}

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	//cout << s << endl;
	//cout << t << endl;
	
}

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

using namespace std;

const long long INF = 1000000000 + 7;
const long long maxn = 1005;

int cost[maxn][maxn];
char cell[maxn][maxn];
long long memo[maxn][maxn];
long long ROW, COL;


/**
- 2D Grid in iterative way.
-Key Observation:
    - we see if pos is [row][0] = [row][1] = [row][2] ... = [row][col] = one way road i.e. 1 way road
    - same for [row][0] = [row][1] = [row][2] = . . .  = [row][col] = 1 way.
    - for [r][c] = [r][c + 1] + [r + 1][c];
     
**/

bool valid (long long row, long long col){
    if(row < ROW && col < COL && cell[row][col] != '#') return true;
    return false;
}

int main(){
    cin >> ROW >> COL;
    //int memo[ROW][COL];
    for(long long r = 0; r < ROW; r++)
        for(long long c = 0; c < COL; c++)
            cin >> cell[r][c];
     
    memset(memo,0,sizeof(memo));
    
    memo[0][0] = 0;
    bool ok = true;
    for(long long i = ROW - 1; i >= 0; i--){
        if(cell[i][COL - 1] == '#') ok = false;
        if(ok)
            memo[i][COL - 1] = 1;
        else memo[i][COL - 1] = 0;
    }
    ok = true;
    for(long long i = COL - 1; i >=0; i--){
        if(cell[ROW - 1][i] == '#') ok = false;
        if(ok) memo[ROW - 1][i] = 1;
        else memo[ROW - 1][i] = 0;
    }
    for(long long r = ROW - 2; r >= 0; r--){
        for(long long c = COL - 2; c >= 0; c--){
            if(valid(r, c+1)){
                memo[r][c] += memo[r][c + 1];
                memo[r][c] %= INF;
            }
            else{
                memo[r][c] += 0;
                //memo[r][c] %= INF;
            }
            if(valid(r + 1, c)){
                memo[r][c] += memo[r + 1][c];
                memo[r][c] %= INF;                
            }
            else
                memo[r][c] += 0;
         }
    }
    cout << memo[0][0] % INF << endl;
}


Measured memory_bytes: 10496
<?php
while((list($h, $w) = explode(" ", trim(fgets(STDIN)))) && $h && $w) {
    $field = array();
    for($i = 0; $i < $h; $i++) {
        foreach(str_split(trim(fgets(STDIN))) as $dir) {
            $field[$i][] = new Tile($dir);
        }
    }
    $person = new Person(0, 0);
    $flg = false;
    while(($dir = $field[$person->getY()][$person->getX()]->getDir()) != null) {
        if($flg = $person->move($dir)) {
            break;
        }
    }
    echo $flg ? $person->showPos() : "LOOP", PHP_EOL;
}

class Tile {
    private $flg_;
    private $dir_;

    function __construct($dir) {
        $this->flg_ = false;
        $this->dir_ = $dir;
    }

    function getDir() {
        if($this->flg_) {
            return null;
        } else {
            $this->flg_ = true;
            return $this->dir_;
        }
    }
}

class Person {
    private $y_;
    private $x_;

    function __construct($y, $x) {
        $this->y_ = $y;
        $this->x_ = $x;
    }

    function move($dir) {
        switch($dir) {
          case "v":
            $this->y_++;
            return false;
          case "^":
            $this->y_--;
            return false;
          case ">":
            $this->x_++;
            return false;
          case "<":
            $this->x_--;
            return false;
          case ".":
            return true;
        }
    }

    function getY() {
        return $this->y_;
    }

    function getX() {
        return $this->x_;
    }

    function showPos() {
        echo $this->x_, " ", $this->y_;
    }
}

Measured memory_bytes: 19768
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

N = int(input())
ans = []
const = 2*3**0.5
def korch_curve(Lx,Ly,Rx,Ry,i):
    if i == 0:
        ans.append((Lx,Ly))
        return 
    third_y = (Ly*2 + Ry)/3
    third_x = (Lx*2 + Rx)/3
    korch_curve(Lx,Ly,third_x,third_y,i - 1)
    middle_x = (Lx + Rx)/2 - (Ry - Ly)/const
    middle_y = (Ly + Ry)/2 + (Rx - Lx)/const
    korch_curve(third_x,third_y,middle_x,middle_y,i - 1)
    third_second_x = (Lx + Rx*2)/3
    third_second_y = (Ly + Ry*2)/3
    korch_curve(middle_x,middle_y,third_second_x,third_second_y,i - 1)
    korch_curve(third_second_x,third_second_y,Rx,Ry,i - 1)
korch_curve(0,0,100,0,N)
ans.append((100,0))
for a in ans:
    print(*a)


Measured memory_bytes: 6212
//...author:MAUNIE...//
#include<bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
    long long ans = 0;  
	int n;
	cin >> n;
	vector<int> s(n);
	vector<int> a(n);
	vector<int> b(n);
    for (int i = 0; i < n; i++) {
	    cin >> a[i] >> b[i];
	    s[i] = a[i] + b[i];
        ans -= b[i];
    }
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    for (int i = 0; i < n; i+=2) {
        ans += s[i];
    }
    cout << ans;
    return 0;
 }

Measured memory_bytes: 1408
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int
 
void rayhan_solve()
{
	int count=0;
	string s,t;
	cin>>s;cin>>t;
	rep(i,0,s.size())
	{
		if(s[i]!=t[i])
			count++;
	}
 
	cout<<count<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 
rayhan_solve();
 
	return 0;
}

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

ll f(ll a, ll b) { // a > 0, b > 0
  int n = 0, m = 0;
  while (a > 0) {
    n++;
    a /= 10;
  }
  while (b > 0) {
    m++;
    b /= 10;
  }
  return (n > m) ? n : m;
}

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

  ll ans = 1e5;
  for (ll i = 1; i * i <= N; i++)
    if (N % i == 0)
      ans = min(ans, f(i, N / i));

  cout << ans << endl;
}

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

int main(){
	int X,Y;
	cin>>X>>Y;
	for(int i=0;i<=X;i++){
		if(i*2+(X-i)*4==Y){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void)
{
    while (1) {
        int n, a, b; scanf("%d", &n);
        if (n == 0) break;
        a = b = 0;
        while (n--) {
            int x, y; scanf("%d%d", &x, &y);
            if (x > y) a += (x + y);
            else if (x < y) b += (x + y);
            else { a += x; b += y; }
        }
        printf("%d %d\n", a, b);
    }
    return 0;
}

Measured memory_bytes: 0
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let mut res = 0;

    for i in a..b+1 {
        if c%i == 0 {
            res+=1;
        }
    }
    out.write_fmt(format_args!("{}\n", res)).unwrap();

}



Measured memory_bytes: 5036
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def beruman(N,edges,start = 0,negative_loop = False):
    find_negative = False #startを含む負の閉路が存在するか
    dist = [INF] * N
    dist[start] = 0

    for i in range(N):
        update = False
        for a,b,c in edges:
            if dist[a] != INF and dist[b] > dist[a] + c:
                dist[b] = dist[a] + c
                update = True

        if not update:
            break
        if i == N - 1:
            find_negative = True
    
    if negative_loop:
        return dist,find_negative
    else:
        return dist

def main():
	V,E,s = map(int,input().split())
	edges = [tuple(map(int,input().split())) for _ in range(E)]
	dist,flag = beruman(V,edges,start = s,negative_loop = True) 
	if flag:
		print('NEGATIVE CYCLE')
	else:
		print('\n'.join(map(lambda x:'INF' if x == INF else str(x),dist)))
if __name__ == '__main__':
	main()


Measured memory_bytes: 5788
#include<bits/stdc++.h>
using namespace std;
string a[3];
char p;
int w;

int main(){
    for(int i=0;i<3;i++){
        for(int u=0;u<3;u++){
            cin>>p;
            if(i==u){
                a[w]=p;
                w++;
            }
        }
    }
    cout<<a[0]<<a[1]<<a[2]<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	char X[200001];
	while(~scanf("%s", X)) {
		int depth = 0;
		int ans = 0;
		for(const char *p = X; *p; ++ p) {
			if(*p == 'T')
				-- depth;
			else
				++ depth;
			if(depth < 0)
				++ ans, ++ depth;
		}
		ans += depth;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
n,m,q = gets.chomp.split.map &:to_i
abcd = q.times.map{gets.chomp.split.map &:to_i}

#配列arr … [A_1..A_N]の全通りを格納した配列
arr = (1..m).to_a.repeated_combination(n)
ans = 0
arr.each do |large_a|
  point = 0
  #与えられた条件の配列内で繰り返す
  abcd.each do |a,b,c,d|
    point += d if large_a[b-1]-large_a[a-1] == c
  end
  ans = [ans,point].max
end

p ans


Measured memory_bytes: 14780
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int MAX_N = 110000;

int dp[MAX_N];

int main () {
  string s; int K; cin >> s >> K;

  int N = s.size();

  vector<string>  sub_s;
  FOR(i,1,min(N,K)+1) {
    FOR(j,0,N-i+1) {
      sub_s.push_back(s.substr(j,i));
    }
  }

  SORT(sub_s);
  unique(ALL(sub_s));
  
  cout << sub_s[K-1] << endl;
}

Measured memory_bytes: 1660
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))

study=[0]*m
ans=float("inf")
for i in range(2**n):
    study=[0]*m
    money=0
    for j in range(n):
        if (i>>j)%2 == 1:
            for k in range(m):
                study[k]+=a[j][k+1]
            money+=a[j][0]

    enough=True
    for k in range(m):
        if study[k]<x:
            enough=False
    if enough==True:
        ans=min(ans,money)

if ans==float("inf"):
    print(-1)
    exit()

print(ans)






Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

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


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	out(S=="ABC"?"ARC":"ABC");
	return 0;
}


Measured memory_bytes: 3616
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, c, count, kc int
	var s string
	fmt.Scan(&a, &b, &c)
	nums := make([]string, 10)
	fmt.Scan(&s)
	nums = strings.Split(s, "")
	for _, v := range nums {
		if v == "a" && count < (b+c) {
			fmt.Println("Yes")
			count++
		} else if v == "b" && count < (b+c) && kc < c{
			fmt.Println("Yes")
			count++
			kc++
		} else {
			fmt.Println("No")
		}
	}

}


Measured memory_bytes: 4192
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int a[110],n,m;
bool Cando(int lim){
  int cnt=0,cls=0;
  for(int i=0;i<n;i++){
    if(a[i]>lim)return false;
    if(cls+a[i]>lim){
      cls=a[i];
      cnt++;
    }
    else cls+=a[i];
  }
  if(cnt<m)return true;
  return false;
}
int main(){
 while(cin>>m>>n&&n+m){
   for(int i=0;i<n;i++)cin>>a[i];
   int left=0,right=100000000,mid;
   while(left<right-1){
     mid=(left+right)/2;
     if(Cando(mid)==false)left=mid;
     else right=mid;
   }
   cout<<right<<endl;
 }
  return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main()
{
	int n;
	int i = 1;
	while(1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		printf("Case %d: %d\n",i,n);
		++i;
	}
	return 0;
}

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


int main() {

    ll n;
    cin >> n;
    int sum = 0;
    ll tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
double d[3],e[3],s[99][3];main(T,n,i,j,k,l){for(scanf("%d",&T);T;T--){
for(scanf("%lf%lf%lf%d",d,d+1,d+2,&n),i=0;i<n;i++)scanf("%lf%lf%lf",s[i],s[i]+1,s[i]+2);
for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(i!=j&&j!=k&&k!=i){
	e[0]=sqrt(pow(s[j][0]-s[i][0],2)+pow(s[j][1]-s[i][1],2)+pow(s[j][2]-s[i][2],2));
	e[1]=sqrt(pow(s[k][0]-s[j][0],2)+pow(s[k][1]-s[j][1],2)+pow(s[k][2]-s[j][2],2));
	e[2]=sqrt(pow(s[i][0]-s[k][0],2)+pow(s[i][1]-s[k][1],2)+pow(s[i][2]-s[k][2],2));
	for(l=0;l<3;l++)if(d[l]/d[(l+1)%3]-e[l]/e[(l+1)%3]>1e-3)break;
	if(l==3)printf("%d %d %d\n",k+1,i+1,j+1);
}
}exit(0);}

Measured memory_bytes: 640
n = int(input())
ls = []
alphabet = [chr(i) for i in range(97, 97+26)]
alphabet_dict = {}
for i, a in enumerate(alphabet):
    alphabet_dict[a] = i
def dfs(A):
    if len(A) == n:
        ls.append(A)
        return
    Max = 0
    for i in range(len(A)):
        Max = max(Max,alphabet_dict[A[i]])
    for i in range(Max+2):
        A += alphabet[i]
        dfs(A)
        A = A[:-1]
dfs('a')
ls.sort()
for i in range(len(ls)):
    print(ls[i])
    

Measured memory_bytes: 17092
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	string s,t;
	cin>>s>>t;
	int n1=s.length(),n2=t.length();
	int dp[n1+1][n2+1];
	for (int i = 0; i < n1+1; ++i){
		for (int j = 0; j < n2+1; ++j){
			dp[i][j]=0;
		}
	}
	for (int i = 0; i < n1; ++i){
		for (int j = 0; j < n2; ++j){
			if(s[i]==t[j])
				dp[i+1][j+1]=dp[i][j]+1;
			else
				dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	int x=n1,y=n2;
	string ans="";
	while(x>=1 && y>=1){
		if(s[x-1]==t[y-1]){
			ans+=s[x-1];
			x--,y--;
			continue;
		}
		if(dp[x-1][y]>=dp[x][y-1])
			x--;
		else
			y--;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 38780
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll x,y,s; cin >> x >> y >> s;
        if(!x && !y && !s) break;
        x += 100; y += 100;
        ll ans = 0;
        REP(i,1,s){
            ll t = -1;
            for(ll j=i;;j--){
                if(j*x/100 == i){
                    t = j;
                    break;
                }else if(j*x/100 < i){
                    t = -1;
                    break;
                }
            }
            ll u;
            for(ll j=s-i;;j--){
                if(j*x/100 == s-i){
                    u = j;
                    break;
                }else if(j*x/100 < s-i){
                    u = -1;
                    break;
                }
            }
            if(t==-1 || u==-1) continue;
            chmax(ans,t*y/100+u*y/100);
        }
        cout << ans << endl;
    }
}


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

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

    int n, k;
    cin >> n >> k;

    int t = 1;
    for(int i = 0; i < n; i++){
        if(t * 2 > t + k){
            t += k;
        }else{
            t *= 2;
        }
    }

    cout << t << endl;

    return 0;
}

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

const int MOD = 100000;
//b 0直前に曲がっていない 1直前に上へ曲がった 2直前に右へ曲がった
//d 1 直前に上へ進んだ 2 直前に右へ進んだ
int w,h;
int memo[105][105][3][3];

int dfs(int x, int y, int b, int d){
	if(x > w || y > h) return 0;
	if(x == w && y == h)return 1;
	
	if(memo[x][y][b][d] >= 0)return memo[x][y][b][d];
	
	if(b == 1) return memo[x][y][1][1] = dfs(x, y + 1, 0, 1) % MOD;
	if(b == 2) return memo[x][y][2][2] = dfs(x + 1, y, 0, 2) % MOD;
	if(d == 1) return memo[x][y][0][1] = dfs(x + 1, y, 2, 1) % MOD + dfs(x, y + 1, 0, 1) % MOD;
	if(d == 2) return memo[x][y][0][2] = dfs(x + 1, y, 0, 2) % MOD + dfs(x, y + 1, 1, 2) % MOD;
	
	return memo[x][y][0][0] = dfs(x + 1, y, 0, 2) % MOD + dfs(x, y + 1, 0, 1) % MOD;
}

int main()
{
	while(cin >> w >> h,!(w==0&&h==0)){
		fill((int*)memo, (int*)(memo+105), -1);
		cout << dfs(1,1,0,0) % MOD << endl;
	}
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
#define MAXN 1000005
using namespace std;
inline int read(){
	int 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<<1)+(x<<3)+(ch^'0');
		ch=getchar();
	}
	return x*f;
}
vector<int>G[MAXN];
inline void AddEdge(int u,int v){
	G[u].push_back(v);
}
int dfs(int u,int father){
	int ans=0;
	for (int i=0;i<G[u].size();++i){
		int v=G[u][i];
		if (v!=father) ans^=(dfs(v,u)+1);
	}
	return ans;
}
int main(){
	int n=read();
	int cnt=0;
	for (int i=1;i<n;++i){
		int u=read(),v=read();
		AddEdge(u,v);
		AddEdge(v,u);
	}
	puts(dfs(1,1)?"Alice":"Bob");
}

Measured memory_bytes: 33024
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.append(0)
d=[0]*(n+1)
for _ in range(n+1):
  d[_]=abs(a[_+1]-a[_])
s=sum(d)
for i in range(1,n+1):
  print(s-d[i-1]-d[i]+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


void gone_shoot(int n, int x){
  std::queue<int> timpo;
  int t1, t2, t3, t4;
  // 1, 2, ..., n - 1, n , n + 1, ..., 2n - 1
  if(x == 2) t1 = x + 1, t2 = x, t3 = x - 1, t4 = x + 2;
  else t1 = x - 1, t2 = x, t3 = x + 1, t4 = x - 2;
  FOReq(i, 1, 2 * n - 1) if(i != t1 and i != t2 and i != t3 and i != t4) timpo.push(i);
  REP(i, n - 2){printf("%d\n", timpo.front()); timpo.pop();}
  printf("%d\n%d\n%d\n%d\n", t1, t2, t3, t4);
  REP(i, n - 3) {printf("%d\n", timpo.front()); timpo.pop();}
}


int main(void){
  int n, x; scanf("%d%d", &n, &x);
  if(x == 1 || x == 2 * n - 1) puts("No");
  else if(n == 2) puts("Yes\n1\n2\n3");
  else {puts("Yes"); gone_shoot(n, x);}
  return 0;
}

Measured memory_bytes: 2304
n=int(input())
v=list(map(int,input().split()))

gu=[]
ki=[]

from collections import Counter

for i in range(n):
  if i%2:
    ki.append(v[i])
  else:
    gu.append(v[i])

g=Counter(gu)
k=Counter(ki)

#gとkが同じ場合は、「gとkの次の候補のうち、最適な方に」ずらしてく処理が必要
#両方とも一種類しかない場合はn//2が答え
x=g.most_common()[0][1]
y=k.most_common()[0][1]
a=x+y
if g.most_common()[0][0]==k.most_common()[0][0]:
  if len(Counter(gu))!=1:
    if g.most_common()[1][1]>k.most_common()[1][1]:
      a=g.most_common()[1][1]+y
    else:
      a=x+k.most_common()[1][1]
  else:
    a=n//2
ans=n-a
print(ans)

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

using namespace std;
const int maxv=1e5+100;
int num[2][maxv];
int n,x;
struct point{
    int v,m;
};
bool cmp(point &a,point &b)
{
    return a.m>b.m;
}
point k1[maxv],k2[maxv];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        num[i%2][x]++;
    }
    int cnt1=0,cnt2=0;
    for(int i=0;i<maxv;i++){
        if(num[0][i]>0){
            k1[cnt1].v=i;
            k1[cnt1].m=num[0][i];
            cnt1++;
        }
        if(num[1][i]>0){
            k2[cnt2].v=i;
            k2[cnt2].m=num[1][i];
            cnt2++;
        }
    }
    sort(k1,k1+cnt1,cmp);
    sort(k2,k2+cnt2,cmp);
    if(k1[0].v!=k2[0].v){
        cout<<n-k1[0].m-k2[0].m<<endl;
    }
    else {
        int n1,n2;
        n2=n/2;
        n1=n-n2;
        int ans=999999999;
        if(cnt1>1){
            ans=min(ans,n-k1[1].m-k2[0].m);
        }
        else ans=min(ans,n1+n2-k2[0].m);
        if(cnt2>1){
            ans=min(ans,n-k1[0].m-k2[1].m);
        }
        else ans=min(ans,n2+n1-k1[0].m);
        cout<<ans<<endl;
    }
    return 0;
}
/*
4
1 2 3 4
2
1 2
*/


Measured memory_bytes: 1792
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n;
    string s;
    cin >> s;
    n = s.length();
    int a[n][2] = {} ;
    rep(i , n) a[i][0] = 1;
    vector<int> v(n , 1);
    // repA(_,1,1000000){
    //     vector<int> na(n , 0);
    //     rep(i , n){
    //         if(s[i] == 'L') na[i-1] += v[i];
    //         else if(s[i] == 'R') na[i+1] += v[i];
    //     }
    //     v.swap(na);
    // }
    // trav(x , v) cout << x << ' ' ;
    // return ;
    rep(i , n){
        if(s[i] == 'R'){
            if(s[i + 1] == 'L') a[i + 1][0] += a[i][1] , a[i][1] = 0;
            else a[i + 1][0] += a[i][1] , a[i+1][1] += a[i][0] , a[i][0] = a[i][1] = 0;
        }
    }
    repD(i , n-1 , 0){
        if(s[i] == 'L'){
            if(s[i - 1] == 'R') a[i - 1][0] += a[i][1] , a[i][1] = 0;
            else a[i - 1][0] += a[i][1] , a[i-1][1] += a[i][0] , a[i][0]=a[i][1]=0;
        }
    }

    // rep(i , n){
    //     if(s[i] == 'R' && s[i + 1] == 'L')
    // }
    // rep(i , n) cout << a[i][0] << ' ' << a[i][1] << '\n' ;
    rep(i , n) cout << a[i][0] + a[i][1] << ' ';
}


     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


struct Node{
public:
    string name;
    int p;
    int idx;
    Node(){
        name="";
        p=0;
        idx=0;
    }
    Node(string name,int p,int idx){
        this->p=p;
        this->name=name;
        this->idx=idx;
    }
};
class Comp{
public:
    bool operator()(const Node &a,const Node &b){
        return a.name!=b.name ? a.name<b.name : a.p > b.p;    
    }
};
void solve(){
    int n;
    cin>>n;
    vector<Node> arr;
    for(int i=0;i<n;++i){
        string name;
        int p;
        cin>>name>>p;
        arr.pb(Node(name,p,i+1));
    }
    sort(all(arr),Comp());
    for(int i=0;i<n;i++){
        cout<<arr[i].idx<<endl;
    }
}





int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[3010],b[3010];
char str[6010];
string dp[3010];
bool vis[6010];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",str+1);
	int num1=0,num2=0;
	for(int i=1;i<=n*2;i++)
		if(str[i]=='a')a[++num1]=i;
		else b[++num2]=i;
	for(int i=n;i>=1;i--)
	{
		if(a[i]<b[i])
		{
			int j=i;
			while(j<=n&&(a[j]<b[i]||b[j]<b[i]))
				j++;
			dp[i]="ab"+dp[j];
		}
		else{
			memset(vis,0,sizeof(vis));
			int mx=a[i],j=i;
			while(j<=n&&a[j]>b[j]&&b[j]<=mx){
				vis[a[j]]=true;
				vis[b[j]]=true;
				mx=max(mx,a[j]);
				j++;
			}
			for(int k=i;k<=n*2;k++)
				if(vis[k])dp[i]+=str[k];
			dp[i]+=dp[j];
		}
		dp[i]=max(dp[i],dp[i+1]);
	}
	cout<<dp[1]<<"\n";
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 100001;
int x[MAX_N], y[MAX_N];

// union-find O(α(n))
// 1. init(n) *** Notice that if 3 groupes, init(3 * n)
// 2. use unite(x, y) and same(x, y)

int par[MAX_N * 2];
int rk[MAX_N * 2];

void init(int n){
  REP(i,n){
    par[i] = i;
    rk[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return;
  if(rk[x] < rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x] == rk[y]) rk[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  cin >> N;
  REP(i, N) cin >> x[i] >> y[i];

  init(2 * MAX_N);
  vpi vx, vy;
  REP(i, N) {
    vx.pb(pi(x[i], y[i]));
    vy.pb(pi(y[i], x[i]));
  }

  sort(ALL(vx));
  sort(ALL(vy));

  REP(i, N - 1) {
    if(vx[i].F == vx[i + 1].F) {
      unite(vx[i].S + MAX_N, vx[i + 1].S + MAX_N);
    }
    if(vy[i].F == vy[i + 1].F) {
      unite(vy[i].S, vy[i + 1].S);
    }
  }

  set<pi> st;
  map<int, int> mpx, mpy;
  REP(i, MAX_N) {
    mpx[find(i)]++;
    mpy[find(MAX_N + i)]++;
  }
  REP(i, N) {
    st.insert(pi(find(x[i]), find(y[i] + MAX_N)));
  }

  ll ans = 0;
  for (auto itr : st) {
    ans += ll(mpx[itr.first]) * mpy[itr.second];
  }

  cout << ans - N << endl;


  return 0;
}


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

int main() {
  int n; cin >> n;
  int m; cin >> m;
  int ac = 0;
  int wa = 0;
  vector<string> vec(n);
  vector<int> arr_wa(n);
  int p;
  string s;
  for (int i = 0; i < m; i++) {
    cin >> p >> s;
    if (vec.at(p-1) == "AC") {
      continue;
    } else if (s == "WA") {
      arr_wa.at(p-1)++;
    } else if (s == "AC") {
      ac++;
      vec.at(p-1) = s;
      wa += arr_wa.at(p-1);
    }
  }
  cout << ac << " " << wa << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}


void solve()
{
    int n;
    cin>>n;
    
    vi h(n+1,0);

    srep(i,1,n) cin>>h[i];

    vi dp(n+1,0);
    
    dp[2] = abs(h[2] - h[1]);

    srep(i,3,n)
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    
    
    cout<<dp[n];


}

int main()
{
    fastio
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 3956
N, Q = map(int, input().split())
S = input()
t = [0 for i in range(N)]

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        t[i+1] = t[i] + 1
    else:
        t[i+1] += t[i]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7768