akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll n, a, b;
    cin >> n >> a >> b;
    
    ull r = 0;
    
    if (n == 1 && b != a) {
        r = 0;
        mes(r);
        re0;
    }
    if (b < a) {
        r = 0;
        mes(r);
        re0;
    }
    
    r = (b - a) * (n - 2) + 1;
    mes(r);
    
    
    
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll cnt = 0;
  sort(A.begin(), A.end());
  vector<bool> ans(1000001, false);
  vector<ll> ans_cnt(1000001, 0);
  for (ll i = 0; i < N; ++i) {
    ans.at(A.at(i)) = true;
    ans_cnt.at(A.at(i)) += 1;
  }

  for (ll i = 0; i < N; ++i) {
    if (ans.at(A.at(i))) {
      if (ans_cnt.at(A.at(i)) == 1) {
        cnt += 1;
      }
      ans.at(A.at(i)) = false;
    }
    else {
      continue;
    }
    ll a = A.at(i);
    ll temp = 2;
    while (a * temp <= 1000000) {
      ans.at(a * temp) = false;
      temp += 1;
    }
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 12760
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

// 1e4
int main()
{
    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    range_for (i, 0, 999)
    {
        string sub(3-GetDigit(i), '0');
        sub += to_string(i);

        int cur = 0;
        rep (i, N)
        {
            if (S[i] == sub[cur]) cur++;
            if (cur == 3) break;
        }
        if (cur == 3)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

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

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<P> v(N);
        REP(i, N) {
            int a, b;
            cin >> a >> b;
            v[i] = {b, a};
        }
        sort(v.begin(), v.end());

        bool ok = true;
        int cur = 0;
        REP(i, N) {
            int b = v[i].first;
            int a = v[i].second;
            cur += a;
            if (b < cur) {
                ok = false;
                break;
            }
        }

        cout << (ok ? "Yes" : "No") << endl;


    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DMegalomania solver;
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, L;
    cin >> N >> L;
    ll res = L*N + N*(N-1)/2;
    if(L>0)          cout<<(res-L)<<endl;
    else if(L+N-1<0) cout<<(res-L-N+1)<<endl;
    else             cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    a: i32,
    b: i32,
  }
  let mut ans = -1;
  for x in 0 .. b * 20 {
    if x * 8 / 100 == a && x * 10 / 100 == b {
      ans = x;
      break;
    }
  }

  puts!("{}\n", ans);
}


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

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++){
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int hi = n / 2;
    int lw = hi - 1;
    int ans = d.at(hi) - d.at(lw);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE -1

int r,c,col[N],row[N],dpos[N*2-1],dneg[N*2-1],B[N][N];
void putQueen(int);
void printBoard(void);

void putQueen(int i){
  int j;

  if(i == N)
  {
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE ||dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
      continue;
    }
  //
  row[i]=j;
  col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
  //try the next row
  putQueen(i+1);
  //remove the questin at (i,j)
  col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;

  }
}

void printBoard(void){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(B[i][j]==NOT_FREE && row[i] != j)return;
    }
  }
  //
for(i=0;i<N;i++){
  for(j=0;j<N;j++){
    if(row[i]==j)printf("Q");
    else printf(".");
    }
  printf("\n");
  }
// print
}

int main(){
  int i, j, n;
scanf("%d",&n);

for(i=0;i<N;i++){
  row[i]=FREE;
  col[i]=FREE;
  for(j=0;j<N;j++){
    B[i][j] =0;
  }
}

for(i=0;i<N*2-1;i++){
  dpos[i]=FREE;
  dneg[i]=FREE;
}

for(i=0;i<n;i++){
  scanf("%d %d",&r,&c);
  B[r][c] = NOT_FREE;
}
putQueen(0);

return 0;
}

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

