akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, M;
const int MAX_N = 100000, MAX_M = 100000;
ll A[MAX_N], C[MAX_M];
ll B[MAX_M];

int main(){
  cin >> N >> M;
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i] >> C[i];

  pll p[M];
  REP(i, M) p[i] = pll(C[i], B[i]);
  sort(A, A + N);
  sort(p, p + M, greater<pll>());
  int i = 0;
  REP(j, M) {
    REP(k, p[j].S) {
      A[i] = max(A[i], p[j].F);
      i++;
      if(i == N) {
        ll ans = 0;
        REP(l, N) {
          ans += A[l];
        }
        cout << ans << endl;
        return 0;
      }
    }
  }

  ll ans = 0;
  REP(l, N) {
    ans += A[l];
  }
  cout << ans << endl;

  
  return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  vector<string> blue(N), cp;

  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }

  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  
  cp = blue;

  int max = 0;
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      if (cp.at(i) == blue.at(j)) {
        tmp++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (cp.at(i) == red.at(j)) {
        tmp--;
      }
    }
    
    if (max < tmp) {
      max = tmp;
    }
  }
  
  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int A, B;
	std::cin >> A >> B;
	if ((B-1)%(A-1)==0) std::cout << (B-1)/(A-1) << std::endl;
	else std::cout << (B-1)/(A-1) + 1 << std::endl;
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main() {
	//code
	char ch;
	scanf("%c",&ch);
	if(ch=='A')
	printf("T");
	else if(ch=='T')
	printf("A");
	else if(ch=='G')
	printf("C");
	else if(ch=='C')
	printf("G");
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,m,r;cin>>n>>m>>r;
    vll city(r);
    rep(i,r)cin>>city[i];
    vvll dp(n,vll(n,INF));
    rep(i,n)dp[i][i]=0;
    rep(i,m){
        ll a,b,c;cin>>a>>b>>c;
        dp[a-1][b-1]=c;
        dp[b-1][a-1]=c;
    }
    rep(k,n)rep(i,n)rep(j,n)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    ll sum=0;
    ll mi=INF;
    sort(all(city));
    do{
        sum=0;
        rep(i,r-1)sum+=(ll)dp[city[i]-1][city[i+1]-1];
        mi=min(mi,sum);
    }while(next_permutation(all(city)));
    cout<<mi<<endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		
		for (;;) {
			int n = sc.nextInt(), m = sc.nextInt();
			if ((n|m) == 0) break;
			
			int[][] t = new int[m][m], c = new int[m][m];
			
			for (int i=0;i<m;i++) {
				fill(t[i], INF);
				fill(c[i], INF);
				t[i][i] = c[i][i] = 0;
			}
			
			for (int i=0;i<n;i++) {
				int a = sc.nextInt()-1, b = sc.nextInt()-1, cost = sc.nextInt(), time = sc.nextInt();
				t[a][b] = t[b][a] = min(t[a][b], time);
				c[a][b] = c[b][a] = min(c[a][b], cost);
			}
			
			for (int k=0;k<m;k++) for (int i=0;i<m;i++) for (int j=0;j<m;j++) {
				t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
			
			int k = sc.nextInt();
			
			for (int i=0;i<k;i++) {
				int p = sc.nextInt()-1, q = sc.nextInt()-1, r = sc.nextInt();
				System.out.println((r == 0 ? c[p][q] : t[p][q]));
			}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 66052
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v.at(i);
    sort(v.begin(), v.end());
    int sum = 0;

    rep(i, N)
    {
        sum += v.at(i);
    }

    int index = 0;
    while(sum % 10 == 0)
    {
        if(v.at(index) % 10 != 0)
        {
            sum -= v.at(index);
        }
        index++;
        if(index == v.size())
        {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
n=int(input())
a=0
w=0
t=0
r=0
for i in range(n):
    s=str(input())
    if(s=='AC'):
        a+=1
    elif(s=="WA"):
        w+=1
    elif(s=="TLE"):
        t+=1
    else:
        r+=1
print('AC', 'x',a)
print('WA', 'x',w)
print('TLE', 'x',t)
print('RE', 'x',r)

Measured memory_bytes: 9220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

int main(){
	char shurui[]={'o','x'},inpStr[10],math[3][3];
	int shuruiCount;
	bool flag;
	while(scanf("%s",inpStr)!=EOF){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				math[i][j]=inpStr[3*i+j];
			}
		}
		flag=false;
		
		for(int i=0;i<3 && !flag;i++){
			for(int j=0;j<3 && !flag;j++){
				for(int k=0;k<2;k++){   //種類選択


					if(shurui[k]==math[i][j]){
						shuruiCount=1;
						
						if(j==0){
							for(int u=1;u<3;u++){ //横移動
								if(math[i][u]!=shurui[k]){
									shuruiCount=1;
									break;
								}
								shuruiCount++;
							}
						}
						if(i==0 && shuruiCount==1){
							for(int u=1;u<3;u++){ //縦移動
								if(math[u][j]!=shurui[k]){
									shuruiCount=1;
									break;
								}
								shuruiCount++;
							}
						}
						if(i==0 && j==0 && shuruiCount==1){
							for(int u=1;u<3;u++){ //斜め右下移動
								if(math[i+u][j+u]!=shurui[k]){
									shuruiCount=1;
									break;
								}
								shuruiCount++;
							}
						}
						if(i==0 && j==2 && shuruiCount==1){
							for(int u=1;u<3;u++){ //斜め左下移動
								if(math[i+u][j-u]!=shurui[k]){
									shuruiCount=1;
									break;
								}
								shuruiCount++;
							}
						}
						if(shuruiCount==3){
							cout<<shurui[k]<<endl;
							flag=true;
							break;
						}
					}
				}
			}
		}
		if(!flag){
			cout<<"d"<<endl;
		}
	}
}

Measured memory_bytes: 1148
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	long[][] dp = new long[20001][256];

	public void run() {
		while (true) {
			int N = in.nextInt(), M = in.nextInt();
			if (N == 0 && M == 0) break;
			int[] C = new int[M], x = new int[N];
			
			for (int i = 0; i < M; i++)
				C[i] = in.nextInt();
			for (int i = 0; i < N; i++)
				x[i] = in.nextInt();
			
			for (int i = 0; i < dp.length; i++) {
				Arrays.fill(dp[i], Long.MAX_VALUE);
			}
			
			
			dp[0][128] = 0;
			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= 255; j++) {
					for (int k = 0; k < M; k++) {
						int idx = j + C[k];
						idx = Math.max(idx, 0);
						idx = Math.min(idx, 255);
						dp[i+1][idx] = (long) Math.min(dp[i+1][idx], dp[i][j] + Math.pow(idx - x[i], 2));
					}
				}
			}
			
			long res = Long.MAX_VALUE;
			for (int i = 0; i <= 255; i++) {
				res = Math.min(res, dp[N][i]);
			}
			System.out.println(res);
			
		}
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

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

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 97384
C = [list(map(int, input().split())) for _ in range(3)]
x = C[1][0]-C[0][0] == C[1][1]-C[0][1] == C[1][2]-C[0][2]
y = C[2][0]-C[0][0] == C[2][1]-C[0][1] == C[2][2]-C[0][2]
if x and y:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int x = scan.nextInt();

		for(int i=0;i<(k*2)-1;i++) {
			System.out.print(x-k+i+1 + " ");
		}
	}

}


