akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

long long len(long long a, long long b, long long n){
    if(a < b){
        return b - a;
    }
    else{
        return (n + b - a);
    }
}

int main(){

    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    vector<int> ans;

    vector<int> next(N, -1);
    vector<int> first(200001, -1);
    vector<int> before(200001, -1);
    for(int i = 0; i < N; i++){
        int temp = A[i];
        int beforePos = before[temp];
        if(beforePos == -1){
            before[temp] = i;
            first[temp] = i;
        }
        else{
            before[temp] = i;
            next[beforePos] = i;
        }
    }

    for(int i = 0; i < N; i++){
        int nextPos = next[i];
        if(nextPos == -1){
            next[i] = first[A[i]];
        }
    }

    // for(int i = 0; i < N; i++){
    //     cout << next[i] << " ";
    // }
    // cout << endl;

    int cycle = 0;
    int pos = 0;
    while(true){

        int beforePos = pos; 
        pos = next[pos];
        if(pos <= beforePos){
            cycle++;
        }
        pos++;
        if(pos == N){
            cycle++;
            break;
        }
    }

    long long cnt = (K % cycle) * N;
    if(cnt == 0){
        cout << endl;
        return 0;
    }
    long long tempLen = 1;
    pos = 0;
    while(tempLen != cnt + 1){
        //cout << tempLen << " " << pos << endl;
        int nextPos = next[pos];
        //cout << nextPos << endl;
        long long nextLen = len(pos, nextPos, N);
        //cout << nextLen << endl;
        long long temp = tempLen + nextLen;
        if(temp > cnt){
            ans.push_back(A[pos]);
            pos++;
            tempLen++;
        }
        else if(temp == cnt){
            break;
        }
        else{
            pos = nextPos;
            pos++;
            tempLen = temp;
            tempLen++;
        }
    }

    int M = (int)ans.size();
    for(int i = 0; i < M; i++){
        cout << ans[i];
        if(i != M - 1){
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5,maxm=4e5+5,INF=1e9;
int n,m,head[maxn],dis[maxn],p[maxn],vis[maxn],edgecnt=1;
struct Edge
{
	int next,to;
}edges[maxm];
void addedge(int from,int to)
{
	edges[edgecnt]=(Edge){head[from],to};
	head[from]=edgecnt++;
}
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > Q;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v);addedge(v,u);
	}
	dis[1]=0;Q.push(make_pair(0,1));
	for(int i=2;i<=n;++i) dis[i]=INF,Q.push(make_pair(dis[i],i));
	while(!Q.empty())
	{
		pair<int,int> cur=Q.top();Q.pop();
		int u=cur.second;
		if(vis[u]) continue;
		vis[u]=1;
		for(int i=head[u],v;i;i=edges[i].next)
		{
			v=edges[i].to;
			if(dis[v]>dis[u]+1){
				dis[v]=dis[u]+1;
				p[v]=u;
				Q.push(make_pair(dis[v],v));
			}
		}
	}
	for(int i=2;i<=n;++i)if(dis[i]>=INF)
	{
		printf("No");
		return 0;
	}
	printf("Yes\n");
	for(int i=2;i<=n;++i) printf("%d\n",p[i]);
	return 0;
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int r, c;
	while(cin >> r >> c && (r || c)) {
		char board[110][110];
		bool b[110][110];
		rep(i,r) {
			rep(j,c) {
				b[i][j] = 0;
			}
		}

		rep(i,r) {
			string s;
			cin >> s;
			rep(j,c) {
				board[i][j] = s[j];
			}
		}
		
		char ch = board[0][0];
		int y = 0, x = 0;
		while(ch != '.' && !b[y][x]) {
			b[y][x] = 1;
			switch(ch) {
			case '>' : 
				x++;
				break;
			case '<' :
				x--;
				break;
			case '^' :   
				y--;
				break;
			case 'v' : 
				y++;
				break;
			default :
				break;
			}
			ch = board[y][x];
		}
		if(b[y][x]) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    string s; cin >> s;
    int n = 0;
    for(int i = 0; i < s.size(); i++) {
        n += s[i] - '0';
    }
    cout << (stoi(s) % n == 0 ? "Yes" : "No") << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> dp(N);
    rep(i,N) {cin >> h[i];}
    rep(i,N) {dp[i] = INF;}
    dp[0] = 0;

    rep(i,N-1){
        dp[i+1] = min(dp[i+1],dp[i] + abs(h[i]-h[i+1]));
        if(i+2 < N)
            dp[i+2] = min(dp[i+2],dp[i] + abs(h[i]-h[i+2]));
    }




    
    cout << dp[N-1]<<endl;
    return 0;
    

}

Measured memory_bytes: 1024
import Data.List
main = mapM_ (putStrLn . solve) . lines =<< getContents
yes = "Yes"
no = "No"
solve t
  |(e>1) /= (w>1) = no
  |(n>1) /= (s>1) = no
  |otherwise = yes
  where [e,n,s,w] = map length . group . sort . ("ENSW"++) $ t

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

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

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;

void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//shift r is search & replace
//shift d is delete a line
int main(){
    setIO();
    int n; cin >> n;
    int a[n];
    ll sum = 0;
    int count[100001];
    fill(count, count + 100001, 0);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
        ++count[a[i]];
    }
    int q; cin >> q;
    while(q--){
        int ai, bi; cin >> ai >> bi;
        sum += ((ll)count[ai]) * (bi - ai);
        count[bi] += count[ai];
        count[ai] = 0;
        cout << sum << "\n";
    }
}



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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l ; i <= r;i++) if(i % d == 0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37; 
int fact[MAXN], rfact[MAXN];

int bin_pow(int num, int n) {
    if (n == 0) {
        return 1;
    }
    if (n & 1) {
        return num * bin_pow(num, n - 1) % MOD;
    }
    else {
        int tmp = bin_pow(num, n / 2);
        return tmp * tmp % MOD;
    }
}

int A(int n, int k) {
    if (k > n) return 0;
    return fact[n] * rfact[n - k] % MOD;
}

int C(int n, int k) {
    if (k > n) return 0;
    return (fact[n] * rfact[k] % MOD) * rfact[n - k] % MOD;
}

void solve() {
    int n, m;
    cin >> n >> m;
    fact[0] = 1, rfact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
        rfact[i] = bin_pow(fact[i], MOD - 2);
    }

    int ans = A(m, n);
    for (int i = 1; i <= n; ++i) {
        int tmp = ((bin_pow(-1, i) * C(n, i)) % MOD) * fact[m - i] % MOD;
        ans = (MOD + ans + tmp * rfact[m - n] % MOD) % MOD;
    }

    cout << ans * A(m, n) % MOD << endl;
}

