akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) (1ll << 12) + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	ll ans = 0, p = 0;
	for(int i = s.size()-1;i>=0;i--){
		if(s[i] == 'B'){
			ans += p;
			p--;
		}
		p++;
	}
	cout << ans;
	return 0;
}


/*
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N=S.size();
    ll ans=0;
    for(ll i=1;i<=N;++i){
        for(ll j=0;j<=N-i;++j){
            ans+=stoll(S.substr(j,i))*(1LL<<(max(0LL,j-1)+max(0LL,N-i-j-1)));
            //cout<<S.substr(j,i)<<" "<<(1LL<<(max(0LL,j-1)+max(0LL,N-i-j-1)))<<endl;
        }
    }
    prt(ans)

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
map<int,int> m;

int mn=200,mx=0;
bool t=true;

int main(){
  cin >> n;
  int a;
  rep(i,0,n){
    cin >> a;
    mn = min(mn,a);
    mx = max(mx,a);
    m[a]++;
  }

  if(mx%2==0){
    if(mn!=mx/2)t=false;
    if(m[mn]!=1)t=false;
    rep(i,mn+1,mx+1){
      if(m[i]<2)t=false;
    }
  }else{
    if(mn!=(mx+1)/2)t=false;
    if(m[mn]!=2)t=false;
    rep(i,mn+1,mx+1){
      if(m[i]<2)t=false;
    }
  }

  if(t){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from math import sqrt
a,b,c=map(int,input().split())
g=gcd(a,b); s=int(sqrt(g)); ans=set()
for i in range(1,s+1):
    if g%i==0:
        ans.add(i)
        ans.add(g//i)
ans=list(ans)
ans.sort(reverse=True)
print(ans[c-1])

Measured memory_bytes: 66156
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define ULLint unsigned long long int

ULLint gcd(ULLint a, ULLint b) {
	if (b ==  0)
		return a;

	return gcd(b, a % b);
}

ULLint lcm(ULLint a, ULLint b) {
	ULLint x = gcd(a, b);
	ULLint c = gcd(a, x);
	x /= c;
	a /= c;
	c = gcd(b, x);
	x /= c;
	b /= c;
	return a * b / x;
}

int main() {
	ULLint T[100];
	int N;
	unsigned long long int Time;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%llu", &T[i]);
	}
	Time = T[0];
	for (int i = 1; i < N; i++) {
  		Time = lcm(Time, T[i]);
	}
	printf("%llu", Time);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using u64 = std::uint_fast64_t;


#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

template <std::uint_fast64_t Modulus>
modint<Modulus> pow(modint<Modulus> x, u64 exp){
  modint<Modulus> ret = 1;

  for(;exp>0;exp>>=1,x=x*x){
    if(exp%2==1) ret = ret * x;
  }
  return ret;
  
}

void solve(void){

  int k;
  std::cin >> k;
  std::string s;
  std::cin >> s;

  u64 total_len = k + s.size();

  modint<1000000007> ret = 0;
  modint<1000000007> combi = 1;
  for(int i=s.size(); i<=total_len; i++){
    if(i != s.size()){
      combi *= i-1;
      combi /= i-s.size();
    }

    modint<1000000007> tmp1 = 25;
    modint<1000000007> tmp2 = 26;
    tmp1 = pow(tmp1, i-s.size());
    tmp2 = pow(tmp2, total_len-i);
    //std::cout << tmp1.a << " " << tmp2.a << " " << combi.a << std::endl;
    ret += tmp1 * tmp2 * combi; 
    
  }

  std::cout << ret.a << std::endl;

}

int main(void){

  solve();
  
  return 0;
}


Measured memory_bytes: 5296
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//const int MAX = 700000;
static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    ll N, ans = 0;

    // input
    cin >> N;

    // process
    ll R = 0, G = 0, B = 0;
    ans = 1;

    for (ll i = 0; i < N; i++) {
        ll A, x = 0;
        cin >> A;

        if (A == R) {
            x++;
        }
        if (A == G) {
            x++;
        }
        if (A == B) {
            x++;
        }

        if (A == R) {
            R++;
        } else if (A == G) {
            G++;
        } else if (A == B) {
            B++;
        }

        ans *= x;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
edge = Array.new(n+1){[]}
(n-1).times do
    a, b = gets.split.map(&:to_i)
    edge[a] << b
    edge[b] << a
end

m = 10 ** 9 + 7

stack = [[1, 0, 0]]
ans = 1
while x = stack.shift
    now, par, s = x
    ans = ans * (k - s) % m

    i = par == 0 ? 1 : 2
    edge[now].each do |y|
        next if y == par
        stack << [y, now, i]
        i += 1
    end
end

puts ans

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

int main(){
    long n, a, b;
    cin >> n >> a >> b;
    long cnt = n/(a+b);
    long rem = n%(a+b);
    if (rem >= a) cout << a*(cnt+1) << endl;
    else cout << a*cnt + rem << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int r;
    cin >> r;

    cout << r * r << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int n, m; cin >> n >> m;
    vector<int> f(m + 1, 0);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int x; cin >> x;
            f[x]++;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= m; i++) {
        if (f[i] == n) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338; // double PI = 4*atan(1);

void solver(){
	int a,b;
	cin >> a >> b;
	a--,b--;
	cout << (a+b-1)/a << endl; // reduce by 1 because one socket already exist in a
}	 

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	//int t;
	//cin >> t;
	//while(t--){
	solver();
 }


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int k, s;
    cin >> k >> s;

    ll count=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z>=0 && z<=k) count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <sstream>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << os.str();                            \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

int N, K;
int ans = INF;

void dfs(int n, int cnt)
{
    if (cnt == N) {
        ans = min(ans, n);
        return;
    }
    dfs(n * 2, cnt + 1);
    dfs(n + K, cnt + 1);
}

signed main()
{
    cin >> N >> K;

    dfs(1, 0);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[4][n+2];
    int i,j;
    for(i=0;i<4;i++)
    {
        for(j=0;j<n+2;j++)
        {
            a[i][j]=0;
        }
    }
    for(i=1;i<3;i++)
    {
        for(j=1;j<n+1;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i=2;i>=1;i--)
    {
        for(j=n;j>=1;j--)
        {
            a[i][j]=a[i][j]+max(a[i+1][j],a[i][j+1  ]);
        }
    }



    cout << a[1][1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int a[110];
    int total = 0;
    int xtotal = 0;
    for(int i = 0; i < m; i++) cin >> a[i];
    for(int i = 0; i < m; i++){
        if(a[i] > x) xtotal++;
        else total++;
    }

    if(xtotal > total) cout << total << endl;
    else cout << xtotal << endl;
}
   

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

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

	char ans = (char)(N + 1);
	cout << ans << endl;
}

Measured memory_bytes: 3192
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int x[15][15], y[15][15];
    int A[15];
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    rep(bit, (1 << N)) {
        bool ok = true;
        int tmp = 0;
        rep(i, N) {
            if(!(bit & (1 << i))) continue;
            tmp++;
            rep(j, A[i]) {
                bool state = !(!((1 << x[i][j]) & bit));
                if(state != y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
const int mod = 1e9 + 7;

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll sum[n];
    sum[n - 1] = a[n - 1];
    for (ll i = n - 2; i >= 0; i--)
    {
        sum[i] = ((sum[i + 1] % mod) + (a[i] % mod)) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        ans = ((ans % mod) + ((a[i] % mod) * (sum[i + 1] % mod)) % mod) % mod;
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
}

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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> abc(N, vector<int>(3)), dp(N, vector<int>(3));
	for (vector<int>& i : abc) {
		for (int& j : i) cin >> j;
	}
	for (int i = 0; i < 3; ++i) dp[0][i] = abc[0][i];
	for (int i = 1; i < N; ++i) {
		dp[i][0] = abc[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = abc[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = abc[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max({ dp.back()[0], dp.back()[1], dp.back()[2] });
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

long long int gcd(long long int a, long long int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

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

int main(void) {
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;
    long long int E = B - A + 1;
    long long int F = lcm(C, D);
    long long int tmp1 = (B/C) - ((A-1)/C);
    long long int tmp2 = (B/D) - ((A-1)/D);
    long long int tmp3 = (B/F) - ((A-1)/F);
    cout << E - tmp1 - tmp2 + tmp3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x1,y1,x2,y2,ans;
    cin>>x1>>y1>>x2>>y2;
    printf("%.5f\n",sqrt(pow((x2-x1),2)+pow((y2-y1),2)));
}


Measured memory_bytes: 3228
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			char[] x = sc.next().toCharArray();
			char[] y = new char[8];
			
			Arrays.sort(x);
			
			for(int j = 0; j < 8; j++)
				y[j] = x[7 - j];
			
			int max = Integer.parseInt(String.valueOf(y));
			int min = Integer.parseInt(String.valueOf(x));
			
			System.out.println(max - min);
		}
		sc.close();
	}
}

Measured memory_bytes: 17288
#ABC144-C Walk on Multiplication Table

N = int(input())
for i in reversed(range(1,int(N ** 0.5)+1)): #forの逆向きの回し方。このやり方以外だとrangeがNoneを返しやすい?
    if N % i == 0:
        print(i + N//i -2)
        break


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

using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
 
template<class Z> map<Z, int> factorize(Z n) {
  map<Z, int> res;
  for (Z i = 2; i * i <= n; ++i) while (n % i == 0) ++res[i], n /= i;
  if (n != 1) ++res[n];
  return res;
}


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
   */

   long long int a,b;
   cin>>a>>b;
   long long int num=__gcd(a,b);
   auto mp=factorize(num);
   cout<<mp.size()+1<<endl;

       return 0;
    
}

