akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
vector<int> v[2], a;
const int N = 2000;
int ips[2][2][N+1]={}, dp[2][N+1]={}; // ips[k][i][j] = |{x|v[k][x<=i]<v[!k][j]}|
signed main(){
    int n;
    cin >> n;
    for(int i = 0; i < 2*n; i++){
        char c; int x;
        cin >> c >> x;
        v[c=='B'].pb(i);
        a.pb(x);
    }
    sort(all(v[0]), [](int x, int y){ return a[x] < a[y]; });
    sort(all(v[1]), [](int x, int y){ return a[x] < a[y]; });
    for(int s = 0; s < 2*n; s++){
        for(int j = max(0,s-n+1); j < n && s-j >= 0; j++)
            ips[1][(s&1)^1][j+1] = ips[1][s&1][j] + (v[1][s-j] < v[0][j]),
            ips[0][(s&1)^1][j+1] = ips[0][s&1][j] + (v[0][s-j] < v[1][j]);
        for(int j = max(0,s-n+1); j < n && s-j >= 0; j++)
            dp[(s&1)^1][j+1] = min(dp[s&1][j+1]+ips[1][(s&1)^1][j+1], dp[s&1][j]+ips[0][(s&1)^1][s-j+1]);
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < i; j++)
            (dp[1][n]+=(v[0][j] > v[0][i]))+=(v[1][j] > v[1][i]);
    cout << dp[1][n] << endl;
}


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

int main() {
  int N;
  cin >> N;
  int x = 0;
  for ( int i = 0 ; i < N ; i++) {
    int l,r;
    cin >> l >> r;
    x += r - l + 1 ;
      }
    cout << x << endl;
  // ここにプログラムを追記
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int c=s.nextInt();
		int d=s.nextInt();
		System.out.println(a!=c?1:0);
	}
}


Measured memory_bytes: 22100
import heapq 

N,K = map(int,input().split())
A = list(map(int,input().split()))
m = min(N,K) #KがNより大きい場合を防ぐ
M = 0 
for i in range(m+1):
    for j in range(m-i+1):
        A1 = A[:i]
        A3 = A[N-j:]
        new_A = A1+A3
        heapq.heapify(new_A)
        h = K - len(new_A)
        while new_A  and h >0:
            q = heapq.heappop(new_A)
            h-=1
            if q > 0:
                heapq.heappush(new_A,q)
                break
        M = max(M,sum(new_A))
print(M)

Measured memory_bytes: 3064
n = int(input())
link = [[] for _ in range(n)]
for i in range(n-1):
    a,b = list(map(int,input().split()))
    link[a-1].append(b-1)
    link[b-1].append(a-1)

from collections import deque
def bfs(s):
    dist = [None]*n
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in link[v]:
            if dist[w] is not None:
                continue
            dist[w] = d + 1
            que.append(w)
    d = max(dist)
    return dist.index(d), d
u, _ = bfs(0)
v, d = bfs(u)

if (d-1)%3==0:
    print("Second")
else:
    print("First")

Measured memory_bytes: 101708
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


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

   
    int r = 0;
    rep(i,0,n){
	if(s[i] != s[i+1]){
	    r = i+1;
	    while(s[i] != s[r] && r < n)r++;
	
	    rep(j,i+1,r){
		if(s[j] == 'L')s[j] = 'R';
		else s[j] = 'L';
	    }
	    i = r-1;
	    k--;
	    if(k <= 0)break;
	}
    }

    ll ans = 0;
    rep(i,0,n-1)if(s[i] == s[i+1])ans++;
  
    P(ans);
  
    return  0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  long long a,b,c,d;cin>>a>>b>>c>>d;
  long long z = 0;
  if(a<d){
    z+=a;
    d-=a;
  }else{
    z+=d;
    cout << z << endl;
    return 0;
  }
  if(b>=d){
    cout << z << endl;
    return 0;
  }
  d-=b;
  cout << z-d << endl;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = 2147483647;
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				a[x] = y;
			} else {
				System.out.println(find(a, x, y));
			}
		}
		reader.close();
	}

	private int find(int[] a, int x, int y) {
		int min = Integer.MAX_VALUE;
		for (int i = x; i <= y; i++) {
			min = Math.min(min, a[i]);
		}
		return min;
	}
}