Measured memory_bytes: 19228
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

int main() {
  int K;
  cin >> K;
  vll A(K);
  repeat(i,K){
    cin >> A[i];
  }
  ll mi=2,ma=2;
  for(int i=K-1;i>=0;i--){
    mi = ((mi-1)/A[i]+1)*A[i];
    ma = (ma/A[i]+1)*A[i]-1;
  }
  if(ma < mi) cout << -1 << endl;
  else  cout << mi << " " << ma << endl;
  return 0;
}


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

int N, flag[101];

int main() {
  cin >> N;
  
  int num;
  for(int i=0; i<N; i++){
    cin >> num;
    flag[num] = 1;
  }
  
  int ans = 0;
  for(int i=0; i<101; i++){
    ans += flag[i];
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int s[4];
    fill(s, s+4, 0);
    int N;
    cin >> N;
    map<string, int> mp;
    mp["AC"] = 0, mp["WA"] = 1, mp["TLE"] = 2, mp["RE"] = 3;
    string x[] = {"AC", "WA", "TLE", "RE"};
    rep(i, N){
        string S;
        cin >> S;
        s[mp[S]]++;
    }
    rep(i, 4){
        cout << x[i] << " x " << s[i] << endl;
    }
}

Measured memory_bytes: 3632
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
S = input()

ans = 0

for i in range(1000):
    x = str(i).zfill(3)
    begin_idx = -1
    idx = 0
    while idx <= 2:
        begin_idx = S.find(x[idx], begin_idx+1)
        if begin_idx == -1:
            break
        idx += 1
    else:
        ans += 1
print(ans)


Measured memory_bytes: 10660
N = int(input())
ans = 0
M = (10**9)+7
dic = {}
pdic = {}
pdic['AAA'] = 1
pdic['AAC'] = 1
pdic['AAG'] = 1
pdic['AAT'] = 1
pdic['ACA'] = 1
pdic['ACC'] = 1
pdic['ACG'] = 0
pdic['ACT'] = 1
pdic['AGA'] = 1
pdic['AGC'] = 0
pdic['AGG'] = 1
pdic['AGT'] = 1
pdic['ATA'] = 1
pdic['ATC'] = 1
pdic['ATG'] = 1
pdic['ATT'] = 1
pdic['CAA'] = 1
pdic['CAC'] = 1
pdic['CAG'] = 1
pdic['CAT'] = 1
pdic['CCA'] = 1
pdic['CCC'] = 1
pdic['CCG'] = 1
pdic['CCT'] = 1
pdic['CGA'] = 1
pdic['CGC'] = 1
pdic['CGG'] = 1
pdic['CGT'] = 1
pdic['CTA'] = 1
pdic['CTC'] = 1
pdic['CTG'] = 1
pdic['CTT'] = 1
pdic['GAA'] = 1
pdic['GAC'] = 0
pdic['GAG'] = 1
pdic['GAT'] = 1
pdic['GCA'] = 1
pdic['GCC'] = 1
pdic['GCG'] = 1
pdic['GCT'] = 1
pdic['GGA'] = 1
pdic['GGC'] = 1
pdic['GGG'] = 1
pdic['GGT'] = 1
pdic['GTA'] = 1
pdic['GTC'] = 1
pdic['GTG'] = 1
pdic['GTT'] = 1
pdic['TAA'] = 1
pdic['TAC'] = 1
pdic['TAG'] = 1
pdic['TAT'] = 1
pdic['TCA'] = 1
pdic['TCC'] = 1
pdic['TCG'] = 1
pdic['TCT'] = 1
pdic['TGA'] = 1
pdic['TGC'] = 1
pdic['TGG'] = 1
pdic['TGT'] = 1
pdic['TTA'] = 1
pdic['TTC'] = 1
pdic['TTG'] = 1
pdic['TTT'] = 1
for i in range(N-3):
  for k in pdic.keys():
    k = str(k)
    if k=='ACG' or k=='AGC' or k=='GAC':
      dic[k] = 0
    elif k[1:]=='GC':
      dic[k] = pdic['C'+k[:-1]]+pdic['G'+k[:-1]]+pdic['T'+k[:-1]]
    elif k[0]=='G' and k[2]=='C':
      dic[k] = pdic['C'+k[:-1]]+pdic['G'+k[:-1]]+pdic['T'+k[:-1]]
    else:
      dic[k] = pdic['A'+k[:-1]]+pdic['C'+k[:-1]]+pdic['G'+k[:-1]]+pdic['T'+k[:-1]]
  for k in pdic.keys():
    pdic[k] = dic[k]
if N==3:
  print(61)
else:
  for v in dic.values():
    ans += v
    ans = ans % M
  print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
    int C[10][10],x[10],y[10];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> C[i][j];
        }
    }
    x[0]=0;
    for(int i=0;i<3;i++)y[i]=C[0][i]-x[0];
    for(int i=0;i<3;i++)x[i]=C[i][0]-y[0];

    bool a=true;

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(C[i][j]!=x[i]+y[j])a=false;
        }
    }
    cout << (a ? "Yes" : "No") << endl;
    return 0;
}

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

