akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int 
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))




int solve(){

    ll deposit_exc;

    cin >> deposit_exc;

    ll deposit = 100;

    for(int i=1; ; i++){
        deposit += deposit * .01;
        if(deposit >= deposit_exc){
            cout << i << endl;
            break;
        } 
    }
    
    return 0;
}

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

    time__("programm time"){
        solve();
	}
    return 0;

}

Measured memory_bytes: 3792
n = int(input())
l = list(map(int, input().split()))

count = 0

for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j] and l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k]:
                count += 1
                
print(count)

Measured memory_bytes: 9096
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

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

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

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

int main(){
	int m,d;
	int ans=0;
	cin>>m>>d;
	if(d<22)ans=0;
	else{
		rep(i,22,d+1){
			rep(j,4,m+1){
				if(i%10<2||i/2<2)continue;
				if((i%10)*(i/10)==j)ans++;
			}
		}
	}
	print(ans);



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A, B, X, tmp, r, ans;
  cin >> A >> B;
  X = A * B;
  if(A < B){
    tmp = B;
    B = A;
    A = tmp;
  }
  r = A % B;
  while(r > 0){
    A = B;
    B = r;
    r = A % B;
  }
  ans = X / B; 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

  vector<bool> t(n + 1, true);
  int n3 = 0, n5 = 0, n15 = 0, n25 = 0, n75 = 0;
  for (auto i : irange(2, n + 1)) {
    if (t[i]) {
      int m = 1;
      for (auto j : irange(i + 1, n + 1)) {
        int c = 1;
        while (j % (c * i) == 0) c *= i, ++m;

        if (c > 1) t[j] = false;
      }
      if (m + 1 >= 75) ++n75;
      if (m + 1 >= 25) ++n25;
      if (m + 1 >= 15) ++n15;
      if (m + 1 >= 5) ++n5;
      if (m + 1 >= 3) ++n3;
    }
  }
  
  int64_t ans = 0;
  ans += n75;
  ans += n15 * (n5 - 1);
  ans += n25 * (n3 - 1);
  ans += n5 * (n5 - 1) / 2 * (n3 - 2);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string A;
	cin >> A;
	if (A.size() == 3) {
		reverse(A.begin(), A.end());
		cout << A;
	}
	else {
		cout << A;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
map<int,int>visited;
for(int i=1; i<=9; ++i)
for(int j=i; j<=9; ++j)
visited[i*j]=1;
if(visited[n]==0)
cout<<"No";
else
cout<<"Yes";
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
path = {}
for i in range(n-1):
    a, b, c = list(map(int, input().split()))
    if not a in path.keys():
        path[a] = [(b, c)]
    else:
        path[a].append((b, c))
        
    if not b in path.keys():
        path[b] = [(a, c)]
    else:
        path[b].append((a, c))
q, k = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(q)]

dist = [None]*(n+1)
dist[k] = 0
que = deque([(k, 0)])
while len(que) > 0:
    node, d = que.popleft()
    dist[node] = d
    for node_next, d_next in path[node]:
        if dist[node_next] is None:
            que.append((node_next, d+d_next))
# print(dist)

for x, y in xy:
    print(dist[x]+dist[y])


Measured memory_bytes: 78052
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    char c, ans;
    cin >> c;
    switch (c) {
    case 'A':
        ans = 'T';
        break;
    case 'T':
        ans = 'A';
        break;
    case 'G':
        ans = 'C';
        break;
    case 'C':
        ans = 'G';
        break;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a = parseMap(split(chomp(readline()),""))
	n = length(a)
	dp = zeros(Int,n,2)
	dp[1,1] = a[1]
	dp[1,2] = 11-a[1]
	for i in 2:n
		dp[i,1] = min(dp[i-1,1],dp[i-1,2])+a[i]
		dp[i,2] = min(dp[i-1,1]+11-a[i],dp[i-1,2]+9-a[i])
	end
	println(min(dp[n,1],dp[n,2]))
end

main()

Measured memory_bytes: 179116
#include<bits/stdc++.h>
using namespace std;
int main(void)
{	
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

int main() {
    int n, a[200000];
    cin >> n;
    
    priority_queue<pair<int, int> > pq;
    for(int i = 0; i < n; i++) {
        int in;
        cin >> in;
        pair<int, int> p(in, i);
        pq.push(p);
    }
    pair<int, int> first = pq.top();
    pq.pop();
    pair<int, int> second = pq.top();

    for(int i = 0; i < n; i++) {
        if(i == first.second) cout << second.first << endl;
        else cout << first.first << endl;
    }

    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int MMAX=200000;
vector<int> C(MMAX);

// Problem Specific Parameter:

int main() {
  int N, M; cin >> N >> M;
  vector<int> v;
  vector<int> g;
  int a[M], b[M];
  for(int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i];
    if(a[i] == 1) C[b[i]-1]++;
    if(b[i] == N) C[a[i]-1]++;
  }

  sort(C.begin(), C.end(), greater<int>());
  if(C[0] > 1) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int n,k;

signed main()
{
	cin>>n>>k;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	sort(begin(a),end(a));
	int ans=0;
	rep(i,k)ans+=a[n-i-1];
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,a[101],sum=0;
	cin>>n;
	for (int i = 1; i <= n; ++i)
		{
			cin>>a[i];
			sum+=a[i];
		}	
	int m,p,x;
	cin>>m;
	while(m--){
		cin>>p>>x;
		cout<<(sum-a[p])+x<<endl;
	}


   return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main{
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int s = sc.nextInt();
			int g1 = sc.nextInt();
			int g2 = sc.nextInt();
			if((n|m|s|g1|g2) == 0) break;
			s--;g1--;g2--;
			int [][]pass = new int[n][n];
			int INF = 1 << 24;
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
			}
			for(int i = 0; i < m; i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				int cost = sc.nextInt();
				pass[a][b] = cost;
			}
			for(int j = 0; j < n; j++){
				for(int i = 0; i < n; i++){
					for(int k = 0; k < n; k++){
						pass[i][k] = Math.min(pass[i][k], pass[i][j] + pass[j][k]);
					}
				}
			}
			int min = INF;
			for(int i = 0; i < n;i++){
				int value = pass[s][i] + pass[i][g1] + pass[i][g2];
				min = Math.min(min, value);
			}
			System.out.println(min);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 62808
import heapq

N = int(input())
A = list(map(int, input().split()))
B = input().split()
C = []
for i in range(N):
    heapq.heappush(C, (A[i] - int(B[i]), i))
B = list(map(int, B))
ans = 0
while True:
    v, i = heapq.heappop(C)
    if v == 0:
        break

    nv = B[i-1] + B[(i+1) % N]
    n = -v // nv
    if n <= 0:
        print(-1)
        exit()
    v += n * nv
    B[i] -= n * nv
    heapq.heappush(C, (v, i))
    ans += n
print(ans)

Measured memory_bytes: 123548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  long long int n,i;
  scanf("%lld",&n);
  long long int p[n];
  for(i=0;i<n;i++) {
    scanf("%lld",&p[i]);
  }
  long long int counter = 0;
  for(i=0;i<n;i++) {
    if(i+1!=p[i]) {
      counter++;
    }
  }
  //printf("%lld\n",counter);
  if(counter < 3) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n;
ll K;
vi hist;
const int M = 40;

ll calc(int X){
    ll ret = 0LL;
    if(X >= 0 and !((K >> X) & 1)) return ret;

    // [X+1, M]
    rrep(k, M+1, X+1){
        ret += bit(k) * (((K >> k) & 1) ? n-hist[k]:hist[k]);
    }

    // X
    if(X >= 0){
        ret += bit(X) * hist[X];
    }

    // [0, X-1]
    rep(k, X){
        ret += bit(k) * max(hist[k], n-hist[k]);
    }

    return ret;
}

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

    cin >> n >> K;
    vll a(n); for(auto& e : a) cin >> e;

    hist = vi(M+1);
    rep(k, M+1){
        for(auto& e : a){
            hist[k] += ((e >> k) & 1);
        }
    }

    ll res = 0LL;
    rep(X, -1, M+1){
        chmax(res, calc(X));
    }

    cout << res << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, k;
        cin >> a >> k;
        while(a >= k){
            if(a % k == 0){
                ans ^= a / k;
                break;
            }
            int r = a - a / k * k;
            int b = a / k + 1;
            a -= ((r - 1) / b + 1) * b;
        }
    }
    if(ans != 0) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
}

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

const int maxi =100005;
ll cost[105][maxi];
ll w[105],val[105];
int main()
{
	ll n,W;cin>>n>>W;
	ll ans = 0;
	for(int i=1;i<=n;i++)cin>>w[i]>>val[i];
	for(int i =0;i<n;i++)
	{
		for(int j =0;j<=W;j++)
		{
		
		if(j-w[i+1]>=0)
		{
				cost[i+1][j-w[i+1]]=max(cost[i+1][j-w[i+1]], val[i+1]+cost[i][j]);
			
		}
				cost[i+1][j]=max(cost[i+1][j],cost[i][j]);
		}	
	}
	for(int i =0;i<=W;i++)ans=max(ans,cost[n][i]);
	cout<<ans<<endl;
	
}

Measured memory_bytes: 81676
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};



int main(){
    string s;cin >> s;
    for (int i = 0; i < s.length(); i++) {
        cout << "x";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    int ans = 1000;
    for(int i=0;i+2<l;i++){
        int t=0;
        t+=(s[i]-'0')*100;
        t+=(s[i+1]-'0')*10;
        t+=(s[i+2]-'0');
        ans = min(ans, abs(t-753));
    }
    cout << ans << endl;

    return 0;
}

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


int main() {
  int n; cin>>n;
  vector<uint32_t> v(n);
  uint32_t b(0);
  rep(i,n){
    int a; cin>>a;
    v[i]=a;
    b=b^v[i];
  }
  rep(i,n){
    uint32_t ans=b^v[i];
    cout<<ans<<" ";}
}
      




Measured memory_bytes: 3988
N=int(input())
A=[]
for i in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    A.append("1")
  else:
    A.append("0")
    
one="".join(A)
if "111" in one:
  print("Yes")
else:
  print("No")

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int tax(int p, int rate)
{
    return (int) p*(100+rate)/100;
}

int solve(int x, int y, int s) {
    int maximum = 0;

    for (int i = 1; i < s; ++i) {
        for (int j = i; j < s; ++j) {
            if ((tax(i, x) + tax(j, x)) == s)
                maximum = max(maximum, tax(i, y)+tax(j, y));
        }
    }
    return maximum;
}

int main()
{   
    int maximum;
    int x, y, s;

    while (cin >> x >> y >> s && x > 0) 
        cout << solve(x, y, s) << endl;
    
}


Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String in[] = new String[2];
		int n = 0, d = 0;
		try {
			line = br.readLine();
			in = line.split(" ");
			n = Integer.parseInt(in[0]);
			d = Integer.parseInt(in[1]);
		} catch (IOException e) {
			e.getStackTrace();
		}
		
		String in_d [] = new String[d];
		int in_dnum [][] = new int [d][n];
		try {
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				in_d = line.split(" ");
				for (int j = 0; j < d; j++) {
					in_dnum[j][i] = Integer.parseInt(in_d[j]);
				}
			}
		} catch (IOException e) {
			e.getStackTrace();
		}
		
		int c = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				double dis;
				dis = dis(i, j, in_dnum);
				if(Math.ceil(dis) == dis) {
					c++;
				}
			}
		}
		System.out.println(c);
	}
	
	static double dis(int s1, int s2, int[][] in) {
		int dis = 0;
		for (int i = 0; i < in.length; i++) {
			dis += Math.pow(Math.abs(in[i][s1] - in[i][s2]),2);
		}
		return Math.sqrt(dis);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  char s[h+2][w+2];
  for(int j = 0; j < w+2; j++){
    s[0][j] = '.';
    s[h+1][j] = '.';
  }
  for(int i = 1; i < h+1; i++){
    s[i][0] = '.';
    for(int j = 1; j < w+1; j++) cin >> s[i][j];
    s[i][w+1] = '.';
  }
  bool chk = true;
  for(int i = 1; i < h+1; i++){
    for(int j = 1; j < w+1; j++){
      if(s[i][j]=='#' && s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.'){
        chk = false;
        break;
      }
    }
  }
  if(chk) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(long long N){
    double ans = ((N+1)/2);
    ans/=N;
    cout<<ans<<endl;

}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long double N;
    cin>>N;
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n,m;
int f[100005];

signed main(){
    FASTER;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        f[a]++;
        f[b+1]--;
    }
    int ans=0;
    for(int i=1;i<=100000;i++)f[i]+=f[i-1];
    for(int i=1;i<=100000;i++)ans+=(f[i]==m);
    cout<<ans;
}

