akhauriyash/Code-Regression huggingface dataset:
(function(stdin){
	var lines = stdin.toString().split(' ').map(Number);
	var resolt = (function (a , b){
		if(a > b){
			return "a > b";
		}else if(a < b){
			return "a < b"
		}else{
			return "a == b"
		}
	}(lines[0],lines[1]));
	console.log(resolt);
}(require('fs').readFileSync('/dev/stdin','utf8')));

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

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

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep3(i, n, m) for (int i = n; i <= m; i++)

using ll = long long;

/* vector<ll> v(N);
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
  xの二乗:  pow(x, 2.0);
  int: -2,147,483,648 ～ 2,147,483,647(2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807(9×10^18)
  long long型の2次元配列(3×4要素の)の宣言
  vector<vector<ll>> ;
  string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)
*/
 
 //126~
 //126-d

int main() {
  int A,B,ans;
  cin >> A >> B;
  if(A <= 5) ans =0;
  else if (A<=12) ans=B/2;
  else ans = B;
  cout << ans << endl;

}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int X, int A) {
	stringstream ss;
	ss << (X < A ? 0 : 10);

	cout << ss.str() << '\n';

    return;
}

signed main() {
    int X, A;
    cin >> X >> A;
    
//    vector<int> A(N);
//    REP(i,0,N) cin >> A[i];
    
    solve(X, A);
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

map<char, string> map1 = {
    {'A', "00000"}, {'B', "00001"}, {'C', "00010"},  {'D', "00011"},
    {'E', "00100"}, {'F', "00101"}, {'G', "00110"},  {'H', "00111"},
    {'I', "01000"}, {'J', "01001"}, {'K', "01010"},  {'L', "01011"},
    {'M', "01100"}, {'N', "01101"}, {'O', "01110"},  {'P', "01111"},
    {'Q', "10000"}, {'R', "10001"}, {'S', "10010"},  {'T', "10011"},
    {'U', "10100"}, {'V', "10101"}, {'W', "10110"},  {'X', "10111"},
    {'Y', "11000"}, {'Z', "11001"}, {' ', "11010"},  {'.', "11011"},
    {',', "11100"}, {'-', "11101"}, {'\'', "11110"}, {'?', "11111"},
};
map<string, char> map2 = {
    {"101", ' '},      {"000000", '\''},  {"000011", ','},   {"10010001", '-'},
    {"010001", '.'},   {"000001", '?'},   {"100101", 'A'},   {"10011010", 'B'},
    {"0101", 'C'},     {"0001", 'D'},     {"110", 'E'},      {"01001", 'F'},
    {"10011011", 'G'}, {"010000", 'H'},   {"0111", 'I'},     {"10011000", 'J'},
    {"0110", 'K'},     {"00100", 'L'},    {"10011001", 'M'}, {"10011110", 'N'},
    {"00101", 'O'},    {"111", 'P'},      {"10011111", 'Q'}, {"1000", 'R'},
    {"00110", 'S'},    {"00111", 'T'},    {"10011100", 'U'}, {"10011101", 'V'},
    {"000010", 'W'},   {"10010010", 'X'}, {"10010011", 'Y'}, {"10010000", 'Z'},
};

int main() {
  string str;
  while (getline(cin, str)) {
    string str2 = "";
    for (auto &v : str)
      str2 += map1[v];

    string str3 = "";
    while (not str2.empty()) {
      bool flag = true;

      for (int i = 1; i <= static_cast<int>(str2.length()); ++i) {
        auto itr = map2.find(str2.substr(0, i));
        if (itr == map2.end())
          continue;
        int len = itr->first.length();
        str2 = str2.substr(len, str2.length() - len);
        str3 += itr->second;
        flag = false;
        break;
      }
      if (flag)
        break;
    }
    cout << str3 << endl;
  }
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int a, b;
	char op;
	while(cin >> a >> op >> b){
		if(op == '?') break;
		switch(op){
			case '+': cout << a + b << endl; break;
			case '-': cout << a - b << endl; break;
			case '*': cout << a * b << endl; break;
			case '/': cout << a / b << endl; break;
		}
	}
}

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

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

  int n, k;
  set<int> s;

  cin >> n >> k;

  while (k --> 0) {
    int d;
    cin >> d;

    for (int i = 0; i < d; ++i) {
      int a;
      cin >> a;

      s.emplace(a);
    }
  }

  cout << n - s.size() << '\n';

  return (0);
}


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

int main(void)
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	long long int n, r;
   cin>>n>>r;
   int c = 0;
   while (n) {
   	 c++;
   	 n /= r;
   }
   cout<<c<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<set>