string s, ans;
int n;
int main(){
  ios::sync_with_stdio(0), cin.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> s >> n;
  for(int i = 0; i < s.size(); i += n){
    ans += s[i];
  }cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, m, q; cin >> n >> m >> q;
  vector< vector<int> > s(n+1, vector<int>());
  for(int i=0; i<m; i++){
    int l, r;
    cin >> l >> r;
    s[l].push_back(r);
  }
  for(int i=0; i<=n; i++) sort(s[i].begin(), s[i].end());

  for(int i=0; i<q; i++){
    int l, r; cin >> l >> r;
    int cnt = 0;
    for(int j=l; j<=r; j++){
      cnt += upper_bound(s[j].begin(), s[j].end(), r) - s[j].begin();
    }
    cout << cnt << endl;
  }

  return 0;
}




//


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;
 
int main() {
int N;
vector<map<char,int>> S(50);

cin>>N;
fx(N){
	string A;
	cin>>A;
	fy(A.size()){
	S.at(x)[A.at(y)]++;
	}
}
char kind='B'-'A';
string ans;
fx(26){
	char k='a'+kind*x;
	int min=51;
	fy(N){
		if(min>S.at(y)[k]){
			min=S.at(y)[k];
		}
	}
	while(min-->0){
		ans+=k;
	}
}

ce(ans);

}

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