Measured memory_bytes: 4428
#include <stdio.h>

int n,A[100][100],cnt[100],d[100],f[100],t=0;

void dfs(int);

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    cnt[i]=0;
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    if(cnt[i]==0){
      dfs(i);
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

  return 0;
}

void dfs(int u){
  int v;
  
  cnt[u]=1;
  d[u]=++t;
  for(v=0;v<n;v++){
    if(A[u][v]==0){
      continue;
    }
    if(cnt[v]==0){
      dfs(v);
    }
  }
  cnt[u]=2;
  f[u]=++t;
  
}



Measured memory_bytes: 2148
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<ty-sy;i++)cout<<"U";
    for(int i=0;i<tx-sx;i++)cout<<"R";
    for(int i=0;i<ty-sy;i++)cout<<"D";
    for(int i=0;i<tx-sx;i++)cout<<"L";
    cout<<"L";
    for(int i=0;i<=ty-sy;i++)cout<<"U";
    for(int i=0;i<=tx-sx;i++)cout<<"R";
    cout<<"D";
    cout<<"R";
    for(int i=0;i<=ty-sy;i++)cout<<"D";
    for(int i=0;i<=tx-sx;i++)cout<<"L";
    cout<<"U"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
    int x = 0, f = 1, c = getchar();
    for (; !isdigit(c); c = getchar())
        if (c == '-')
            f = -1;
    for (;  isdigit(c); c = getchar())
        x = x * 10 + c - '0';
    return x * f;
}