using namespace std;
#define fl(i,n)             for(int i=0;i<n;i++)
#define fit(it,x)           for(auto it=x.begin();it!=x.end();it++)
#define fll(j,n)            for(int j=n-1;j>=0;j--)
#define pb                  push_back
#define mp                  make_pair
#define f                   first
#define s                   second
#define all(x)              x.begin(),x.end()
typedef vector<int>         vi;
typedef vector<double>      vd;
typedef vector<char>        vc;
typedef vector<string>      vs;
typedef map<int, int>       mii;
typedef map<string, int>    msi;
typedef pair<int, int>      pii;
typedef set<int>            si;
typedef long long ll;
const int mod = 1000000007;
int sum = 0, max = 0, min = 0;
void solve() {
    int n, k; cin >> n >> k;
    vi price;
    for (int i = 0; i < n; i++) {
        int item; cin >> item;
        price.pb(item);
    }
    sort(price.begin(),price.end());
    for (int i = 0; i < k; i++) sum += price[i];
    cout << sum << endl;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin >> test_case;
    while (test_case--) {
        solve();
        cout << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b;
    int ans=-1;
    cin >> a >> b;
    rep(i,100000){
        int x,y;
        x = i*0.08;
        y = i*0.1;
        if(x == a && y == b){
            ans = i;
            break;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll H, W; cin >> H >> W;
	char c[51][51];
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> c[i][j];
		}
	}
	int x[4] = { 1,0,0,-1 };
	int y[4] = { 0,1,-1,0 };
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (c[i][j] == '#') {
				bool valid = false;
				rep(k, 0, 4) {
					if (i + y[k] >= 0 && i + y[k] < H && j + x[k] >= 0 && j + x[k] < W) {
						if (c[i + y[k]][j + x[k]] == '#') {
							valid = true;
						}
					}
				}
				if (!valid) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

//価値の小さいほうから入れていけばいい
  int N;    cin >> N;
  vector<int> v(N);
  for(int i = 0 ; i < N ; i++)
    cin >> v[i];

  sort(v.begin() , v.end());
  double ans = (double)(v[0] + v[1]) / 2;
  for(int i = 0 ; i < N - 2 ; i++){
    ans += v[i + 2];
    ans /= 2;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(1, N):
        # print(A[i])
        if A[i] < A[i-1]:
            ans += A[i - 1] - A[i]
            A[i] = A[i-1]
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 32216
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{max, min};
use im_rc::HashSet;

#[fastout]
fn main() {
    input! {
    x: usize,
    n: usize,
    p: [usize; n]
    }
    let mut ans = 0;
    let p = p.into_iter().collect::<HashSet<usize>>();
    let mut i = 0;
    loop {
        if x >= i {
            let md = x - i;
            if !p.contains(&md){
                ans = md;
                break;
            }
        }
        let pd = x + i;
        if !p.contains(&pd) {
            ans = pd;
            break;
        }
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2196
#include <stdio.h>
#include <string.h>

//#define dprintf(arg1, ... ) printf( arg1, __VA_ARGS__)
#define dprintf(arg1, ... ) 

int map[32][32];
int supply;
int h, w;

int alldemand;

struct s_ret {
	int cnt;
	int regmin;
};

struct s_ret memo[32][33][32][33];


inline int max ( int a, int b ) {
	return (a>b)? a : b;
}
inline int min ( int a, int b ) {
	return (a<b)? a : b;
}

int sum_region( int x0, int x1, int y0, int y1 ) {
	int sum = 0;
	
	for ( int i=y0; i<y1; i++ ) {
		for ( int j=x0; j<x1; j++ ) {
			sum += map[i][j];
		}
	}
	
	return sum;
}

struct s_ret divide( int x0, int x1, int y0, int y1 ) {
	
	if ( memo[x0][x1][y0][y1].cnt != -1 ) {
		return memo[x0][x1][y0][y1];
	}

	
	dprintf("CALL %d %d %d %d\n", x0, x1, y0, y1);
	
	int sumreg = sum_region(x0, x1, y0, y1);
	if ( sumreg < (alldemand-supply) ) {
		memo[x0][x1][y0][y1].cnt = 0;
		dprintf(" Ah\n", 0);
		return memo[x0][x1][y0][y1];
	}
	
	
	struct s_ret ret = { 1, 0 };
	
	struct s_ret r1, r2;
	
	bool hukabun = true;
	
	if ( (x1-x0) > 1 ) {
		// ツ縦ツづ可環づゥ
		for ( int i=(x0+1); i<x1; i++ ) {
			r1 = divide ( x0, i, y0, y1 );
			if ( r1.cnt == 0 ) { continue; }
			r2 = divide ( i, x1, y0, y1 );
			if ( r2.cnt == 0 ) { continue; }
			
			hukabun = false;
			
			if ( ret.cnt < (r1.cnt + r2.cnt) ) {
				ret.cnt = (r1.cnt + r2.cnt);
				ret.regmin = min ( r1.regmin, r2.regmin );
			} else if ( ret.cnt == (r1.cnt + r2.cnt) ) {
				ret.regmin = max ( ret.regmin, min ( r1.regmin, r2.regmin ) );
			}
		}
	}
	
	if ( (y1-y0) > 1 ) {
		// ツ可。ツづ可環づゥ
		for ( int i=(y0+1); i<y1; i++ ) {
			r1 = divide ( x0, x1, y0, i );
			if ( r1.cnt == 0 ) { continue; }
			r2 = divide ( x0, x1, i, y1 );
			if ( r2.cnt == 0 ) { continue; }
			
			hukabun = false;
			
			if ( ret.cnt < (r1.cnt + r2.cnt) ) {
				ret.cnt = (r1.cnt + r2.cnt);
				ret.regmin = min ( r1.regmin, r2.regmin );
			} else if ( ret.cnt == (r1.cnt + r2.cnt) ) {
				ret.regmin = max ( ret.regmin, min ( r1.regmin, r2.regmin ) );
			}
		}
	}
	
	if ( /*ret.regmin == 0*/ hukabun ) {
		dprintf("  HUKABUN %d %d %d %d : return %d, sum %d\n",x0, x1, y0, y1, ret.cnt, sumreg);
		ret.regmin = sumreg;
	}
	
	dprintf(" %d %d %d %d : return %d, sum %d\n",x0, x1, y0, y1, ret.cnt, ret.regmin);
	

	memo[x0][x1][y0][y1] = ret;
	
	return ret;
}

int main(void) {
	
	while(1) {
		scanf("%d %d %d", &h, &w, &supply);
		if ( h == 0 && w == 0 && supply == 0 ) { break; }
		
		alldemand = 0;
		for ( int i=0; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				scanf("%d", &(map[i][j]) );
				alldemand += map[i][j];
			}
		}
		
		for( int i=0; i<(32*33*32*33); i++ ) {
			memo[0][0][0][i].cnt = -1;
		}
		
		struct s_ret r = divide( 0, w, 0, h );
		printf("%d %d\n", r.cnt, supply - (alldemand - r.regmin) );
	}
}

Measured memory_bytes: 9476
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll H, W, A, B;

// a^b
ll calc(ll a, ll b)
{
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 0) {
    ll d = calc(a, b/2);
    return (d * d) % MOD;
  } else {
    return (a * calc(a, b-1)) % MOD;
  }
}

// nCk
ll comb(ll n, ll k, const std::vector<ll>& v_fact, const std::vector<ll>& v_inv)
{
  ll res = (v_fact[n] * v_inv[k]) % MOD;
  res = (res * v_inv[n-k]) % MOD;
  return res;
}

int main()
{
  std::cin >> H >> W >> A >> B;

  ll N = 1000010;
  std::vector<ll> v_fact(N, 0LL);
  std::vector<ll> v_inv(N, 0LL);
  v_fact[0] = 1;
  v_inv[0] = 1;
  for (ll i = 1; i < N; i++) {
    v_fact[i] = (v_fact[i-1] * i) % MOD;
  }
  for (ll i = 1; i < N; i++) {
    v_inv[i] = (calc(i, MOD - 2) * v_inv[i-1]) % MOD;
  }

  ll ans = 0;
  for (ll d = 1; true; d++) {
    ll ny = A + d;
    ll nx = B + d;
    if (nx <= W && ny <= H) {
      ll H1 = H - ny + 1;
      ll W1 = nx;
      ll H2 = ny;
      ll W2 = W - nx + 1;
      ans = (ans + (comb(H1+W1-2, H1-1, v_fact, v_inv) * comb(H2+W2-2, H2-1, v_fact, v_inv)) % MOD) % MOD;
    } else {
      break;
    }
  }

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


Measured memory_bytes: 16000
N = int(input())
A = list(map(int, input().split()))
capacity = [1 for k in range(N+1)]
cut = 0
for k in range(N+1):
    #print(capacity)
    if A[k] >= capacity[k] and k!= N:
        print(-1)
        break
    if A[k] > capacity[k] and k == N:
        print(-1)
        break
    if k < N:
        capacity[k+1] = 2*(capacity[k] - A[k])
    if k == N:
        ans = [0 for k in range(N+1)]
        ans[0] =1
        sumA = 0
        for m in range(1, N+2):
            sumA += A[-m]
            ans[-m] = min(capacity[-m], sumA)
        print(sum(ans))





Measured memory_bytes: 707044
def main():
    N = int(input())
    As = list(map(int, input().split()))
    ans = 0
    for i in range(len(As)-1):
        if As[i+1] < As[i]:
            ans += As[i]-As[i+1]
            As[i+1] = As[i]


    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 32080
S=list(map(str,input()))
nen=0
tsuki=0
nen=int(S[0]+S[1]+S[2]+S[3])
tsuki=int(S[5]+S[6])
if nen<2019:
  print("Heisei")
elif nen>2019:
  print("TBD")
elif nen==2019 and tsuki<5:
  print("Heisei")
else:
  print("TBD")

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

typedef long long ll;
typedef long long ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;

#define MAX 1
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());


main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    map<ll, ll> m;
    ll answer = 0;
    FORE(ll, i, 1, n){
        ll num; cin >> num;
        answer += m[i - num];
        m[i + num]++;
    }
    cout << answer;
}

Measured memory_bytes: 26404
sx,sy,tx,ty = map(int,input().split())

S = ""
for k in range(2):
    if k == 1:
        S += "L"
    for i in range(ty-sy+k):
        S += "U"
    for i in range(tx-sx+k):
        S += "R"
    if k == 1:
        S += "DR"
    for i in range(ty-sy+k):
        S += "D"
    for i in range(tx-sx+k):
        S += "L"
    if k == 1:
        S += "U"

print(S)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> pii;
typedef vector<int> vi;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  priority_queue<pii >q;
  int N,R,L,S[1000001],T[1000001],d,t,x;

  cin>> N>> R>> L;
  q.push(pii(0,-1));

  for(int i=0;i<=N;i++) S[i]=T[i]=0;
  int pret=0,pred=1;

  for(int i=0;i<R;i++){
    cin>> d>> t>> x;
    S[d]+=x;
    q.push(pii(S[d],-d));
    while(1){
      pii p=q.top();
      if(p.fr==S[-p.sc]){
	T[pred]+=t-pret;
	pred=-p.sc;
	pret=t;
	break;
      }
      q.pop();
    }
  }
  T[pred]+=L-pret;
  int max=-INF;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(max<T[i]){
      max=T[i]; ans=i;
    }
  }
  cout<< ans<< endl;
}

Measured memory_bytes: 14056
#include<stdio.h>

const int mod = 1e9 + 7;
int fact[302020], rfact[302020];

int modPow(int x, int n)
{
  int ret;
  if(n == 0) return (1);
  ret = modPow(x, n / 2);
  ret = 1LL * ret * ret % mod;
  if(n % 2 == 1) {
    ret = 1LL * ret * x % mod;
  }
  return (ret);
}

int modInv(int p)
{
  return (modPow(p, mod - 2));
}

int modCombination(int p, int q)
{
  if(q < 0 || p < q) return (0);
  return (1LL * fact[p] * rfact[q] % mod * rfact[p - q] % mod);
}

void init()
{
  int i;
  fact[0] = rfact[0] = 1;
  for(i = 1; i < 302020; i++) {
    fact[i] = 1LL * fact[i - 1] * i % mod;
    rfact[i] = modInv(fact[i]);
  }
}

int main()
{
  int N, A[100000];
  int appear[100000];
  int i, left = -1, right = -1;

  for(i = 0; i < 100000; i++) appear[i] = 0;
  init();

  scanf("%d", &N);
  ++N;
  for(i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    --A[i];
    ++appear[A[i]];
  }


  for(i = 0; i < N; i++) {
    if(appear[A[i]] == 2) {
      left = i;
      break;
    }
  }
  for(i = N - 1; i >= 0; i--) {
    if(appear[A[i]] == 2) {
      right = N - i - 1;
      break;
    }
  }

  for(i = 1; i <= N; i++) {
    printf("%d\n", (modCombination(N, i) + mod - modCombination(right + left, i - 1)) % mod);
  }

  return (0);
}

Measured memory_bytes: 4224
import java.util.Scanner;

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

		long n = sc.nextLong();

		long a = (long) Math.sqrt(n);

		long ans = 0;
		for (long i = a; i >= 1; i--) {
			if (n % i == 0) {
				ans += i;
				ans += n / i;
				break;
			}
		}
		System.out.println(ans - 2);
	}
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n;
  cin >> n;
  vector <double> p (n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  vector <vector <double> > dp (2 + 1, vector <double> (n + 1, 0.0));
  dp[0][0] = 1.0;
  int id = 0;
  for (int i = 1; i <= n; i++) {
    id = (id^1);
    for (int j = 0; j <= i; j++) dp[id][j] = 0;
    for (int j = 0; j <= i; j++) {
      if(j) dp[id][j] += dp[id ^ 1][j - 1] * p[i];
      dp[id][j] += dp[id ^ 1][j] * (1 - p[i]);
    }
  }
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    if (i > n - i) ans += dp[id][i];
  }
  cout << setprecision(10) << fixed;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void solve()
{
    int n;
    cin>>n;

    cout<<(n+1)/2<<endl;
}

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

        solve();

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b;int k;cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    if(i%2==0){a/=2;b+=a;}
    else{b/=2;a+=b;}
  }
  cout<<a<<' '<<b<<endl;
}
   


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;
    OP(H * W - H * w - W * h + h * w);

    
    return 0;
}

