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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];

    ll ans = 0;
    rep(i,0,n-1){
        if(a[i] + a[i+1] > k){
            if(a[i] >= k){
                ans += a[i+1] + a[i] - k;
                a[i] = k;
                a[i+1] = 0;
            }
            else{
                ans += a[i]+a[i+1]-k;
                a[i+1] -= a[i]+a[i+1]-k; 
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4396
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

using namespace std;

int main(){
    string s;
    string a = "ATCG";
    int maxi = -1;

    cin >> s;

    for(int i = 0;i < s.size(); i++){
        int cnt = 0;

        for(int j = i; j < s.size(); j++){
            bool flag = false;
            for(int k = 0; k < a.size(); k++){
                if(s[j] == a[k]) flag = true;
            }
            if(flag) cnt++;
            else break;
        }
        maxi = max(maxi, cnt);
    }
    cout << maxi << endl;
    return 0;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, dp[max_n], mx[max_n], p[max_n], tot[max_n];
vector<int> g[max_n], f[max_n];

void dfs0(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        if (g[v][i] == p[v]) {
            swap(g[v][i], g[v].back());
            g[v].pop_back();
            break;
        }
    }
    for (int i = 0; i < g[v].size(); ++i) {
        p[g[v][i]] = v;
        mx[g[v][i]] = max(mx[v], v);
        dfs0(g[v][i]);
    }
}

int dfs3(int v, int mx) {
    if (v >= mx) {
        return 0;
    }
    int res = 1;
    for (int to : g[v]) {
        res += dfs3(to, mx);
    }
    return res;
}

void dfs1(int v) {
    for (int to : g[v]) {
        dfs1(to);
    }
    f[v].resize(g[v].size());
    if (v < mx[v]) {
        for (int i = 0; i < g[v].size(); ++i) {
            const int to = g[v][i];
            if (to < mx[v]) {
                f[v][i] = tot[to] + 1;
            }
            tot[v] += f[v][i];
        }
    } else {
        for (int i = 0; i < g[v].size(); ++i) {
            f[v][i] = dfs3(g[v][i], mx[v]);
            tot[v] += f[v][i];
        }
    }
}

void dfs2(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        const int to = g[v][i];
        dp[to] = 1 + dp[v] + tot[to] - f[v][i];
        dfs2(to);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs0(1);
    dfs1(1);
    dfs2(1);
    for (int i = 2; i <= n; ++i) {
        printf("%d ", dp[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 45312
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!{ h: usize, w: usize, k: usize, s: [Chars; h], };
    let mut ans = 0;
    for is in 0 .. (1 << h) {
        for js in 0 .. (1 << w) {
            let mut c = 0;
            for i in 0 .. h {
                for j in 0 .. w {
                    if (is >> i & 1 != 0) && (js >> j & 1 != 0) {
                        if s[i][j] == '#' {
                            c += 1;
                        }
                    }
                }
            }
            if c == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n,k)
    SS(string,s)
    ll score = 0;
    rep(i, n - 1)if(s[i] == s[i + 1]) score++;//2連を数える
    ll ans = min(score + 2*k, n - 1);//右端まで連続してた場合の処理
    cout << ans << endl;
}


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

int x[105];
char p;
string s[105];
int main()
{
	cin >> s['a'] >> s['b'] >> s['c'];
	p = 'a';
	while (1) {
		if (x[p] == s[p].size()) {
			cout << char(p - 32);
			return 0;
		} else {
			x[p]++;
			p = s[p][x[p] - 1];
		}
	}
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

int main()
{
	ll n,m,cnt=0;
	cin >> n;
	rep(i,n){
		cin >> m;
		if(IsPrime(m)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>


using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T, class BinaryOperation>
constexpr T fold(std::initializer_list<T> args, T init, BinaryOperation op)
{
    return std::accumulate(args.begin(), args.end(), init, op);
}

// numeric_low
namespace numeric
{
    // 最大公約数
    template<class T>
    constexpr T gcd(const T x, const T y)
    {
        if (x < 0)return gcd(-x, y);
        if (y < 0)return gcd(x, -y);
        return (!y) ? x : gcd(y, x % y);
    }

    // 最小公倍数
    template<class T>
    constexpr T lcm(const T x, const T y)
    {
        if (x < 0)return lcm(-x, y);
        if (y < 0)return lcm(x, -y);
        return x * (y / gcd(x, y));
    }
}

// argsからハッシュ値を作成
template <class... Args>
std::size_t hash(Args... args)
{
    return fold({ static_cast<std::size_t>(args)... }, 0_sz,
        [](std::size_t seed, std::size_t x)
    {
        // uses magic number from boost
        return seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    });
}

template <class Begin, class End>
void printAll(Begin beginIter, End endIter, std::string delimiter)
{
    for (auto iter{ beginIter }; iter != endIter; ++iter)
    {
        std::cout << *iter;
        if (std::distance(iter, endIter) != 1)
            std::cout << delimiter;
    }
}

template <class Container>
void printAll(const Container& c, std::string delimiter)
{
    printAll(std::cbegin(c), std::cend(c), delimiter);
}

template<class T>
void printAll(const std::initializer_list<T>& ini, std::string delimiter)
{
    printAll(ini.begin(), ini.end(), delimiter);
}


void print(std::vector<int> v)
{
    for (auto e : v)
    {
        std::cout << e << std::endl;
    }

}

int main()
{
    using namespace std;

    int n, m;
    cin >> n >> m;

    vec<int> E(m);

    for (auto& e : E)
        cin >> e;


    vec<int> used(n + 1, -1);

    for (auto e : E)
    {
        used[e]++;
    }
    
    for_each(make_reverse_iterator(E.cend()), make_reverse_iterator(E.cbegin()), [&used](int e)
    {
        if (used[e] >= 0)
        {
            cout << e << endl;
            used[e] = -2;
        }
    });
    

    for (int i = 1; i <=n; ++i)
    {
        if (used[i] == -1)
            cout << i << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3896
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100001];

LL ans = -1;

void solve(){
	if(N==0){
		if(A[0]==1) ans = 1;
		return;
	}
	//深さiの、それぞれ考えられるノードの数の
	//最小値と最大値
	vector<LL> min_node(N+1);
	vector<LL> max_node(N+1);
	min_node[N] = A[N];
	max_node[N] = A[N];
	// for(int i=N-1;i>=0;i--){
	// 	min_node[i] = max(1LL + A[i],(min_node[i+1]+1LL)/2LL + A[i]);
	// 	max_node[i] = min(max_node[i+1] + A[i],1LL<<i);
	// 	if(min_node[i]>max_node[i]) return;
	// }
	for(int i=N-1;i>=0;i--){
		min_node[i] = (min_node[i+1])/2LL + A[i];
		max_node[i] = max_node[i+1] + A[i];
	}
	if(min_node[0]>1) return;

	// for(int i=0;i<=N;i++){
	// 	printf("depth=%d:[%lld,%lld]\n",i,min_node[i],max_node[i]);
	// }

	LL allof_nodes = 1;
	LL prev_nodes = 1;
	for(int i=1;i<=N;i++){
		LL enable_nodes = (prev_nodes-A[i-1])*2LL;
		LL used_nodes = min(max_node[i],enable_nodes);
		//printf("d=%d:%lld\n",i,used_nodes);
		if(used_nodes<min_node[i]) return;
		allof_nodes += used_nodes;
		prev_nodes = used_nodes;
	}
	ans = allof_nodes;
}

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

    solve();

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

Measured memory_bytes: 5160
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

struct coin {
  ll a;
  ll b;
  ll c;
  bool operator<(const coin & another) const {
    return a - b < another.a - another.b;
  }
};

struct coinl {
  ll b;
  ll c;
  bool operator<(const coinl & another) const {
    return b - c > another.b - another.c;
  }
};

struct coinr {
  int id;
  ll a;
  ll c;
  bool operator<(const coinr & another) const {
    return a - c < another.a - another.c;
  }
};

int main() {
  int x, y, z; cin >> x >> y >> z;
  int n = x + y + z;
  vector<coin> coins(n);
  Loop(i, n) {
    cin >> coins[i].a >> coins[i].b >> coins[i].c;
  }
  sort(coins.begin(), coins.end());
  priority_queue<coinl> pq1;
  priority_queue<coinr> pq2;
  vector<bool> in_c(n, false);
  ll buf = 0;
  Loop(i, y) {
    pq1.push({ coins[i].b, coins[i].c });
    buf += coins[i].b;
  }
  Loop1(i, x + z) {
    pq2.push({ n - i, coins[n - i].a, coins[n - i].c });
    buf += coins[n - i].c;
    in_c[n - i] = true;
  }
  Loop(i, x) {
    coinr to_a = pq2.top(); pq2.pop();
    buf += to_a.a - to_a.c;
    in_c[to_a.id] = false;
  }
  ll ans = buf;
  for (int k = y; k < y + z; ++k) {
    if (in_c[k]) {
      in_c[k] = false;
      buf += -coins[k].c;
    }
    else {
      coinr to_a;
      while (1) {
        to_a = pq2.top(); pq2.pop();
        if (in_c[to_a.id]) break;
      }
      in_c[to_a.id] = false;
      buf += -coins[k].a + to_a.a - to_a.c;
    }
    pq1.push({ coins[k].b, coins[k].c });
    coinl to_c = pq1.top();
    pq1.pop();
    buf += coins[k].b - to_c.b + to_c.c;
    ans = max(ans, buf);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    
    int N,D,X,cnt=0;
    cin >>N>>D>>X;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >>A[i];
        cnt+=((D-1)/A[i]+1);
    }
    
    cout <<(cnt+X);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long n,x,m,ans=0;
    cin >> n >> x >> m;
    if(x==0){
        cout << 0 << endl;
        return 0;
    } 
    vector<long> k,s(m);
    map<long,long> mp;
    long cur = x,d=0,e=0;
    k.push_back(cur);
    mp[cur] = 1;
    for(int i=2;i<=m;i++){
        cur = (cur*cur)%m;
        k.push_back(cur);
        if(1<=mp[cur]){
            d = mp[cur];
            e = i;
            break;
        }  
        mp[cur] = i;
    }
    long fsum = 0,cirsum=0,resum=0;
    for(int i=0;i<d-1;i++) fsum += k[i];
    for(int i=d-1;i<e-1;i++) cirsum += k[i];
    for(int i=0;i<=(n-d)%(e-d);i++) resum += k[d-1+i];
    cout << fsum + (n-d)/(e-d)*cirsum + resum << endl;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

vector<bool> flag(8, true);
vvi edge(8, vi(0));

int result(int m, int n, vector<bool> flag){
  if(n == 0) return 1;
  int num = 0;
  for(int i = 0; i < edge.at(m).size(); i++){
    int next = edge.at(m).at(i);
    if(flag.at(next)){
      vector<bool> flag2 = flag;
      flag2.at(next) = false;
      num += result(next, n-1, flag2);
    }
  }
  return num;
}

int main(){
  int N, M;
  cin >> N >> M;
  
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge.at(a).push_back(b);
    edge.at(b).push_back(a);
  }

  flag.at(0) = false;
  cout << result(0, N-1, flag) << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m, q int
	fmt.Scanf("%d %d %d", &n, &m, &q)
	a := make([]int, q)
	b := make([]int, q)
	c := make([]int, q)
	d := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i])
	}
	answer := maxPoint(n, m, q, a, b, c, d)
	fmt.Println(answer)
}

func maxPoint(n, m, q int, a, b, c, d []int) int {
	sequences := createSequences(n, m)
	maxPoint := 0
	for _, sequence := range sequences {
		point := 0
		for i := 0; i < q; i++ {
			if sequence[b[i]-1]-sequence[a[i]-1] == c[i] {
				point += d[i]
			}
		}
		if maxPoint < point {
			maxPoint = point
		}
	}
	return maxPoint
}

func createSequences(length, max int) [][]int {
	nextSeqs := make([][]int, max)
	for i := 1; i <= max; i++ {
		nextSeqs[i-1] = []int{i}
	}
	for i := 0; i < length; i++ {
		var tmpNextSeqs [][]int
		for _, nextSeq := range nextSeqs {
			t := createNextSequences(nextSeq[len(nextSeq)-1], max, nextSeq)
			for _, tSeq := range t {
				tmpNextSeqs = append(tmpNextSeqs, tSeq)
			}
		}
		nextSeqs = tmpNextSeqs
	}
	return nextSeqs
}

func createNextSequences(prev, max int, currentSeq []int) [][]int {
	nextSeqList := make([][]int, max-prev+1)
	for i := 0; i < len(nextSeqList); i++ {
		nextSeqList[i] = make([]int, len(currentSeq)+1)
		copy(nextSeqList[i], currentSeq)
	}
	for d, i := prev, 0; d <= max; {
		nextSeqList[i][len(currentSeq)] = d
		d++
		i++
	}
	return nextSeqList
}


Measured memory_bytes: 50704
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int n,m,r=0;
	scanf("%d%d",&n,&m);
	vector<int>v(m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		v[i]=max(n-a,0);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<m-1;i++)r+=v[i];
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2716
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int n, m, d;
    while (~scanf("%d %d %d", &n, &m ,&d)) {
          int offset = 2;
          if (!d) offset = 1;
          double tmp = (double)(n - d) * offset * (m - 1);
          printf("%.10lf\n", tmp / n / n);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<ll, ll> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<ll> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL);
    int tt;
    // cin>>tt;
    tt=1;
    while(tt--){
        ll i,j,k,n;
        cin>>n;
        if(n)cout<<0<<endl;
        else cout<<1<<endl;
    }
    
    return 0;
}

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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  
  int x =0;
  int y =0;
  
  for(int i=0;i<N;i++){
    char z;
    cin>>z;
    
    if(z=='a'){
      if(x<A+B){
        x++;
        cout << "Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    if(z=='b'){
      y++;
      if(x<A+B && y<=B){
        x++;
        cout <<"Yes"<<endl;
      }
      else{
        cout <<"No"<<endl;
      }
    }
    if (z=='c'){
      cout <<"No"<<endl;
    }
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> ivec;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		ivec.push_back(a);
	}
	sort(ivec.begin(),ivec.end());
	reverse(ivec.begin(),ivec.end());
	int others=0;
	for(int i=1;i<ivec.size();i++)
		others+=ivec[i];
	if(others>ivec[0])
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  bool torf1=false,torf2=false;
  
  vector<ll> A(M);
  vector<ll> dp(N,0);
  vector<bool> B(N,false);
  
  rep(i,M){
    cin >> A.at(i);
    B.at(A.at(i)-1)=true;
  }
    

  
  if(B.at(0)!=true)
  dp.at(0)=1;
  

  
  for(int i=1;i<N;i++){
    if(i==1){
    if(B.at(0)!=true && B.at(1)!=true)
    dp.at(1)=2;
  else if(B.at(0)==true && B.at(1)!=true)
    dp.at(1)=1;
    }
    else{
    if(B.at(i)!=true){

    dp.at(i)=(dp.at(i-1)+dp.at(i-2))%1000000007;
      //cout << dp.at(i) << endl;
    }
    
    }
   // cout << dp.at(i) << endl;
  }
  
  
  cout << dp.at(N-1) << endl;
  
}

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

const int maxn = 2e5 + 10;

int n;
int A, B, C, D;
string s;
bool f[maxn] = {0}, g[maxn] = {0};


bool check(bool* F, int L, int R) {
	memset(F, 0, sizeof F);
	F[L] = 1;
	for (int i = L + 1; i <= R; ++i) {
		if (s[i] == '.') {
			F[i] |= F[i - 1];
			if (i - 2 > 0) F[i] |= F[i - 2];
		}
	}
	return F[R];
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> A >> B >> C >> D;
	cin >> s;
	s = ' ' + s;
	bool mark = 1;
	mark &= check(f, B, D);
	mark &= check(g, A, C);
	if (D < C) {
		bool mk = 0;
		for (int i = B; i <= D; ++i) {
			if (f[i] && g[i - 1] && g[i + 1]) { mk = 1; break; }
		}
		mark &= mk;
	}
	cout << (mark ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 792
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] < '2' || s[0] == '2' && s[1] == '0' && (s[2] == '0' || s[2] == '1' && (s[3] <= '8') || s[3] == '9' && s[5] == '0' && s[6] <= '4')) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
N=parse(Int,readline())
s=chomp(readline())
pre=-1
ans=1
A=Int[]
i=1
while i<=N
  if i+1<=N&&s[i]==s[i+1]
    push!(A,1)
    i+=1
  else
    push!(A,0)
  end
  i+=1
end
mod=10^9+7
for a=A
  if a==0
    if pre==-1
      ans=ans*3%mod
    elseif pre==0
      ans=ans*2%mod
    end
  else
    if pre==-1
      ans=ans*6%mod
    elseif pre==0
      ans=ans*2%mod
    else
      ans=ans*3%mod
    end
  end
  pre=a
end
println(ans)

Measured memory_bytes: 165388
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string S;
    cin >> S;
    int a = 0;
    int sum = 0;
    for(int i=0;i<(1<<3);i++){
        sum = S[0] - '0';
        for(int j=0;j<3;j++){
            if(i & (1 << j)){
                sum += S[j+1]-'0';
            }else{
                sum -= S[j+1]-'0';
            }
        }
        if(sum == 7){
            cout << S[0];
            for(int j=0;j<3;j++){
                if(i & (1 << j)){
                    cout <<"+"<<S[j+1];
                }else{ 
                    cout <<"-"<<S[j+1];
                }
            }
            cout<< "=7"<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a,b;
  cin>>a>>b;
  ll c = b-a;
  ll p = 0;
  rep(i,0,c){
    p += i;
  }
  cout << p-a << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if (u==s)
    cout << a-1 << ' ' << b << endl;
  else
    cout << a << ' ' << b-1 << endl;
}

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

int N,K;
int P[200000];

int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>P[i];
    }

    int sum=0;
    int ans=0;
    for(int i=0;i<K;i++){
        sum+=P[i];
        ans+=P[i];
    }

    for(int i=0;i<N-K;i++){
        sum-=P[i];
        sum+=P[i+K];
        if(sum>ans){
            ans=sum;
        }
    }

    if((ans+K)%2==0){
        ans=(ans+K)/2;
        cout<<ans<<endl;
    }else{
        ans=(ans+K)/2;
        cout<<ans<<".5"<<endl;
    }
}

Measured memory_bytes: 1024
INF = int(10e20)


def main():
    N, K = tuple([int(_x) for _x in input().split()])

    minval = N
    sub = N // K - 5
    if sub > 0:
        N = N - K * sub

    for i in range(20):
        N = abs(N - K)
        minval = min(N, minval)

    print(minval)


main()


Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int P[21];
int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> P[i];
	}
	int sum = 0;
	for (int i = 1; i < n-1; i++)
	{
		if ((P[i - 1] > P[i] && P[i + 1] < P[i]) || (P[i - 1] < P[i] && P[i + 1] > P[i]))
		{
			sum++;
		}
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        if(s.at(i) == '1')
        s.at(i) = '9';
        else 
        s.at(i) = '1';
    }
    cout << s << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int myfunc(int N){
  if (N < 10) {
    return N;
  } else{
    return myfunc(N/10) + N%10;
  }
}
int main(void)
{

    int n;
    int a,b;
    long num = 0;
    long ans = 0;
    cin >> n >> a >> b;

    for(int i = 1; i <= n; i++){
      if(i < 10){
        num = i;
        if((num >= a) && (num <= b)){
          ans += i;
        }
      }else if(10 <= i){
        num = myfunc(i);
        if((num >= a) && (num <= b)){
          ans += i;
        }
      }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, k, ans, u = 0;
	string s;
	cin >> n >> k >> s;
	if (n == 1) {
		cout << 0;
		return 0;
	}
	ll x = 0;
	rep(i, n - 1) {
		if (s.at(i) == 'R' && s.at(i + 1) == 'L') {
			x++;
		}
	}
	if (s.at(0) == 'L') u++;
	if (s.at(n - 1) == 'R') u++;
	if (x >= k) {
		x -= k;
		ans = n - u - x * 2;
	}
	else ans = n - 1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    
    else:
        ans += a[i]
        c = b[i] - a[i]
        t = a[i+1]
        a[i+1] = t-c
        if a[i+1] <= 0:
            ans += t
            a[i+1]=0
        else:
            ans += c

print(ans)

Measured memory_bytes: 18476
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    # Create a boolean array "prime[0..n]" and initialize 
    #  all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    return prime
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
if __name__ == '__main__':
	n,m=map(int,stdin.readline().split(" "))
	l=list(map(int,stdin.readline().split(" ")))
	total=sum(l)
	if(total>n):
		stdout.write(str(-1)+"\n")
	else:
		stdout.write(str(n-total)+"\n")

Measured memory_bytes: 11364
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  a = input_list()
  mod = 10**9+7
  ans = 0
  for i in range(n):
    for j in range(n):
      if i < j and a[i] > a[j]:
        ans += k*(k-1) // 2 + k
        ans %= mod
      elif i > j and a[i] > a[j]:
        ans += k*(k-1) // 2
        ans %= mod
  print(ans)
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INF 1ll<<63 - 1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair<pair<ll,ll>, ll> 
#define pii pair< int, pair<int,int> >
vector<ll> v;
ll seive[1000005];
void seiv(){
	for(int i =2; i*i<1000005; i++){
		if(!seive[i]){
			v.pb(i);
			for(int j = i*i ; j<1000005; j+=i)
			seive[j] = 1;
		}
	}
	rep(i,2,1000000){
		if(!seive[i]) v.pb(i);
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,x,b,y,q,z,k,n,m;
    seiv();
    cin>>x;
    cout<<*lower_bound(v.begin(),v.end(),x);
}









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

int main(){
	string input;
	int mas[14][14];
	for(int i=0; i<14; i++){
		for(int j=0; j<14; j++){
			mas[i][j] = 0;
		}
	}
	int size1x[] = {-1, 0, 1, 0};	
	int size1y[] = {0, -1, 0, 1};	
	int size2x[] = {-1, 1, 1, -1};	
	int size2y[] = {-1, -1, 1, 1};	
	int size3x[] = {-2, 0, 2, 0};	
	int size3y[] = {0, -2, 0, 2};	
	while(cin>>input){
		int x, y, size;
		sscanf(input.c_str(), "%d,%d,%d", &x, &y, &size);
		x += 2;
		y += 2;
		mas[x][y]++;
		for(int i=0; i<4; i++){
			if(size >= 1) mas[x+size1x[i]][y+size1y[i]]++;
			if(size >= 2) mas[x+size2x[i]][y+size2y[i]]++;
			if(size >= 3) mas[x+size3x[i]][y+size3y[i]]++;
		}
		/* //ツデツバツッツグツ用
		for(int i=2; i<12; i++){
			for(int j=2; j<12; j++){
				cout<<mas[i][j];
			}
			cout<<endl;
		}
		cout<<endl;
		// */
	}
	int num = 100;
	int maxv = 0;
	for(int i=2; i<12; i++){
		for(int j=2; j<12; j++){
			if(mas[i][j]){
				num--;
				maxv = max(maxv, mas[i][j]);
			}
		}
	}
	cout<<num<<endl<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod (ll)1000000007
const int MAXN=1000005;
int spf[MAXN];
ll fac1[MAXN],fac2[MAXN],inv[MAXN];
ll gcd(ll x, ll y){ return y?gcd(y,x%y):x; }

void sieve(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

void pre(){
    fac1[0]=fac2[0]=inv[1]=1;
    for(ll i=1;i<MAXN;i++){
        fac1[i]=(fac1[i-1]*i)%mod;
        if(i>1) inv[i]=( mod - ((ll)(mod/i)*inv[mod%i])%mod ) %mod;
    }
    for(int i=1;i<MAXN;i++) fac2[i]=(fac2[i-1]*inv[i])%mod;
}
ll C(int n,int k){
    if(n<k) return 0;
    return ((fac1[n]*fac2[n-k]%mod)*fac2[k]%mod);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        ll ans=1,sum=1,add=1;
        rep(i,n){
            ans=(ans*10)%mod;
            sum=(sum*9)%mod;
            add=(add*8)%mod;
        }
        cout<<(ans-2*sum+add+2*mod)%mod<<nl;
    }
    return 0;
}

Measured memory_bytes: 3200
N  = int(input())
#n = list(range(N))
x = []
for i in range(1,N+1):
  counter = 0
  while i % 2 == 0:
    a = i
    i/=2
    counter +=1
  x.append(counter)
    
#print(x)
print(x.index(max(x))+1)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Magatro
{ 

    public void Solve()
    {
        var s = Console.ReadLine();
        Console.WriteLine(s.Substring(0,s.Length-8));
    }

    static public void Main()
    {
        new Magatro().Solve();
    }
}


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  string S;
  cin >> S;

  if (S[0] == S[1] && S[1] == S[2] && S[0] == 'R') {
    cout << 3 << endl;
  }
  else if ((S[0] == S[1] || S[1] == S[2]) && S[1] == 'R') {
    cout << 2 << endl;
  }
  else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
ans = 1
big = False
if 0 in A:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            big = True
            break
    if big:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int f, l;
  for(int i=0; i<n; i++) {
    if(s.at(i) == 'A') {
      f = i;
      break;
    }
  }
  for(int i=0; i<n; i++) {
    if(s.at(n-i-1) == 'Z') {
      l = n-i-1;
      break;
    }
  }
  cout << l-f+1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

/**
 * Grid 1
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            boolean[][] G = new boolean[H][W];
            for (int i = 0; i < H; i++) {
                char[] c = sc.next().toCharArray();

                for (int j = 0; j < W; j++) {
                    if (c[j] == '.') {
                        G[i][j] = true;
                    }
                }
            }

            long[][] dp = new long[H][W];
            dp[0][0] = 1;

            for (int k = 1; k <= H + W - 2; k++) {
                for (int i = 0; i < H; i++) {
                    int j = k - i;

                    if (j < 0) {
                        break;
                    }

                    if (j >= W) {
                        continue;
                    }

                    if (!G[i][j]) {
                        continue;
                    }

                    if (i == 0) {
                        dp[i][j] = dp[i][j - 1];
                    } else if (j == 0) {
                        dp[i][j] = dp[i - 1][j];
                    } else {
                        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;
                    }
                }
            }

            System.out.println(dp[H - 1][W - 1]);
        }
    }

}


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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int64_t M = 0;
  int64_t A = 0;
  int64_t R = 0;
  int64_t C = 0;
  int64_t H = 0;
  
  for(int j=0; j<N; j++){
    string S = vec.at(j);
    if(S.at(0) == 'M'){
      M++;
    }
    if(S.at(0) == 'A'){
      A++;
    }
    if(S.at(0) == 'R'){
      R++;
    }
    if(S.at(0) == 'C'){
      C++;
    }
    if(S.at(0) == 'H'){
      H++;
    }
  }
  
  vector<int64_t> MARCH(5);
  MARCH.at(0) = M;
  MARCH.at(1) = A; 
  MARCH.at(2) = R;
  MARCH.at(3) = C; 
  MARCH.at(4) = H;
  sort(MARCH.begin(),MARCH.end());
  
  int64_t ans = 0;
  if(MARCH.at(1) == 0 && MARCH.at(2) != 0){
    ans = MARCH.at(2) * MARCH.at(3) * MARCH.at(4);
  }
  else if(MARCH.at(0) == 0){
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(1);
  }
  else{
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(1);
    
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(1);
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(4);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 6144
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-08 01:29:57
**/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    /*rep(i, N){
        cout << h[i];
    }*/
    int min = h[N-1] - h[0];
    rep(i,N-K+1){
        if(h[i+K-1]-h[i]<min){
            min=h[i+K-1]-h[i];
        }
    }
    cout<<min;
return 0;}

/**
 * compile: g++ code.cpp
 * run: ./a.out
 * insert date string: ctrl + shift + i
 * 
**/ 

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int n = s.length;
			Set<Character> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				set.add(s[i]);
			}

			if (n < 26) {
				for (char c = 'a'; c <= 'z'; c++) {
					if (!set.contains(c)) {
						out.println(new String(s) + c);
						return;
					}
				}
			} else {
				int pnt = n - 1;
				set.remove(s[pnt]);
				pnt--;

				while (pnt >= 0) {
					if (s[pnt] > s[pnt + 1]) {
						set.remove(s[pnt]);
						pnt--;
						continue;
					}
					for (char c = (char)(s[pnt] + 1); c <= 'z'; c++) {
						if (!set.contains(c)) {
							out.println(new String(Arrays.copyOf(s, pnt)) + c);
							return;
						}
					}
				}
			}
			out.println(-1);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
    long long A, B, K, K_;
    cin >> A >> B >> K;
    K_ = max((long long)0, K-A);
    A = max((long long)0, A-K);
    B = max((long long)0, B-K_);

    cout << A << " " << B << endl;

    return 0;
}

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

int main() {
	

	int N,M,day,dday;
	cin >> N>>M;
	vector<int> A(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
	}
	
	day = 0;
	for (int i = 0; i < M; i++)
	{
		day += A[i];
	}

	dday = N - day;

	if (dday >= 0)
	{
		cout << dday << endl;
	}
	else
	{
		cout << -1 << endl;

	}

	return 0;
}




Measured memory_bytes: 3568