const int MAXN = 305;
const int mod = 1e9 + 7;

int n, a[MAXN], fac[MAXN], inv[MAXN], f[MAXN][MAXN][2];

int main()
{
#ifdef wxh010910
    freopen("data.in", "r", stdin);
#endif
    n = Read(), fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i ++)
        fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
    bool sam = true;
    for (int i = 1; i <= n; i ++)
        inv[i] = 1LL * inv[i - 1] * inv[i] % mod, a[i] = Read(), sam &= a[i] == 2;
    if (sam)
        return printf("%d\n", 1LL * fac[n - 1] * inv[2] % mod), 0;
    f[0][0][0] = 1;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j <= i; j ++)
            for (int k = 0; k < 2; k ++)
                if (f[i][j][k])
                {
                    f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % mod;
                    if (a[i + 1] >= 2)
                        f[i + 1][j + 1][k] = (1LL * f[i][j][k] * (a[i + 1] - 1) + f[i + 1][j + 1][k]) % mod;
                    if (a[i + 1] >= 3 && !k)
                        f[i + 1][j + 1][1] = (1LL * f[i][j][k] * (a[i + 1] - 1) * (a[i + 1] - 2) + f[i + 1][j + 1][1]) % mod;
                }
    int ans = 0, cur = 1;
    for (int i = 1; i <= n; i ++)
        cur = 1LL * cur * inv[a[i] - 1] % mod;
    for (int i = 3; i < n; i ++)
        if (f[n][i][1])
            ans = (1LL * fac[i - 1] % mod * f[n][i][1] % mod * fac[n - i - 1] % mod * inv[2] + ans) % mod;
    return printf("%d\n", 1LL * ans * cur % mod), 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int q;
	cin >> q;
	for (int z = 0; z < q; z++) {
		int a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		int ans;
		if (a == b || a + 1 == b) {
			ans = 2 * a - 2;
		}
		if (a != b) {
			int k = floor(sqrt(a*b));
			if (k == sqrt(a*b)) {
				k--;
			}
			if (k*(k+1) >= a*b) {
				ans = 2 * k - 2;
			}
			else {
				ans = 2 * k - 1;
			}
		}
		cout << ans << endl;
	}
	getchar(); getchar();
}