Measured memory_bytes: 3604
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int H, W;
    int[][] F;
    bool input() {
        readf("%d %d\n", &H, &W);
        if (H == 0 && W == 0) return false;
        F = iota(0, H, 1).map!((i) => readln.chomp.split(" ").map!(to!int).array).array;
        return true;
    }
    void solve() {
        int calc_vol(int sy, int sx, int ty, int tx) {
            auto ys = [sy - 1, ty + 1];
            auto xs = [sx - 1, tx + 1];
            int min_height = int.max;
            foreach (y; ys) {
                for (int x = sx - 1; x <= tx + 1; x++) {
                    min_height = min(min_height, F[y][x]);
                }
            }
            foreach (x; xs) {
                for (int y = sy - 1; y <= ty + 1; y++) {
                    min_height = min(min_height, F[y][x]);
                }
            }

            int vol = 0;
            for (int y = sy; y <= ty; y++) {
                for (int x = sx; x <= tx; x++) {
                    if (F[y][x] >= min_height) return 0;
                    vol += min_height - F[y][x];
                }
            }
            return vol;
        }

        int ans = 0;
        for (int sy = 1; sy <= H - 2; sy++) {
            for (int sx = 1; sx <= W - 2; sx++) {
                for (int ty = sy; ty <= H - 2; ty++) {
                    for (int tx = sx; tx <= W - 2; tx++) {
                        ans = max(ans, calc_vol(sy, sx, ty, tx));
                    }
                }
            }
        }
        writeln(ans);
    }
    while (input()) {
        solve();
    }
}