Measured memory_bytes: 256
<?php
  //分ける場所を移動させてく.
  //左側を切り分ける
  //右側をfor文で回して in_array
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%s",$s);

//$a_li=explode(" ",trim(fgets(STDIN)));

$c=0;
$max=0;

for($i=1;$i<$n;$i++){
  $tmp_s=$s;
  $right_s = substr($s, $i);  // abcd
  $left_s = str_replace($right_s,'',$tmp_s);
  $right_s = array_unique(str_split($right_s));
  $left_s= str_split($left_s);
  foreach($right_s as $v){
    if(in_array($v,$left_s)){
      $c++;
    }
  }
  $max=max($c,$max);
  $c=0;
}

echo $max."\n";




Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    lint ret = o;
    ret += 2 * (i / 2);
    ret += 2 * (j / 2);
    ret += 2 * (l / 2);
    if (j > 0 && l > 0 && i > 0) {
        if (j % 2 == 1 && l % 2 == 1 && i % 2 == 1)
            ret += 3;
        else if ((j % 2 == 1 && l % 2 == 1) || (l % 2 == 1 && i % 2 == 1) || (i % 2 == 1 && j % 2 == 1))
            ret += 1;
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    int N,A,B;
    cin>>N>>A>>B;
    int r=0;
    for(int i=1;i<=N;i++){
        int c=0;
        int t=i;
        for(int j=0;j<5;j++)c+=t%10,t/=10;
        if(A<=c&&c<=B)r+=i;

    }

    cout<<r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)){
    if(s.at(1)==s.at(2)){
      cout << "No" << "\n";
    }
    else{
      cout << "Yes" << "\n";
    }
  }else{
    cout << "Yes" << "\n";
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;



// Geometry
using Float = long double;
using Point = complex<Float>;
constexpr Float EPS = 1e-7;

inline int sgn(const Float &r) {
	return (r > EPS) - (r < -EPS);
}
bool operator==(const Point &a, const Point &b) {
	bool xeq = sgn(real(a) - real(b)) == 0;
	bool yeq = sgn(imag(a) - imag(b)) == 0;
	return xeq && yeq;
}
bool operator<(const Point &a, const Point &b) {
	int xsgn = sgn(real(a) - real(b));
	if (xsgn == 0) {
		return sgn(imag(a) - imag(b)) < 0;
	}
	return xsgn < 0;
}

Float dot(const Point &a, const Point &b) {
	return real(conj(a)*b);
}
Float cross(const Point &a, const Point &b) {
	return imag(conj(a)*b);
}

struct Circle {
	Point center;
	Float radius;

	Circle() {}
	Circle(const Point &center, const Float &radius)
		: center(center), radius(radius) {}

	// 1: interior, 0: boundary, -1: exterior
	int relation(const Point &p) const {
		return sgn(radius - abs(p - center));
	}
};

vector<Point> intersection(const Circle &a, const Circle &b) {
	Point p = b.center - a.center;
	Float d = norm(p);
	Float t = (d + a.radius*a.radius - b.radius*b.radius) / 2.;
	Float q = d*a.radius*a.radius - t*t;
	int qsgn = sgn(q);
	vector<Point> ret;
	if (qsgn < 0) return ret;
	ret.emplace_back(
		(t*real(p) + imag(p)*sqrt(q)) / d,
		(t*imag(p) - real(p)*sqrt(q)) / d
	);
	if (qsgn > 0) {
		ret.emplace_back(
			(t*real(p) - imag(p)*sqrt(q)) / d,
			(t*imag(p) + real(p)*sqrt(q)) / d
		);
	}
	for (auto &x : ret) {
		x += a.center;
	}
	return ret;
}


int main() {
	int n; cin >> n;
	vector<Point> p(n);
	for (int i = 0; i < n; i++) {
		Float x, y; cin >> x >> y;
		p[i] = { x, y };
	}
	vector<Circle> c(n);
	for (int i = 0; i < n; i++) c[i].center = p[i];
	auto ok = [&](const Point &center) {
		bool ret = true;
		for (int i = 0; i < n; i++) {
			ret &= c[i].relation(center) >= 0;
		}
		return ret;
	};
	Float lo = 0, hi = 1e9;
	for (int iter = 0; iter < 100; iter++) {
		Float mid = (hi + lo)/2;
		for (int i = 0; i < n; i++) c[i].radius = mid;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				auto points = intersection(c[i], c[j]);
				cerr << points.size() << endl;
				for (const auto &v : points) {
					flag |= ok(v);
				}
			}
		}
		if (flag) hi = mid;
		else lo = mid;
	}
	printf("%.15Lf\n", hi);
	return 0;
}