Measured memory_bytes: 256
ll=[]
J=0
a,b=map(int,input().split())
for i in range(a):
    l=input().rstrip().split()
    l=list(map(int,l))
    ll+=l
    #print(ll)
for j in range(b):
    n=int(input())
    for i in range(a):
        ll[j]=ll[j]*n
        j=j+b
#print(ll)
for i in range(0,a*b,b):
    print(sum(ll[i:i+b]))


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, k;
    cin>>n>>k;
    n = n%k;
    cout << min(n, k-n) << "\n";
    return 0;
}



Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 10:51:00
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

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

  string str;

  getline(cin, str);

  str += '\n';

  REP(i, str.size())
  {
      if (isupper(str[i]))
      {
          printf("%c", tolower(str[i]));
      }
      else
      {
          printf("%c", toupper(str[i]));
      }
  }
  
  return 0;
}


Measured memory_bytes: 3220
R,C=map(int,input().split())
sx,sy=1,1
gx,gy=R,C
count=0
mp = [[i for i in input().rstrip()] for i in range(R)]
for i in range(R):
  mp[i]=list(mp[i])
for i in range(R):
	for j in range(C):
		if(mp[i][j]=='#'):
			count+=1
ans=[[3000 for i in range(C)] for j in range(R)]
ans[sx-1][sy-1]=0
start=[sx-1,sy-1]
goal=[gx-1,gy-1]
nsx=[1,0,-1,0]
nsy=[0,1,0,-1]

