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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef pair<int, int> ii;

int A[25];
int B[25];

int perm[25];

int set1[25];
int set2[25];

const int INF = 1012345678;

long long nxs(long long r){
    long long ls1 = r&(-r);
    long long rest = r+ls1;
    return rest|(((rest^r)/ls1) >> 2);
}

int main(){
    int N;
    scanf("%d", &N);

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

    for(int i = 0; i < N; i ++){
        scanf("%d", &B[i]);
    }

    int ans = INF;
    int noBits = (N+1)>>1;
    for(int i = (1<<noBits)-1; i < (1<<N); i = nxs(i)){
        //printf("i=%d\n", i);
        int size1 = 0;
        int size2 = 0;
        for(int j = 0; j < N; j ++){
            if(i&(1<<j)){
                // Place in first set, parity is even (0-indexed)
                if((j&1) == 0){
                    set1[size1++] = (A[j]<<6)|j;
                }else{
                    set1[size1++] = (B[j]<<6)|j;
                }
            }else{
                // Place in second set, parity is odd
                if((j&1) == 0){
                    set2[size2++] = (B[j]<<6)|j;
                }else{
                    set2[size2++] = (A[j]<<6)|j;
                }
            }
        }

        sort(set1, set1+size1);
        sort(set2, set2+size2);

        bool boleh = true;
        for(int j = 0; j < (int)size2; j ++){
            //printf("set1[%d]=ii(%d, %d), set2[%d]=ii(%d, %d)\n", j, set1[j].first, set1[j].second, j, set2[j].first, set2[j].second);
            if((set1[j]>>6) > (set2[j]>>6)){
                boleh = false;
                break;
            }

            if( ((N&1) == 0) && j == (int)size2-1 ){
                break;
            }

            if( (set1[j+1]>>6) < (set2[j]>>6) ){
                boleh = false;
                break;
            }
        }

        if(boleh){
            for(int j = 0; j < size2; j ++){
                perm[j<<1] = set1[j]&63;
                perm[(j<<1)|1] = set2[j]&63;
            }
            if(N&1){
                perm[N-1] = set1[size2]&63;
            }

            int inv = 0;
            for(int j = 0; j < N; j ++){
                for(int k = j+1; k < N; k ++){
                    if(perm[j] > perm[k]){
                        inv ++;
                    }
                }
            }

            ans = min(ans, inv);
        }
    }

    if(ans == INF){ans = -1;}
    printf("%d", ans);
    return 0;
}


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

#define DIV 1000000007
using namespace std;