const int N = 1e6 + 7;
const int MOD = 1e9 + 7;

int l[N], r[N], h[N], decide[N];
int n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &l[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &r[i]);
		decide[i] = false;
	}
	l[0] = 1;
	r[n + 1] = 1;
	for (int i = 1; i <= n; i++) {
		h[i] = min(l[i], r[i]);
	}
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		int decidel = -1, decider = -1;
		if (l[i] != l[i - 1]) {
			decidel = l[i];
		}
		if (r[i] != r[i + 1]) {
			decider = r[i];
		}
		if (decidel != -1 && decider != -1 && decidel != decider) {
			puts("0");
			return 0;
		}
		if (decidel != -1 || decider != -1) {
			int d = max(decidel, decider);
			if (d > h[i]) {
				puts("0");
				return 0;
			} else {
			}
		} else {
			ans = 1LL * ans * h[i] % MOD;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int i,res=0;
  int p[3];
  for(i=0;i<3;i++){
    cin >> p[i];
    res+=p[i];
  }
  res-=*max_element(p,p+3);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int A = 10000;
const int INF = 19191919;

int dp[101][A+1];

int main()
{
    int n,C;
    cin >>n >>C;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin >>a[i] >>b[i] >>c[i];

    fill(dp[0],dp[101],-INF);
    dp[0][0]=0;
    rep(i,n)
    {
        for(int j=C; j>=0; --j)if(j+c[i]<=C)
        {
            int nx = j+c[i];
            rep(k,A+1)
            {
                dp[nx][min(A,k+a[i])] = max(dp[nx][min(A,k+a[i])], dp[j][k]+b[i]);
                dp[nx][min(A,k+b[i])] = max(dp[nx][min(A,k+b[i])], dp[j][k]+a[i]);
            }
        }
    }

    int ans = 0;
    rep(i,C+1)rep(j,A+1) ans = max(ans,min(j,dp[i][j]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7036
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;

int main() {
  Int n;
  cin >> n;
  vector<Int> v[100005];
  Int m = 0;
  Int sum = 0;
  while (sum < n) {
    for (Int i = 0; i <= m; i++) {
      v[m].push_back(sum + i + 1);
    }
    m++;
    sum += m;
  }
  if (sum != n) {
    dump("No");
    return 0;
  }
 /*  for (Int i = 0; i < 3; i++) {
    for (Int j = 0; j <= i; j++) {
      cout << v[i][j] << " ";
    }
    cout << endl;
  } */
  vector< vector<Int> > res;
  vector<Int> x;
  for (Int i = 0; i < m; i++) x.push_back(v[i][i]);
  // cout << m << endl;
  res.push_back(x);
  for (Int i = 0; i < m; i++) {
    vector<Int> s;
    for (Int j = i ; j >= 0; j--) s.push_back(v[i][j]);
    for (Int j = i + 1; j < m; j++) s.push_back(v[j][i]);
    res.push_back(s);
  }
  dump("Yes");
  dump(res.size());
  for (Int i = 0; i < (Int)res.size(); i++) {
    cout << res[i].size() << " ";
    for (Int j = 0; j < (Int)res[i].size(); j++) {
      cout << res[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

double perform(vector<vector<int>> &g, int block_beg, int block_end) {
    int n = (int)g.size() - 1;
    vector<double> dp(n + 1);
    for (int i = n - 1; i >= 1; --i) {
        double sum = 0;
        for (auto &j:g[i]) {
            if (i == block_beg && j == block_end) {
                continue;
            }
            sum += dp[j];
        }
        if (i == block_beg) {
            dp[i] = 1 + sum / ((int)g[i].size() - 1);
        } else {
            dp[i] = 1 + sum / ((int)g[i].size());
        }
    }
    return dp[1];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n + 1);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[min(u, v)].push_back(max(u, v));
    }
    vector<double> dp(n + 1);
    vector<double> max_exp(n + 1);
    for (int i = n - 1; i >= 1; --i) {
        double sum = 0;
        double exp = 0;
        for (auto &j:g[i]) {
            sum += dp[j];
            if (dp[j] > exp) {
                max_exp[i] = j;
                exp = dp[j];
            }
        }
        dp[i] = 1 + sum / g[i].size();
    }
    double ans = dp[1];
    for (int i = n - 1; i >= 1; --i) {
        ans = min(ans, perform(g, i, max_exp[i]));
    }
    cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static int n;
	public static int A[];
	public static int B[];
	public static int C[] = new int[10000];
	public static StringBuilder sb = new StringBuilder();

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		A = new int[n];
		B = new int[n];

		for(int i = 0; i<n ;i++){
			A[i] = scan.nextInt();
			C[A[i]]++;
		}

		for(int i=1;i<10000;i++){
			C[i] = C[i-1]+C[i];
		}

		for(int i = n-1;i>=0;i--){
			B[C[A[i]]-1] = A[i];
			C[A[i]]--;
		}

		for(int i = 0; i < n-1 ;i++){
			sb.append(B[i]);
			sb.append(" ");
		}
		System.out.println(sb.toString()+B[n-1]);

	}

}

Measured memory_bytes: 602640
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  C=new Array(M);
  P=new Array(0);
  for(i=0;i<M;i++){
    tmp=input[i+1].split(" ");
    Csub=[parseInt(tmp[0]),parseInt(tmp[1]),i];
    C[i]=Csub;
  }
  C.sort(function(a, b) {
    return (a[0]-b[0]||a[1]-b[1])
	});
  for(i=0;i<M;i++){
    var y="";
    c=`00000${C[i][0]}`.slice(-6);
    if(i==0){
      var cnt=1;
    }else if(C[i][0]!=C[i-1][0]){
      cnt=1;
    }else{
      cnt++;
    }
    y=`00000${cnt}`.slice(-6);
    P.push([`${c}${y}`,C[i][2]]);
  }
  P.sort((a,b)=>a[1]-b[1]);
  var ans="";
  for(i=0;i<M;i++){
    if(i!=M-1){
      ans=ans+P[i][0]+"\n";
    }else{
      ans=ans+P[i][0];
    }
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a + b+ c >= 22){
        printf("bust\n");
    }
    else{
        printf("win\n");
    }
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int inf = 1e9;

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<vector<pair<int, int>>> v(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a - 1].push_back({b - 1, c - p});
  }

  vector<bool> is_parent(n);
  vector<int> s(n, -1e9);
  s[0] = 0;
  function<void(int)> dfs = [&](int i) {
    is_parent[i] = true;
    for (auto e : v[i]) {
      if (s[e.first] < min(inf, s[i] + e.second)) {
        s[e.first] = is_parent[e.first] || s[i] == inf ? inf : s[i] + e.second;
        dfs(e.first);
      }
    }
    is_parent[i] = false;
  };
  dfs(0);

  cout << (s[n - 1] == inf ? -1 : max(0, s[n - 1])) << endl;
}


Measured memory_bytes: 768
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    d, n = im.inputMultiple()
    # Logic ############################################################################################################
    message = ""
    if n == 100:
        message += "101"
    else:
        message += str(n)
    for i in range(d):
        message += "00"
    # Output ###########################################################################################################
    print(message)
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 13752
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)

inline int read() 
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - 48; cc = getchar();}
	return cn * flus;
}