string str;
int dp[302][302][302];
int solve(int l, int r, int i){
	if(r-l == 1){
		return dp[l][r][0] = 1;
	}else if(r-l == 2){
		dp[l][r][i] = 1;
		if(str[l] == str[r-1] || i > 0)dp[l][r][i] = 2;
		return dp[l][r][i];
	}
	if(i == 0){
		if(str[l] == str[r-1])dp[l][r][0] = dp[l+1][r-1][0]+2;
		else dp[l][r][0] = max(dp[l+1][r][0], dp[l][r-1][0]);
	}else{
		if(str[l] == str[r-1])dp[l][r][i] = max(dp[l][r][i], dp[l+1][r-1][i]+2);
		int res1 = max(dp[l+1][r][i], dp[l][r-1][i]);
		int res2 = dp[l+1][r-1][i-1]+2;
		int res = max(res1, res2);
		dp[l][r][i] = max(dp[l][r][i], res);
	}
	return dp[l][r][i];
}

int main(){
	int k, ans = 0;
	cin >> str >> k;
	int n = str.size();
	for(int i = 0;i <= k;i++){
		for(int l = n-1;l >= 0;l--){
			for(int r = l+1;r <= n;r++){
				int res = solve(l, r, i);
				ans = max(ans, res);
			}
		}
	}
	
	/*for(int i = 0;i < n;i++){
		for(int j = 0;j <= n;j++)printf("%d ", dp[i][j][0]);
		printf("\n");
	}*/
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 106752
import java.util.*;

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

        System.out.println(BiteEating(N, L, 1));
    }
    public static int BiteEating(int N, int L, int index) {
        int min = L;
        int max = N + L - 1;
        if (min <= 0 && 0 <= max) {
            return N * (L + N + L - 1) / 2;
        } else if (min < 0) {
            return (N - 1) * (L + (N + L - 2)) / 2;
        } else {
            return (N - 1) * ((L + 1) + (N + L - 1)) / 2;
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int n,k;
	cin >> n >> k;
	long long int a = n%k;
	long long int ans = min(a,k-a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 1000000007;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; 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(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
long long co[100010] = { 0 };
int main() {
	COMinit();
	long long n;
	long long e;
	cin >> n;
	for (int i = 1; i <= n + 1; i++) {
		int a;
		cin >> a;
		if (co[a] != 0) {
			e = (co[a] - 1) + (n - i + 1);
		}
		co[a] = i;
	}
	cout << n << endl;
	for (long long i = 2; i <= n + 1; i++) {
		long long ans = COM(n + 1, i) - COM(e, i - 1);
		while (ans < 0) {
			ans += 1000000007;
		}
		cout << ans << endl;
	}
	return 0;
}



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

void code()
{
    float n;
    cin>>n;
    cout<<2*3.1415*n<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int mn = 10000000;
  int mx = -10000000;
  long long sum = 0;
  for(int i=0; i<n; i++){
    int j;
    cin >> j;
    mn = min(mn,j);
    mx = max(mx,j);
    sum += j;
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// // for multiset
// // typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
// //              tree_order_statistics_node_update>
// //     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
// cout << fixed << setprecision(0) << pi <<endl;

// lli power(lli x, lli y) {
//     // return (x^y) % mod
//     lli ans = 1;
//     x = x % mod;
//     while (y > 0) {
//         if (y & 1) {
//             ans *= x;
//             ans %= mod;
//         }
//         y = y >> 1;
//         x = (x * x) % mod;
//     }
//     return ans;
// }

lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a, b, m, p;
    vector<lli> va, vb;
    va.pb(1e10);
    vb.pb(1e10);
    cin >> a >> b >> m;
    fr(i, 0, a) {
        cin >> p;
        va.pb(p);
    }
    fr(i, 0, b) {
        cin >> p;
        vb.pb(p);
    }
    lli x, y, c;
    lli ans = 1e15;
    fr(i, 0, m) {
        cin >> x >> y >> c;
        lli cost = va[x] + vb[y] - c;
        ans = min(ans, cost);
    }
    sort(all(va));
    sort(all(vb));
    ans = min(ans, va[0] + vb[0]);
    cout << ans << endl;
    rt;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  ll nums = 1;
  bool ok = false;
  for (; nums * (nums - 1) / 2 <= n; ++nums) {
    if (nums * (nums - 1) / 2 == n) {
      ok = true;
      break;
    }
  }

  if (!ok) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  
  ll length = nums - 1;
  vector<vector<int>> ans(nums);
  int cur = 1;
  for (int i = 0; i < nums; ++i) {
    for (int j = i + 1; j < nums; ++j) {
      ans[i].push_back(cur);
      ans[j].push_back(cur);
      cur++;
    }
  }
  cout << nums << endl;
  rep(i, nums) {
    cout << ans[i].size() << " ";
    rep(j, ans[i].size()) printf("%lld%c", ans[i][j], (j == length - 1 ? '\n' : ' '));
  } 

}

Measured memory_bytes: 4232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int N; ll a[402], dp[402][402];
int main(){
    scanf("%d", &N);
    for(int i=1; i<=N; i++){
        scanf("%lld", &a[i]); a[i] += a[i-1];
    }
    for(int len = 1; len < N ; len++){
        for(int i=1; i+len <= N; i++){
            int j = i + len;  dp[i][j] = dp[i+1][j];
            for(int k=i; k<j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j]);
            }
            dp[i][j] += a[j] - a[i-1];
        }
    }
    printf("%lld\n", dp[1][N]);
}

Measured memory_bytes: 1536
#include <iomanip>
#include <string>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;
int main() {
	string s[30][30], a = "snuke";
	char b;
	int h, w, c;
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
			if (s[i][j] == a) {
				b = 'A' + j - 1;
				c = i;
			}
		}
	}
	cout << b << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define PB push_back
#define MP make_pair
#define ll long long
#define ull unsigned long long 
#define pii pair<int,int>
#define all(X) (X).begin(),(X).end()
#define F first
#define S second
#define endl cout<<'\n';
#define __IO ios::sync_with_stdio(false),cin.tie(0);
#define int long long 
using namespace std;
int w[101] , v[101] , dp[101][100005];
main(){
__IO
	int n , W; cin >> n >> W;
	for(int i=0 ; i<n ; ++i)
		cin >> w[i] >> v[i]; //weight , price

	for(int j=0 ; j<=W ; ++j)
		if(j>=w[0]) dp[0][j] = v[0];

	for(int i=1 ; i<n ; ++i)
		for(int j=0 ; j<=W ; ++j)
			if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i]]+v[i]);
			else dp[i][j] = dp[i-1][j];

	cout << dp[n-1][W];endl
}