Measured memory_bytes: 84904
n = int(input())
a = list(map(int, input().split()))

if len(a) % 2 == 1:
  odd = a[1::2]
  even = a[-1::-2]
else:
  odd = a[::2]
  even = a[-1::-2]

for i in even + odd:
  print(i)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
typedef long long ll;
using namespace std;

int N,D,X;
int res,a;

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>D>>X;

    for(int i=0;i<N;i++){
        cin>>a;
        res+=(D-1)/a +1;
        //cout<<i<<" "<<a<<" "<<(D-1)/a+1<<endl;
    }
    cout<<res+X;


    return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import combinations

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = [0] * N
    for i in range(N):
        c, *a = map(int, input().split())
        C[i] = c
        A[i] = a

    min_price = INF
    for r in range(1, N + 1):
        for comb in combinations(range(N), r):
            skills = [0] * M
            for i in range(N):
                if i in comb:
                    for j in range(M):
                        skills[j] += A[i][j]

            if all(s >= X for s in skills):
                total_price = sum(c for i, c in enumerate(C) if i in comb)
                if min_price > total_price:
                    min_price = total_price

    if min_price < INF:
        print(min_price)
    else:
        print(-1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
from  itertools import combinations
N, M = map(int, input().split())
N = range(N)
M = range(M)
count_n = len(list(combinations(N,2))) if len(N) >=2 else 0
count_m = len(list(combinations(M,2))) if len(M) >=2 else 0

print(count_n+count_m)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


int main()
{
   
                        
     fio

      lli n;
      cin>>n;
      lli hash[n+1]={0};

      fr(x,1,101)
      fr(y,1,101)
      fr(z,1,101)
      {if(x*x+y*y+z*z+x*y+z*y+x*z<=n)hash[x*x+y*y+z*z+x*y+z*y+x*z]++;}
      fr(i,1,n+1)cout<<hash[i]<<'\n';

     

     
    
      
      



     



     


     
    
     




      
     

     
              


return 0;}    


Measured memory_bytes: 3660
#include <stdio.h>

int main(void){
  int A, B, K;
  int i, j, k;
  scanf("%d %d %d", &A, &B, &K);
  for(i = A; i <= B; i++){
    if(i < A + K || i > B - K){
      printf("%d\n", i);
    }
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        int m = Integer.parseInt(scanner.next());
        int k = Integer.parseInt(scanner.next());
        UnionFind uf = new UnionFind(n);
        int[] fb = new int[n+1];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(scanner.next());
            int b = Integer.parseInt(scanner.next());
            fb[a] += 1;
            fb[b] += 1;
            uf.unite(a, b);
        }
        for (int i = 0; i < k; i++) {
            int c = Integer.parseInt(scanner.next());
            int d = Integer.parseInt(scanner.next());
            if (uf.same(c, d)) {
                fb[c] += 1;
                fb[d] += 1;
            }
        }
        for (int i = 1; i < n+1; i++) {
            System.out.print(uf.size(i)-1-fb[i]);
            System.out.print(" ");
        }
    }
}

class UnionFind {
    int[] data = new int[1000000];
    UnionFind(int n) {
        for (int i = 0; i < n+1; i++) {
            this.data[i] = -1;
        }
    }
    public int root(int x) {
        if (this.data[x] < 0) {
            return x;
        }
        this.data[x] = root(this.data[x]);
        return this.data[x];
    }
    public void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (this.data[x] < this.data[y]) {
                this.data[x] += this.data[y];
                this.data[y] = x;
            } else {
                this.data[y] += this.data[x];
                this.data[x] = y;
            }
        }
    }
    public boolean same(int x, int y) {
        return root(x) == root(y);
    }
    public int size(int x) {
        return -this.data[root(x)];
    }
}