const int MAXN = 1e5 + 10;
const int Mod = 998244353, G = 3;

int a[MAXN], sum[MAXN]; 
int n, res1, res2;

/*inline void balance(int &inc, int &dec)
{
	int tmp(0);
	tmp += inc - dec;
	if(tmp > 0) inc = tmp, dec = 0;
	if(tmp == 0) inc = 0, dec = 0;
	if(tmp < 0) inc = tmp, dec = -tmp;
}*/

void solve1()
{
	res1 = 0;
	int inc(0);
	rep(i, 1, n) 
	{
//		printf("sum[%d] = %d \n",i,sum[i] + inc);
		if(i & 1) 
		{
			if(sum[i] + inc <= 0) 
			{
				res1 += (1 - sum[i] - inc);
				inc += (1 - sum[i] - inc);
			}
		}
		if(!(i & 1))
		{
			if(sum[i] + inc >= 0)
			{
				res1 += sum[i] + inc + 1;
				inc -= sum[i] + inc + 1;
			}
		}
	}
}

void solve2()
{
	res2 = 0;
	int inc(0);
	rep(i, 1, n) 
	{
//		printf("sum[%d] = %d \n",i,sum[i] + inc);
		if(!(i & 1)) 
		{
			if(sum[i] + inc <= 0) 
			{
				res2 += (1 - sum[i] - inc);
				inc += (1 - sum[i] - inc);
			}
		}
		if(i & 1)
		{
			if(sum[i] + inc >= 0)
			{
				res2 += sum[i] + inc + 1;
				inc -= sum[i] + inc + 1;
			}
		}
//		printf("res2 = %d inc = %d \n",res2,inc);
	}
}
signed main()
{
	n = read();
	rep(i, 1, n) a[i] = read(), sum[i] = sum[i - 1] + a[i];
	solve1(), solve2();
//	printf("res1 = %d res2 = %d \n",res1,res2);
	printf("%lld\n",std::min(res1, res2));
	return 0;
}

