akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((ll)2e5+5)
#define MOD ((ll)998244353)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

ll n, m, k;
ll A = 0;
ll ans;

void mulself(ll& a, ll b)
{
	a *= b;
	a %= MOD;
}

ll fast(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
		{
			res*=a;
			res%=MOD;
		}
		b>>=1LL;
		a*=a;
		a%=MOD;
	}
	return res;
}

ll inv(ll x)
{
	return fast(x, MOD-2);
}

ll C(ll a, ll b)
{
	ll ret = 1;
	for (int i = 0; i < b; ++i)
 		mulself(ret, a-i);

 	for (int i = 2; i <= b; ++i)
 		mulself(ret, inv(i));

 	return ret;
}


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;

	A = m * fast(m-1, n-k-1);
	A %= MOD;

	mulself(A, C(n-1, k));

	ans = (ans + A) % MOD;

	ll B = A;

	for (int i = k-1; i >= 0; --i)
	{
		mulself(B, m-1);
		mulself(B, i+1);
		mulself(B, inv(n-(i+1)));

		ans = (ans + B) % MOD;
	}

	cout << ans << endl;
}

/* stuff you should look for
	* ll overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

long long dp[55][55][2605];
long long mod = 1e9 + 7;

int main(int argc, char *argv[])
{
	int n, k;

	cin >> n >> k;
	dp[0][0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i + 1; j++) {
			for (int l = 0; l < k + 1; l++) {
				int nj = j;
				(dp[i + 1][nj][l + nj * 2] += dp[i][j][l]) %= mod;

				nj = j + 1;
				(dp[i + 1][nj][l + nj * 2] += dp[i][j][l]) %= mod;

				nj = j;
				int x = j * 2 % mod;
				(dp[i + 1][nj][l + nj * 2] += dp[i][j][l] * x) %= mod;

				if (j >= 1) {
					nj = j - 1;
					x = j * j % mod;
					(dp[i + 1][nj][l + nj * 2] += dp[i][j][l] * x) %= mod;
				}
			}
		}
	}

	cout << dp[n][0][k] % mod << endl;

	return 0;
}

Measured memory_bytes: 55552
n = int(input())
x, y = 0, 0
t = 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    l = abs(xi - x + yi - y)
    if l <= ti - t and l % 2 == (ti - t) % 2:
        x, y = xi, yi
        t = ti
    else:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;

int main() {
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    
    for(int i=0;i<10000000;i++){
        int ans=k*i;
        if(ans>=a&&ans<=b){
            cout<<"OK"<<endl;
            break;
        }
        if(ans>b){
            cout<<"NG"<<endl;
            break;
        }
        
    }
    

}

Measured memory_bytes: 3636
#include <stdio.h>

class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};
	~Dice(){
		delete[] number;
		delete[] work;
	};

	void setLabel(int index,int num){
		number[index] = num;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}


	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int label;
	char ch;
	for(int i = 0; i < 6; i++){
		scanf("%d",&label);
		dice.setLabel(i,label);
	}
	getchar(); 
	while((ch = getchar()) != '\n'){
		dice.roll(ch);
	}
	printf("%d\n",dice.returnPeek());
}



Measured memory_bytes: 2748
import sys
import heapq as hq
input = sys.stdin.readline
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans = []
for p in range(1,x+1):
  for q in range(1,y+1):
    for r in range(min(k//(p*q)+1,z)):
      ans.append(-(a[p-1]+b[q-1]+c[r]))
hq.heapify(ans)
for i in range(k):
  s = hq.heappop(ans)
  print(-s)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i<= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    
    cout << sum << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data


Measured memory_bytes: 3616
program prob3
    implicit none
    integer :: a,b,i
    read(*,*) a,b
    do i = 1, 100000
        if((i*8)/100 == a .and. (i*10)/100 == b) then
            write(*,*) i
            stop
        end if
    end do
    write(*,*) "-1"
    stop
contains
end program prob3

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

int main()
{
    int n = 0;
    std::cin >> n;

    int m = 0;
    std::cin >> m;

    int x = 0;
    std::cin >> x;

    std::vector<int> values(n);
    std::vector<std::vector<int>> studies(n, std::vector<int>(m));
    for (auto bookIndex = 0; bookIndex < n; ++bookIndex)
    {
        std::cin >> values[bookIndex];
        for (auto studyIndex = 0; studyIndex < m; ++studyIndex)
        {
            std::cin >> studies[bookIndex][studyIndex];
        }
    }

    int minCost = std::numeric_limits<int>::max();

    for (auto pattern = 0; pattern < (1 << n); ++pattern)
    {
        auto cost = 0;
        std::vector<int> study(m, 0);
        for (auto index = 0; index < n; ++index)
        {
            if ((pattern >> index) & 1)
            {
                cost += values[index];
                for (auto algoIndex = 0; algoIndex < m; ++algoIndex)
                {
                    study[algoIndex] += studies[index][algoIndex];
                }
            }

            bool isSatisfied = true;

            for (const auto & algo : study)
            {
                if (algo < x)
                {
                    isSatisfied = false;
                    break;
                }
            }

            if (isSatisfied)
            {
                minCost = std::min(minCost, cost);
            }
        }
    }

    if (minCost == std::numeric_limits<int>::max())
    {
        std::cout << -1;
    }
    else
    {
        std::cout << minCost;
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 100009;
struct edge{
	int x, y, w;
	bool operator < (const edge &e){
		return w < e.w;
	}
} e[maxn*2];
struct point{
	int x, y, pos;
} p[maxn];
int n, pa[maxn];
long long ans;

inline bool cmpX(point a, point b){
	return a.x < b.x;
}

inline bool cmpY(point a, point b){
	return a.y < b.y;
}

int getpa(int x){
	return pa[x] == x ? x : pa[x] = getpa(pa[x]);
}

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%d%d", &p[i].x, &p[i].y);
		p[i].pos = i;
	}
	
	sort(p+1, p+n+1, cmpX);
	for (int i=1; i<=n-1; i++){
		e[i].x = p[i].pos;
		e[i].y = p[i+1].pos;
		e[i].w = p[i+1].x - p[i].x;
	}

	sort(p+1, p+n+1, cmpY);
	for (int i=1; i<=n-1; i++){
		e[n-1+i].x = p[i].pos;
		e[n-1+i].y = p[i+1].pos;
		e[n-1+i].w = p[i+1].y - p[i].y;
	}
	
	for (int i=1; i<=n; i++) pa[i] = i;
	sort(e+1, e+2*n-2+1);
	for (int i=1; i<=2*n-2; i++){
		if (getpa(e[i].x) == getpa(e[i].y)) continue;
		pa[getpa(e[i].x)] = getpa(e[i].y);
		ans += e[i].w;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	if (A.back() == B.front() && B.back() == C.front()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main(){
	int n; cin >> n;
	int count = 0;
	vector<pair<int, int> > a(n), b(n);
	rep(i,n){
		int n,m; cin >> n >> m;
		a[i] = make_pair(n,m);
	}
	rep(i,n){
		int n,m; cin >> n >> m;
		b[i] = make_pair(n,m);
	}
	sort(all(b));
	rep(i,n){
		int m = MOD;
		int index = 0;
		rep(j,a.size()){
			if (b[i].second  > a[j].second && b[i].first > a[j].first){
				if (m > b[i].second-a[j].second){
					m = b[i].second-a[j].second;
					index = j;
				}
			}
		}
		if (m != MOD){
			count++;
			a.erase(a.begin()+index);
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main() 
{ 
  long k,n,max;
  cin>>k>>n;
  long i,a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  max=k-(a[n-1]-a[0]);
  for(i=0;i<n-1;i++)
  {
  	 if(a[i+1]-a[i]>max)
  	 max=a[i+1]-a[i];
  }
  cout<<k-max<<"\n";
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	string t;
	cin >> s >> t;

	s += t;

	n = stoi(s);
	t = "No";
	rep(i, 500){
		if(i * i == n){
			t = "Yes";
		}
	}

	cout << t ;
}


Measured memory_bytes: 256
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    counter = Counter(A)

    odd = even = 0
    for v in counter.values():
        if v % 2 == 0:
            even += 1
        else:
            odd += 1

    if even % 2 == 0:
        ans = odd + even
    else:
        ans = odd + even - 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 22264
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define mem(a,b) memset(a,b,sizeof(a))
const int maxn = 1e5+5;
const int ff = 0x3f3f3f3f;

char s[maxn];

int main()
{
	scanf(" %s",s);
	int len = strlen(s);
	for(int i = 0;i< len;i++)
		if(i%2 == 0)
			printf("%c",s[i]);
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 384
A = [chr(i) for i in range(65,91)]
k = []
H,W = map(int,input().split())
for i in range(H):
    S = input().split()
    k.append(S)
for i in range(H):
    for j in range(W):
        if k[i][j] == "snuke":
            print(A[j]+str(i+1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

ll g(ll n,ll p) {
  if(n == 0) return 0;
  return n / p + g(n/p,p);
}

int main() {
  ll n;cin >> n;
  if(n%2==1) {
    cout << 0 << endl;
    return 0;
  }
  n /= 2;

  cout << g(n,5) << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define maxn 105
#define INF 123456789
using namespace std;
int n,m;
inline int ID(int i,int j) {
	return i * m + j;
}
string s[maxn];
struct edge {
	int v,cap;
};
vector<edge> E;
vector<int> G[maxn*maxn*2];
void make_edge(int u,int v) {
	G[u].emplace_back((int)E.size());
	E.emplace_back(edge{v,1});
	G[v].emplace_back((int)E.size());
	E.emplace_back(edge{u,0});
}
int dis[maxn*maxn*2];
bool bfs(int st,int ed) {
	memset(dis,-1,sizeof dis);
	dis[st] = 0;
	queue<int> q;
	q.push(st);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int idx : G[u]) {
			int v = E[idx].v , cap = E[idx].cap;
			if(cap > 0 && dis[v] == -1) {
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	return dis[ed] != -1;
}
int cur[maxn*maxn*2];
int dfs(int u,int flow,int ed) {
	if(u == ed)
		return flow;
	else {
		for(;cur[u] < (int)G[u].size();cur[u]++) {
			int idx = G[u][cur[u]];
			int v = E[idx].v , cap = E[idx].cap;
			if(dis[u] + 1 == dis[v] && cap > 0) {
				int now = dfs(v,min(flow,cap),ed);
				if(now != 0) {
					E[idx].cap   -= now;
					E[idx^1].cap += now;
					return now;	
				}
			}
		}
		dis[u] = -1;
		return 0;
	}
}
int dinic(int st,int ed) {
	int ret = 0;
	while(bfs(st,ed)) {
		memset(cur,0,sizeof cur);
		int f;
		while((f = dfs(st,INF,ed)) != 0)
			ret += f;
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> s[i];
	int st,ed;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(s[i][j] != '.') {
				if(s[i][j] == 'S')	st = ID(i,j);
				if(s[i][j] == 'T')	ed = ID(i,j) + n * m;
				int u = ID(i,j);
				if(s[i][j] == 'o')
					make_edge(u + n * m,u);
				for(int x=0;x<n;x++)
					if(x != i && s[x][j] != '.') {
						int v = ID(x,j) + n * m;
						make_edge(u,v);
					}
				for(int y=0;y<m;y++)
					if(y != j && s[i][y] != '.') {
						int v = ID(i,y) + n * m;
						make_edge(u,v);
					}
			}
	if(st % m == (ed - n * m) % m || st / m == (ed - n * m) / m)
		cout << -1 << endl;
	else
		cout << dinic(st,ed) << endl;
	return 0;
}


Measured memory_bytes: 54112
import sys
import math
input = sys.stdin.readline

n, a, b = map(int, input().split())
x = list(map(int, input().split()))
k = math.floor(b / a)
ans = 0
for i in range(1, n):
    if k >= x[i] - x[i - 1]:
        ans += (x[i] - x[i - 1]) * a
    else:
        ans += b
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 10000000000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
long long fact[20015], invfact[20015];
long long mod = 1e9 + 7;
//5^9 = (5^4)^2 * 5
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
//a^(p - 1) = 1 mod p [fermat's little theorem] so, a^(-1) = a^(p - 2) mod p
long long inverse(long long a){
    return bigmod(a, mod - 2);
}
void precalc(){
    fact[0] = 1;
    invfact[0] = inverse(fact[0]);
    for(long long i = 1; i <= 20005; i++){
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = inverse(fact[i]);
    }
}
//nCr = (fact[n]/(fact[r] * fact[n - r])) mod p = (fact[n] * invfact[r] * invfact[n - r]) mod p
long long nCr(long long n, long long m){
    long long ans = (fact[n] * invfact[m]) % mod;
    return (ans * invfact[n - m]) % mod;
}
int main(){
	precalc();
	
    ll n,c,x,ava,i;
    cin>>n;
    x = n/3;
    c=0;
    if(n<=2) cout<<0<<endl;
    else{

    for(i=2;i<=x;i++){
        ava = n-i*2;
        
        c+= nCr(ava-1,i-1);
        c = c%mod;
    }
    cout<<(c+1)%mod<<endl;
    }
 
	return 0;
}

Measured memory_bytes: 3928
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int K = sc.nextInt();
		int X = sc.nextInt();
if(X<=500*K)
	System.out.println("Yes");
else
	System.out.println("No");

	}

	//以下、自作ライブラリ

	//指定した値以上の要素が最初に現れる位置
	//要素の数は+1（配列のズレ)
	public static long lowerBound(int n, long[] x, long y) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (x[mid] < y) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return left;
	}

	//指定した値より大きい要素が最初に現れる位置
	//要素の数は+1（配列のズレ)
	public static long upperBound(int n, long[] x, long y) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (x[mid] <= y) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return left;
	}

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main() {
  int a,b;cin >> a >> b;
  if(a>=13){
      cout << b << endl;
  }else if(a>=6 && a<=12){
      cout << b/2 << endl;
  }else{
      cout << 0 << endl;
  }
}


Measured memory_bytes: 256
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back;
#define endl "\n";
#define X first;
#define Y second;
#define pii pair<int,int>;
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int arr[maxn];
int main(){
	migmig;
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]){
	    cout << "Yes" << endl;
	  }else if(s[1] == s[2] && s[2] == s[3]){
	    cout << "Yes" << endl;
	  }else{
	    cout << "No" << endl;
	  }
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define ld long double
#define hell 1000000007
#define dd double
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define sep(i,n,b) for(ll i=n-1;i>=b;i--)
#define pb push_back
#define mp make_pair
#define Mll map<ll,ll>
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k<=a){
		cout << k;
	}	
	else if(k>a and k<=a+b){
		cout << a;
	}
	else if(k>a+b){
		k-=a;
		k-=b;
		cout << a-k;
	}
	return 0;
}

Measured memory_bytes: 3648
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :x, :y, :s ,:t

  def initialize
    @a,@b,@x = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    count(b,x) - count(a-1,x)
  end

  def count(a,x)
    a / x + 1
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


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

int main() {
  vector<int64_t> vec;
  vec.push_back(2);
  vec.push_back(1);
  int x;
  
  cin >> x;
  
  for (int i = 0; i <= x; i++) {  
    if (i == 0 || i == 1) continue;
    
    vec.push_back(vec[i - 1] + vec[i - 2]);
  }
  
  cout << vec[x] << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
ll n,m,v,p,a[N],ans,d;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	ans=p;
	for(ll i=p+1;i<=n&&a[i]+m>=a[p];i++)
	{
		if(n-(i-p)>=v) ans++;
		else if( ((v+(i-p)-n)*m-d-1) / (i-p) +1+a[p] <=a[i]+m ) ans++;
		d+=a[p]-a[i];
	}
	cout<<ans<<endl;
	return 0;
}
/* 10 4 8 5
7 6 6 6 5 5 4 3 2 1
*/