Measured memory_bytes: 80936
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> A(1<<N); for (auto &a : A) cin >> a;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (1<<N); j += 1<<(i+1)) {
            int k = j + (1<<i);
            if (A[j] != A[k]) A[j] = abs(A[j] - A[k]);
            A[k] = 0;
        }
    }
    cout << A[0] << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N, Q; cin >> N >> Q;
    vec A(Q), B(Q);
    REP(i, Q){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vec p(N);
    REP(i, N) p[i] = i;
    vector<bool> f(N, false);
    f[0] = true;
    f[1] = true;

    int b = 0;
    REP(i, Q){
        swap(p[A[i]], p[B[i]]);
        if(p[A[i]] == 0) b = A[i];
        else if(p[B[i]] == 0) b = B[i];
        if(b > 0) f[p[b - 1]] = true;
        if(b < N - 1) f[p[b + 1]] = true;
    }
    int ans = 0;
    REP(i, N) if(f[i]) ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n>m)swap(n,m);
	if(n==1 && m==2)puts("3");
	if(n==1 && m==3)puts("2");
	if(n==2 && m==3)puts("1");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        while (n != 0) {

            int a[] = new int[n];
            int sum = 0;
            double dispersion = 0;

            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
                sum += a[i];
            }

            double ave = (double) sum / n;

            for (int i = 0; i < n; i++) {
                dispersion += Math.pow((a[i] - ave), 2);
            }
            dispersion /= n;

            System.out.println(Math.sqrt(dispersion));

            n = sc.nextInt();

        }

        sc.close();
    }
}


Measured memory_bytes: 31404
#!/usr/bin/perl

use strict;
use warnings;

my ($a, $b, $k);
{
    my $in = <STDIN>;
    ($a, $b, $k) = split(" ", $in);
}
if ($a<=$k)
{
	$k -= $a;
	$a = 0;
    $b -= $k;
    $b = 0 if $b<0;
}
else
{
	$a -= $k;
}
print "$a $b\n";

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const double eps = 1e-8;
double n;
double a, b, c;

int main()
{
    scanf("%lf", &n);
    for(int i = 1; i <= 3500; i++) {
        for(int j = 1; j <= 3500; j++) {
            double res = 1 / (4 / n - 1 / (double)i - 1 / (double)j);
            double cl = ceil (res);
            double fl = floor(res);
            if((res > 0 && res < 3600) && (fabs(cl - res) <= eps || fabs(fl - res) <= eps)) {
                printf("%d %d %lld", i, j, (LL) (res + 0.5));
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

int n;
int pr[N];
vector<int> primes;

map<vector<pair<long long, long long> >, int> have;
map<vector<pair<long long, long long> >, int>::iterator it;
long long ans;

vector<pair<long long, long long> > paired(vector<pair<long long, long long> > v)
{
	vector<pair<long long, long long> > res;

	for (int i = 0; i < v.size(); i++)
	{
		if (v[i].second == -1)
		{
			res.push_back(make_pair(-1, -1));
			return res;
		}
	}
	
	for (int i = 0; i < v.size(); i++)
	{
		res.push_back(v[i]);
		res[i].second = 3 - res[i].second;
		res[i].second %= 3;
	}

}

bool perf_square(long long x)
{
	long long val = sqrt(x + .5);
	return (val*val == x);
}

vector<pair<long long, long long> > parse(long long x)
{
	vector<pair<long long, long long> > res;

	for (int i = 0; i < primes.size(); i++)
	{
		if (x%primes[i])
			continue;
		int cnt = 0;
		while (x%primes[i] == 0)
		{
			cnt++;
			x /= primes[i];
		}
		if (cnt % 3 == 0)
			continue;
		res.push_back(make_pair(primes[i], cnt % 3));
	}
	if (x == 1)
		return res;
	if (perf_square(x))
	{
		int ss = sqrt(x + .5);
		res.push_back(make_pair(ss, 2));
		return res;
	}
	if (x <= 100000)
	{
		res.push_back(make_pair(x, 1));
		return res;
	}

	res.push_back(make_pair(1, -1));
	return res;
}
int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;

	pr[1] = 1;
	for (int i = 2; i <= 10000; i++)
	{
		if (pr[i] == 0)
		{
			for (int j = i * 2; j <= 10000; j+=i)
			{
				pr[j] = 1;
			}
		}
	}

	for (int i = 2; i <= 3000; i++)
	{
		if (pr[i] == 0)
		{
			primes.push_back(i);
		}
	}

	for (int i = 1; i <= n; i++)
	{
		long long val;
		cin >> val;
		vector<pair<long long, long long> > p = parse(val);
		/*for (int j = 0; j < p.size(); j++)
		{
			cout << p[j].first << "%" << p[j].second << endl;
		}
		cout << "!" << endl;
		*/
		have[p]++;
	}

	for (it = have.begin(); it != have.end(); it++)
	{
		int cnt = (*it).second;
		vector<pair<long long, long long> > p = (*it).first;
		vector<pair<long long, long long> > p2 = paired(p);
		if (p2 == p)
		{
			ans += 2;
			continue;
		}
		if (have.find(p2) == have.end())
		{
			ans += cnt * 2;
			continue;
		}
		ans += max(have[p2], have[p]);
	}

	cout << ans / 2 << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 11520
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int cnt = 0;
		for(int i = a; i <= b; i++) {
			int n10 = i % 10;
			int n100 = i / 10 % 10;
			int n1000 = i / 1000 % 10;
			int n10000 = i / 10000 % 10;
			if(n10 == n10000 && n100 == n1000) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21972
N, K = (int(x) for x in input().split())
H = [int(i) for i in input().split()]


def filter_height_by_K(x):
    return x >= K


def solve(N, H):
    ride_list = list(
        filter(filter_height_by_K, H)
    )
    return len(ride_list)


print(solve(N, H))


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

typedef long long ll;


int main() {
int N, Q;   cin >> N >> Q;
string S;   cin >> S;
vector<int> l(Q), r(Q);
for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
}

vector<int> Left(N), Right(N);
int left = 0;
int right = 0;
Left[0] = 0;
Right[N - 1] = 0;
for (int i = 1; i < N; i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
        left++;
    }
    Left[i] = left;
    if (S[N - i - 1] == 'A' && S[N - i] == 'C') {
        right++;
    }
    Right[N - i - 1] = right;
}

int total = Left[N - 1];
for (int i = 0; i < Q; i++) {
    cout << total - Left[l[i] - 1] - Right[r[i] - 1] << endl;
}


}

Measured memory_bytes: 2688
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int sum = 0;
	int l = s.length();
	for(int i = 0 ; i < s.length()/2; i++){
		if(s[i] != s[l-i-1])sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        int ans = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '+') {
                ans++;
            }
            if (S.charAt(i) == '-') {
                ans--;
            }
        }
        System.out.println(ans);
    }
}


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

