akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool judge(vector<string>& W){
  int n= W.size();
  for(int i = 0; i < n-1 ;i++){
    if (W[i].back() != W[i+1].front()) return false;
    for(int j = i+1; j < n ; j++){
      if (W[i] == W[j]) return false;
    }
  }
    return true;
  }
 
int main(){
  int n;
  cin >> n;
  vector<string> W(n);
  for(int i=0; i < n; i++){
  	cin >> W[i];
  }
  if(judge(W)){
    cout<< "Yes"<< endl;
  }else{
    cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b;
    char op;

    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;

        switch(op){
            case '+':
                printf("%d\n",a+b);
                break;
            case '-':
                printf("%d\n",a-b);
                break;                
            case '*':
                printf("%d\n",a*b);
                break;
            case '/':
                printf("%d\n",a/b);
                break;                
        }
    }

    return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,w;
  cin >> n >> w;
  string s[n+2];
  string head = "";
  rep(i,w+2){
    head += ".";
  }
  s[0] = head;
  rep(i,n){
    string a;
    cin >> a;
    s[i+1] = "." + a + ".";
  }
  s[n+1]=head;
  rep(i,n){
    string ansl = "";
    rep(j,w){
    ll ans = 0;
      if(s[i+1][j+1]=='.'){
        if(s[i][j] == '#') ans++;
        if(s[i][j+1] == '#') ans++;
        if(s[i][j+2] == '#') ans++;
        if(s[i+1][j] == '#') ans++;
        if(s[i+1][j+1] == '#') ans++;
        if(s[i+1][j+2] == '#') ans++;
        if(s[i+2][j] == '#') ans++;
        if(s[i+2][j+1] == '#') ans++;
        if(s[i+2][j+2] == '#') ans++;
        ansl = ansl + to_string(ans);
      } else {
        ansl = ansl + '#';
      }
    }
    pri(ansl);
  }
  return 0;
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<vector<Pi>> mp(H, vector<Pi>(W));
  FOR(i, H) FOR(j, W) cin >> mp[i][j].first;
  FOR(i, H) FOR(j, W) cin >> mp[i][j].second;
  vector<vector<vector<int>>> dp(
      H, vector<vector<int>>(W, vector<int>(80 * 162 * 2)));
  FOR(i, H) FOR(j, W) {
    if (i == 0 && j == 0) {
      dp[i][j][80 * 161 + mp[0][0].first - mp[0][0].second] = 1;
      dp[i][j][80 * 161 - mp[0][0].first + mp[0][0].second] = 1;
    } else {
      if (i > 0) {
        FOR(k, 80 * 162 * 2) {
          if (dp[i - 1][j][k] == 1) {
            dp[i][j][k + mp[i][j].first - mp[i][j].second] = 1;
            dp[i][j][k - mp[i][j].first + mp[i][j].second] = 1;
          }
        }
      }
      if (j > 0) {
        FOR(k, 80 * 162 * 2) {
          if (dp[i][j - 1][k] == 1) {
            dp[i][j][k + mp[i][j].first - mp[i][j].second] = 1;
            dp[i][j][k - mp[i][j].first + mp[i][j].second] = 1;
          }
        }
      }
    }
  }
  int ans = INF;
  FOR(i, 80 * 162 * 2)
  if (dp[H - 1][W - 1][i] == 1) ans = min(ans, abs(i - 80 * 161));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 658816
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vi prime(1,2);
	for(int i=3;prime.back()<=50000;i+=2){
		bool ok=true;
		for(int j=0;prime[j]*prime[j]<=i;j++)
			if(i%prime[j]==0){
				ok=false;
				break;
			}
		if(ok)
			prime.push_back(i);
	}
	
	for(int n;cin>>n,n;){
		int res=0;
		for(int i=0;prime[i]<=n/2;i++)
			if(binary_search(allof(prime),n-prime[i]))
				res++;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 964
module Main where
--import Debug.Trace
import Data.List
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: Int -> Int -> [[Int]] -> [Int] -> [Int]
solve n m aij bj = iterR 0 where
    iterR i
        | i >= n = []
        | otherwise = iterC 0 bj : iterR (i+1) where
            iterC _ [] = 0
            iterC j (b:bs)
                | otherwise = b * mt ! (i, j) + iterC (j+1) bs
    mt = listArray ((0,0), (n-1,m-1)) (concat aij)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n)))
            