Measured memory_bytes: 4428
a = [-1]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

if min(b) < 0:
    print(0)
else:
    result = 1

    f_list = []
    for i in range(max(b)+1):
        if i == 0 or i == 1:
            f_list.append(1)
        else:
            f_list.append(f_list[i-2] + f_list[i-1])

    for i in range(M+1):
        result = result * f_list[b[i]]
        result = result % (10**9 + 7)

    print(result)


Measured memory_bytes: 460148
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll h,n,s=0;
    cin>>h>>n;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        s+=x;

    }
    if(h-s>0)
        No
    else
        Yes
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int MX = 100010;
ll bit[MX];
void add(int i, ll x){
	for(; i < MX; i += i & -i) bit[i] = max(bit[i], x);
}
ll sum(int i){
	ll res = 0;
	for(; i; i -= i & -i) res = max(res, bit[i]);
	return res;
}

int main(){
	int n, a;
	cin >> n;
	rep(i, n){
		cin >> a;
		add(a, sum(a - 1) + a);
	}
	cout << n * (n + 1ll) / 2 - sum(n) << endl;
	return 0;
}

Measured memory_bytes: 1936
#include <cstdio>
#include <cmath>
using namespace std;
int a, b;

int main() {
	while(~scanf("%d %d", &a, &b)) {
		if((a + b) % 2 == 0) printf("%d\n", (a + b) / 2);
			else printf("%d\n", (a + b) / 2 + 1);
	}
}