Measured memory_bytes: 23764
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var P = parseInt(input[0].split(" ")[1]);
  A = new Array();
  P2=Math.sqrt(P);
  var j=-1;
  var k=0;
  for(i=2;i<P2;i){
    if(P%i==0){
      if(k==0){
        j++;
      }
      k++;
      A[j]=[i,k];
      P=P/i;
    }else{
      i++;
      k=0;
    }
    if(P==1){
      break;
    }else if(P==P){
      A[j+1]=[P,1];
    }
  }
  var ans=1;
  for(i=0;i<A.length;i++){
    ans*=Math.max(Math.pow(A[i][0],Math.floor(A[i][1]/N)),1);
  }

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



Measured memory_bytes: 10060
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)
  









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

using namespace std;

int bus_num(int n, int c, int k, vector<int> time);

int main()
{
	int n, c, k;
	cin >> n >>  c >> k;
	vector<int> time;
	for(int i=0; i<n; i++) {
		int t;
		cin >> t;
		time.push_back(t);
	}
	cout << bus_num(n, c, k, time);
	return 0;
}

int bus_num(int n, int c, int k, vector<int> time)
{
	int num = 0;
	sort(time.begin(), time.end());

	int st = time[0];
	int cnt = 1;

	for(int i=1; i<n; i++) {
		if(cnt < c && (time[i] - st) <= k)
			cnt++;
		else {
			st = time[i];
			cnt = 1;
			num++;
		}
	}
	return num+1;
}

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