int main(void){
  std::string s;
  std::cin>>s;
  
  for(int i=0;i<s.size();i+=2){
    if(s[i]=='h'){
      if(s[i+1]=='i'){
      }else{
        std::cout<<"No";
        exit(0);
      }
    }else{
      std::cout<<"No";
      exit(0);
    }
  }
  std::cout << "Yes";
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n,m,ac=0,wa=0;
	cin >> n >> m;
	vll p(m),wat(n+1,0);
	vector<string> s(m);

	vector<bool> a(n + 1, true);

	rep(i, 0, m) {
		cin >> p[i] >> s[i];
		if (a[p[i]]) {
			if (s[i] == "AC") {
				a[p[i]] = false;
				ac++;
			}
			else {
				wat[p[i]]++;
			}
		}
	}
	repeq(i, 1, n) {
		if (!a[i]) {
			wa += wat[i];
		}
	}

	cout << ac << " "<< wa << endl;
	return 0;
}


Measured memory_bytes: 7296
import java.util.*;

public class Main{

	//2116 start
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			ArrayList<Character> list = new ArrayList<Character>();
			String input = sc.nextLine();
			while(! input.equals("")){
				for(int i = 0; i < input.length(); i++){
					list.add(input.charAt(i));
				}
				input = sc.nextLine();
			}

			String keystr = sc.nextLine();

			HashMap<Character, Integer> index = new HashMap<Character, Integer>();
			for(int i = 0; i < keystr.length(); i++){
				index.put(keystr.charAt(i), -1);
			}

			int s = -1, e = -1, anss = -1, anse = -1;
			boolean allcontain = false;