Measured memory_bytes: 5320
fun main(args: Array<String>) {
    val nm = readLine()!!.split(" ").map(String::toInt)

    var ans = arrayOfNulls<String>(nm[0])
    for (i in 1.. nm[0]) {
        ans[i -1] = " "
    }
    var fail = false
    for (i in 1.. nm[1]) {
        val sc = readLine()!!.split(" ")

        if (ans[sc[0].toInt()-1] == " " || ans[sc[0].toInt()-1] == sc[1]) {
            ans[sc[0].toInt()-1] = sc[1]
        } else {
            fail = true
        }
    }

    if (fail) {
        println("-1")
    } else {
        if (ans[0] == "0") {
            if (nm[0] == 1 ) println("0")
            else  println("-1")
        } else {
            for (i in 1..nm[0]) {
                if (ans[i -1] == " ") {
                    if (i==1) {
                        if (nm[0] == 1 ) ans[i -1] = "0"
                        else  ans[i -1] = "1"
                    } else { ans[i -1] = "0" }
                }
                print(ans[i -1])
            }
            println()
        }
    }
}


Measured memory_bytes: 38072
#include <stdio.h>

int calTheNumOfFloor(double v){
	return (int)((v*v/(2*9.8) + 5) / 5);
}

int main(void){
	double v;
	while(scanf("%lf", &v) != EOF){
		printf("%d\n", calTheNumOfFloor(v) + 1);
	}

	return 0;
}

Measured memory_bytes: 628
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int W=stdIn.nextInt();
		boolean S[][]=new boolean[H][W];
		boolean visit[][]=new boolean[H][W];
		Deque<Integer> Q=new ArrayDeque<Integer>();
		int max=0;
		for(int i=0;i<H;i++){
			String a=stdIn.next();
			for(int j=0;j<W;j++){
				char b=a.charAt(j);
				if(b=='.')
					S[i][j]=true;
			}
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(S[i][j]){
					Q.add(i);Q.add(j);Q.add(0);
					visit[i][j]=true;
					while(Q.size()>0){
						int I=Q.poll();
						int J=Q.poll();
						int cout=Q.poll();
						if(I!=0&&S[I-1][J]&&visit[I-1][J]==false){
							Q.add(I-1);Q.add(J);Q.add(cout+1);
							if(cout+1>max)
								max=cout+1;
							visit[I-1][J]=true;
						}
						if(I!=H-1&&S[I+1][J]&&visit[I+1][J]==false){
							Q.add(I+1);Q.add(J);Q.add(cout+1);
							if(cout+1>max)
								max=cout+1;
							visit[I+1][J]=true;
						}
						if(J!=0&&S[I][J-1]&&visit[I][J-1]==false){
							Q.add(I);Q.add(J-1);Q.add(cout+1);
							if(cout+1>max)
								max=cout+1;
							visit[I][J-1]=true;
						}
						if(J!=W-1&&S[I][J+1]&&visit[I][J+1]==false){
							Q.add(I);Q.add(J+1);Q.add(cout+1);
							if(cout+1>max)
								max=cout+1;
							visit[I][J+1]=true;
						}
					}
					visit=new boolean[H][W];
				}
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

#include <functional>
template<typename T>
class SegmentTreeOneAll {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    Func query_func;
    SegmentTreeOneAll(int _n, T _init, Func up, Func qu) {
        init = _init;
        update_func = up;
        query_func = qu;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        data[pos] = update_func(data[pos], val);
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = query_func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        T res = init;
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                res = query_func(res, data[l]);
            }
            if (!(r & 1)) {
                res = query_func(res, data[r - 1]);
            }
        }
        return res;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    auto UPDATE = [](ll a, ll b) { return b; };
    auto MIN = [](ll a, ll b) { return min(a, b); };
    SegmentTreeOneAll<ll> segtree(n, (1LL << 31) - 1, UPDATE, MIN);
    REP(i, 0, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) {
            cout << segtree.query(x, y + 1) << endl;
        } else {
            segtree.update(x, y);
        }
    }

    return 0;
}



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


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	for(int i = 0;i<1e4;i++){
		int first = i* 8/100 , second = i*10/100;
		if(a == first && b == second){
			cout<<i;
			return 0;
		}
	}