main :: IO() 
main = do
    [n, m] <- readLine
    aij <- readLines n
    bj  <- readLines m
    mapM_ print (solve n m aij (concat bj))



Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int ans=0;
    vector<int> dp(n);
    vector<vector<int>> g(n);
    vector<int> indeg(n);
    rep(i,0,m) {
        int u,v;
        cin>>u>>v;
        --u;
        --v;
        g[u].push_back(v);
        ++indeg[v];
    }
    vector<int> st;
    rep(i,0,n) if(indeg[i]==0) st.push_back(i);
    while(!st.empty()) {
        int u = st.back();
        st.pop_back();
        ans = max(ans, dp[u]);
        for(int v:g[u]) {
            dp[v] = max(dp[v], dp[u]+1);
            --indeg[v];
            if(indeg[v]==0) st.push_back(v);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6528
n,k=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
    if X[i]>=0:
        break
else:
    i=n

if i==0:
    M=[]
else:
    M=X[i-1::-1]
if i==n:
    P=[]
else:
    P=X[i:]
    
ans=10**10
for j in range(k+1):
    if len(M)<j or len(P)<k-j:
        continue
    if j==0:
        ans=min(P[k-1],ans)
    elif j==k:
        ans=min(-M[k-1],ans)
    else:
        l=max(-M[j-1],P[k-j-1])
        s=min(-M[j-1],P[k-j-1])
        ans=min(s*2+l,ans)
print(ans)

Measured memory_bytes: 14660
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    vector<ll> ans ;
    rep(i, 2){
        ll inp;
        cin >> inp;
        ans.pb(inp);
        ans.pb(inp-1);
    }
    sort(rall(ans));

    cout << ans[0] + ans[1] << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<nl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<int,int>
#define vi vector<int>
#define md 998244353

using namespace std;

int solve()
{
    ll n;
    cin>>n;
    map<string, int> mp;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

int main()
{
    fast;
    solve();

    return 0;
}













Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int a,b;
  cin>>a>>b;
  int i=0;
  while(true){
    int l=(a-1)*i+1;
    if(l>=b){
      cout<<i<<endl;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int r;
    cin >> r;
    cout << 3 *r * r << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000;

int h, w;
char c[500][500];
bool reached[500][500];

int main()
{
    int list[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int k;

    cin >> k;
    cout << list[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    string str;cin >> str;
    bool result = false;
    int ans_a,ans_b;
    for(int a = 0;a < str.size();a++){
        if(a+2<str.size()){
            if(str.at(a)==str.at(a+2)){
                result = true;
                ans_a = a+1;
                ans_b = a+3;
            }
        }
        if(a+1<str.size()){
            if(str.at(a)==str.at(a+1)){
                result = true;
                ans_a=a+1;
                ans_b=a+2;
            }
        }
    }
    cout<<(result?ans_a:-1)<<" "<<(result?ans_b:-1)<<endl;
}


Measured memory_bytes: 512
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    cnt = 0
    def dfs(l):#区間i,jについて最小水やり回数を求める
        global cnt
        if l == [] or l == [0]:return
        elif 0 in l:#0の前と後ろで分割して探索
            i = l.index(0)
            dfs(l[:i])
            dfs(l[i+1:])
        else:
            l = [k-1 for k in l]
            cnt += 1
            dfs(l)
    dfs(a)
    print(cnt)

Measured memory_bytes: 9232
while (1):
    input_list = input().split(' ')

    val1 = int(input_list[0])
    op = input_list[1]
    val2 = int(input_list[2])

    if op == '?':
        break

    if op == '+':
        print(val1 + val2)
    elif op == '-':
        print(val1 - val2)
    elif op == '*':
        print(val1 * val2)
    else:
        print(int(val1 / val2))



Measured memory_bytes: 5592
S = input()

# Rの連続を数える. Lの数は数えない
even = [0] * len(S)
start = -1
#print('R')
for i in range(len(S)):
    if S[i] == 'R':
        if start == -1:
            start = i
    elif start >= 0:
        end = i
        #print(start, end)
        even[i] += (end - start) // 2
        even[i-1] += (end - start) // 2 + (end - start) % 2
        start = -1
    else:
        pass

# Lの連続を数える Rの数は数えない
start = -1
#print('L')
for i in range(len(S)-1, -1, -1):
    if S[i] == 'L':
        if start == -1:
            start = i
    elif start >= 0:
        end = i
        #print(start, end)
        even[i] += (start - end) // 2
        even[i+1] += (start - end) // 2 + (start - end) % 2
        start = -1
    else:
        pass

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

Measured memory_bytes: 10484
N=int(input())

L=[]
# xでソート
#でソート
#min, max


for i in range(N):
    x,y=map(int, input().split())
    L.append([x+y,x-y])
    

L=sorted(L)
ans=abs(L[0][0]-L[-1][0])
L=sorted(L, key=lambda x: x[1])
ans=max(ans, abs(L[0][1]-L[-1][1]))

print(ans)

Measured memory_bytes: 115952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h1, m1, h2, m2;
    cin >> h1 >> m1 >> h2 >> m2;
    while(h2 > h1) {
        m2 += 60;
        h2--;
    }
    int k;
    cin >> k;
    cout << (m2 - m1) - k << '\n';
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
      b--;
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
  a %= md;
  if(a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= a * t; swap(a, b);
    u -= v * t; swap(u, v);
  }
  assert(b == 1);
  if(u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string n;
  cin >> n;
  int l = n.length();
  int d;
  cin >> d;
  vector<vector<int>> dp(l, vector<int>(d, 0));
  dp[0][0] = 1;
  for (int i = 1; i < l; i++)
  {
    for (int c = 0; c < 10; c++)
    {
      for (int crr = 0; crr < d; crr++)
      {
        int nxt = (crr + c) % d;
        add(dp[i][nxt], dp[i - 1][crr]);
      }
    }
  }

  int ans = 0;
  int res = 0;
  for (int i = 0; i < l; i++)
    {
    int c = n[i] - '0';
    while(c--){
      add(ans, dp[l - 1 - i][res]);
      res--;
      if (res < 0) {
        res += d;
      }
    }
  }
  if (res == 0) {
    add(ans, 1);
  }
  sub(ans, 1);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
  using namespace std;
   
  #define ll long long
  #define pb push_back
  #define mp make_pair
  #define ff first
  #define ss second


   
void func(){

ll k,n;
cin>>k>>n;
ll a[n+1];
for(int i=1;i<=n;i++)
  cin>>a[i];


ll max=-1;

for(int i=2;i<=n;i++){
  if(a[i]-a[i-1]>max)
    max=a[i]-a[i-1];
}
if(k+a[1]-a[n]>max)
 max=k+a[1]-a[n];

max=k-max;
cout<<max<<endl;
}
   
   
  int main(){
          ios_base::sync_with_stdio(false);
          cin.tie(0);
          cout.tie(0);
   
       /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r" , stdin);
        freopen("output.txt", "w" , stdout);
        #endif*/
   
     ll t=1;
     //cin>>t;
     while(t--)
     func();
   }

Measured memory_bytes: 1792
N,K=map(int,input().split())
count=0
for b in range(K+1,N+1):
	if K==0:
		count+=N
	else:
		x=N//b
		y=N%b
		count+=(x)*(b-K)
		if y>=K:
			count+=(y-(K-1))
print(count)

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

int main(){
	int n;
	cin>>n;
	string a;
	int ac=0,wa=0,tle=0,re=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a=="AC"){
			ac++; continue;
		} 
		if(a=="WA"){
			wa++; continue;
		}
		if(a=="TLE"){
			tle++; continue;
		}
		if(a=="RE"){
			re++; continue;
		}
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
} 

Measured memory_bytes: 3628
N = gets.to_i
words = []
words = N.times.map { gets.chomp }
flag = true
words.each.with_index do |word, i|
  flag = false unless words.count(word) == 1
  flag = false if (i != 0 && words[i-1][-1] != word[0])
end
puts flag ? "Yes" : "No"


Measured memory_bytes: 1788
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;
//c(a,b)long*a,*b;{t=*a-*b;}
c(a,b)int*a,*b;{t=*a-*b?:a[*I=1]-b[1];}
p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s){for(;++X<_;~scanf("%d",A+i)&&i++%2&&gets(P))I[X]=p(s=F[X]=X*s%M,M-2);
for(qsort(A,i/2,8,c);j<i;P[j++-1]=X)
  for(X=f(t=A[++j]-=*I=1,s=A[k=j]-=1);k;
      X=t<A[--k]?X:(X-f(s-A[k-1],t-A[k])*P[k-1]%M+M)%M,k--);
printf("%d",X);}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int e[101010]={};
bool p[101010];

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  // p[i]はiがprimeならfalseを返す。
  for(int i=2;i<=100000;i++){
    if(!p[i]){
      for(int j=i+i;j<=100000;j+=i){
        p[j]=true;
      }
    }
  }
  for(int i=3;i<=100000;i+=2)if(!p[i] && !p[(i+1)/2])e[i]++;
  for(int i=3;i<=100000;i++)e[i]+=e[i-1];
  int Q;cin>>Q;
  REP(i,Q){
    int l,r;cin>>l>>r;
    P(e[r]-e[l-1]);
  }
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

bool check(long long a) {
  long long b = 0;
  while (a > 0) {
    b++;
    a /= 10;
  }
  return (b%2)==1;
}

void solve(long long N){
  long long a = 1;
  long long ret = 0;
  while (a <= N) {
    if (check(a)) ret++;
    a++;
  }
  std::cout << ret << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  char s;
  cin>>s;
  if(isupper(s))
    cout<<"A"<<endl;
  else
    cout<<"a"<<endl;
    

  return 0;
}

Measured memory_bytes: 3632
from itertools import combinations
from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))

is_counted = defaultdict(lambda: 0)
cnt = 0
for t in combinations(range(n), 3):
    t = [l[x] for x in t]
    if len(set(t)) != 3:
        continue
    if sum(t) - max(t) > max(t):
        cnt += 1
print(cnt)

Measured memory_bytes: 68700
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ull i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();
  string s;cin>>s;
  loop(i,0,s.size())
  {
    if(s[i]=='9')s[i]='1';
    else if(s[i]=='1')s[i]='9';
  }
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

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

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N;
    std::cin >> N;
    
    //dp[i] i円引き出すのに必要な回数
    vector<int> dp(N+1);
    for (int i = 0; i < N; i++) {
        dp[i+1] = dp[i] + 1;
        int diff, now;
        diff = 6;
        now = i+1-diff;
        while (now >= 0) {
            dp[i+1] = std::min(dp[i+1], dp[now] + 1);
            diff *= 6;
            now = i+1-diff;
        }
        diff = 9;
        now = i+1-diff;
        while (now >= 0) {
            dp[i+1] = std::min(dp[i+1], dp[now] + 1);
            diff *= 9;
            now = i+1-diff;
        }
    }
    std::cout << dp[N] << std::endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>

int main() {
    long long l, r;
    std::cin >> l >> r;

    long long ans = 2018;

    for (long long i = l; i <= r; ++i) {
        if (i > l + 2019) {
            break;
        }
        for (long long j = l; j <= r; ++j) {
            if (j == i) {
                continue;
            }
            if (j > l + 2019) {
                break;
            }
            long long m = ((i % 2019) * (j % 2019)) % 2019;
            if (m < ans) {
                ans = m;
            }
        }
    }

    std::cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int f = 0;
    if(!((String.valueOf(s.charAt(0))).equals("A"))) f++;
    int p = 0;
    int q = 0;
    for(int i = 2; i < s.length() - 1; i++) {
      if((String.valueOf(s.charAt(i))).equals("C")) {
        p++;
        q = i;
      }
    }
    if(p != 1) f++;
    for(int i = 1; i < s.length(); i++) {
      if(q != i) {
        String a = (String.valueOf(s.charAt(i))).toLowerCase();
        if(!(a.equals(String.valueOf(s.charAt(i))))) f++;
      }
    }
    String ans = "AC";
    if(f > 0) ans = "WA";
    System.out.println(ans);
  }
}

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

typedef long long ll;

vector<vector<ll> > graph;
vector<bool> vis;
vector<ll> dis;
ll dfs(ll x)
{
	vis[x]=true;
	ll mi=-1;
	for(int i=0;i<graph[x].size();i++)
	{
		if(!vis[graph[x][i]])
			mi=max(mi,dfs(graph[x][i]));
		else
			mi=max(mi,dis[graph[x][i]]);
	}
	if(mi==-1)
		return dis[x]=0;
	else
		return dis[x]=mi+1;
}


int main() 
{
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifdef DEBUG
    //  		freopen("input.txt", "rt", stdin);
 	// #endif
	ll n,m; 
	cin >> n >> m;
	graph.resize(n);
	vis.resize(n);
	dis.resize(n);
	for(int j=0;j<n;j++)
	{
		vis[j]=false;
		dis[j]=-1;
	}
	ll a,b=0;
	while(m--)
	{
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
	}
	ll ans=-1;
	for(ll h=0;h<n;h++)
	{
		if(!vis[h])
		{
			ans=max(ans,dfs(h));
		}
	}
	cout<<ans<<"\n";
	return 0;	
}




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

int count(int n, int x){
int cnt = 0;
for ( int i = 1; i <= n-2; i++ ){
 for ( int j = i+1; j <= n-1; j++ ){
  for ( int k = j+1; k <= n; k++ ){
  if ( i + j + k == x) cnt++;
}
}
}
 return cnt;
}

int main(){
 int n, x;
 
 while(1){
  cin >> n >> x;
  if ( n == 0 && x == 0) break;
  cout << count(n, x) << endl;
}

return 0;

}  


Measured memory_bytes: 3116
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = x.split("\n");

for (var k = 0 ; k < input.length; k++) {

    var arr = input[k].split(" ").map(Number);
    var H = arr[0];
    var W = arr[1];
 
    if(H === 0 && W === 0) break;
    var result = "";
    for( var i = 0; i < H; i++){
        for( var j = 0; j < W; j++) {
            result += (i%2 && j%2) || (!(i%2) && !(j%2)) ? "#": "."; 
        }
        result += "\n";   
    }
        console.log(result);

}




Measured memory_bytes: 17784
import java.util.Scanner;

public class Main {
	
	static boolean [][]node;
	static boolean []visit;
	static int n;
	static int m;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		 n = Integer.parseInt(sc.next());
		 m = Integer.parseInt(sc.next());
		
		node = new boolean [n][n];
		visit = new boolean [n];
		
		int []a = new int [m];
		int []b = new int [m];
		
		for(int i = 0 ; i < m ;i++) {
			a[i] = Integer.parseInt(sc.next())-1;
			b[i] = Integer.parseInt(sc.next())-1;
			
			node[a[i]][b[i]] = true;
			node[b[i]][a[i]] = true;
		}
		int cnt = 0;
				
		for(int i = 0 ;i < m ;i++) {
			
			node[a[i]][b[i]] = false;
			node[b[i]][a[i]] = false;
			
			for(int j = 0; j < n ;j++) {
				visit[j] = false; 
			}
			
			dfs(0);
			
			boolean bridge = false;;
			
			for(int j = 0 ;j < n ;j++) {
				
				if(!visit[j]) {
				    bridge = true;
				}
			}
			
			if(bridge) {
				cnt++;
			}
			
			node[a[i]][b[i]] = true;
			node[b[i]][a[i]] = true;
			
		}
		
		System.out.println(cnt);
		
		
	}
	
	static void dfs(int s) {
		
		visit[s] = true;
		
		for(int i = 0 ; i < n ;i++) {
			if(!node[s][i] || !node[i][s]) {
				continue;
			}
			if(visit[i]) { 
				continue;
			}
			dfs(i);
			
		}
	}
	
}


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

int main(){
	bool flag = true;
	int i,j,count;
	static bool year[3001];
	for(int i=0;i<3001;i++){
		if(i % 4 == 0){
			if (i % 100 == 0){
				if(i % 400 == 0){
					year[i] = true;
				}
			}
			else{
				year[i] = true;
			}
		}
	}
	while(cin >> i >> j && (i!=0&&j!=0)){
		if(!flag) cout << "\n";
		flag = false;
		count = 0;
		for(int x = i;x<=j;x++){
			if(year[x] == true){
				cout << x << endl;;
				count++;
			}
		}
		if(count == 0) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[101][100001]={0};
int main()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<w[i];j++)
            dp[i][j]=dp[i-1][j];
        for(int j=w[i];j<=W;j++)
            dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


int main(){
    ll n,k; cin >> n >> k;
    ll r,s,p; cin >> r >> s >> p;
    string t;cin >> t;
    vector<ll> vec(n);
    rep(i,n){
        if(t[i] == 'r')vec[i] = 1;
        if(t[i] == 's')vec[i] = 2;
        if(t[i] == 'p')vec[i] = 3;
    }
    auto f = [&](ll x) -> ll{
        if(x == 1)return p;
        if(x == 2)return r;
        if(x == 3)return s;
        return 0;
    };
    rep(i,n){
        if(i < k)continue;
        if(vec[i-k] == vec[i])vec[i] = 0;
    }
    ll sum = 0;
    rep(i,n)sum += f(vec[i]);
    cout << sum << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    for(int i=0; i<n; i++) {
        int a;
        cin >> a;
        v.push_back({a,i});
    }
    sort(v.begin(),v.end());
    
    for(auto e: v){
        cout << e.second + 1 << " ";
    }

    return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int l, r; cin >> l >> r;
	if (r - l >= 2020) {
		cout << 0 << endl; return 0;
	}
	int ans = INF;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			chmin(ans, (i*j)%2019);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
        int i,n,r=0,w=0,j,l,k=0;
       cin>>n;
   string s;
       cin>>s;
       for(i=0;i<n;i++){
        if(s[i]=='R') r++;
        else w++;
       }
       int ans=min(w,r);
       l=0,r=n-1;
       while(l<r){
        while(l<r&&s[r]=='W') r--;
        while(l<r&&s[l]=='R') l++;
        if(l<r){
            swap(s[l],s[r]);
            k++;
        }
       }
       cout<<min(k,ans);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10 ;
map<string, int> mp;

int main () {
    int n;
    ios ::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int ma = 0;
    for (int i = 1 ; i <= n;  ++ i) {
        string s;
        cin >> s;
        mp[s] ++ ;
        ma = max(ma, mp[s]);
    }
    vector<string> v;
    for (auto it: mp) {
        if (it.second == ma)
            v.emplace_back(it.first);
    }
    cerr << "\n";
    sort(v.begin(), v.end());
    for (auto it : v) {
        cout << it << '\n';
    }
}
/*
    Good Luck
        -Lucina
*/


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

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

const ll INF = 1LL << 60;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int n, y; cin >> n >> y;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; i + j <= n; ++j) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y ){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout <<  "-1 -1 -1" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int n,k,m;
	cin >> n >> k;
	m = n;
	n = k;
	for (int i = 1; i < m; i++) {
		n *= k - 1;
	}
	cout << n;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main(){
  int n,q;cin>>n>>q;
  vector<int>c(n);
  rep(i, n)cin>>c[i];
  vector<int> p(n+1, -1);
  vector<vector<int>> ps(n);
  rep(i, n){
    int l = p[c[i]];
    if(l != -1) ps[l].push_back(i);
    p[c[i]]=i;
  }

  vector<vector<pi>> qs(n);
  rep(i, q){
    int l,r;cin>>l>>r;l--,r--;
    qs[l].emplace_back(r, i);
  }

  vector<int> ans(q);
  BIT<int> d(n);
  rrep(x, n){
    for(auto y:ps[x]) d.add(y, 1);
    for(pi query:qs[x]){
      int r = query.first;
      int i = query.second;
      ans[i] = (r-x+1)-d.sum(r);
    }
  }

  rep(i, q)cout<<ans[i]<<endl;

  return 0;
}

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

int main() {
    int n,m,x,y,res;
    cin>>n>>m>>x>>y;
    vector<int> X(n),Y(m);
    rep(i,n) cin>>X[i];
    rep(i,m) cin>>Y[i];
    sort(Y.begin(),Y.end());
    sort(X.begin(),X.end());
    res=Y[0];
    if (X[n-1]<res&&x<res&&res<=y) {
        cout<<"No War"<<endl;
    } else {
        cout<<"War"<<endl;
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll res = a[0];

  repz(i, 1, n) {
    if (res > (ll)1e+18) {
      cout << -1 << endl;
      return 0;
    }
    if ((ll)1e+18 / res < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    res *= a[i];
  }
  if (res > (ll)1e+18) {
    cout << -1 << endl;
    return 0;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3972
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    map<char, int> mp;
    
    for(char c : s){
        mp[c]++;
    }

    ll N = mp['N'];
    ll W = mp['W'];
    ll S = mp['S'];
    ll E = mp['E'];

    if(N > 0 && W > 0 && S > 0 && E > 0){
        p_yes();
    }
    else if(N>0 && S>0 && W==0 && E==0){
        p_yes();
    }
    else if(N==0 && S==0 && W>0 && E>0){
        p_yes();
    }else{
        p_no();
    }

    return 0;
}

Measured memory_bytes: 256