Measured memory_bytes: 128
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

class UnionFind
{
private:
  vector<int> par, sizes;

public:
  UnionFind(int n = 200010) : par(n), sizes(n, 1)
  {
    rep(i, n) par[i] = i;
  }

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

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sizes[x] < sizes[y])
      swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

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

  int size(int x)
  {
    return sizes[root(x)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n, m;
  cin >> n >> m;
  int p[100010];
  int pos[100010];
  rep(i, n)
  {
    cin >> p[i];
    p[i]--;
    pos[p[i]] = i;
  }
  UnionFind uf;
  rep(i, m)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    uf.unite(x, y);
  }
  int cnt = 0;
  rep(i, n)
  {
    if (uf.same(pos[i], i))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
int64_t A,B,K;
  cin >> A >> B >> K;
  if(A + B <= K){
  	cout << "0 0" << endl;
  }
  else{
  	if(A >= K){
 	 	cout << A-K << " " << B << endl;
 	}
    else {
      cout << 0 << " " << B+A-K << endl;
    }
  
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long int i,j,l,r,min=2019,mod;
  scanf("%lld%lld", &l, &r);
  if(r-l>=2019){
    puts("0");
    return 0;
  }
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      mod=(i*j)%2019;
      if(mod<min){
        min=mod;
      }
    }
  }
  printf("%lld", min);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int a[28] = { 0 };
bool v[28];
bool f(int i,int t){
	v[i] = true;
	if (a[i] == t)return 1;
	if (v[a[i]])return 0;
	return f(a[i], t);
}

int main() {
	int n;
	int ans = 0;
	cin >> n;
	hei(string) s(n);
	hei(bool) a(n,false), b(n,false);
	int A=0, B=0, C=0;
	rep(i, 0, n) {
		cin >> s[i];
		if (s[i][0] == 'B') {
			b[i] = 1;
		}

		if (s[i][s[i].size() - 1] == 'A') {
			a[i] = 1;
		}
		rep(j, 0, s[i].size() - 1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
		}
	}
	rep(i, 0, n) {
		if (a[i] && b[i])C++;
		else if (a[i])A++;
		else if (b[i])B++;
	}
	if (C) {
		ans += C - 1;
		if (B) {
			B--;
			ans++;
		}
		if (A) {
			A--;
			ans++;
		}
	}
	if (A && B)ans += min(A, B);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
using namespace std;
        
int main(){
    ll A,B,K;
    cin>>A>>B>>K;
    ll a = max(A-K, 0LL);
    cout << a << endl;
    ll b;
    if(a == 0) b = max(B - (K-A), 0LL);
    else b = B;
    cout << b << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define f first

#define s second

ll a;

string s;

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

    if (a>=3200) cout << s; else cout << "red";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int find(vector<int> v, int x) {
    for(int i = 0; i < v.size(); i++) {
        if(v[i] == x) {
            return v[i];
        } 
    }

    return -1;
}

int main() {
    int s;
    vector<int> v;
    int count = 0;
    int tmp = 0;
    int result = 0;

    cin >> s;
    v.push_back(s);

    while(1) {
        count ++;

        if(v[count-1] % 2 == 0) {
            tmp = v[count-1] / 2;
        } else {
            tmp = 3 * v[count-1] + 1;
        }

        result = find(v, tmp);

        if(result == -1) {
            v.push_back(tmp);
        } else {
            result = count + 1;
            break;
        }

    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,a,flg=0,x[12];
	for(i=0;i<12;i++)  {
		scanf("%d",&x[i]);
	}
	for (i=0;i<12;i++) {
		for (j=i+1;j<12;j++){
	if (x[i]>x[j]){
		a=x[i];
		x[i]=x[j];
		x[j]=a;
			}
		}
	}
	for(i=0;i<12;i+=4){		
		for(j=i+1;j<i+4;j++){
			if(x[i]!=x[j]){
				flg=1;
			}
		}
	}
	if(flg==1){
		printf("no\n");
	}
	else printf("yes\n");
	return 0;
}			


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define M 1000000007
#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int k,n;cin>>k>>n;
	int a[n],i;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int ma=0;
	for(i=1;i<n;i++)
		ma=max(ma,a[i]-a[i-1]);
	ma=max(ma,k-(a[n-1]-a[0]));
	cout<<k-ma<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

int n;
int h[100000];
int dp[100000];
int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = list(map(int, input().split()))
sa = list(reversed(sorted(a)))

total=0
for i in range(n):
	total = total + sa[i]

score = 0
for i in range(m):
	if sa[i]>=total/(4*m):
		score = score +1
if score>=m:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=1,cur=a[0];
    for(ll i=1;i<n;i++)if(a[i]>=cur)ans++,cur=a[i];
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

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

    rep(i,N){
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    double rep = 0;

    vector<int> one_case;
    for (int i = 0; i < N; i++) { // one_case = {0,1,2,3,...n-1} とする
        one_case.emplace_back(i);
    }

    do {
        rep += 1;
        double len_sum = 0;
        for(int i=0;i<N-1;i++){
            double len = 0;
            len = pow(x[one_case[i]]-x[one_case[i+1]],2)+pow(y[one_case[i]]-y[one_case[i+1]],2);
            len = sqrt(len);
            len_sum += len;
        }
        ans += len_sum;


    } while (next_permutation(one_case.begin(), one_case.end()));

    ans = ans/rep;

    cout << std::fixed << std::setprecision(15) << ans << endl;

}

Measured memory_bytes: 3804
#include<iostream>
#include<map>
#define sqr(x) ((x)*(x))
//description:
//given an array A with length n,
//calculate the sum of all pairs of lcm(ai,aj) which i < j
using namespace std;
int mod = 998244353;
inline int reversi(int x){
	long long now = x;
	long long ans = 1;
	for(long long a = 1;a <= mod-2;a*=2){
		if (a&(mod-2)){
			ans = (ans*now)%mod;
		}
		now = (now*now)%mod;
	}
	return ans;
}
int mu[1000001];
int prime[1000001] = {0};
int cnt[1000002] = {0};
long long f[1000000+1] = {0};
int main(){
	cin.tie(0);
	int n;
	cin >> n;
	int s[n];
	int maxs = 0;
	for(int a = 0;a < n;a++){
		cin >> s[a];
		maxs = max(maxs,s[a]);
	}
	
	for(int a = 1;a <= maxs;a++){
		mu[a] = 1;
	}
	prime[1] = 1;
	for(int a = 2;a <= maxs;a++){
		if (!prime[a]){
			mu[a] = -1;
			for(int b = 2;a*b <= maxs;b++){
				prime[a*b] = 1;
				if (b%a == 0) mu[a*b] = 0;
				else mu[a*b] *= -1;
			}
		}
	}
	//cout << "azazz";
	for(int a = 0;a < n;a++){
		//cout << a << ' ';
		cnt[s[a]]++;
	}
	
	//cout << "aaaa";
    for(int a = 1;a <= maxs;a++){
    	long long s = 0;
    	long long sqs = 0;
    	for(int b = 1;b*a <= maxs;b++){
    		if (cnt[b*a]){
    			s = s + (long long)b*a*cnt[b*a];
    			sqs = sqs + ((((((long long)b*a)%mod)*a)%mod)*b*cnt[a*b]+mod)%mod;
    			s = s%mod;
    			sqs = sqs%mod;
			}
    		
		}
		f[a] = ((((s*s)%mod-sqs)*reversi(2))%mod+mod)%mod;
	}
	long long ans = 0;
	for(int a = 1;a <= maxs;a++){
		long long ansd = 0;
		for(int b = 1;b*a <= maxs;b++){
			ansd += (f[a*b]*mu[b]);
			ansd %= mod;
		}
		ans = (ans + (ansd)*reversi(a)+mod)%mod;
	}
	cout << ans;
}

Measured memory_bytes: 23928
/*
 * Lang  : C++ 17
 * Author: little_angel
 * Date  : 23-07-2020 03:45 23
 */

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define sort(a) sort(a.begin(), a.end())
#define ub(a, x) upper_bound(a.begin(), a.end(), x)
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define dbg(x) cerr<<"["<<#x<<"="<<x<<"]"
#define endl '\n'

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

void sol() {
//    int k;
//    cin >> k;
//    if (k % 2 == 0) {
//        cout << -1 << endl;
//        return;
//    }
//    if (k == 1 or k == 7) {
//        cout << 1 << endl;
//        return;
//    }
//    if (k % 7 == 0)k /= 7;
//
    int n;
    cin >> n;

    string c;
    cin >> c;

    int r = 0, w = 0;
    for (int i = 0; i < n; ++i) {
        if (c[i] == 'R')r++;
        else w++;
    }
    if (r > w) {
        r = 0;
        for (int i = n - 1; i >= n - w; --i) {
            if (c[i] == 'R')r++;
        }
        cout << r << endl;
    } else {
        w = 0;
        for (int i = 0; i < r; ++i) {
            if (c[i] == 'W')w++;
        }
        cout << w << endl;
    }
}

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

    int t = 1;
//    cin >> t;
    while (t--) sol();
}

Measured memory_bytes: 3748
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def main():
    N = MI()
    a = LI()
    a = sorted(a, reverse=True)
    mx = a[0]

    if mx % 2 == 0:
        target = mx // 2
        mn = 10**9
        ans = -1
        for i in range(1, len(a)):
            if mn > abs(target - a[i]):
                ans = a[i]
                mn = abs(target - a[i])
        print(a[0], ans)
    else:
        target1 = mx // 2
        target2 = mx // 2 + 1
        mn = 10**9
        ans = -1
        for i in range(1, len(a)):
            if mn > abs(target1 - a[i]):
                ans = a[i]
                mn = abs(target1 - a[i])
            if mn > abs(target2 - a[i]):
                ans = a[i]
                mn = abs(target2 - a[i])
        print(a[0], ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88428
#include <stdio.h>

int main(){
  int sen = 1000, count, kinngaku, oturi, i;

  while(scanf("%d",&kinngaku) != EOF){
    if(kinngaku == 0) break;
    count = 0;
    oturi = sen - kinngaku;
    for(i = 0 ; oturi != 0 ; i++){
      if(oturi >= 500){
	oturi -= 500;
	count += 1;
      }
      else if(oturi < 500 && oturi >=100){
	oturi -= 100;
	count += 1;
      }
      else if(oturi < 100 && oturi >= 50){
	oturi -= 50;
	count += 1;
      }
      else if(oturi < 50 && oturi >= 10){
	oturi -= 10;
	count += 1;
      }
      else if(oturi < 10 && oturi >= 5){
	oturi -= 5;
	count += 1;
      }
      else if(oturi < 5 && oturi >= 1){
	oturi -= 1;
	count += 1;
      }
    }
    printf("%d\n",count);
  }

  return 0;

}

Measured memory_bytes: 600
#include<iostream>
#define init(i)constexpr auto s##i = s.a[i]
using namespace std;
constexpr int f(int a){
	return a?a%10+f(a/10):0;
}
template<int N>struct ans{
	int a[N+1][37];
	constexpr ans():a(){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[i][j]=a[i-1][j];
			a[i][f(i)]+=i;
		}
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[i][j]+=a[i][j-1];
		}
	}
};
void print(int a){
	a?print(a/10),putchar(a%10+48):0;
}
constexpr auto s=ans<10000>();
int t,in[3],ini;
char buf[114514];
main(){
	fgets(buf,sizeof(buf),stdin);
	for(char*p=buf;*p;p++){
		if(*p<47)ini++;
		else in[ini]=in[ini]*10+*p-48;
	}
	auto b=s.a[in[0]];
	t=b[in[2]]-b[in[1]-1];
	t?print(t),0:putchar(48);
}


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

int a[100010];
int b[100010];

int main() {
	int n, cnt = 0;
	long long s = 0;
	priority_queue<int>over;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] < b[i]) {
			s += b[i] - a[i];
			cnt++;
		} else if (a[i] > b[i]) {
			over.push(a[i] - b[i]);
		}
	}
	long long t = 0;
	while (t < s) {
		if (over.empty())break;
		t += over.top();
		over.pop();
		cnt++;
	}
	if (t >= s)cout << cnt << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,a,b;