Measured memory_bytes: 78336
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int N=1e5+5;
const int mod=1e9+7;
bool vis[N]={false};
vector<int> adj[N];
ll dp[N][2];
void dfs(int s)
{
	vis[s]=true;
	dp[s][0]=1;
	dp[s][1]=1;
	int x;
	for(int i=0;i<adj[s].size();i++)
	{
		x=adj[s][i];
		if(vis[x]==0)
		{
			dfs(x);
			dp[s][1]=((dp[s][1]*((dp[x][0]+dp[x][1])%mod))%mod);
			dp[s][0]=(dp[s][0]*dp[x][1])%mod;
		}
	}
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int  x,y;
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(1);
	cout<<(dp[1][0]+dp[1][1])%mod;
	return 0;
}

Measured memory_bytes: 17680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int s, w;
    cin >> s >> w;

    if (w>=s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }


    return 0;
}


Measured memory_bytes: 3648
open Batteries

(* purpose
        ある地点の住所Pと全住人の住所リストから全住人の住所からpにかけての距離の総和を求める
   - detail of data
        P:
                detail: 全住人からの距離が最小と成る点
                condition: 1 <= P <= 100
        N, M:
                detail: Pが存在する範囲の始点と終点
                condition: 1 <= N <= 100
                           1 <= M <= 100
                           N <= M

   amount_of_calculation
        upper_limit: O(N)
        actual     : O(N)
*)
(* - function type
        solver: int -> int list -> int

   - I/O example
        input    -> output
        1 [1; 2] -> 1
        1 [1]    -> 0
        1 []     -> 0
*)
let rec solver p lst =
        match lst with
                  [] -> 0
                | first :: rest -> 
                        (Int.pow (first - p) 2) + (solver p rest)