Measured memory_bytes: 3232
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long MOD = 1000000007;
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			ans += A[i];
		}
		ans %= MOD;
		ans = (ans * ans)%MOD;
		for(int i=0; i<N; i++) {
			ans = (ans - (((long)A[i]*A[i])%MOD)+MOD)%MOD;
		}
		
		System.out.println(ans%2==0 ? ans/2 : (ans+MOD)/2);

		sc.close();
	}
}


Measured memory_bytes: 49992
#include <bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
/*#define cin fin
#define cout fout
ifstream cin("input.in");ofstream cout("output.out");*/
int main() 
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n,a[1009];
    cin>>n;
    set<long> s;
    for(long i=1;i<=10000;i++)
        s.insert(i);
    rep(i,0,n){
        cin>>a[i];
        //cout<<a[i]<<" ";
        s.erase(a[i]);
    }
    //cout<<"\n";
    //for(auto i:s)
    //    cout<<i<<" ";
    long p=0,k=1;
    if(a[1]==a[0]){
        p++;
        k=2;
        a[1]=*s.begin();
        s.erase(s.begin());
    }
    //for(long i=0;i<n;i++)
    //    cout<<a[i]<<" ";
    //cout<<"\n";
    a[n]=0;
    for(long i=k;i<n;i++){
        if(a[i]==a[i-1] || a[i]==a[i+1]){
            p++;
            i++;
            a[i]=*s.begin();
            s.erase(s.begin());
        }
    }
    //for(long i=0;i<n;i++)
    //    cout<<a[i]<<" ";
    //cout<<"\n";
    cout<<p;
}