typedef pair<int, int> P; //最短距離,頂点の番号
struct edge{
    int to,cost;
};
vector<edge> G[MAX+2];
int d1[MAX+2]; //1からの最短距離
void dijkstra1(){
    int s=1;
    priority_queue<P, vector<P>,greater<P> > que; //(<距離、座標>、照準)
    fill(d1,d1+N+1,INF);
    d1[s]=0; //スタート地点
    que.push(P(0,s));
    
    while(!que.empty()){
        P p=que.top(); que.pop(); //すでに更新した中で一番sから近いとこ
        int v=p.second;
        if(d1[v] < p.first) continue; //その場所の距離が前の記録より大きい時
        for(auto u:G[v]){
            if(d1[u.to]>d1[v]+u.cost){
                d1[u.to] =d1[v]+u.cost; //更新
                que.push(P(d1[u.to],u.to)); //更新したとこを記録
            }
        }
    }
}

int d2[MAX+2]; //1からの最短距離
void dijkstra2(){
    int s=N;
    priority_queue<P, vector<P>,greater<P> > que; //(<距離、座標>、照準)
    fill(d2,d2+N+1,INF);
    d2[s]=0; //スタート地点
    que.push(P(0,s));
    
    while(!que.empty()){
        P p=que.top(); que.pop(); //すでに更新した中で一番sから近いとこ
        int v=p.second;
        if(d2[v] < p.first) continue; //その場所の距離が前の記録より大きい時
        for(auto u:G[v]){
            if(d2[u.to]>d2[v]+u.cost){
                d2[u.to] =d2[v]+u.cost; //更新
                que.push(P(d2[u.to],u.to)); //更新したとこを記録
            }
        }
    }
}