def bfs(graph,st,end):
  queue=[st]
  while queue:
    nw=queue.pop(0)
    if nw==end:
      return ans[end[0]][end[1]]
    else:
      for i in range(4):
        ns1=nw[0]+nsx[i]
        ns2=nw[1]+nsy[i]
        if (0 <= ns1)and(ns1<=(R-1))and(0<=ns2)and(ns2<=(C-1)) and ans[ns1][ns2]==3000 and mp[ns1][ns2]=='.':
          ans[ns1][ns2]=ans[nw[0]][nw[1]]+1
          queue.append([ns1,ns2])
  return

while True:
	try:
		print(R*C-bfs(mp,start,goal)-1-count)
		break
	except (RuntimeError,TypeError,NameError):
		print(-1)
		break


Measured memory_bytes: 3192
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int h, w, d;
int a[300][300];
int q;
int l, r;
int px[90001];
int py[90001];
int dis[90001];
int tmp;

int main(){
  cin >> h >> w >> d;
  REP(i, h){
    REP(j, w){
      cin >> tmp;
      px[tmp] = j;
      py[tmp] = i;
    }
  }
  cin >> q;

  for(int i=d+1;i<=(h*w);++i){
    dis[i] = dis[i-d] + abs(px[i] - px[i-d]) + abs(py[i] - py[i-d]);
  }

  REP(k, q){
    cin >> l >> r;
    cout << dis[r] - dis[l] << endl;
  }


	return 0;
}

Measured memory_bytes: 2176
from collections import Counter as C
n=int(input())
a=list(map(int,input().split()))
a.sort()
aset=list(set(a))
ca = C(a)
ans=0
for i in aset:
    if ans<ca[i-1]+ca[i]+ca[i+1]:
        ans=ca[i-1]+ca[i]+ca[i+1]
print(ans)

Measured memory_bytes: 14944
from calendar import isleap
s = []
while True:
    a, b = map(int, input().split())
    if not a:
        break
    s.append([])
    for i in range(a, b + 1):
        if isleap(i):
            s[-1].append(str(i))

print('\n\n'.join(['\n'.join(ss) if ss else 'NA' for ss in s]))

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define fastio    ios::sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  fastio;
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  int sum = 0;
  string t2;
  rep(i, n) {
    if (t[i] == 's') {
      if (i >= k && t2[i - k] == 'r') t2.pb('x');
      else sum += r, t2.pb('r');
    }
    else if (t[i] == 'r') {
      if (i >= k && t2[i - k] == 'p') t2.pb('x');
      else sum += p, t2.pb('p');
    }
    else if (t[i] == 'p') {
      if (i >= k && t2[i - k] == 's') t2.pb('x');
      else sum += s, t2.pb('s');
    }
  }
  cout << sum;

  return 0;
}


Measured memory_bytes: 3780
x = int(input())
l = [1]

for i in range(2,32):
  for j in range(2,10):
    if i**j <= 1000:
      l.append(i**j)
      
l = sorted(l,reverse = True)

for k in sorted(list(range(1,x+1)),reverse = True):
  if k in l:
    print(k)
    exit()

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
MOD = 10**9+7