Measured memory_bytes: 768
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 100005;
ll a[MAX];
map<ll, ll> mp;

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
		mp[a[i]] = i;
	}
	sort(a + 1, a + 1 + n);
	ll cnt = 0;
	REP(i, 1, n) {
		ll b = a[i];
		cnt += (abs(mp[b] - i) % 2);
	}
	cout << cnt / 2 << endl;

}

Measured memory_bytes: 7296
def resolve():
    N, M = list(map(int, input().split()))
    AB = {}
    for _ in range(M):
        a, b = list(map(int, input().split()))
        a, b = a-1, b-1
        if a not in AB:
            AB[a] = []
        if b not in AB:
            AB[b] = []
        AB[a].append(b)
        AB[b].append(a)

    import collections
    q = collections.deque([0])
    passed = [-1 for i in range(N)]
    passed[0] = 0
    while q:
        node = q.pop()
        for nxt in AB[node]:
            if passed[nxt] == -1:
                passed[nxt] = node
                q.appendleft(nxt)
    #print(metrics)
    for m in passed:
        if m == -1:
            print("No")
            return
    print("Yes")
    for i in range(1, N):
        print(passed[i]+1)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[200010],ans[200010];

int main() {
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll z;
		cin>>z;
		a[i]=z;
		if(i*2>n){
			ans[i]=z;
		}
	}
	for(int i=n/2;i>=1;i--){
		ll sum=0;
		for(int j=1;i*j<=n;j++){
			sum+=ans[i*j];
		}
		if(sum%2!=a[i]){
			ans[i]=1;
		}
	}
	ll cnt=0;
	for(int i=1;i<=n;i++){
		if(ans[i]==1){
			cnt++;
		}
	}
	cout << cnt<<endl;
	for(int i=1;i<=n;i++){
		if(ans[i]==1){
			cout << i << " ";
		}
	}
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>WA(n,0);
  vector<bool>AC(n,false);
  int WA_cnt = 0;
  int AC_cnt = 0;
  for(int i=0;i<m;i++){
    int p;
    string s;
    cin >> p >> s;
    if(AC[p]) continue;
    if(s=="AC"){
      AC[p] = true;
      AC_cnt++;
      WA_cnt += WA[p];
    }
    else if(s=="WA"){
      WA[p]++;
    }
  }
  cout<< AC_cnt <<" "<< WA_cnt <<endl;
}


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