Measured memory_bytes: 384
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

x,y = map(int,stdin.readline().rstrip().split())

for i in range(x+1):
    j = x-i
    if i*2+j*4 == y:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 9168
N, K = map(int, input().split())

bucket = [0] * (10 ** 5 + 1)
for _ in range(N):
    a, b = map(int, input().split())
    bucket[a] += b

cnt = 0
for i, c in enumerate(bucket):
    if c == 0:
        continue
    cnt += c
    if cnt >= K:
        print(i)
        exit()

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

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

    vector<int> price(n);
    vector<vector<int>> skill(n, vector<int>(m));

    rep(i, n){
        cin >> price[i];

        rep(j, m){
            cin >> skill[i][j];
        }
    }

    int ans = INT_MAX;
    
    for(int bit = 0; bit < (1<<n); bit++){
        vector<int> tmpskill(m);
        int tmpsum = 0;

        rep(i, n){
            if(bit & (1<<i)){
                tmpsum += price[i];

                rep(j, m){
                    tmpskill[j] += skill[i][j];
                }
            }
        }

        bool able = true;
        rep(i, m){
            if(tmpskill[i] < x){
                able = false;
                break;
            }
        }

        if(able){
            ans = min(ans, tmpsum);
        }
    }

    if(ans == INT_MAX){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
N = int(input())
S = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            s = ["0", "0", "0"]
            s[0] = str(i)
            s[1] = str(j)
            s[2] = str(k)

            ind = 0
            cnt = 0
            while cnt < 3 and ind < N:
                if S[ind] == s[cnt]:
                    cnt += 1
                ind += 1

                if cnt == 3:
                    ans += 1

print(ans)


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  int64_t n, m;
  cin >> n;

  map<int64_t, set<int64_t>> ds;
  map<int64_t, set<int64_t>> dl;

  REP(i, n){
    ds[i] = {};
    dl[i] = {};
  }  
  int64_t dist;
  REP(i, n){
    cin >> dist;
    if(i-dist>=0){
      dl[i-dist].insert(i);
    }
    if(i+dist<n){
      ds[i+dist].insert(i);
    }
  }

  int64_t count = 0;
  REP(i, n){
    if( ds[i].size()>0 && dl[i].size()>0){
      count += ds[i].size()*dl[i].size();
    }
  }  
  cout << count;
  return 0;
}