			int len = list.size();
			int anscount= 0;
			for(int i = 0; i < len; i++){
				char now = list.get(i);
				if(! index.containsKey(now)) continue;

				if(allcontain){
					int value = index.get(now);
					index.put(now, i);
					if(s == value){
						//次の最小値をもとめる
						s = min(index);
					}
					e = i;

					//判定
					if((e - s) < (anse - anss)){
						anse = e;
						anss = s;
						anscount=1;
					}
					else if((e - s) == (anse - anss)){
						anscount++;
					}
				}
				else{

					//これで見つかったかもしれない
					index.put(now, i);
					boolean isOK = true;
					int min = Integer.MAX_VALUE, max = 0;
					for(char key: index.keySet()){
						int value = index.get(key);
						if(value == -1){
							isOK = false;
							break;
						}
						else{
							max = Math.max(max, value);
							min = Math.min(min, value);
						}
					}

					if(isOK){
						allcontain = true;
						s = min;
						e = max;
						anss = min;
						anse = max;
						anscount++;
					}
				}
			}
			System.out.println(anscount);

			if(anscount > 0){
				System.out.println();
				print(anss,anse,list);
			}
			System.out.println();
			if(sc.hasNext()){
				sc.nextLine();

			}
		}
	}

	private void print(int s, int e, ArrayList<Character> list) {
		int count = 0;
		StringBuilder sb = new StringBuilder();
		for(int i = s; i <= e; i++ ){
			count++;
			sb.append(list.get(i));
			if(count == 72){
				count = 0;
				System.out.println(sb.toString());
				sb = new StringBuilder();
			}
		}
		if(sb.length() != 0) System.out.println(sb.toString());

	}

	private int min(HashMap<Character, Integer> index) {
		int min = Integer.MAX_VALUE;
		for(char key: index.keySet()){
			min = Math.min(min, index.get(key));
		}
		return min;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 17000
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll R, G;
    scanf("%lld %lld", &R, &G);
    printf("%lld\n", R+2*(G-R));
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a = [0] + a + [0]

li1 = [0,abs(a[1])]
li2 = [0,abs(a[n])]

for i in range(2,n+1):
    li1.append(abs(a[i-1]-a[i])+li1[len(li1)-1])
    li2.append(abs(a[n-i+1]-a[n-i+2])+li2[len(li2)-1])
    #print(abs(a[n-i+1]-abs(a[n-i+2])))
li1.append(abs(a[n])+li1[len(li1)-1])
li2.append(abs(a[1])+li2[len(li2)-1])

#print(li1)
#print(li2)


for i in range(1,n+1):
    print(li1[i-1]+li2[n-i]+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 17088
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a ={0,1,2,3,4,5,6,7};
    int n;
    cin >> n;
    int b[n],c[n];
    for(int i=0;i<n;i++) cin >> b[i] >> c[i];
    do{
        int flag = 1;
        for(int i=0;i<n;i++){
            if(a[b[i]]!=c[i]) flag = 0;
        }
        if(flag){
            int map[8][8] = {};
            int flag1 = 1;
            for(int i=0;i<8;i++){
                int r=i,c=a[i];
                if(map[r][c]) flag1 = 0;
                for(int j=0;j<8;j++){
                    for(int k=0;k<8;k++){
                        if(r==j||c==k) map[j][k]=1;
                        if(abs(r-j)==abs(c-k)) map[j][k]=1; 
                    }
                }
            }
            if(flag1){
                    for(int j=0;j<8;j++){
                        for(int k=0;k<8;k++){
                            if(k==a[j]) cout << 'Q';
                            else cout << '.';
                        }
                        cout << endl;
                    }
                return 0;
            }
        }
    }while(next_permutation(a.begin(),a.end()));
}



Measured memory_bytes: 3112
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n, q = map(int, input().split())
    edge = defaultdict(list)
    counter = [0] * n

    for _ in range(n - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)

    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    que = deque()
    que.append(0)

    while len(que) > 0:
        node = que.popleft()
        for next in edge[node]:
            counter[next] += counter[node]
            que.append(next)

    print(' '.join(map(str, counter)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 134852
#include<iostream>
#include<vector>
using namespace std;main(){for(int N,W,H,x,y,S,T,i,j,c;cin>>N,N;cout<<N<<endl){
cin>>W>>H;vector<vector<int> >f(W+1,vector<int>(H+1));for(;N-->0;f[x][y]=1)cin>>x>>y;cin>>S>>T;for(i=1;i<=W-S+1;i++)for(j=1;j<=H-T+1;j++,N<c&&(N=c))for(c=x=0;x<S;x++)for(y=0;y<T;y++)f[i+x][j+y]&&c++;}}

Measured memory_bytes: 0
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define all(v) v.begin() , v.end()
#define pb push_back

inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }

const ll N = 1e5 + 10;

ll n , a[N];

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(ll i = 1 ; i <= n ; i++)
		cin >> a[i];
	ll res = 0;
	if(a[1] == 1)
		swap(a[1] , a[2]) , res++;
	if(a[n] == n)
		swap(a[n] , a[n - 1]) , res++;
	for(ll i = 2 ; i <= n - 1 ; i++)
	{
		if(a[i] == i)
		{
			swap(a[i] , a[i + 1]);
			res++;
		}
	}
	cout << res << '\n';
	return 0;
}


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

int main()
{
    int x,y;
    while(~scanf("%d%d",&x,&y)&&x&&y)
    {
         cout<<(x-1)*(y-1)<<endl;
    }
    return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			
		}
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		boolean flag = false;
		int tt = 0, aa = 0;
		boolean[] b = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (tt < t[i]) {
				if (t[i] > a[i]) {
					flag = true;
					break;
				}
				tt = t[i];
				b[i] = true;
			}
			if (aa < a[n - 1 - i]) {
				if (a[n - 1 - i] > t[n - 1 - i]) {
					flag = true;
					break;
				}
				aa = a[n - 1 - i];
				b[n - 1 - i] = true;
			}
		}
		
		if (flag) {
			out.println(0);
		} else {
			long total = 1;
			for (int i = 0; i < n; i++) {
				if (!b[i]) {
					total *= min(t[i], a[i]);
				}
				total %= 1000000007;
			}
			
			out.println(total);
		}
		out.flush();
	}
	
	static int min(int a, int b) {
		return a < b ? a : b;
	}
	
}

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 byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte 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();
		}
	}
	
}