int main(){
    int n, p[100];
    while(cin >> n){
        for(int i = 0; i < n; i++){
            cin >> p[i];
        }
        sort(p, p+n);
        int a = 0, t = 0;
        for(int i = 0; i < n; i++){
            a += t + p[i];
            t += p[i];
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for (double i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
const int INF=1001001001;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
  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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  ll n;
  cin>>n;
  vector<ll> c(n);
  rep(i,n)cin>>c[i];
  sort(c.begin(),c.end());
  vector<mint> v(n+5);
  mint temp=1;
  rep(i,n+1){
    v[i]=temp;
    temp*=2;
  }
  mint ans=0;
  rep(i,n){
    mint now=0;
    int x=n-1-i;
    now+=(v[x]/2)*x;
    now+=v[x];
    now*=v[i];
    now*=c[i];
    now*=v[n];
    ans+=now;

  //  cout<<x<<"x"<<i<<"i"<<now<<"now"<<endl;
  }

cout<<ans.x;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k;
double a[35], ans;
int main(){
	scanf("%d%d", &n, &m);
	for(i=1; i<=n; i++){
		if(i < m){
			for(k=1; (i<<k)<m; k++);
			ans += 1.0/n / (1<<k);
		}
		else ans += 1.0 / n;
	}
	printf("%.9lf\n", ans);
	return 0;
}

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

int main() {
    int Q; cin >> Q;
    while(Q--) {
        int C, A, N; cin >> C >> A >> N;
        int ans = 0;
        for(int k = 0; k <= N; k++) {
            for(int i = 0; i <= (A-k); i++) {
                for(int j = 0; j <= (C-k-2*i)/3; j++) {
                    int c = i*2 + j*3 + k;
                    int a = i + k;
                    int n = k;
                    if(c <= C && a <= A && n <= N) ans=max(ans,i+j+k);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
console.log(function(args){
  const [[X,N],p] = args.trim().split('\n').map( r=>r.split(' ').map(x=>parseInt(x,10)) );
  if ( N === 0 || !p.some(v=>v===X) ) return X.toString();
  for ( let i = 1; i <= 100; i++ ) {
    if ( !p.some(v=>v===X-i) ) return (X-i).toString();
    if ( !p.some(v=>v===X+i) ) return (X+i).toString();
  }
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29632
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
int n;
int main(){
	
	_io;
	cin>>n;
	cout<< n*n*n;
}


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

int main()
{
	int i,j,n,d,k;
	cin>>n>>k;
	int a[n+1]={0};
	for(i=0;i<k;i++)
	{
		cin>>d;
		for(j=0;j<d;j++)
		{
			int x;
			cin>>x;
			a[x]++;
			
		}
	}
	int ans=0;int f=0;
	
	for(i=1;i<n+1;i++)
	{
		if(a[i]==0)
		{
			ans++;
		}
	}
	
	cout<<ans;
	
}

Measured memory_bytes: 3624
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
#define N              1e5+1
 
void solve()
{
	ll n;
	
	cin>>n;
	
	cout<<n*n;
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int A = s.nextInt(), B = s.nextInt(), C = s.nextInt(), x = 0, y = 0, z = 0;
		if(A == B) x++;
		if(B == C) y++;
		if(C == A) z++;
		System.out.println(x + y + z == 1 ? "Yes" : "No");
	}
}

Measured memory_bytes: 35820
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0  |  \
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;
#define MAX 50 







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 






int main()
{
	long long int k,n,i,sum=0;
	cin>>n>>k;
	int ar[n];
	for(i=0;i<n;i++)
		cin>>ar[i];
	sort(ar,ar+n);
	for(i=0;i<k;i++)
		sum+=ar[i];

	cout<<sum;


	return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

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

    sort(p,p+n);
    int sum=0;

    for(int i=0;i<k;i++)
    	sum+=p[i];
    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		for(int i =0;i < h+2;i++) {
			StringBuilder sb = new StringBuilder();
			for(int j =0;j < w+2;j++) {
				if(i ==0 || i ==h+1 || j ==0 || j == w+1) {
					sb.append("#");
				}else {
					sb.append(sc.next());
					j+=w-1;
				}
			}
			System.out.println(sb);
		}
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, cnt = 0, cnt2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			cnt++;
		} else if (a % 2 == 0) {
			cnt2++;
		}
	}
	if (cnt + (cnt2 / 2) >= n / 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s,t;
        bool flag=false;
        cin>>s>>t;
        for(int i=(int)s.size()-1;i>=(int)t.size()-1;--i){
                int cnt=0;
                for(int j=(int)t.size()-1;j>=0;--j){
                        cnt+=s[i-((int)t.size()-1-j)]==t[j]||s[i-((int)t.size()-1-j)]=='?';
                }
                if(cnt==(int)t.size()){
                        flag=true;
                        s.replace(i-(int)t.size()+1,(int)t.size(),t);
                        int pos=(int)s.find("?");
                        while(pos!=-1){
                                s.replace(pos,1,"a");
                                pos=(int)s.find("?");
                        }
                        break;
                }
        }
        printf("%s\n",flag?s.c_str():"UNRESTORABLE");
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

//#define int long long //change int main to int32_t main


void solve()
{
	int n; cin >> n;
	string s; cin >> s;
	int rl = 0, wl = 0, rr = 0, wr = 0;
	int score = INT_MAX;
	fr0(i, n)
	{
		if (s[i] == 'R')rr++;
		else wr++;
	}
	score = min(rr, wr);
	fr0(i, n)
	{
		if (s[i] == 'R') rl++, rr--;
		else wl++, wr--;
		score = min(score, max(wl, rr));
	}
	cout << score;


}





int main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int d;
    cin >> d;
    if(d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    } else if(d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if(d == 24) {
        cout << "Christmas Eve" << endl;
    } else {
        cout << "Christmas" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import heapq
N = int(input())
A = list(map(int, input().split()))

Left, Right = A[:N], list(map(lambda a: -a, A[-N:]))
heapq.heapify(Left)
heapq.heapify(Right)
Left_SUM, Right_SUM = [sum(Left)], [-sum(Right)]

M = A[N:2*N]
# 左側
for k in range(N):
    lo = heapq.heappushpop(Left, M[k])
    Left_SUM.append(Left_SUM[-1] + M[k] - lo)

# 右側
for k in reversed(range(N)):
    hi = -heapq.heappushpop(Right, -M[k])
    Right_SUM.append(Right_SUM[-1] + M[k] - hi)

# 最大値を計算
ans = max([l - r for l, r in zip(Left_SUM, Right_SUM[::-1])])
print(ans)


Measured memory_bytes: 40336
#include<cstdio>
#include<cstring>
using namespace std;
int main(void)
{
	char a[1001],b[1001];
	int len,i;
	scanf("%s",a);
	len=strlen(a);
	for(i=0;i<len;i++){
		
		if(a[i]=='A'){
			b[i]='X';
		}
		else if(a[i]=='B'){
			b[i]='Y';
		}
		else if(a[i]=='C'){
			b[i]='Z';
		}
		else{
			b[i]=a[i]-3;
		}
		printf("%c",b[i]);
	}
	printf("\n");
		
	return 0;
}

Measured memory_bytes: 936
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

deque<int> res;

void dfs(vector<int>& visited, int now, vector<vector<int>>& path, bool flag) {
	for (auto v : path[now]) {
		if (!visited[v]) {
			visited[v] = 1;
			if (flag) {
				res.push_back(v);
			} else {
				res.push_front(v);
			}
			dfs(visited,v,path,flag);
			break;
		}
	}
}

int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	vector<vector<int>> path(n);
	REP(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		path[a[i]].push_back(b[i]);
		path[b[i]].push_back(a[i]);
	}
	int s = 0;
	vector<int> v(n, 0);
	v[s] = 1;
	res.push_back(s);
	dfs(v, s, path, true);
	dfs(v, s, path, false);
	put(res.size());
	while(!res.empty()) {
		cout << res.front()+1 << " ";
		res.pop_front();
	}
	put("");
	return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll k;
    cin >> k;
    queue<ll> q;
    for(int i=1;i<10;i++){
        q.push(i);
    }
    for(int i=0;i<k-1;i++){
        ll v = q.front();
        if(v%10==9){
            ll v1 = v*10 + (v%10)-1; q.push(v1);
            ll v2 = v*10 + (v%10); q.push(v2);
            q.pop();
        }else if(v%10==0){
            ll v1 = v*10 + (v%10); q.push(v1);
            ll v2 = v*10 + (v%10)+1; q.push(v2);
            q.pop();
        }else{
            ll v1 = v*10 + (v%10)-1; q.push(v1);
            ll v2 = v*10 + (v%10); q.push(v2);
            ll v3 = v*10 + (v%10)+1; q.push(v3);
            q.pop();
        }
    }
    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main() {
    int a;
    double b;
    cin >> a;
    b = a * 2 * 3.1415926;
    cout << b << endl;
}

  

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		ans += 1ll * x * x + 1ll * y * y <= 1ll * d * d;
	}
	cout << ans;
}



Measured memory_bytes: 3600