Measured memory_bytes: 59712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 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;
}
signed main() {
    int N;
    cin >> N;
    int sum = 0, mm = 0;
    rep(i, N) {
        int l;
        cin >> l;
        chmax(mm, l);
        sum += l;
    }
    if(mm < sum - mm)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t n, m, s;
uint32_t a[11];
uint32_t q[51][4];
uint64_t max;
void df(int d){
	if(d==0){
		uint64_t now=0;
		for(uint32_t i=s; i>0; i--){
			if(a[q[i][1]]-a[q[i][0]]==q[i][2]) now+=q[i][3];
		}
		if(now>max) max=now;
	}else{
		for(uint32_t i=a[d]; i>0; i--){
			a[d-1]=i;
			df(d-1);
		}
	}
}

int main(void){
	scanf("%"SCNu32"%"SCNu32"%"SCNu32, &n, &m, &s);
	for(uint32_t i=s; i>0; i--){
		scanf("%"SCNu32"%"SCNu32"%"SCNu32"%"SCNu32, &q[i][0], &q[i][1], &q[i][2], &q[i][3]);
		q[i][0]--;
		q[i][1]--;
	}
	a[n]=m;
	df(n);
	printf("%"PRIu64"\n", max);
}



Measured memory_bytes: 1732
#include <stdio.h>
#include <stdlib.h>

#define Mod 1000000007

typedef struct List {
	struct List *prev, *next;
	long long v;
} list;

int main()
{
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	if (A > B) {
		B += A;
		A = B - A;
		B -= A;
	}
	
	int i, j, k;
	list **head = (list**)malloc(sizeof(list*) * B), **tail = (list**)malloc(sizeof(list*) * B), *d = (list*)malloc(sizeof(list) * B * (A + 1)), *p;
	long long ans = 0, dp[2][5001], tmp[2], pow;
	if (A == 1 || B == 1) {
		for (i = 1, ans = 1; i <= N; i++) ans = ans * 2 % Mod;
	} else if (A == B) {
		for (j = A - 2, dp[A%2][A-1] = 2; j >= 1; j--) dp[A%2][j] = dp[A%2][j+1] * 2 % Mod;
		for (i = A + 1, ans = 2; i <= N; i++) {
			ans = (ans * 2 + dp[1-i%2][A-1]) % Mod;
			for (j = A - 2, dp[i%2][1] = dp[1-i%2][A-1]; j >= 1; j--) {
				dp[i%2][j+1] = dp[1-i%2][j];
				dp[i%2][1] += dp[1-i%2][j];
			}
			dp[i%2][1] %= Mod;
		}
	} else {
		for (j = 0; j <= B - 1; j++) {
			head[j] = &(d[j*(A+1)]);
			tail[j] = &(d[j*(A+1)+A]);
			d[j*(A+1)].v = 0;
			d[j*(A+1)].prev = &(d[j*(A+1)+A]);
			d[j*(A+1)+A].next = &(d[j*(A+1)]);
			for (k = 1; k <= A; k++) {
				d[j*(A+1)+k].v = 0;
				d[j*(A+1)+k].prev = &(d[j*(A+1)+k-1]);
				d[j*(A+1)+k-1].next = &(d[j*(A+1)+k]);
			}
		}
		d[1].v = 1;
		d[A+1].v = 1;
		for (i = 2, pow = 2; i <= N; i++, pow = pow * 2 % Mod) {
			for (j = 0, tmp[0] = 0; j <= B - 1; j++) tmp[0] += head[j]->v + tail[j]->v;
			tmp[0] = (pow - ans - tmp[0] + tail[B-A]->v) % Mod;
			if (tmp[0] < 0) tmp[0] += Mod;
			ans = (ans * 2 + head[B-1]->v + tail[B-A]->prev->v + tail[B-A-1]->v * 2) % Mod;
			
			for (j = B - 1, tmp[1] = head[B-A]->v; j > B - A; j--) {
				tmp[1] += head[j]->v;
				head[j]->v = head[j-1]->v;
				if (j >= A + 1) head[j]->v = (head[j]->v + tail[j-A-1]->v) % Mod;
			}
			head[B-A]->v = tmp[1] % Mod;
			tail[B-A]->v = head[B-A-1]->v;
			if (B - A >= A + 1) tail[B-A]->v += tail[B-A*2-1]->v;
			tail[B-A]->v %= Mod;
			head[B-A] = tail[B-A];
			tail[B-A] = tail[B-A]->prev;
			for (j = B - A - 1; j >= A + 1; j--) {
				tail[j]->prev->v = (tail[j]->prev->v + tail[j-1]->v) % Mod;
				tail[j]->v = (head[j-1]->v + tail[j-A-1]->v) % Mod;
				head[j] = tail[j];
				tail[j] = tail[j]->prev;
			}
			for (; j >= 1; j--) {
				tail[j]->prev->v = (tail[j]->prev->v + tail[j-1]->v) % Mod;
				tail[j]->v = head[j-1]->v;
				head[j] = tail[j];
				tail[j] = tail[j]->prev;
			}
			head[1]->v = tmp[0];
			head[0] = tail[0];
			tail[0] = tail[0]->prev;
			head[0]->v = 0;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 325372
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int n, ans = 0;
long long t;
vector<long long> a;

int main() {
	cin >> n >> t;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	long long Max = 0;
	int old = 0;
	map<int, vector<int>>ids;
	for (int i = 1; i < n - 1; i++) {
		if (a[i] > a[i - 1] && a[i] > a[i + 1]) {
			if (ids.size() == 0) {
				ids[i] = {0, i - 1};
				old = i;
			}
			else {
				ids[i] = { old + 1, i - 1 };
				old = i;
			}
		}
	}
	if (a[n - 1] > a[n - 2]) {
		ids[n - 1] = {old + 1, n - 1};
	}
	int Gmin = 10000000000;
	for (auto it = ids.begin(); it != ids.end(); it++) {
		int id = 0;
		long long Min = 10000000000;
		for (int i = it->second[0]; i <= it->second[1]; i++) {
			if (Gmin > a[i]) {
				Gmin = a[i];
				id = i;
			}
		}
		if (Max < a[it->first] - Gmin) {
			Max = a[it->first] - Gmin;
			ans = 1;
		}
		else if(Max == a[it->first] - Gmin){
			ans++;
		}
	}
	cout << ans << endl;
//	cin >> t;
	return 0;
}

Measured memory_bytes: 6528
while True:
    a, op, b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == "?":
        break
    if op == "+":
        print(a+b)
    if op == "-":
        print(a-b)
    if op == "*":
        print(a*b)
    if op == "/":
        print(a//b)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  string s;
  cin>>s;
  int red=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='R')
      red++;
  }
  if(red==n || red==0)
  {
    cout<<0<<endl;
    exit(0);
  }
  int ans=red;
  int alr=0;
  for(int i=0;i<red;i++)
  {
    if(s[i]=='R')
      alr++;
  }
  int curr=red-alr;
  ans=min(ans,curr);
  cout<<ans<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 3948
n,m = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i).sort_by{|a| -a}

while m > 0 do
  m -= 1
  max = a_arr.shift
  max_2 = max / 2
  index = a_arr.bsearch_index{|a| a < max_2} || a_arr.length
  # indexよりも前の要素は(割引券がある限り)割引対象になる
  t = m >= index ? index : m
  (0..(t-1)).each do |i|
    a_arr[i] /= 2
  end
  m -= t
  a_arr << max_2
  a_arr = a_arr.sort_by{|a| -a}
end

puts a_arr.inject(&:+)




Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int n, k, a[MAXN];
void run(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int ans = 0;
    for(int i = 1; i <= k; i++) ans += a[i];
    cout << ans;
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 3612
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        h1: i32,
        m1: i32,
        h2: i32,
        m2: i32,
        k: i32,
    }

    println!("{}", (h2 * 60 + m2 - (h1 * 60 + m1) - k).max(0));
}


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

const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


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

  mint ans = 0;
  for (ll i = 0; i < 60; i++) {
    ll number_of_zeros = 0;
    for (ll j = 0; j < N; j++) if(A[j]>>i & 1) number_of_zeros++;
    mint now = number_of_zeros * (N - number_of_zeros);
    mint multiplier = 2; multiplier = multiplier.pow(i);

    ans += now * multiplier;
  }

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


Measured memory_bytes: 2560
import numpy as np
import sys
def input(): return sys.stdin.readline().strip()

n = int(input())
As = list(map(int, input().split()))
ans = n
val = 10 ** 6
table = np.array([0] * (val + 1))
for a in As:
    if table[a] > 1:
        continue
    table[::a] += 1
for a in As:
    ans -= (table[a] > 1)
print(ans)


Measured memory_bytes: 53508
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

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

  string ans = "Yes";
  for (int i = N - 2; i >= 0; i--) {
    if (H[i + 1] >= H[i]) {
    } else if (H[i + 1] + 1 == H[i]) {
      H[i]--;
    } else {
      ans = "No";
      break;
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int n=0;
  int buy[10];
  int i;
  int max =0;
  int sum =0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&buy[i]);
    sum = sum +buy[i];
    if(max<buy[i]) max =buy[i];
 }
  sum = sum - (max/2);
  printf("%d",sum);
}