using namespace std;

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

	int count = 0;

	for (int l = 0; l < N; l++) {
		int r;
		while (h[l] != 0) {
			int Min = h[l];
			for (r = 1; l + r < N; r++) {
				if (h[l + r] == 0) break;
				Min = min(Min, h[l + r]);
			}
			for (int i = l; i < l + r; i++) {
				h[i] -= Min;
			}
			count += Min;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3608
//ABC162 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;


int main() {
  cin >> n;

  if((n/100)%10 == 7 || (n/10)%10 == 7 || n%10 == 7){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  
  //printf("%lld\n",ans);
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

using namespace std;


int main() {
	int N, M;
	cin >> N >> M;
	vector<int> v(M);
	for(auto &x: v) cin >> x;

	sort(v.begin(), v.end());

	vector<int> l(M-1);

	for(int i = 0; i < M - 1; i++) {
		l[i] = v[i+1] - v[i];
	}

	sort(l.begin(), l.end());

	int out = 0;

	for(int i = 0; i < M - N; i++) {
		out += l[i];
	}

	cout << out << endl;

}

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

using namespace std;


const int N = 101000;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vipb(v) int x;cin>>x;v.pb(x);
#define vllpb(v) ll x;cin>>x;v.pb(x);
typedef vector<int> VI;
typedef vector<ll> VL;
string s;
ll n, m;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin >> s;
	if (s.size() == 2) {
		cout << s << endl;
	}
	else {
		cout << s[2] << s[1] << s[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> String
solve x = let 
    isOk a b = a^5 - b^5 == x
    (a, b) = head [(a, b) | a <- [-200..200], b <- [-200..200],  isOk a b]
    in 
    show a <> " " <> show b


main :: IO ()
main = do
    x <- readInt
    putStrLn $ solve x





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

int main(){
  string L[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  rep(i,7){
    if(s==L[i]){
      cout << 7-i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
                if (i+j)%2 == 0:
                        print('#', end='')
                else:
                        print('.', end='')
        print()
    print()


Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


long long int multiply(long long int a,long long int b) 
{ 
    long long int res = 0,f=0,p=0; 
    a =(a+mod)%mod;
    if(b<0)
     f=1;
     b=abs(b);
    while (b) 
    {
        if (b & 1) 
            res = (res + a) % mod;
        a = (2 * a) % mod; 
        b >>= 1;
    } 
    if(f)
    res*=(-1);
    return res; 
}

// <----- Actual solve() function to print output -----> //
int tc=1;
void solve()
{
   ll n,k=0,z=-1,ans=0;
cin>>n;
ll a[n];
ll p[n];
forp(i,0,n)
{
   cin>>a[i];

   if(i==0)
   p[i]=a[i];
   else
   {
      p[i]=p[i-1]+a[i];
   }
}
ans=0;
forp(i,0,n)
{
   k=multiply(a[i],(p[n-1]-p[i]))%mod;
   ans=ans%mod+k%mod;
}
  cout<<ans%mod;
 //  cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  single_testcase_t
 // multiple_testcases_t
return 0;
}





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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> price;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    price.push(a);
  }
  for(int i = 0; i < M; i++) {
    int a = price.top();
    a /= 2;
    price.pop();
    price.push(a);
  }
  int64_t ans = 0;
  for(int i = 0; i < N; i++) {
    ans += price.top();
    price.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "No\n"; return;}

void solve() {
    int n; string s;
    cin >> n;
    set <string> ans;
    loop(i, n) {
        cin >> s;
        ans.insert(s);
    }
    cout << ans.size();
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    while(true){
        c -= b;
        if(c<=0){
            cout << "Yes";
            break;
        }
        a -= d;
        if(a<=0){
            cout << "No";
            break;
        } 
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    long long int a;
    double bd;
    char bc1,bc2,bc3;
    cin >> a;
    cin >> bc1;
    cin >> bc2;
    cin >> bc2 >> bc3;
    int b1,b2,b3;
    b1=bc1-'0';
    b2=bc2-'0';
    b3=bc3-'0';
    int b =100*b1+10*b2+b3;
    // cin >> a >>bd;
    if(b==0){
        cout << 0 << endl;
        return 0;
    }
    // int b=int(bd*100);

    cout <<(a*b)/100 << endl;
    return 0;

}

Measured memory_bytes: 3596
#include <iostream>

int main()
{
    int n;
    int a[100];
    std::cin >> n;
    for (int i = 0; i < n; ++i)
        std::cin >> a[i];

    for (int k = 0; k < n; ++k) {
        std::cout << a[k];
        if (k != n - 1) std::cout << " ";
        else std::cout << std::endl;
    }
    // Insersion Sort
    for (int i = 1; i < n; ++i) {
        int key = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > key) {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = key;
        for (int k = 0; k < n; ++k) {
            std::cout << a[k];
            if (k != n - 1) std::cout << " ";
            else std::cout << std::endl;
        }
    }
}



Measured memory_bytes: 3092
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
const int N = 4005;
const int inf = 0x3f3f3f3f;
typedef long long ll;
vector<int>VR,VG,VB;
char a[N];
ll ans=0;
void fun(vector<int>VR,vector<int>VG,vector<int>VB)
{
    for(int i=0; i<VR.size(); i++)
    {
        int x=upper_bound(VG.begin(),VG.end(),VR[i])-VG.begin();
        if(x==VG.size())
            break;
        for(int j=x; j<VG.size(); j++)
        {
            int y=upper_bound(VB.begin(),VB.end(),VG[j])-VB.begin();
            if(y==VB.size())
                break;
            ans+=VB.size()-y;
            int id=2*VG[j]-VR[i];
            if(id<=VB.back()&&a[id]==a[VB[0]])
                ans--;
        }
    }
}
int main()
{
    int n;
    scanf("%d%s",&n,a);
    for(int i=0; i<n; i++)
        if(a[i]=='R')
            VR.push_back(i);
        else if(a[i]=='G')
            VG.push_back(i);
        else
            VB.push_back(i);
    fun(VR,VG,VB);
    fun(VR,VB,VG);
    fun(VG,VR,VB);
    fun(VG,VB,VR);
    fun(VB,VR,VG);
    fun(VB,VG,VR);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e6+5;
const int mod=1e9+7;
int fact[nmax+1],invfact[nmax+1];
int modpow(int x,int y){
  int ans=1;
  while(y){
   if(y&1)ans=(1LL*ans*x)%mod;
   x=(1LL*x*x)%mod;
   y>>=1;
  }
  return ans;
}
int nCr(int n,int r){
  if(r>n)return 0;
  return (1LL*( (1LL*fact[n]*invfact[r])%mod )*invfact[n-r])%mod;
}  
void preprocess(){
 fact[0]=1;
 for(int i=1;i<=nmax;i++){
   fact[i]=(1LL*i*fact[i-1])%mod;
 }
 invfact[nmax]=modpow(fact[nmax],mod-2);
 for(int i=nmax-1;i>=0;i--){
   invfact[i]=(1LL*(i+1)*invfact[i+1])%mod;
 }
}  
int main()
{
  int r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  preprocess();
  long long ans=0;
  for(int i=r1;i<=r2;i++){
    ans+=nCr(i+c2+1,i+1);
    ans-=nCr(i+c1,i+1);
    ans=(ans+mod)%mod;
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
typedef long long ll;

int main()
{
   string s;cin>>s;
   for (int i = 0; i < s.size(); i++)
   {
	   if(s[i]=='?') cout<<"D";
	   else cout<<s[i];
   }
   return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j + (j-i);
    if (k < n) {
      if (s[i] == s[j]) continue;
      if (s[i] == s[k]) continue;
      if (s[k] == s[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
use strict;
my ($n, $t) = split(' ', <>);

my @a = split(' ', <>);

my $min = 1000000000;
my $mx = 0;
for (@a) {
    my $dif = $_ - $min;
    if ($dif > $mx) {
        $mx = $dif;
    } elsif ($_ < $min) {
        $min = $_;
    }
}
my $fin_mx = $mx;

$min = 1000000000;
$mx = 0;
my $cnt;
for (@a) {
    my $dif = $_ - $min;
    if ($dif >= $mx) {
        $mx = $dif;
        if ($mx == $fin_mx) {
            $cnt++;
        }
    } elsif ($_ < $min) {
        $min = $_;
    }
}

print "$cnt\n";

Measured memory_bytes: 17260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string S;
  cin >> S;
  int ans = 0, red = 0, blue = 0;
  for(auto x : S){
    if(x == '0') red++;
    else blue++;
    if(red && blue) ans += 2, red--, blue--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
def main():
    n, x, y = map(int, input().split()) 

    ans = [0] * n
    for i in range(1,n):
        for j in range(i+1, n+1):
            r1 = j-i
            r2 = abs(x-i) + 1 + abs(j-y)
            r3 = abs(y-i) + 1 + abs(j-x)
            ans[min(r1,r2,r3)] += 1

    for i in range(1,n):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)

	count := 0
	for i := 2; i <= k; i += 2 {
		for j := 1; j <= k; j += 2 {
			count++
		}
	}
	fmt.Println(count)
}


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

int main() {
  string s;
  cin >> s;
  map<ll,ll> cnt;
  ll n=s.size();
  ll tmp=1;
  ll res=0;
  cnt[0]++;
  for(ll i=n-1;i>-1;i--) {
    res+=(s[i]-'0')*tmp;
    res%=2019;
    tmp*=10;
    tmp%=2019;
    cnt[res]++;
  }
  ll ans=0;
  for(auto p:cnt) {
    ans+=p.second*(p.second-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> R_count(N-1);
    vector<int> G_count(N-1);
    vector<int> B_count(N-1);
    for (int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
            if (S.at(j) == 'R') R_count.at(i)++;
            else if (S.at(j) == 'G') G_count.at(i)++;
            else if (S.at(j) == 'B') B_count.at(i)++;
        }
    }
    ll count = 0;
    for (int i=0; i<N-2; i++) {
        for (int j=i; j<N-1; j++) {
            if (S.at(i) != S.at(j)) {
                bool labelR = false, labelG = false, labelB = false;
                if (S.at(i) == 'R' || S.at(j) == 'R') labelR = true;
                if (S.at(i) == 'G' || S.at(j) == 'G') labelG = true;
                if (S.at(i) == 'B' || S.at(j) == 'B') labelB = true;
                if (labelR && labelG) {
                    count += B_count.at(j);
                    if (2*(j-i) + i <= N-1) {
                        if (S.at(2*(j-i) + i) == 'B') count--;
                    }
                }
                else if (labelG && labelB) {
                    count += R_count.at(j);
                    if (2*(j-i) + i <= N-1) {
                        if (S.at(2*(j-i) + i) == 'R') count--;
                    }
                }
                else if (labelB && labelR) {
                    count += G_count.at(j);
                    if (2*(j-i) + i <= N-1) {
                        if (S.at(2*(j-i) + i) == 'G') count--;
                    }
                }
            }
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3688
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  ll tot = 0;
  for(auto it: a) tot^=it;
  for(auto it: a) cout << (tot^it) << " ";
  return 0;
} //good night.

Measured memory_bytes: 4744
using System;
using System.Linq;

namespace ABC125_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var minus = A.Where(x => x < 0).Count();

            var abs = A.Select(x => Math.Abs(x));
            if (minus % 2 == 0)
            {
                var ans = abs.Sum();
                Console.WriteLine(ans);
            }
            else
            {
                var ans = abs.Sum() - abs.Min() * 2;
                Console.WriteLine(ans);
            }

        }
    }
}


Measured memory_bytes: 29532
N = int(input())
A = list(map(int, input().split()))
A.sort()

res = 0

from collections import defaultdict
D = defaultdict(int)

for i in range(N):
    D[A[i]] += 1

P = [0 for _ in range(10**6 + 1)]

for i in range(N):
    if P[A[i]]:
        continue
    if D[A[i]] == 1:
        res += 1
    for j in range(A[i], 10**6 + 1, A[i]):
        P[j] = 1

print(res)

Measured memory_bytes: 170552
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int x,y,a,b,c,mid,mx,mn,k,i,cnt,t,ans,cnt1,cnt2;
    cin>>x>>y>>a>>b>>c;
    t=x+y;
    vector<long long int>v1,v2,v3;
    for(i=0;i<a;i++){cin>>k;
        v1.push_back(k);
    }
    for(i=0;i<b;i++){cin>>k;
        v2.push_back(k);}
        for(i=0;i<c;i++){cin>>k;
            v3.push_back(k);
        }
        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());
        sort(v3.begin(),v3.end());
        mx=1000000000,mn=0;
        k=0;
        while(mn<=mx){
            mid=(mn+mx)/2;
            cnt=0;
            auto it1=upper_bound(v1.begin(),v1.end(),mid);
            int k1,k2,k3;
            k1=it1-v1.begin();
            auto it2=upper_bound(v2.begin(),v2.end(),mid);
            k2=it2-v2.begin();
            auto it3=upper_bound(v3.begin(),v3.end(),mid);
            k3=it3-v3.begin();
            cnt=min(a-k1,x)+min(b-k2,y)+c-k3;
            
            if(cnt>=t){
                k=mid;
                mn=mid+1;
            }else{mx=mid-1;}
        }k++;
        cnt=0;
        cnt1=0,cnt2=0;
        ans=0;
        for(i=a-1;i>=0&&cnt<=t;i--){if(v1[i]>k){ans+=v1[i];cnt++;
            cnt1++;
            if(cnt1>=x||cnt>t)break;
        }}
         for(i=b-1;i>=0&&cnt<=t;i--){if(v2[i]>k){ans+=v2[i];cnt++;cnt2++;
             if(cnt2>=y||cnt>=t){break;}
         }}
          for(i=c-1;i>=0&&cnt<=t;i--){if(v3[i]>k){ans+=v3[i];cnt++;if(cnt>=t)break;}}
          cnt=min(t,cnt);
          //cout<<ans;
          ans+=(t-cnt)*k;
          cout<<ans;
    return 0;}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,k;
  cin >> n >> k;
  cout << n-k+1 << endl;
  return 0;
}

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

vector<ll>a;
void dep(ll now,ll keta){
	if(keta==11){
		return ;
	}
	ll next=now%10;
	a.push_back(now*10+next);dep(now*10+next,keta+1);
	if(next>=1){
		a.push_back(now*10+next-1);dep(now*10+next-1,keta+1);
	}
	if(next<=8){
		a.push_back(now*10+next+1);dep(now*10+next+1,keta+1);
	}
}
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=9;i++){
		a.push_back(i);
		dep(i,1);
	}
	sort(a.begin(),a.end());
	cout << a[n-1];
	// your code goes here
	return 0;
}

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

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

  vector<int> L(N);

  for (int i = 0; i < N; i++)
  {
    cin >> L.at(i);
  }
  

  sort(L.begin(), L.end());

  int sum = 0;

  for (int i = 0; i < N - 1; i++){
    sum += L.at(i);
  }

  cout << (sum > L.at(N - 1) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	int max = a+b;
	if( a+b > max){
		max = a+b;
	}
	if( (a-b)>max){
		max = a-b;
	}
	if( (a*b)>max ){
		max = a*b;
	}
	printf("%d",max);
	return 0;
}

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

const int N = 18, mod = 1e9 + 7;

int dp[44][1 << N], x, y, z;
int yo(int n, int mask) {
	mask &= (1 << 18) - 1;
	if (mask >> x & 1 && mask >> (x + y) & 1 && mask >> (x + y + z) & 1) return 0;
	if (n == 0) return 1;
	int &ret = dp[n][mask];
	if (ret != -1) return ret;
	int ans = 0;
	for (int i = 1; i <= 10; i++) {
		ans += yo(n - 1, (mask << i) | (1 << i));
		if (ans >= mod) ans -= mod;
	}
	return ret = ans;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n >> x >> y >> z;
	memset(dp, -1, sizeof dp);
	int ans = 1;
	for (int i = 1; i <= n; i++) ans = 1LL * ans * 10 % mod;
	ans = (ans - yo(n, 0) + mod) % mod;
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double v = a * a * b, ans;
  if (x >= v / 2) {
    ans = atan(2 * (v - x) / (a * a * a));
  } else {
    ans = atan(a * b * b / (2 * x));
  }
  ans = ans * 180 / M_PI;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N;
    int A;
    cin >> N;
    for(int i =0; i<N; i++) {
        cin >> A;
        if (A%2 == 0){
            if((A%3==0)||(A%5==0)) {
                // OK
            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        } else {
            // OK
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
        return 0;
    }
    if (0 < a) {
        cout << "Positive" << endl;
        return 0;
    }
    assert(b < 0);
    if ((b - a + 1) % 2 == 0) {
        cout << "Positive" << endl;
        return 0;
    }
    cout << "Negative" << endl;
    return 0;
}


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

int main(){
    long long int n,m;
    cin>>n>>m;
    long long int l,r;
    int max=1e6,min=-1e6;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        if(min<l)min = l;
        if(r<max) max = r;
    }
    if(min<=n && n<=max){
        //cout<<"hoge"<<endl;
        cout<<n-min+1<<endl;
        return 0;
    }else if(min>n){
        //cout<<"fuga"<<endl;
        cout<<"0"<<endl;
        return 0;
    }else if(min> max){
        cout << "0" << endl;
        return 0;
    }
    else{
        //cout << min << " " << max << endl;
        cout << max - min + 1 << endl;
    }   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int tc=1;

void solve()
    { 
     
     int n;
     cin>>n;
     int i=0,j=n-1;
     string s;
     cin>>s;
     if(count(s.begin(),s.end(),'R')==n||count(s.begin(),s.end(),'W')==n)
     {
       cout<<"0"<<endl;
       return;
     }

     ll int c=0;
     while(i<j)
     {
       while(s[i]!='W')
       i++;
       while(s[j]!='R')
       j--;
       if(i<j&&s[i]=='W'&&s[j]=='R')
       {
        i++;j--;
        c++;
       }
     } 
   cout<<c<<endl;


    }
     
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
   // wi(t)
    {
    solve();
    }
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 10812
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    string s, ans;

    cin >> s;

    for (int i=0; i<s.size(); i++){
        if (s[i] != 'B') ans += s[i];
        else if (s[i] == 'B' and ans.size() > 0){
            ans.pop_back();
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;

const int mod = 1e9+7;
const int N = 6e5+2;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
string p;
int main() {
    int n; string s;
    rep(i, 0, 26) p += ('A'+i);
    cin>>n>>s;
    string ret;
    rep(i, 0, sz(s)) {
        ret += p[(s[i]-'A'+n)%26];
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

add_l = 0
add_r = 0

for e in s:
	if e == "(":
		add_r += 1

	else: # e == ")"
		if add_r == 0:
			add_l += 1
		else:
			add_r -= 1

ans = add_l * "(" + s + ")" * add_r
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
//int fib(int);

int Fib[44];
int main() {
  int i,n;
  Fib[0]=1;
  Fib[1]=1;
  for (i = 2; i < 45; i++) {
    Fib[i] = Fib[i-1]+Fib[i-2];
  }
  scanf("%d",&n);
  printf("%d\n",Fib[n]);
  return 0;
}
/* int fib(int n){


} */

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<sstream>
#include <iomanip>
#include<cmath>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define SORT(n,p) sort(n,n+p);
#define llong long long
#define pb(a) push_back(a)

using namespace std;
int main() {
	int ken, shi;
	cin >> ken >> shi;
	vector<vector<int>> vec(shi,vector<int>(3,0));
	vector<pair<int,int>> order(shi);
	REP(i,shi) {
		cin >> vec[i][0] >> vec[i][1];
		vec[i][2] = i;
	}
	sort(vec.begin(), vec.end(), [](const vector<int>& x, const vector<int>& y) {return x[0] < y[0]; });
	int old_ken=vec[0][0];
	vector<vector<int>>::iterator top=vec.begin();
	for (vector<vector<int>>::iterator itr = vec.begin(); itr != vec.end();itr++) {
		if ((*itr)[0]!=old_ken) {
			sort(top, (itr), [](auto& x, auto& y) {return x[1] < y[1]; });
			top = itr;
			old_ken = (*itr)[0];
		}
	}
	sort(top, vec.end(),[](auto& x, auto& y) { return x[1] < y[1]; });
	old_ken = vec[0][0];
	int cnt = 1;
	for (auto itr : vec) {
		if (old_ken != itr[0]) {
			cnt = 1;
			old_ken = itr[0];
		}
		order[itr[2]].first = itr[0];
		order[itr[2]].second = cnt;
		cnt++;
	}
	
	REP(i, order.size()) {
		ostringstream oss1,oss2;
		oss1 << setw(6) << setfill('0') << order[i].first;
		oss2 << setw(6) << setfill('0') << order[i].second;
		string str1 = oss1.str();
		string str2 = oss2.str();
		string strr = str1 + str2;
		cout << strr << endl;
	}
	return 0;
}


Measured memory_bytes: 7808
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    count = [0]*(n)

    for i in range(1, n):
        for j in range(i, n, i):
            count[j] += 1
    
    ans = sum(count)
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 16668
N, M = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A, reverse=True)
guard = sum(A) / (M * 4)
count = 0
for i in range(M):
    if sorted_A[i] >= guard:
        count += 1

if M == count:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060