cout<<-1;		
}


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

int main() {
    int a, b;
    cin >> a >> b;

    int num = stoi(to_string(a) + to_string(b));

    for (int i = 1; i <= 400; i++) {
        if (i * i == num) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		cnt += p != i + 1;
	}
	cout << (cnt <= 2 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b = map(int,input().split())
    s = input()

    if s[a:a+1] != '-':
        print('No')
    elif len(s) > a + b + 1:
        print('No')
    else:
        s2 = s[:a] + s[a+1:a+b+1]
        if  all([48 <= ord(str(c)) <= 57  for c in s2]):
            print('Yes')
        else:
            print('No')

main()

Measured memory_bytes: 3060
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

std::string solve(std::string S) {
  if (S[S.length() - 1] == 's') {
    return S + "es";
  }
  return S + "s";
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  std::string S;
  std::cin >> S;
  auto ans = solve(S);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3632
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn lms(a: usize, b: usize) -> usize {
    let mut x = cmp::max(a,b);
    let mut y = cmp::min(a,b);
    while x%y > 0 {
        let z = x % y;
        x = y;
        y = z;
    }
    y
}

fn main() {
    let nk: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nk[0];
    let k = nk[1];

    if k % 2 == 0 {
        let div = (n / k) as u64;
        let div2 = ((n+k/2) / k) as u64;
        println!("{}", div * div * div + div2 * div2 * div2);
    } else {
        let div = (n / k) as u64;
        println!("{}", div * div * div);
    }
}


Measured memory_bytes: 4352
fun main(args: Array<String>)
{
    val s = readString().toByteArray()

    var codeIsGood = true
    for (i in 0..2) {
        if (s[i] == s[i + 1]) codeIsGood = false
    }

    println(if (codeIsGood) "Good" else "Bad")
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 33720
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	int count[100005] = {};
	
	REP(i,N){
		int x; SCD(x);
		count[x] = count[x] + 1;
	}
	
	int ans = count[0];
	FORq(X,1,100002){
		ans = max(ans,count[X-1] + count[X] + count[X+1]);
	}
	
	PRINTD(ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
    }
    else if(k>a && k<=a+b)
    {
        cout<<a;
    }
    else if(k>b+a)
    {
        cout<<(a)-(k-(a+b));
    }
    cout<<endl;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
//#define DEBUG
//#define FILEIO

int GCD(int a, int b) { int c; while(b > 0) { c = a % b; a = b; b = c; } return a; }
void SWAP(int *a, int *b) { int c; c = *a; *a = *b; *b = c; }
int MAX(int a, int b) { return (a > b) ? a : b; }
int MIN(int a, int b) { return (a < b) ? a : b; }

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    // variables
    char s[10];
    int i;
    #ifdef DEBUG
    while(1) {
    # endif

    // code
    scanf("%s", s);
    for(i = 0; i < 6; i++)
    {
        if(s[2] == s[3] && s[4] == s[5])
        {
            printf("Yes\n");
            break;
        }
        else
        {
            printf("No\n");
            break;
        }
    }


    #ifdef DEBUG
    }
    #endif

    return 0;
}




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

int main() {
  long long x,y;
  cin >> x >> y;
  if (x*y >= 0) {
    if (x < y) {
      cout << y-x << endl;
    }
    else {
      if (x==0 || y==0){
        cout << x-y+1 << endl;
      }
      else {
        cout << x-y+2 << endl;
      }
    }
  }
  else {
    cout << abs(abs(x) - abs(y)) +1 << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
C=list(input())
if C.count("W")==0:
    print(0)
elif C.count("W")==1:
    if C[-1]=="W":
        print(0)
    else:
        print(1)
else:
        tmpw=C.count("W")
        #print(tmpw,C)
        #if tmpw%2==0:
        C=C[(n-tmpw):]
            #print(tmpw,C)
        print(C.count("R"))
        #else:
            #C=C[tmpw-1:]
            #print(tmpw,C)
            #print(C.count("R"))
        

Measured memory_bytes: 11868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  pll l,r;
  ll temp;
  string s;
  map<string,ll> c;
  c["Vacant"]=0;
  c["Male"]=1;
  c["Female"]=-1;
  cout << 0 << endl;
  cin >> s;
  if(c[s]==0) {
    return 0;
  }
  l=pll(0,c[s]);
  cout << n-1 << endl;
  cin >> s;
  if(c[s]==0) {
    return 0;
  }
  r=pll(n-1, c[s]);
  temp=(n-1)/2;
  while(1) {
    cout << temp << endl;
    cin >> s;
    ll ans=c[s];
    if(ans==0) break;
    if((temp-l.first)%2) {
      if(ans!=l.second) {
        l=pll(temp,ans);
      }
      else {
        r=pll(temp,ans);
      }
    }
    else {
      if(ans==l.second){
        l=pll(temp,ans);
      }
      else {
        r=pll(temp,ans);
      }
    }
    temp=(l.first+r.first)/2;
  }
}


Measured memory_bytes: 852
#include<iostream>
#include<cstring>
using namespace std;

int main(){
	char str[30], *end_p;
	int end;;
	cin >>str;
	
	end_p = strrchr(str, '\0');
	end = end_p - str;
	
	for(int i = (end - 1); i >= 0; i--){
		cout <<str[i];
	}
	
	cout <<endl;
	return 0;
}

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

using namespace std;

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

    long long int x,ans=0;
    double sum = 100.0;
    cin>>x;

    while(sum<x){
        sum+=floor(sum*0.01);//cout<<sum<<"\n";
        ans++;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main(void)
{
    int x, y;
    cin >> x >> y;
    if ((y >= 2 * x) && (4 * x >= y) && (y % 2 == 0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
n = gets.chomp
n_i = n.to_i
n_len = n.size

count = 0

(1 .. n_len / 2).each{ |i|
	count += 10 ** (i * 2 - 1) - 10 ** (i * 2 - 2)
}

if n_len % 2 == 1 then
	count += n_i - 10 ** (n_len - 1) + 1
end

puts count


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

int main() {
  
  int N;
  cin >> N;
  vector<int> H(N);
  
  for(int i=0;i<N;i++) {
    cin >> H.at(i);
  }
  
  int count=0;
  int max=H.at(0);
  for(int i=0;i<N;i++){
    if(max<=H.at(i)) count++;
    if(max<H.at(i)) max=H.at(i);
  }
  
  cout << count << endl;
  
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    vector<ll> cost(n, 0);
    FOR(i,1,n){
        cost[i] = LLINF;
        FOR(j,max(0ll,i-k),i){
            chmin(cost[i], abs(h[i] - h[j]) + cost[j]);
        }
    }

    cout << cost[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1408
from statistics import median
n = int(input())
A = list(map(int,input().split()))
A = [a-i-1 for i,a in enumerate(A)]
A.sort()
mA = int(median(A))
print(min([sum([abs(a-mA-1) for a in A]), sum([abs(a-mA) for a in A]), sum([abs(a-mA+1) for a in A])]))

Measured memory_bytes: 34024
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


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

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    ll r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x=x*r-d;
        cout<<x<<endl;
    }
}
/*

*/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int w,h,x,y; cin>>w>>h>>x>>y;
	cout <<fixed<<setprecision(10)<< (double)w*(double)h/2 << " ";
	if (x*2==w&&y*2==h) cout << 1 << endl;
	else cout<< 0 << endl;
}

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

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val r = (0 until N).map { readLine()!!.toLong() }

  var min = r[0]
  var profit = -1000000000L
  (1 until N).forEach { i ->
    min = Math.min(min, r[i-1]) 
    profit = Math.max(profit, r[i] - min)
  }  

  println(profit)
}


Measured memory_bytes: 52384
#include <stdio.h>
 
int main(void) {
    int A, B;
    int ans;
 
    scanf("%d %d", &A, &B);
 
    for(ans = 10*B ; ans < 10*(B+1); ans++){
      if(ans * 8 /100 == A){
        printf("%d", ans);
        return 0;
      }
    }
  printf("-1");
 
    return 0;
}

Measured memory_bytes: 256