(* - purpose
       任意の住所のリストと全住人の住所のリストから住人の住所からリストに含まれる任意の住所までの距離の全住人についての総和の最小値を求める

   - detail of data
        住所:
                detail: 全住人からの距離が最小と成る点
                condition: 1 <= 住所 <= 100

   - amount_of_calculation 
        upper_limit: O(N^2)
        actual     : O(N^2)
*)
(* - purpose
        detail

   - detail of data
        data1:
                detail: detail
                condition: cond

   - amount of calculation
        upper_limit: O(order)
        actual     : O(order)
*)
(* - function type
        solver2: int list -> int list -> int(acm) -> int

   - accumulator(option)
   	minsum: (調べ終わった総和のうち最小の値を格納) 
*)
let rec solver2 rlst lst minsum = 
        match rlst with
                  [] -> minsum
                | first :: rest -> 
                        let sum = solver first lst in (* O(N) *)
                                if sum < minsum then
                                        solver2 rest lst sum
                                else
                                        solver2 rest lst minsum

let test1 = (
        solver2 [] [] max_int
        =
        max_int
)
let test2 = (
        solver2 [1] [1] max_int
        =
        0
)
let test3 = (
        solver2 [1; 2] [1; 2] max_int
        =
        1
        ||
        solver2 [1; 2] [1; 2] max_int
        =
        2
)

let lst =
        Scanf.sscanf (read_line ()) "%d" (
                fun _ -> 
                        Str.split (Str.regexp " ") (read_line ())
                        |> List.map int_of_string 
        )