Measured memory_bytes: 128
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=lcm(c,d);
	int ans=(b/c-(a-1)/c)+(b/d-(a-1)/d)-(b/x-(a-1)/x);
	cout<<b-a+1-ans<<endl;
	return 0;
}
signed main()
{	
	fastio;
//	test
		solve();
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int k;
    string s;
    cin >> s >> k;
    int i=0;
    while (s[i]=='1')
    {
        k--;i++;
        if (k==0) {printf("1\n");return 0;}
    }
    cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
fn read_as_vec(buf: &mut String) -> Vec<i16> {
    std::io::stdin().read_line(buf).ok();
    buf.split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let mut buf = String::new();
    let lhw = read_as_vec(&mut buf);
    buf.clear();
    let hw = read_as_vec(&mut buf);
    println!("{}", (lhw[0] - hw[0]) * (lhw[1] - hw[1]));
}


Measured memory_bytes: 4352
//import java.lang.Math;
import java.util.*;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;

class Main{

	public static void main(String[] arg) {

		
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] demo= new int[n];
		for(int i=0;i<n;i++){
			demo[i]=sc.nextInt();
			
		}
		int m=sc.nextInt();
		int[] demo2= new int[m];
		for(int i=0;i<m;i++){
			demo2[i]=sc.nextInt();
			
		}
		
		int c=Math.min(n, m);
		int key=0;
		for(int i=0;i<c;i++){
			//if(demo[i]==demo2[i])continue;
			if(demo[i]!=demo2[i]){
				
			if(demo[i]<demo2[i]){ 
				key=1;
			}	
			else if(demo[i]>demo2[i]){ 
				key=-1;
				
				}
			break;}		 
		}  
		if(key==1||(key==0&&n<m)){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
			}		}


Measured memory_bytes: 31976