# nCk % mod
def modCom(n, k, mod):
    p, q = 1, 1
    for i in range(n-k+1, n+1):
        p = (p * i) % mod
    for i in range(2, k+1):
        q = (q * i) % mod
    return p * pow(q, mod-2, mod) % mod

X, Y = map(int, input().split())
l, r = -1, X//2
while l+1 < r:
    m = (l+r)//2
    n = X-2*m
    if 2*n+m > Y:
        l = m
    else:
        r = m
m = r
n = X-2*r
if 2*m+n == X and m+2*n == Y:
    print(modCom(n+m, n, MOD))
else:
    print(0)

Measured memory_bytes: 39280
def prime_factorize(n):
    pf = []
    while n % 2 == 0:
        pf.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            pf.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        pf.append(n)
    return pf

A, B = map(int, input().split())

prime_A = set(prime_factorize(A))
prime_B = set(prime_factorize(B))
ans = len(prime_A & prime_B) + 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define long int64_t

int main()
{
   double n, k;
   cin >> n;
   cin>> k;
   double ans;

   for(int i=1; i<=n; i++)
   {
      double x = max(0.0,ceil(log2(k/i)));
      double y = pow(0.5,x);
      ans += y/n;
   	//ans += pow( (double(0.5)), ceil( log2(k/i)  ) )/n ;
      //cout<<ans<<endl;
   }

   
   
   std::cout.precision(10);
   cout<< std::fixed;
   cout<<ans;
   cout << endl;
   return 0;
}
 