Measured memory_bytes: 11120
n,k = map(int,input().split())
mod = 10**9+7

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,2010):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
      
    return fact[n]*finv[r]*finv[n-r]%mod

for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        print((nCr(n-k+1,i,mod)*nCr(k-1,i-1,mod))%mod)

Measured memory_bytes: 3572
//quming
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
int P;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e5+5,inf=0x3f3f3f3f;
typedef pair<int,int> pi;
//struct Queue{
//	priority_queue<pi,vector<pi>,greater<pi> >A,B;
//	inline void push(R pi p){A.push(p);}
//	inline void pop(R pi p){B.push(p);}
//	inline pi top(){
//		while(!B.empty()&&A.top()==B.top())A.pop(),B.pop();
//		return A.empty()?pi(inf,233333):A.top();
//	}
//}q;
set<pi>sr;
char s[N];int n,m,nxt[N];pi p[N];
int main(){
	scanf("%d%d%s",&n,&m,s);
	fp(i,0,n)p[i]=pi(inf,2333);
	sr.insert(p[n]=pi(0,n));
	fd(i,n-1,0){
		if(i+m+1<=n&&s[i+m+1]=='0')sr.erase(p[i+m+1]);
		if(s[i]=='1')continue;
		if(sr.empty())return puts("-1"),0;
		R pi pwp=*sr.begin();
//		printf("%d %d %d %d %d\n",sr.size(),i,p[i].fi,p[i].se,nxt[i]);
		p[i]=pi(pwp.fi+1,i),nxt[i]=pwp.se;
		sr.insert(p[i]);
	}
	if(p[0].fi==inf)return puts("-1"),0;
	for(R int i=0;i<n;i=nxt[i])printf("%d ",nxt[i]-i);
	return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define Mx 2000001
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef long long  L;
typedef pair<L, L> pii;
L in,a,a1,a2,a3,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx,mn,flg,flg1,flg2,id1,id2,id3,id4,lim,tm1,st,en;
L A[201][201];
void fun(){
    for(L i=1;i<=3;i++){
        for(L j=1;j<=3;j++){
            if(A[i][j]==d){
                A[i][j]=-1;return;
            }
        }
    }
}
void solve(){
    for(L i=1;i<=3;i++){
        if((A[i][1]==A[i][2]&&A[i][2]==A[i][3]&&A[i][3]==-1)){
            printf("Yes\n");return;
        }
    }
    for(L i=1;i<=3;i++){
        if((A[1][i]==A[2][i]&&A[2][i]==A[3][i]&&A[3][i]==-1)){
            printf("Yes\n");return;
        }
    }
    if(A[1][1]==A[2][2]&&A[2][2]==A[3][3]&&A[3][3]==-1){
        printf("Yes\n");return;
    }
    if(A[1][3]==A[2][2]&&A[2][2]==A[3][1]&&A[3][1]==-1){
        printf("Yes\n");return;
    }
    printf("No\n");
}
int main()
{
    for(L i=1;i<=3;i++){
        for(L j=1;j<=3;j++){
            scanf("%lld",&A[i][j]);
        }
    }
    scanf("%lld",&n);
    for(L i=0;i<n;i++){
        scanf("%lld",&d);
        fun();
    }
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e9
// #define ll long long ll
 
typedef long long ll;
ll mod = 1e9 + 7;
 
long long fast_exp(long long a, long long b)
{
	if(b <= 0)
	   return 1;
	else
	{
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
	}
}
typedef long double ld;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int a[3];
    for(int i = 0; i<3 ; i++)
        cin>>a[i];
    int chk = 0;
    for(int i = 0; i<3 ; i++)
        {
            if(a[i] == a[(i+1)%3] && a[i] != a[(i+2)%3])
                chk = 1;
        }
    if(chk)
        cout<<"Yes\n";
    else
        cout<<"No\n";


    return 0; 
}

Measured memory_bytes: 256
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 3000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000 * 1ll * 10000000 * 1ll * 1000;
const ld pi = acosl(-1.0);

int n;
string s;

void input() {
    cin >> n;
    cin >> s;
}

void solve(int testId) {
    int W = 0, R = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            R++;
        } else  {
            W++;
        }
    }
    int ans = n, r = 0, w = W;
    for (int i = n; i >= 0; i--) {
        r += (i < n && s[i] == 'R' ? 1 : 0);
        w -= (i < n && s[i] == 'W' ? 1 : 0);
        ans = min(ans, max(r, w));
    }
    cout << ans << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;

    ll count = 0;
    ll count_a = 0;
    ll count_bc = 0;
    bool flag = false;

    rep(i, 0, s.size()){
        if(i + 1 >= s.size()){
            break;
        }

        if(s[i] == 'A' && !flag){
            count_a++;
        }else if(s[i] == 'B' && s[i + 1] == 'C'){
            count_bc++;
            i++;
            flag = true;
        }else{
            count += count_a * count_bc;
            if(s[i] == 'A'){
                count_a++;
            }else{
                count_a = 0;
            }
            count_bc = 0;
            flag = false;
        }
    }

    count += count_a * count_bc;

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 640
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll k, n;
  k = 26;
  cin >> n;
  n--;
  ll base = k;
  int cnt = 0;
  while (n >= base) {
    n -= base;
    cnt++;
    base *= k;
  }
  // dmp(n);
  vector<int> ans;
  for (int i = 0; i <= cnt; i++) {
    ans.push_back(n % k);
    n /= k;
  }
  // dmp(ans);
  reverse(all(ans));
  for (int i = 0; i < ans.size(); i++) cout << (char)('a' + ans[i] + 26 - k);
  cout << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//#define int long long
const int INF = numeric_limits<int>::max();
vector<vector<ll>> Warshall_Floyd(int V, vector<vector<ll>>&dp) {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				if (dp[i][k] == INF || dp[k][j] == INF) {
					continue;
				}
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	return dp;
}
signed main() {	
	int H, W;
	cin >> H >> W;
	vector<vector<ll>>dp(10, vector<ll>(10));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> dp[i][j];
		}
	}
	dp = Warshall_Floyd(10, dp);
	ll ans = 0;
	vector<vector<int>>As(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> As[i][j];
			if (As[i][j] != -1) {
				ans += dp[As[i][j]][1];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N = i_input()

    for i in range(1,N+1):
        if math.floor(i*1.08) == N:
            print(i)
            exit()

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


Measured memory_bytes: 68160