void solve(){
    dijkstra1();
    dijkstra2();
    int cunt1=0;
    for(int i=1;i<=N;i++){
        if(d1[i]<=d2[i]) cunt1++;
    }
    if(cunt1>N/2)cout<<"Fennec"<<"\n";
    else cout<<"Snuke"<<"\n";
    /*
    for(int i=1;i<=N;i++){
        cout<<d1[i]<<" "<<d2[i]<<"\n";
    }*/
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N;
    for(int i=0;i<N-1;i++){
        cin>>a>>b;
        G[a].push_back((edge){b,1});
        G[b].push_back((edge){a,1});
    }
    solve();
    
    return 0;
}


Measured memory_bytes: 7536
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,b,a,q,m;
                double r;
                cin>>r;
                cout<<2.0*3.141*r<<endl;

            }



Measured memory_bytes: 3804
n = int(input())
c = len(list(str(n)))
if c % 2 == 1:
    # 奇数処理
    if c == 1:
        print(n)
    elif c == 3:
        print(9 + (n - 100 + 1))
    else:
        print(9 + 900 + (n - 10000 + 1))
else:
    # 偶数処理
    if c == 2:
        print(9)
    elif c == 4:
        print(9 + 900)
    else:
        print(9 + 900 + 90000)

Measured memory_bytes: 3060
n, m, x, y = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