Measured memory_bytes: 384
#include <map>
#include <cstdio>
using namespace std;
void solve(int T){
	map<pair<int,int>,int> m;
	char cmd[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(auto it=m.begin();it!=m.end();)if(it->second==n)m.erase(it++);else	++it;
		}else if(*cmd=='R'){
			auto it=m.lower_bound(make_pair(n,2000000000));
			if(it==m.begin()){
				puts("-1");
			}else{
				printf("%d\n",(--it)->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int cur=0;
			scanf("%d",&k);
			for(auto it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>k)d=k;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				k-=d;
				if(k==0)break;
				cur=it->first.second+1;
			}
			if(k)m[make_pair(cur,cur+k-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll X, Y;
    cin >> X >> Y;
    vector<ll> out;
    ll tmp = X;
    while (true) {
      out.push_back(tmp);
      tmp *= 2;
      if (tmp > Y) break;
    }
    cout << out.size() << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize ("-Ofast")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) (long long)a.size()
#define all(a) a.begin(), a.end()
#define reset(a, n) a.clear(), a.resize(n)
#ifndef ONLINE_JUDGE
#define cin ___in
#endif
std::ifstream ___in("input.in");
using namespace std;
using ll = long long;
typedef pair<ll, ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > vvec;
typedef vector<pair<ll, ll> > vecpi;
typedef vector<vector<pair<ll, ll> > > vvecpi;
typedef set<ll> seti;
typedef set<pair<ll, ll> > setpi;
typedef multiset<ll> mseti;
typedef multiset<pair<ll, ll> > msetpi;
typedef map<ll, ll> mpi;

static const bool tc = 0;
static const ll mod = LLONG_MAX - 24;

void solve() {
        int n;
        ll r = 0, w = 0;
        string s;
        cin >> n >> s;
        for(int i = 0; i < n; ++i) {
                if(s[i] == 'W') ++w;
                else ++r;
        }
        ll R = 0, W = 0;
        for(int i = 0; i < r; ++i)
                if(s[i] == 'R') ++R;
        for(int i = n - 1, j = w; i >= 0 && j; --i, --j)
                if(s[i] == 'W') ++W;

        cout << min(r - R, w - W);
}

int main() {
        srand(time(0));
        int T = 1;
        if(tc) cin >> T;
        for(int i = 1; i <= T; ++i) {
                #ifndef ONLINE_JUDGE
                cout << "----- " << i << " -----\n";
                #endif
                solve();
        }
        return 0;
}


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

#define rep(i,st,en) for(int i=st;i<=en;i++)
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

typedef long long LL;
const LL MOD=1000000007;
LL p[10];

int main(){
    FAST_IO;
    int n;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(s[0]=='M') p[1]++;
        else if(s[0]=='A') p[2]++;
        else if(s[0]=='R') p[3]++;
        else if(s[0]=='C') p[4]++;
        else if(s[0]=='H') p[5]++;
    }
    sort(p+1,p+1+5);
    int idx=-1;
    for(int i=1;i<=5;i++){
        if(p[i]!=0) {idx=i;break;}
    }
    if(idx==-1||idx>3){
        cout<<0<<endl;
        return 0;
    }
    else if(idx==3){
        cout<<p[3]*p[4]*p[5]<<endl;
    }
    else if(idx==2){
        cout<<p[2]*p[3]*p[4]+p[2]*p[3]*p[5]+p[2]*p[4]*p[5]+p[5]*p[3]*p[4]<<endl;
        return 0;
    }
    else if(idx==1){
        LL ans=0;
        for(int i=3;i<=5;i++) ans+=p[1]*p[2]*p[i];
        ans+=p[1]*p[3]*p[4]+p[1]*p[3]*p[5]+p[1]*p[4]*p[5];
        ans+=p[2]*p[3]*p[4]+p[2]*p[3]*p[5]+p[2]*p[4]*p[5];
        ans+=p[3]*p[4]*p[5];
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}


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

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

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

int is_exist(int i, int j, vector<Pii> &ab){
    int n = Lower_bound(ab, Pii(i, j));
    if(n != ab.size() && ab[n] == Pii(i, j)) return 1;
    else return 0;
}

int count(int i, int j, int H, int W, vector<Pii> &ab){
    if(i < 0 || j < 0 || i >= H - 2 || j >= W - 2) return -1;
    int n = 0;
    REP(x, 3) REP(y, 3) n += is_exist(i + x, j + y, ab);
    return n;
}

signed main(){

    int H, W, N; cin >> H >> W >> N;
    int a, b; vector<Pii> ab(N);
    REP(i, N){
        cin >> a >> b;
        ab[i] = Pii(a - 1, b - 1);
    }
    SORT(ab);

    vec ans(10, 0);
    set<Pii> s;
    REP(i, N){
        int i0 = ab[i].first, j0 = ab[i].second;
        FOR(x, -2, 1) FOR(y, -2, 1){
            if(s.count(Pii(i0 + x, j0 + y)) > 0) continue;
            int n = count(i0 + x, j0 + y, H, W, ab);
            if(n > 0){
                ans[n]++;
                s.insert(Pii(i0 + x, j0 + y));
            }
        }
    }
    ans[0] = (H - 2) * (W - 2);
    FOR(i, 1, 10) ans[0] -= ans[i];
    REP(i, 10) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 58112
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
using ll=long long;
unordered_map<ll,ll> D;
ll N,M;
int main(){
    cin>>N;
    for(int i{};i<N;++i){
        ll d;cin>>d;
        ++D[d];
    }
    cin>>M;
    for(int i{};i<M;++i){
        ll T;cin>>T;
        if(!D[T]){
            cout<<"NO"<<endl;
            return 0;
        }
        --D[T];
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 8520
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;
typedef pair<int, string> P;


void solve()
{
	int N, Q;
	cin >> N >> Q;
	deque<bool> deq(300001);
	int maxv = -1;
	for (int i = 0; i < N; ++i)
	{
		int c;
		cin >> c;
		deq[c] = true;
		maxv = max(maxv, c);
	}
	for (int i = 0; i < Q; ++i)
	{
		int q;
		cin >> q;
		for (int j = 0; j < q; ++j)
		{
			for (int k = q - j - 1; k <= maxv; k += q)
			{
				if (deq[k])
				{
					cout << q - j - 1 << endl;
					goto END;
				}
			}
		}
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int h, w, n; cin >> h >> w >> n;
    set<pair<int, int>> cand, black;
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b; a--, b--;
        black.insert(make_pair(a, b));
        for (int dy = -1; dy <= 1; dy++) {
            if (a + dy <= 0 || a + dy >= h - 1) continue;
            for (int dx = -1; dx <= 1; dx++) {
                if (b + dx <= 0 || b + dx >= w - 1) continue;
                cand.insert(make_pair(a + dy, b + dx));
            }
        }
    }

    vector<ll> ans(10);
    ans[0] = 1LL * (h - 2) * (w - 2) - (ll)cand.size();
    for (auto &p: cand) {
        int y = p.first, x = p.second;
        int cnt = 0;
        for (int dy = -1; dy <= 1; dy++) {
            for (int dx = -1; dx <= 1; dx++) {
                if (black.count(make_pair(y + dy, x + dx))) cnt++;
            }
        }
        ans[cnt]++;
    }
    for (auto &e: ans) cout << e << endl;    
    return 0;
}


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

int main() {
	int N;	//酸化数
	int R;
	int I;	//内部

	cin >> N;
	cin >> R;

	if (N >= 10) {
		I = R;
	}
	else {
		I = R + 100 * (10 - N);
	}

	cout << I;
}

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



int main(){
	long long int N,C;cin>>N>>C;
	vector<long long> locs(N),vals(N),best(N),best2(N),bloc(N),bloc2(N);
	for(int i=0;i<N;i++) cin>>locs[i]>>vals[i];
	for(int i=0;i<N;i++) bloc[i] = bloc2[i] = locs[i];
	best[0] = best2[0] = vals[0];
	for(int i=1;i<N;i++) best[i] = vals[i] + best[i-1];
	for(int i=1;i<N;i++) best2[i] = vals[i] + best2[i-1];
	for(int i=0;i<N;i++) best[i] = best[i] - locs[i];
	for(int i=0;i<N;i++) best2[i] = best2[i] - 2*locs[i];
	for(int i=1;i<N;i++) if(best[i-1] > best[i]){
		best[i] = best[i-1];
		bloc[i] = bloc[i-1];
	}
	for(int i=1;i<N;i++) if(best2[i-1] > best2[i]){
		best2[i] = best2[i-1];
		bloc2[i] = bloc2[i-1];
	}
	long long int ans = max(0LL,best[N-1]),totc = 0;
	for(int i=N-1;i>=0;i--){
		totc += vals[i];
		long long curr = totc - (C - locs[i]);
		//cout<<totc<<" "<<locs[i]<<endl;
		ans = max(ans,curr);
		if(i-1>=0){
			ans = max(ans, curr + best2[i-1]);
			ans = max(ans, curr + best[i-1] - (C-locs[i]));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int cost[10]={0,2,5,5,4,5,6,3,7,6};
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];
  sort(a.begin(),a.end());

  vector<string> dp(n+100,"");
  auto cmp=[](string a,string b){
             if(a.size()!=b.size()) return a.size()<b.size();
             for(Int i=0;i<(Int)a.size();i++)
               if(a[i]!=b[i]) return a[i]<b[i];
             return false;
           };
  
  for(Int i=0;i<n;i++){
    if(i&&dp[i]==""s) continue;
    for(Int x:a){
      if(cmp(dp[i+cost[x]],dp[i]+char('0'+x))) dp[i+cost[x]]=dp[i]+char('0'+x);
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}


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

int main()
{
    int count = 0;
    int max = 0;
    int N;
    cin >> N;
    
    vector<long int> H(N);
    vector<bool> C(N);
    
    for (int i=0; i<N; i++){
        long int h;
        cin >> h;
        H[i] = h;
    }
    
    for(int i=0; i<N; i++){
        if(i == 0){
            C[i] = false;
        }
        else{
            if(H[i-1] >= H[i]){
                C[i] = true;
            }
        }
    }
    
    for(int i=0; i<N; i++){
        if(C[i] == false){
            count = 0;
        }
        else{
            count++;
            if (count >= max){
                max = count;
            }
        }
        
    }
    cout << max << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define int long long

int N;

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int Y, M, D;
		cin >> Y >> M >> D;
		int ans = 0;
		for (int y = 1; y <= Y; y++)
		{
			if (y != Y)
			{
				if (y % 3) ans += (19 + 20) * 5;
				else ans += 20 * 10;
				continue;
			}
			for (int m = 1; m <= M; m++)
			{
				if (m == M)
				{
					ans += D - 1;
					break;
				}
				if (y % 3) ans += (m & 1) ? 20 : 19;
				else ans += 20;
			}
		}
		printf("%d\n", (999 / 3 * 20 * 10 + (999 - 999 / 3) * (20 + 19) * 5) - ans);
	}
	return 0;
}

Measured memory_bytes: 1144