let () =
        let maxval = List.max lst in
        let minval = List.min lst in
                solver2 (List.range minval `To maxval) lst max_int
                |> Printf.printf "%d\n"

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

int main() {
  string s;
  cin >> s;
  for(int i=s.size()-1;i>=0;i--) {
    string ans=s.substr(0,i);
    if(i%2 != 0) continue;
    bool flag=true;
    for(int j=0;j<i/2;j++) {
      if(ans[j] != ans[j+i/2]) {
        flag=false;
        break;
      }
    }
    if(flag) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int ans = 0;
	VI A(N);
	REP(i, N)cin >> A[i];
	REP(i, N) {
		FOR(j, i + 1, N) {
			ans += A[i] * A[j];
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>d[1001];
int c[1001];
typedef long long ll;
ll mod = 1000000007;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 2; i <= num; i++)
	{
		int n = i;
		for (int j = 0; j < d[i].size(); j++)n /= d[i][j], c[d[i][j]]++;
		if (n != 1)
		{
			for (int j = i; j <= num; j += i)d[j].push_back(n);
			c[n]++;
		}
	}
	ll ans = 1;
	for (int i = 1; i <= num; i++)ans = ans*(c[i] + 1) % mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


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

  vector<pair<ll, ll>> v(n);
  REP(i, n){
    ll x, y;
    cin>>x>>y;
    v[i] = make_pair(x, y);
  }

  double sum = 0;
  vector<ll> order(n);
  REP(i, n) order[i] = i;

  do {
    for(int i=0;i<n-1;i++){
      sum += sqrt((v[order[i+1]].first-v[order[i]].first)*(v[order[i+1]].first-v[order[i]].first)+(v[order[i+1]].second-v[order[i]].second)*(v[order[i+1]].second-v[order[i]].second));
    }
    
  } while (std::next_permutation(order.begin(), order.end()));

  double all = 1;
  REP(i, n) all *= (i+1);
  std::cout << std::setprecision(20) <<sum/all<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int num[50];
    int N;
    int wrongCount = 0;

    cin >> N;

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

    for (int i = 0; i < N; i++)
    {
        if (num[i] != i + 1)
        {
            wrongCount++;
        }
    }

    if (wrongCount == 2 || wrongCount == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int main() {
  int N;
  string s, t;
  cin >> N >> s >> t;
  string res = s;
  int mini = N;
  for (int i = 0; i < N; ++i) {
	if (s.substr(i) == t.substr(0, N-i)) {
	  mini = min(mini, i);
	}
  }
  cout << N +  mini << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int K,N;
  scanf("%d",&N);
  scanf("%d",&K);
  
  int i,j,k=1;
  
  for(i=0;i<N;i++){
    if(k*2 < k + K)
      k *= 2;
    else
      k +=K;
  }
  
  printf("%d\n",k);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,a[40010],b[40010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N && N){
		rep(i,N)cin>>a[i];
		rep(i,N)cin>>b[i];
		sort(a,a+N,greater<int>());
		sort(b,b+N,greater<int>());
		int ans=-1;
		rep(i,N/2){
			if(a[i*2] > b[i]){
				ans=i*2+1;
				break;
			}
		}
		if(ans==-1)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b>>c>>d;
 
  if (a+b>c+d) {
    cout << "Left" << endl;
  }
  else if(a+b<c+d){cout<<"Right"<<endl;}
  else{cout<<"Balanced"<<endl;}
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

nml = 0
idx = -1
if abs(min(a)) > abs(max(a)):
    nml = min(a)
    idx = a.index(nml)
else:
    nml = max(a)
    idx = a.index(nml)
    
print(2*n-1)
for i in range(n):
    print(idx+1,i+1)

if nml < 0:
    for j in range(n,1,-1):
        print(j, j-1)
else:
    for j in range(1,n):
        print(j, j+1)

Measured memory_bytes: 3064
s = int(input())
l =[s]
m = 0
while l[m]<1000000:
    if l[m]%2:
        l.append(3*l[m]+1)
    else:
        l.append(l[m]//2)
    if l[m+1] in l[:m]:
        print(len(l))
        break
    else:
        m+=1



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

const int MN = 233333;
int n;
int a[MN];
int l[MN], r[MN];

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

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

    V<int> st;
    for (int i = 0; i < n; i++) {
        while (st.size() && a[i] < a[st.back()]) st.pop_back();
        l[i] = st.size() ? st.back() + 1 : 0;
        st.push_back(i);
    }
    st.clear();
    for (int i = n - 1; i >= 0; i--) {
        while (st.size() && a[i] <= a[st.back()]) st.pop_back();
        r[i] = st.size() ? st.back() - 1 : n - 1;
        st.push_back(i);
    }

    ll sm = 0;
    for (int i = 0; i < n; i++) {
        sm += ll(a[i]) * (i + 1 - l[i]) * (r[i] + 1 - i);
    }
    cout << sm << "\n";

    return 0;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

#define ll long long

ll f(int b, ll n) {
    if (n < b) return n;
    else return n % b + f(b, n / b);
}

int main() {
    ll n, s;
    cin >> n >> s;

    int b = 2;
    while (1LL * b * b <= n) {
        if(f(b, n) == s) {
            cout << b;
            return 0;
        }
        b++;
    }

    int u = b - 1;
    if (1LL * u * u == n)
        u--;

    while (u >= 1) {
        ll bmax = n / u, bmin = n / (u + 1) + 1;
        ll rmin = n % bmax, rmax = n % bmin;
        if (s - u >= rmin && s - u <= rmax && (s - u - rmin) % u == 0) {
            ll cat = (s - u - rmin) / u;
            if (bmax - cat > 1) {
                cout << bmax - cat;
                return 0;
            }
        }
        u--;
    }

    if (n == s) cout << n + 1;
    else cout << -1;
    return 0;
}


Measured memory_bytes: 384
/* YOU LOST THE GAME */
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  vl A(N);
  FOR (i, 0, N)
  {
    cin >> A[i];
  }

  double cond = 0;

  FOR (i, 0, N)
  {
    cond += (1. / A[i]);
  }

  cout << 1. / cond << endl;

  return 0;
} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 256
def median2(lst):
    lst.sort()
    l = len(lst)
    if l % 2:
        return lst[(l - 1)//2]
    else:
        return lst[l // 2 - 1] + lst[l // 2]
        

def submit():
    n = int(input())
    a = list()
    b = list()
    
    for _ in range(n):
        ae, be = map(int, input().split())
        a.append(ae)
        b.append(be)

    m1 = median2(a)
    m2 = median2(b)
    print(m2 - m1 + 1)


submit()

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False

    def is_prime(self, n):
        return self.A[n]

def main():
    rr = []
    pr = Prime(1299709**2)

    while True:
        n = I()
        if n == 0:
            break
        l = r = n
        while not pr.is_prime(l):
            l -= 1
        while not pr.is_prime(r):
            r += 1
        rr.append(r-l)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 19184
fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}

fn main() {
    let state = read_line().trim().chars().collect::<Vec<_>>();
    let mut count = 0;
    for i in 1 .. state.len() {
        if state[i] != state[i - 1] {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2620
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> PP;
set<string> t;
string s,d,f;
string Rev(string q){
	f="";
	for(int i=q.size()-1;i>=0;i--)
	f.push_back(q[i]);
	return f;
}

void Solve(){
	t.clear();t.insert(s);
	for(int i=1;i<s.size();i++){
		d=s.substr(i,s.size()-1)+s.substr(0,i);t.insert(d);
		d=s.substr(0,i)+Rev(s.substr(i,s.size()-i));t.insert(d);
		d=Rev(s.substr(0,i))+s.substr(i,s.size()-i);t.insert(d);
		d=Rev(s.substr(0,i))+Rev(s.substr(i,s.size()-i));t.insert(d);
		d=s.substr(i,s.size()-i)+Rev(s.substr(0,i));t.insert(d);
		d=Rev(s.substr(i,s.size()-i))+s.substr(0,i);t.insert(d);
		d=Rev(s.substr(i,s.size()-i))+Rev(s.substr(0,i));t.insert(d);
	}
}
int main(){
	int n;cin>>n;
	while(n--){
		cin>>s;Solve();
		cout<<t.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string str;
    cin >> str;

    char cc = 'R';
    int cnt = 0;
    int N = str.size();
    vector<int> distro;
    for (int i = 0; i < N; i++) {
        if (str[i] == cc) {
            cnt++;
        } else {
            distro.push_back(cnt);
            cnt = 1;
            cc = (cc == 'R' ? 'L' : 'R');
        }
    }
    distro.push_back(cnt);
    distro.push_back(0);

    // for (int i = 0; i < distro.size(); i++) {
    //     cout << distro[i] << endl;
    // }


    vector<int> ansvec;
    bool isright = true;
    int ans = 0;
    for (int di = 0; di < (int)distro.size()-1; di++) {
        if (isright) {
            for (int zi = 0; zi < distro[di]-1; zi++) {
                ansvec.push_back(0);
            }
            isright = false;
            int k1 = (distro[di] / 2);
            int k2 = (distro[di+1] / 2);
            ans = k1 + k2;
            if (distro[di] % 2 == 1) {
                ans += 1;
            }
            ansvec.push_back(ans);
        } else {
            isright = true;
            int k1 = (distro[di-1] / 2);
            int k2 = (distro[di] / 2);
            ans = k1 + k2;
            // if ( (distro[di] % 2 == 1 && distro[di+1] % 2 == 1) ||
            // (distro[di] % 2 == 0 && distro[di+1] % 2 == 1) ){
            if (distro[di] % 2 == 1)
                ans += 1;

            ansvec.push_back(ans);
            for (int zi = 0; zi < distro[di]-1; zi++) {
                ansvec.push_back(0);
            }
        }
    }


    for (int i = 0; i < N; i++) {
        if (i == 0) {
            cout << ansvec[i];
        } else {
            cout << " " << ansvec[i];
        }
    }
    cout << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;

LL a,b;
LL gcd(LL x,LL y){
	if(!y) return x;
	return gcd(y,x % y);
}

int main(){
	cin >> a >> b;
	cout << (a * b / gcd(a,b)) << endl;
	return 0;
}

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

int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<set<int>> V(26);
  for (int i = 0; i < N; i++) V.at(S.at(i) - 'a').insert(i + 1);
  while (Q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int i;
      char c;
      cin >> i >> c;
      V.at(S.at(i - 1) - 'a').erase(i);
      S.at(i - 1) = c;
      V.at(S.at(i - 1) - 'a').insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      int ans = 0;
      for (int i = 0; i < 26; i++) {
        auto iter = V.at(i).lower_bound(l);
        if (iter != V.at(i).end() && *iter <= r) ans++;
      }
      cout << ans << "\n";
    }
  }
}

Measured memory_bytes: 24196
N, K = [int(i) for i in input().split()]
h = [int(i)for i in  input().split()]

d=[1e16]*N
d[0]=0
for i in range(1,N):
    from_num=max(0, i-K)
    for j in range(from_num, i):
        d[i]=min([d[i], abs(h[i]-h[j])+d[j]])

print(d[-1])


Measured memory_bytes: 55776
function Main(input) {
let dataset = input.split('\n');
let nx = [];
let n, x
for (let i = 0; i < dataset.length; i++){
nx = dataset[i].split(' ').map(Number);
n = nx[0]
x = nx[1]

let count = 0;
if (n === 0 && x === 0) {
break;
} else {
for (let j = 1; j < n; j++){
for (let k = j + 1; k < n; k++){
for (let l = k + 1; l <= n; l++ ){
if ((l + k + j) === x) {
count++;
} else {

}
}
}
}
console.log(count);
}
}
}

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



Measured memory_bytes: 16372
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n;cin>>n;
    string s;cin>>s;
    vec<ll> W,R;

    rep(i, n){
        if (s[i] == 'W') W.pb(i);
        if (s[i] == 'R') R.pb(i);
    }

    ll cnt = 0;
    ll wi = 0;
    ll ri = sz(R)-1;
    dump(W);
    dump(R);
    while(true){
        if (wi == sz(W) || ri < 0) break;

        if (W[wi] < R[ri]){
            cnt++;
            wi++;
            ri--;
        }
        else{
            break;
        }
    }

    cout << cnt << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

struct StGoods
{
  StGoods() : m_nPrice(0), m_nNum(0) { }

  int m_nPrice;
  int m_nNum;
};

void input(int& rnTrgNum, vector<StGoods>& rvoGoods)
{
  int nGoodsSiz;
  cin >> nGoodsSiz >> rnTrgNum;
  rvoGoods.resize(nGoodsSiz);

  for (StGoods& roGoods : rvoGoods)
    cin >> roGoods.m_nPrice >> roGoods.m_nNum;
}

llong calcMinCost(int nTrgNum, const vector<StGoods>& cnrvoGoods)
{
  map<int, int> mpGoods;

  for (StGoods oGoods : cnrvoGoods)
    mpGoods[ oGoods.m_nPrice ] += oGoods.m_nNum;

  llong nCost = 0;

  for (auto PGoods : mpGoods)
  {
    int nUsedNum = min(nTrgNum, PGoods.second);
    nCost += (llong)PGoods.first * nUsedNum;
    nTrgNum -= nUsedNum;

    if ( !nTrgNum ) break;
  }
  return nCost;
}
 
int main()
{
  int nTrgNum;
  vector<StGoods> voGoods;

  input(nTrgNum, voGoods);
  cout << calcMinCost(nTrgNum, voGoods) << endl;

  return 0;
}

Measured memory_bytes: 8804