left = max(a)
right = min(b)

if left < right and (x <= left < y or x < right <= y):
    print('No War')
else:
    print('War')

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define RREP(i, a, b) for (int i = int(a) - 1; i >= int(b); i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  string o, e;
  cin >> o >> e;
  int ocnt = 0, ecnt = 0;
  rep(i, sz(o) + sz(e)) {
    if (i % 2 == 0) {
      cout << o[ocnt];
      ocnt++;
    } else {
      cout << e[ecnt];
      ecnt++;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a,int *b); 
int count= 0;

int main()  {
  int i,j,flag,A[100],N,count=0;
  while(1) {
    scanf("%d",&N);
    if(1<=N && N<=100) break;
  }
  for(i=0;i<N;i++)  {
    scanf("%d",&A[i]);
  }

flag =1;
  i = 0;
  while(flag) {
    flag = 0;
    for (j = N-1; j>=i+1;j--) {
      if (A[j] < A[j-1]) {
	swap(&A[j],&A[j-1]);
	flag = 1;
       ++count;
      }
    }
    i++;
  }

  for(i=0;i<N-1;i++) 
    printf("%d ",A[i]);
  
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

void swap(int *a,int *b)
{ 
  int t; 
  t =*a; 
  *a = *b;
  *b =t;
}

Measured memory_bytes: 600
n = int(input())
l = []
total = 0
for i in range(n):
    l.append(list(input().split()))
for i in range(n):
    if l[i][1] == 'JPY':
        total += float(l[i][0])
    else:
        total += float(l[i][0]) * 380000
print(total)
    

Measured memory_bytes: 2940