int main() {
    string S;
    cin >> S;

    bool flag ;
    vector<string> moji(4);
    moji[0] = "dream", moji[1] = "dreamer", moji[2] = "erase", moji[3] = "eraser";
    for (int i = S.size() - 1; i >= 0; i--) {
        flag = false;
        for (int j = 0; j < 4; j++) {
            int si = moji[j].size();
            //cout << i - si + 1 << endl;
            if (i - si + 1 < 0)continue;
            if (moji[j] == S.substr(i-si+1,si)) {
                flag = true;
                i = i - si + 1;
            }
            if (flag)
                break;
        }
        if (i == 0)break;
        if (!flag)
            break;
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
   
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A;
    double B;
    cin >> A >> B;

    ll C = ll((B+0.0001)*100);

    cout << ll((A*C)/100) << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> C(N + 1);
  
  for (int i = 1; i <= N; ++i) {
    int val = i;
    int count = 0;
    while (val % 2 == 0) {
      val /= 2;
      ++count;
    }
    C.at(i) = count;
  }
  
  int maxvalue = 0;
  int index = -1;
  for (int i = 1; i <= N; ++i) {
    maxvalue = max(C.at(i), maxvalue);
	if (C.at(i) >= maxvalue) {
      index = i;
    }
  }
  
  cout << index << endl;
  
}

Measured memory_bytes: 3580
// 2017-02-21
#include <iostream>
#include <string>
#include <list>
using namespace std;

int main() {
	int n;
	cin >> n;
	for (; n > 0; n--) {
		string s, t;
		list<char> l;
		cin >> s >> t;
		for (int i = 0; i < t.length(); i++) {
			l.push_back(t[i]);
		}
		for (int i = s.length() - 1; i >= 0; i--) {
			if (s[i] == 'J') {
				char c = l.back();
				l.pop_back();
				l.push_front(c);
			} else if (s[i] == 'C') {
				char c = l.front();
				l.pop_front();
				l.push_back(c);
			} else if (s[i] == 'E') {
				list<char> m;
				int a = l.size();
				while (l.size() > a / 2) {
					char c = l.front();
					l.pop_front();
					m.push_back(c);
				}
				if (a % 2 != 0) {
					char c = m.back();
					m.pop_back();
					l.push_back(c);
				}
				while (!m.empty()) {
					char c = m.front();
					m.pop_front();
					l.push_back(c);
				}
			} else if (s[i] == 'A') {
				l.reverse();
			} else if (s[i] == 'P') {
				for (auto it = begin(l); it != end(l); it++) {
					if (*it >= '0' && *it <= '9') {
						*it = (*it - '0' + 9) % 10 + '0';
					}
				}
			} else if (s[i] == 'M') {
				for (auto it = begin(l); it != end(l); it++) {
					if (*it >= '0' && *it <= '9') {
						*it = (*it - '0' + 1) % 10 + '0';
					}
				}
			}
		}
		for (auto it = begin(l); it != end(l); it++) {
			cout << *it;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long X;
	cin>>X;
	if(X==2){
	  cout<<2<<endl;
		return 0;
	}
	while(true){
		long long i=2;
		bool sp=true;
		while (i*i<=X){
			if(X%i==0){
				X++;
				sp=false;
			  break;
			}
			i++;
		}
		if(sp){
			cout<<X<<endl;
		  return 0;
		}
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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;
}

int main() {
    int N;
    cin >> N;
    ll tmp1 = 2;
    ll tmp2 = 1;
    ll ans = 0;
    if(N == 1){
        cout << 1;
    }
    else {
        for (int i = 1; i < N; i++){
            ans = tmp1 + tmp2;
            tmp1 = tmp2;
            tmp2 = ans;
        }
        cout << ans << endl;
    }
}

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

int main()
{
	long long a, b;
	cin >> a >> b;
	long long sum = 0;
	while(a <= b){
		sum += 1;
		a *= 2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	//n,dを入力
	int n, d;
	scanf("%d", &n);
	scanf("%d", &d);
	//監視員カウント
	int cnt = 1;
	int x = d * 2 + 1;
	while(x < n){
		x = x + d * 2 + 1;
		cnt++;
	}
	//表示
	printf("%d\n", cnt);

	return 0;
}

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

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {   //structとclassの違いは，メンバが初期状態でpublicとなっているかprivateとなっているか
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
LL mVertex(LL a, LL b){
    return a * ((LL)1e8) + b;
}
bool isInSpace(LL a, LL b,LL& h, LL& w){
    return 0<a && a<h-1 && 0<b && b<w-1;
}

LL h, w, n;
int a, b;
unordered_map<LL, int> blackCount;
int counter[10]={};
int main() {
    ios::sync_with_stdio(false);
    scanf("%d%d%d", &h, &w, &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a, &b);a--;b--;
        for (int j = 0; j < 9; ++j) {
            if(isInSpace(a+dx[j],b+dy[j],h,w))
                blackCount[mVertex(a+dx[j],b+dy[j])]++; //もしmapに対応する値がなければ，新しい要素が作成されそのValueは0
        }
    }
    for(auto it= blackCount.begin();it!=blackCount.end();it++){
        counter[it->second]++;
    }
    int sum=0;
    for (int i = 1; i < 10; ++i) {
        sum+=counter[i];
    }
    cout<<(h-2)*(w-2)-sum<<endl;
    for (int i = 1; i < 10; ++i) {
        cout<<counter[i]<<endl;
    }


}

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

public class Main {

	public static void main(String[] args) {
		try(BufferedReader bf = new BufferedReader(new InputStreamReader(System.in))){
			 int A,B,C,D;
			 String[] s = bf.readLine().split(" ");
			 A = Integer.parseInt(s[0]);
			 B = Integer.parseInt(s[1]);
			 C = Integer.parseInt(s[2]);
			 D = Integer.parseInt(s[3]);
			 if(B<=C||D<=A) {
				 System.out.println(0);
			 }else if(A < C && C < B && B <= D) {
				 System.out.println(B - C);
			 }else if(A < C &&  B > D) {
				 System.out.println(D - C);
			 }else if(A >= C && B <= D) {
				 System.out.println(B - A);
			 }else if(C < A && A < D && D <= B) {
				 System.out.println(D - A);
			 }
		}catch(IOException ioe) {
			ioe.getMessage();
		}
	}
}

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

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

    int da, db;
    da = abs(x - a);
    db = abs(x - b);

    if (da < db) {
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }

    return 0;
}


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

int main(){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int N,M,p[1<<17],y[1<<17],i;
vector<int> v[1<<17];
int main(){
  scanf("%d%d",&N,&M);
  for(i=0;i<M;i++)scanf("%d%d",p+i,y+i),v[--p[i]].push_back(y[i]);
  for(i=0;i<N;i++)sort(v[i].begin(),v[i].end());
  for(i=0;i<M;i++)printf("%06d%06d\n",p[i]+1,lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1);
  return 0;
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld a,b;
    cin>>a>>b;
    if(a>8 or b>8) cout<<":(";
    else cout<<"Yay!";
    return 0;
}

Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    ll l,r;cin>>l>>r;
    if(r-l>2020){
        cout<<0<<nnn;
        return 0;
    }
    ll ans=inf;
    rep(i,l,r+1){
        rep(j,i+1,r+1)ans=min((i*j)%2019,ans);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
s = input()
f = 0
s_k = s[0::2]
s_g = s[1::2]

for i in range(len(s_k)):
    if s_k[i] in ['R','U','D']:
        pass
    else:
        f = 1
        break
    
for j in range(len(s_g)):
    if s_g[j] in ['L','U','D']:
        pass
    else:
        f = 2
        break
        
if f == 1 and f == 2 or f == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>

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

using namespace std;

int main()
{
    int N;
    int A[230];

    cin >> N;
    REP(i, N)   cin >> A[i];

    int cnt = 0;

    while (true){
        bool Odd = false;
        REP(i, N){
            if (A[i]%2 == 0)    A[i] /= 2;
            else    Odd = true;
        }
        if (Odd)    break; 
        ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    int max_l = INT_MIN;
    int min_r = INT_MAX;
    for (int i = 0; i < M; i++)
    {
        int l, r;
        cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }
    if (min_r - max_l < 0)
        cout << 0 << endl;
    else
        cout << min_r - max_l + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>

int main() {
    int n;
    long long ret = 0, mod = 1000000007;
    std::deque<bool> q;
    std::string s1, s2;
    std::cin >> n >> s1 >> s2;

    for (auto i = 0; i < n; i++) {
        if (s1[i] == s2[i]) q.push_back(true); // 縦
        else q.push_back(false), i++; // 横
    }

    bool keep = q.front();
    if (keep) ret += 3;
    else ret += 6;
    q.pop_front();
    for (auto b : q) {
        if (keep) {
            ret = (ret * 2) % mod;
        } else {
            if (!b) ret = (ret * 3) % mod;
        }
        keep = b;
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
    double R;
    cin >> R;

    printf("%.10lf\n", 2*R * M_PI);
}


Measured memory_bytes: 3776
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
long long a[10001], b[10001], sum = 0, A, B;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum -= a[i];
	}
	rep(i, n) {
		cin >> b[i];
		sum += b[i];
	}
	if (sum < 0) {
		puts("No");
		return 0;
	}
	A = sum, B = sum;
	rep(i, n) {
		if (a[i] < b[i]) {
			if ((b[i] - a[i]) % 2)A -= (b[i] - a[i]) / 2 + 1, B--;
			else A -= (b[i] - a[i]) / 2;
		}
		else B -= a[i] - b[i];
	}
	if (A >= 0 && B >= 0)puts("Yes");
	else puts("No");
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 384
import Control.Monad
import Data.Char
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 2 <= n <= 10^5, 1 <= k <= 100
  h <- V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- 1 <= hi <= 10^4
  let dp = V.create $ do
        dp <- VM.new n
        VM.write dp 0 0
        forM_ [1..n-1] $ \i -> do
          c <- fmap minimum $ forM [max 0 (i-k)..i-1] $ \j -> do
            c <- VM.read dp j
            return $! c + abs (h V.! i - h V.! j)
          VM.write dp i c
        return dp
  print (V.last dp :: Int)


Measured memory_bytes: 3708
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	ul n;
	cin >> n;
	vector<ul>a = vector<ul>(n, (ul)0);
	for (ul i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<ul>b = vector<ul>(n, (ul)0);

	if (n % 2 == 0) {
		for (ul i = 0; i < n; i++) {
			if (n - 2 * i - 1 >= 1) {
				b[i] = a[n - 2 * i - 1];
			}
			else {
				b[i] = a[ 2 * i -n];
			}
		}
	}
	else {
		for (ul i = 0; i < n; i++) {
			if (n - 2 * i - 1 >= 0) {
				b[i] = a[n - 2 * i - 1];
			}
			else {
				b[i] = a[2 * i - n];
			}
		}
	}

	cout << b[0];
	for (ul i = 1; i < n; i++) cout << " "<<b[i];

	return 0;
}





Measured memory_bytes: 5248
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int mi = 1e6;
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int x;
        cin >> x;
        if(mi >= x)ans++;
        mi = min(x, mi);
    }
    cout << ans << endl;
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;

const D EPS = 1e-8;
const D PI = acos(-1);
//for vector
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

inline D seg_seg_dis(L a,L b){
  D res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}

D g[111][111];
L l[5], stars[111][5];
P v[5];

int main(){
  int n,m,l;
  while(scanf("%d%d%d",&n,&m,&l), n){
    for(int i=0;i<n;i++){
      int x,y,a,r;
      scanf("%d%d%d%d",&x,&y,&a,&r);
      P c = P(x,y);

      P p = P(0,r);
      for(int j=0;j<5;j++){
	v[j] = c+rotate(p,PI*(a+j*72)/180);
      }
      
      for(int j=0;j<5;j++){
	stars[i][j] = L(v[j],v[(j+2)%5]);
      }
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	D dis = 1e9;
	for(L a : stars[i]){
	  for(L b : stars[j]){
	    if(is_cp(a,b)){
	      dis = 0;
	      break;
	    }else dis = min(dis, seg_seg_dis(a,b));
	  }
	}
	g[i][j] = g[j][i] = dis;
      }
      g[i][i] = 0;
    }

    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	}
      }
    }

    printf("%.9lf\n",g[m-1][l-1]);
  }
}	

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

int main()
{
    string A,B,C;
    cin>>A>>B>>C;
    char choice = 'a';
    for(int i=0;i<300;i++)
    {
        if(choice == 'a')
        {
            if(A=="")
            {
                break;
            }
            choice = A[0];
            A = A.substr(1);
        }
        if(choice == 'b')
        {
            if(B=="")
            {
                break;
            }
            choice = B[0];
            B = B.substr(1);
        }
        if(choice == 'c')
        {
            if(C=="")
            {
                break;
            }
            choice = C[0];
            C = C.substr(1);
        }
    }

    cout<<char(choice+'A'-'a')<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <string>
#include <map>//map<int, int> x;
#include <numeric>
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using ll = long long;
using namespace std;
 int main(){
 ll n,sum=0;
 string s;
 cin>>s;
if(s=="ABC")
cout<<"ARC"<<endl;
if(s=="ARC")
cout<<"ABC"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int d, n; 

int32_t main()
{
        cin >> d >> n;
        int s = 1;
        for (int i=0; i<d; i++) s *= 100;
        if (n<=99) cout << s * n;
        else cout << s * 101;
        return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B;
	std::cin >> A >> B;
	std::cout << ((A+B)%24) << "\n";
}


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

int main()
{
    ll K, N;
    cin >> K >> N;

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

    ll ans = K;
    for (size_t i = 0; i < N; i++)
    {
        ll k1 = K - (A[i] - A[i - 1]);
        if (i == 0)
        {
            k1 = A[N - 1] - A[0];
        }

        ll k2 = K - (A[i + 1] - A[i]);
        if (i == N - 1)
        {
            k2 = A[N - 1] - A[0];
        }

        ll k;
        if (k1 < k2)
        {
            k = k1;
        }
        else
        {
            k = k2;
        }

        if (k < ans)
        {
            ans = k;
        }
    }

    cout << ans << endl;
}


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

int main(){
  int n; cin>>n;
  vector<int>L(n);
  rep(i,n) cin>>L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  rep(i,n-1) sum += L[i];
  if (sum>L[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
using namespace std;         //  名前空間指定

int main()
{
  string s;
  cin >> s;
  int s_size = s.size();
  int alpha_num = 26;
  int offset = 97;
  
  bool unblance = false;
  int start_pos = -1;
  int end_pos = -1;
  
  for (int i=0; i<s_size-1; ++i){
    if (s[i] == s[i+1]){
      unblance = true;
      start_pos = i+1;
      end_pos = i+2;
      break;
    }
  }
  if (!unblance){
    for (int i=0; i<s_size-2; ++i){
      if (s[i] == s[i+2]){
        unblance = true;
        start_pos = i+1;
        end_pos = i+3;
        break;
      }
    }
  }
    
  
  cout << start_pos << ' ' << end_pos << endl;
}


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

int main()
{
    ll n,m;
    while(~scanf("%lld%lld",&n,&m))
    {
        ll res=0LL;
        res+=max(0LL,n-2)*max(0LL,m-2);
        if(n==1||m==1) res=max(max(0LL,n-2),m-2);
        if(n==1&&m==1) res=1LL;
        printf("%lld\n",res);
    }
}


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

int main() {
  int N, k, s, sam = 0;
  cin >> N;
  s = N;
  for(int i = 0;; i++){
    k = s;
    s /= 10;
    sam += (k - s * 10);
    if (s == 0){
      break;
    }
  }
  if (N % sam == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, x, y, z;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 998244353;
ld epi = 0.00000001;
ll cas=0;

void init(){}

void solve(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')s=s+"es";
    else s=s+"s";
    prs(s);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
    init();
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 


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

int main() {
  int h, a;
  cin >> h >> a;
  int ans = (h+a-1)/a;
  cout << ans << endl;
  return 0;
}


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

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

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--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string s;
    cin>>s;
    ll n=s.size();
    int t=0;
    rep(i,n){
        t+=(s[i]-'0');
        t%=9;
    }
    if(t%9==0) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll X, t;

    cin >> X >> t;

    cout << (X - t > 0 ? X - t : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    A = input_int_list()
    MOD = 10**9 + 7
    cnt = 1
    x, y, z = 0, 0, 0
    for a in A:
        tmp = 0
        is_used = False  # x,y,zのどこかに配った。
        if a == x:
            tmp += 1
            if not is_used:
                x += 1
                is_used = True
        if a == y:
            tmp += 1
            if not is_used:
                y += 1
                is_used = True
        if a == z:
            tmp += 1
            if not is_used:
                z += 1
                is_used = True
        cnt *= tmp
        cnt = cnt % MOD
    print(cnt)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 83952
x,n = map(int,input().split())
p = list(map(int,input().split()))
b = [1]*201
for a in p:
    b[a]=0

wk = 999
idx = 0
for i in range(201):
    if wk > abs(x - b[i]*i):
        wk1 = abs(x - b[i]*i)
        idx = i
    wk = wk1

print(idx)



Measured memory_bytes: 61828
#include<stdio.h>
int main(){
  int N,a[100],i,j;
  int t,c=0;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(a[j]<a[j-1]){
	t=a[j];
	a[j]=a[j-1];
	a[j-1]=t;
	c++;
      }
    }
  }

  for(i=0;i<N;i++){
    printf("%d",a[i]);
    if(i<N-1)printf(" ");
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = 60*h2+m2-60*h1-m1-k;
    if(ans<=0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int h, w;
string f[20];
int d[20][20];


bool isin(int y,int x) {
	return 0 <= y && y < h && 0 <= x && x < w;
}


int bfs(int sy, int sx) {
	memset(d, -1, sizeof(d));
	d[sy][sx] = 0;
	queue<pair<int, int>> q;
	q.emplace(sy, sx);

	int dy[] = { -1,0,1,0 };
	int dx[] = { 0,1,0,-1 };
	while (!q.empty()) {
		auto p = q.front();
		q.pop();

		rep(i, 4) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (isin(ny,nx) && f[ny][nx] == '.' && d[ny][nx] == -1) {
				d[ny][nx] = d[p.first][p.second] + 1;
				q.emplace(ny, nx);
			}
		}
	}
	int ret = 0;
	rep(y, h)rep(x, w)ret = max(ret, d[y][x]);
	return ret;
}


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

	cin >> h >> w;
	rep(y,h) {
		cin >> f[y];
	}

	int ans = 0;
	rep(y,h)rep(x,w) {
		if (f[y][x] =='.') {
			ans = max(ans, bfs(y, x));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define swap(type,x,y) do{type t=x; x=y; y=t;}while(0)

void sort(int a[],int left,int right){
	int pl=left;
	int pr=right;
	int x=a[(pl+pr)/2];

	do{
		while(a[pl]<x) pl++;
		while(a[pr]>x) pr--;
		if(pl<=pr){
			swap(int,a[pl],a[pr]);
			pl++;
			pr--;
		}
	}while(pl<=pr);
	if(left<pr) sort(a,left,pr);
	if(pl<right) sort(a,pl,right);
}

int main(void){
	int i,j;

  int n;

  scanf("%d",&n);

  int d[n+1];

  for(i=1;i<=n;i++){
    scanf("%d",&d[i]);
  }

  sort(d,1,n);

  printf("%d\n",d[n/2+1]-d[n/2]);

	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	string s, t; cin >> s >> t;
	vector<vector<int>>dp(s.size() + 1, vector<int>(t.size() + 1,10000));
	dp[0][0] = 0;
	for (int i = 0; i <= s.size(); ++i) {
		for (int j = 0; j <= t.size(); ++j) {
			if(i!=s.size())dp[i + 1][j] = min(dp[i][j]+1, dp[i + 1][j]);
			if(j!=t.size())dp[i][j + 1] = min(dp[i][j]+1, dp[i][j + 1]);
			if (i != s.size() && j != t.size())dp[i + 1][j + 1] = min(dp[i][j] + (s[i] != t[j]), dp[i + 1][j + 1]);
		}
	}
	cout << dp[s.size()][t.size()] << endl;
	return 0;
}

Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  if(s == "ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  return 0;
}

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

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

    long long ans = 0;
    long long k;
    for( k = 2; k * k < n; k++ )
    {
        if( (n - 1) % k == 0 ) 
        {
            if( (n - 1) / k == k )
            {
                ans += 1;
            }
            else
            {
                ans += 2;            
            }            
        }
        if( n % k == 0 )
        {
            long long a = n / k;
            while( a % k == 0 ) a /= k;
            if( a % k == 1 ) ans++;
        }
    }
    if( k * k == n ) ans++;
    ans += 1;
    if( n >= 3) ans += 1;

    cout << ans;
}

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

using namespace std;

int main()
{
  int c[3][3];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>> c[i][j];

  string ret="No";
  for(int a1=0;a1<=max({c[0][0],c[0][1],c[0][2]});a1++)
  for(int a2=0;a2<=max({c[1][0],c[1][1],c[2][2]})-a1;a2++)
  for(int a3=0;a3<=max({c[2][0],c[2][1],c[1][2]});a3++)
  {
    int b1=c[0][0]-a1;
    int b2=c[1][1]-a2;
    int b3=c[2][2]-a3;
    if(a1+b2==c[0][1]&&a1+b3==c[0][2]&&a2+b1==c[1][0]&&a2+b3==c[1][2]&&a3+b1==c[2][0]&&a3+b2==c[2][1])
    {
      ret="Yes";
      break;
    }
  }
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, K, sum = 0;
    string S;
    cin >> N >> K >> S;
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == 'R' && S.at(i + 1) == 'R') {
            sum++;
        }
    }
    for (int i = N - 1; i > 0; i--) {
        if (S.at(i) == 'L' && S.at(i - 1) == 'L') {
            sum++;
        }
    }
    cout << min(sum + 2 * K, N - 1) << endl;


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

    vector<bool> isexist(1000, false);
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                int l = 0;
                for(; l < n;){
                    if(s[l++]-'0' == i) break;
                }
                for(; l < n;){
                    if(s[l++]-'0' == j) break;
                }
                for(; l < n; l++){
                    if(s[l]-'0' == k) break;
                }
                if(l < n) isexist[i*100+j*10+k] = true;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 1000; i++){
        if(isexist[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int KASU=52;
const int SISU=12;
using ll=long long;
using Float=pair<int,ll>;
void output(Float f){
    cout<<bitset<SISU>(f.first)<<bitset<KASU>(f.second)<<endl;
}

Float solve(ll n,ll b,Float sum){
    if(n==0) return sum;
    
    ll x=((1LL<<KASU)+b)>>sum.first;
    if(x==0) return sum;
    ll v=(1LL<<(KASU+1));
    sum.second+=(1LL<<KASU);
    ll c=(v-sum.second-1)/x;
    if(n<=c){
        sum.second+=x*n;
        sum.second-=(1LL<<KASU);
        return sum;
    }    
    else{
        sum.second+=x*(c+1);
        sum.first++;
        sum.second>>=1;
        sum.second-=(1LL<<KASU);
        n-=c+1;
        return solve(n,b,sum);
    }
}

int main(){
    ll n;
    while(cin>>n,n){
        bitset<KASU> tmp;
        cin>>tmp;
        Float f;
        f.first=0;
        f.second=tmp.to_ulong();
        auto ret=solve(n,f.second,f);
        output(ret);
    }
    return 0;
}


Measured memory_bytes: 3144
n = int(input())
S = [list(map(int,input())) for i in range(n)]
Graph = [[] for i in range(n)]
for i in range(n):
    for j in range(n):
        if S[i][j]==1:
            Graph[i]+=[j]
colors = [0 for i in range(n)]

def is_bipartite(es):
    stack = [(0,1)]
    while stack:
        v,color = stack.pop()
        colors[v] = color
        for to in es[v]:
            if colors[to] == color:
                 return False
            if colors[to] == 0:
                 stack.append((to, -color))
    return True

if not is_bipartite(Graph):
    print(-1)
    exit()

S2 = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        if S[i][j]==1:
            S2[i][j]=1
        elif i==j:
            S2[i][j]=0

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

warshall_floyd(S2)

diam = 0
for i in range(n):
    for j in range(n):
        diam = max(diam,S2[i][j])
print(diam+1)

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

using namespace std;

bool isvalid(char x){
    return x=='A'||x=='C'||x=='G'||x=='T';
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<(int)s.size();++i){
        int cur=0;
        for(int j=i;j<(int)s.size();++j){
           if(isvalid(s[j])){
               ++cur;
           }else break;
       } 
       ans=max(ans,cur);
    }
    cout<<ans<<endl;

    return 0;
}



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

using namespace std;

int main() {
	int N, W, H; cin >> N >> W >> H;
	vector<int> imosx(W + 2), imosy(H + 2);
	for (int i = 0; i < N; ++i) {
		int x, y, w; cin >> x >> y >> w;
		imosx[max(0, x - w)]++; imosx[min(W, x + w)]--;
		imosy[max(0, y - w)]++; imosy[min(H, y + w)]--;
	}
	bool flagx = true, flagy = true;
	for (int i = 0; i < W; ++i) {
		imosx[i + 1] += imosx[i];
		if (imosx[i] <= 0) flagx = false;
	}
	for (int i = 0; i < H; ++i) {
		imosy[i + 1] += imosy[i];
		if (imosy[i] <= 0) flagy = false;
	}
	cout << (flagx || flagy ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3616
def main():
    x,y,a,b,c=map(int,input().split())
    p=list(map(int,input().split()))
    q=list(map(int,input().split()))
    r=list(map(int,input().split()))
    p.sort(reverse=True)
    q.sort(reverse=True)
    for i in range(x):
        r.append(p[i])
    for j in range(y):
        r.append(q[j])
    r.sort(reverse=True)
    ans=sum(r[:x+y])
    print(ans)
if __name__=="__main__":
    main()

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

int main() {
  int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
  vector<int> vec = {b-a,c-a,d-a,e-a,c-b,d-b,e-b,d-c,e-c,e-d};
  sort(vec.begin(),vec.end());
  if(vec[9] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 10000000
#define NIL -1
#define BLACK 1
#define WHITE 0

void prim(void);

int n,a[101][101],w=0,d[101],pi[101],color[101];

int main()
{
  int i,j;


  scanf("%d",&n);

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

  prim();

  for(i=0;i<n;i++){
    if(pi[i]!=NIL && a[pi[i]][i]!=-1) {
      w+=a[pi[i]][i];
    }
  }

  printf("%d\n",w);

  return 0;
}

void prim(void){
  int mincost,u,v,i;

  for(u=0;u<n;u++){ // each u in G
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INF;
    for(i=0;i<n;i++){ //each i in G
      if (color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    color[u] = BLACK;

    if(mincost == INF) break;


    for(v=0;v<n;v++){// each v in Adj[u]
      if(a[u][v]!=-1){
	if (color[v] != BLACK && a[u][v] < d[v]){
	  pi[v] = u;
	  d[v] = a[u][v];
	}
      }
    }
  }
}

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

bool comp(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void){
    int n, used[110] = {0};
    cin >> n;
    vector<pair<int,int>> re(n), bl(n);
    for(int i=0;i<n;++i){
        cin >> re[i].first >> re[i].second;
    }
    for(int i=0;i<n;++i){
        cin >> bl[i].first >> bl[i].second;
    }
    sort(re.begin(), re.end(), comp);
    sort(bl.begin(), bl.end());
    int cnt = 0;
    for(int i=0;i<n;++i){
        for(int j=n-1;j>=0;--j){
            if(used[j]) continue;
            if(re[j].first < bl[i].first && re[j].second < bl[i].second){
                ++cnt;
                used[j] = 1;
                break;
            }
        }
    }
    /*int ma = cnt;
    sort(re.begin(), re.end(), comp);
    sort(bl.begin(), bl.end(), comp);
    cnt = 0;
    for(int i=0;i<110;++i) used[i] = 0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            if(used[j]) continue;
            if(re[i].second < bl[j].second && re[i].first < bl[j].first){
                ++cnt;
                used[j] = 1;
                break;
            }
        }
    }*/
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long A,B,C;
	cin >> A >> B >> C;
	if(A%2==0||B%2==0||C%2==0){
		cout << "0" << endl;
		return 0;
	}
	long long m = min(A*B,B*C);
	m = min(m,C*A);
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256