akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())
sorteda = a.copy()
sorteda.sort(reverse=True)
maxa = sorteda[0]
secmaxa = sorteda[1]
for i in range(n):
  if a[i]==maxa:
    print(secmaxa)
  else:
    print(maxa)

Measured memory_bytes: 14160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	string s, t;
	int ans = 0;
	cin >> s >> t;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main() {
	char S[] = "    ";

	cin >> S[1] >> S[2] >> S[3] >> S[4];


	if (S[1] == S[2] && S[3] == S[4]&&S[1]!=S[3]) {
		cout << "Yes" << endl;
	}
	else if (S[1] == S[3] && S[2] == S[4] && S[1] != S[2]){
		cout << "Yes" << endl;
	}
	else if (S[1] == S[4] && S[2] == S[3] && S[1] != S[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
  string wea;
  cin >> wea;
  if(wea=="Sunny")
    cout << "Cloudy" <<endl;
  else if(wea=="Cloudy")
    cout << "Rainy" <<endl;
  else
    cout << "Sunny" <<endl;
}

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

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll N; cin >> N; vll h(N);
    for(auto &x: h) cin >> x;

    vector<ll> dn(N+1);

    dn[0] = 0;
    dn[1] = abs( h[N-1] - h[N-2] );

    for(ll i = 2; i <= N; ++i){
       dn[i] = min(dn[i-1] + abs(h[N - i - 1] - h[N - i]), dn[i-2] + abs(h[N - i - 1] - h[N - i + 1]));
    }

    cout << dn[N-1] << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 1792
function main()
	N=parse(Int,readline())
	ca=cb=cab=0
	ans=0
	for _=1:N
		s=chomp(readline())
		n=length(s)
		for i=2:n
			if s[i-1]=='A'&&s[i]=='B'
				ans+=1
			end
		end
		if s[1]=='B'
			cb+=1
			if s[end]=='A'
				cab+=1
			end
		end
		if s[end]=='A'
			ca+=1
		end
	end
	println(ans+min(ca,cb)-(ca==cb==cab>0 ? 1 : 0))
end
main()


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

int main(){
    int n;cin>>n;
    vin h(n);
    rep(i,n)cin>>h[i];
    reverse(all(h));
    rep(i,n-1){
        if(h[i]>=h[i+1])continue;
        else if(h[i]+1==h[i+1])h[i+1]=h[i];
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

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

ll dfs(vector<vector<int>> const& g, vector<bool> &visited, ll k, int now, int par) {
  ll ans = 1;
  ll childNum = g[now].size();
  visited[now] = true;
  if (g[now].size() > k) return 0;
  if (par == -1) {
    for (int i = 1; i <= childNum; ++i) {
      ans *= (k - i);
      ans %= MOD;
    }
    for (auto&& to : g[now]) {
      ans *= dfs(g, visited, k, to, now);
      ans %= MOD;
    }
  } else {
    // childNum -= 1;
    for (int i = 2; i <= childNum; ++i) {
      // cout << (k - i) << endl;
      ans *= (k - i);
      ans %= MOD;
    }
    for (auto&& to : g[now]) {
      if (!visited[to]) {
        ans *= dfs(g, visited, k, to, now);
        ans %= MOD;
      }
    }
  }
  return ans % MOD;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> g(n);
  vector<bool> visited(n, false);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  ll ans = k * dfs(g, visited, k, 0, -1); 
  cout << ans % MOD << endl;
}


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

using namespace std;
typedef long long int ll;
#define LL_HALFMAX 9223372036854775807 / 2	

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll result = LL_HALFMAX;
    ll addcost = 0;
    for(ll bit = 0; bit <(1<<n); bit++)
    {
        ll cost = 0;
        ll look = 0;
        ll hmax = a[0] - 1;
        for(ll i = 0; i < n; i++)
        {
            if(a[i] > hmax)
            {
                hmax = a[i];
                look++;
            }
            else if(bit&(1ll<<i))
            {
                addcost = hmax - a[i] + 1;
                look++;
                hmax += 1;
                cost += addcost;
            }
        }
        if(look >= k)
        {
            result = min(result,cost);
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3540
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = long.Parse(buffer[0]);
            var K = long.Parse(buffer[1]);

            var tmp = N - N / K * K;
            var tmp2 = Math.Abs(tmp - K);

            Console.WriteLine(Math.Min(tmp, tmp2));
        }
    }
}


Measured memory_bytes: 27448
def composite(d,n,s):
    for a in (2,3,5,7):
        maybe_prime = False
        if pow(a,d,n) == 1:
            maybe_prime = True
            continue
        for i in range(s):
            if pow(a, 2**i * d, n) == n-1:
                maybe_prime = True
                break
        return not maybe_prime
    return False

def is_prime(n):
    if n==2:
        return True
    elif n%2==0:
        return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return not composite(d,n,s)
r = []
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n):
      if n not in r:
          r.append(n)

print(len(r))

Measured memory_bytes: 7760
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

bool isOK(ll key, vector<ll> h, ll A, ll B) {
    ll cnt = 0;
    rep(i, h.size()) {
        h[i] -= (key * B);
        if (h[i] <= 0)
            continue;
        cnt += h[i] / (A - B) + (h[i] % (A - B) == 0 ? 0 : 1);
    }

    if (cnt <= key)
        return true;
    else
        return false;
}

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

    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    rep(i, N) { cin >> h[i]; }

    int ok = pow(10, 9), ng = 0;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(mid, h, A, B))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok << endl;
}


Measured memory_bytes: 4780
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define ll long long

int main()
{
    ll k, a = 1, b;
    cin >> k;
    b = 7 % k;

    while (b)
    {
        if (a > 1000000)
        {
            a = -1;
            break;
        }

        a++;
        b *= 10;
        b += 7;
        b %= k;
    }

    cout << a << "\n";
}

Measured memory_bytes: 3624
def main():
    #input
    N,M=map(int,input().strip().split())
    cnt=[0 for n in range(N)]
    flag=[0 for n in range(N)]
    
    for _ in range(M):
        pS=list(input().strip().split())
        x=int(pS[0])
        y=pS[1]
        if flag[x-1]==0:
            if y=="WA":
                cnt[x-1]+=1
            else:
                flag[x-1]=1
                
    num_AC=sum(flag)
    num_WA=sum([cnt[n] for n in range(N) if flag[n]==1])
                
    print(str(num_AC)+" "+str(num_WA))

if __name__=="__main__":
   main()

Measured memory_bytes: 5540
#include<stdio.h>
#include<math.h>
int main(){
    long n,k;
    scanf("%ld",&n);
    k=sqrt(n);
    for(long i=k;i>=1;i--){
        if(n%i==0){
            k=i;
            break;
        }
    }
    printf("%ld\n",k+n/k-2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll r, c, i, j, cb = 0, k;
    cin >> r >> c >> k;
    vector <string> a(r);
    for(i = 0; i < r; i++)
    {
        cin >> a[i];
        for(auto x: a[i])
            if(x == '#')
                cb++;
    }
    ll ans = 0;
    for(i = 0; i < (1 << r); i++)
    {
        for(j = 0; j < (1 << c); j++)
        {
            ll c1 = cb;
            for(ll m = 0; m < r; m++)
            {
                for(ll n = 0; n < c; n++)
                {
                    if(((i & (1 << m)) || (j & (1 << n))) && a[m][n] == '#')
                        c1--;
                }
            }
            if(c1 == k)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
const int inf = 1e9;
const int maxn = 1e5 + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a && c)
	{
		c -= b;
		if (c <= 0) { cout << "Yes"; break; }
		a -= d;
		if (a <= 0) { cout << "No"; break; }
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    ll ans=0;
    map<int,int> mp;
    rep(i,n){
        int a;
        cin>>a;
        ans += mp[i-a];
        mp[a+i]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 20996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  queue<int> Q;
  for(int i=0; i<pow(2,N); i++){
    int x;
    cin >> x;
    Q.push(x);
  }
  while(Q.size() >= 2){
    int x = Q.front();
    Q.pop();
    int y = Q.front();
    Q.pop();
    if(x == y){
      Q.push(x);
    }
    else{
      Q.push(abs(x-y));
    }
  }
  cout << Q.front() << endl;
}

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


int main(){
    int N, M; cin >> N >> M;
    vector<int> patterns(N);
    for (int i = 0;i <= M - 1; ++i) {
        int k; cin >> k;
        for (int j = 0; j <= k - 1; ++j) {
            int s; cin >> s; s--;
            patterns[s] |= 1 << i;
        }
    }

    int ans = 0;
    int condition = 0;
    for (int i = 0; i <= M - 1; ++i) {
        int x; cin >> x;
        condition |= x << i;
    }
    for (int s = 0; s < (1 << N); s++) {
        int t = 0;
        for (int i = 0; i < N; i++) {
            if (s >> i & 1) t ^= patterns[i];
        }
        if (t == condition) ans++;
    }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main = do
  [x1,y1,x2,y2] <- (return . map (read::String->Double) . words) =<< getLine
  print $ f (x1,y1) (x2,y2)
f (x1,y1) (x2,y2) = ((x1 - x2)**2 + (y1 - y2)**2)**0.5


Measured memory_bytes: 4108
#include <stdio.h>

int main(){
	char s[10];
	int i;
	for(i = 0; i < 10; i++){
		s[i] = getchar();
		if(s[i] == '\n' || s[i] == '\r') break;
	}
	s[i] ='\0';
	
	int s_index = 0;
	int s_len = i;
	int consec_b_count = 0;
	
	if(s[0] == 'B'){ // if first letter is B, don't need to delete anything beforehand
		while(s[s_index] == 'B'){
			s_index++;
		}
	}
	
	while(s_index < s_len){
		s_index++;
		if(s[s_index] == 'B' ){
			consec_b_count++;
		}
		else if( consec_b_count != 0){ // if we run into a 0 or a 1 after a B
			int index_to_change = s_index - consec_b_count;
			
			for(; consec_b_count > 0; consec_b_count--){
				
				if(index_to_change < 0){
					consec_b_count = 0;
					break;
				}
				while( s[index_to_change] !='0' && s[index_to_change] !='1' ){
					index_to_change--;
					if(index_to_change < 0){
						break;
					}
				}
				
				if(index_to_change < 0){
					consec_b_count = 0;
					break;
				}
				s[index_to_change] = 'X';
				index_to_change--;
				
			}
		}
		
	}
	
	i = 0;
	while(i < s_len){
		if(s[i] == '0' || s[i] == '1') printf("%c", s[i]);
		
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
n1 = sum([int(x) for x in s])
n2 = int(s[0])-1+9*(len(s)-1)
print(max(n1,n2))

Measured memory_bytes: 3564
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: usize = sc.cin();
    let a: usize = sc.cin();
    put!(if x<a { 0 } else { 10 });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#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>;

const int ALP_NUM = 26;
const int INF = 1001001001;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];
    vector<int> T;
    vector<set<int>> schedules(ALP_NUM);
    rep(i, ALP_NUM) schedules[i].insert(-1);
    

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        n = min(d, n);
        rep(i, n) {
            int t = A[i];
            if (t >= 0) {
                res += S[i][t];
                D[t] = i;
            }
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    auto change = [&](int nd, int nt) {
        int pt = T[nd];
        int res = S[nd][nt] - S[nd][pt];

        auto it_l = schedules[pt].lower_bound(nd);
        auto it_r = schedules[pt].upper_bound(nd);
        --it_l;
        int pt_ld = *it_l;
        int pt_rd;
        if (it_r != schedules[pt].end()) pt_rd = *it_r;
        else pt_rd = d;
        res -= C[pt] * (nd-pt_ld) * (pt_rd-nd);

        it_l = schedules[nt].lower_bound(nd);
        it_r = schedules[nt].upper_bound(nd);
        --it_l;
        int nt_ld = *it_l;
        int nt_rd;
        if (it_r != schedules[nt].end()) nt_rd = *it_r;
        else nt_rd = d;
        res += C[nt] * (nd-nt_ld) * (nt_rd-nd);

        return res;
    };

    rep(k, 26) {
        int max_score = -INF;
        vector<int> T_(d, -1);
        rep(i, d) {
            int max_score_ = -INF;
            int tmp = 0;
            T_[i] = 0;
            rep(j, ALP_NUM) {
                T_[i] = j;
                int score = get_score(T_, i+1+k);
                if (score > max_score_) {
                    max_score_ = score;
                    tmp = j;
                }
            }
            T_[i] = tmp;
        }
        int score = get_score(T_, d);
        if (max_score < score) {
            max_score = score;
            T = T_;
        }
    }
    

    rep(i, d) {
        cout << T[i]+1 << endl;
    }

    //cout << get_score(T, d) << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R')
	{
		cout<<"3"<<endl;
	}
	else if(s[0]=='R' && s[1]=='R')
	{
		cout<<"2"<<endl;
	}
	else if(s[1]=='R' && s[2]=='R')
	{
		cout<<"2"<<endl;
	}
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
	{
		cout<<"1"<<endl;
	}
	else
	cout<<"0"<<endl;
}

Measured memory_bytes: 3620
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}



int main() {
    fast_io();
    //read("input");
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << n - k << '\n';
    return 0;
}   


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    for(int a=0; a<=n; ++a){
        for(int b=0; b<=m; ++b){
            int x = a * (m - b) + b * (n - a);
            if(x == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include<string>
#include<vector>
#include<cmath>
#include <math.h>
using namespace std;
#include <iomanip>

int main() {
	double hl, ml, h, m;
	double ans;
	double angm, angh;
	double delta;
	cin >> hl >> ml >> h >> m;
	angm = m * 6;
	angh = (h+m/60) * 30;
	delta = abs(angm - angh);
	ans = pow(hl, 2) + pow(ml, 2) - 2 * ml * hl * cos(delta * M_PI / 180);
	cout << fixed << setprecision(20)<< pow(ans,0.5);
	return 0;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n,fa[N],f[N][2];
vector <int> a[N];
void search(int x){
	int s = 0;
	for (int i = 0; i < a[x].size(); i++)
		if (a[x][i] != fa[x]){
			fa[a[x][i]] = x;
			search(a[x][i]);
			s++;
		}
	if (s == 0){
		f[x][0] = 0;
		f[x][1] = 1;
		return;
	}
	f[x][0] = 0;
	f[x][1] = 0;
	int ma = 0;
	for (int i = 0; i < a[x].size(); i++)
		if (a[x][i] != fa[x]){
			if (f[a[x][i]][0] != 0)
			f[x][0] = n;
			f[x][1] += f[a[x][i]][1];
			ma = max(ma, f[a[x][i]][1] - f[a[x][i]][0]);
		}
	if (s != 1){
		f[x][0] = n;
		f[x][1] -= ma;
	}
}
int sea(int x){
	int s = 0;
	for (int i = 0; i < a[x].size(); i++)
		if (a[x][i] != fa[x]){
			fa[a[x][i]] = x;
			int xx = sea(a[x][i]);
			if (xx != -1) return xx;
			s++;
		}
	if (s > 1){
		return x;
	} return -1;
}
int main(){
	scanf("%d",&n);
	for (int i = 0; i < n; i++)
		a[i].clear();
	for (int i = 1; i < n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int x = sea(0);
	fa[x] = x;
	search(x);
//	printf("%d\n",x);
	printf("%d\n",f[x][1]);
}

Measured memory_bytes: 14592
#include<iostream>
#include<string>
#include<map>
#include<queue>
using namespace std;
typedef pair<string,int> P;
char color[3] = {'r','g','b'};
string com[3];
string str;
int len;
int bfs();

int main(){
	while(1){
		cin >> str;
		if(str == "0") break;
		len = str.size();
		for(int i=0;i<3;i++){
			com[i] = "";
			for(int j=0;j<len;j++){
				com[i] += color[i];
			}
		}
		int ans = bfs();
		if(ans == -1) cout << "NA" << endl;
		else cout << ans << endl;
	}
}

int bfs(){
	queue<P> que;
	que.push(P(str,0));
	map<string,int> dp;
	while(!(que.empty())){
		P p = que.front(); que.pop();
		string now = p.first;
		int cou = p.second;
		for(int i=0;i<3;i++){
			if(now == com[i]) return cou;
		}
		if(dp[now]) continue;
		dp[now] = 1;
		for(int j=0;j<len-1;j++){
			if(now[j] != now[j+1]){
				string tmp = now;
				for(int k=0;k<3;k++){
					if(tmp[j] != color[k] && tmp[j+1] != color[k]){
						tmp[j] = color[k];
						tmp[j+1] = color[k];
						break;
					}
				}
				que.push(P(tmp,cou+1));
			}
		}
	}
	return -1;
}

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

long N;
string S;

int main(void) {

    cin >> N;
    cin >> S;

    if (N >= S.length()) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0, N) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
n,m = map(int,input().split())
c=10**9+7
a = [-1 for _ in range(m + 1)]
for i in range(1, m+1):
	a[i] = int(input())
a = a+[n+1] 
for i in range(m+1):
    a[i] = a[i+1] - a[i] - 1
b = [0 for _ in range(max(a) + 1)]
b[1] = 1
for i in range(2, max(a)+1):
  	b[i] = (b[i-1] + b[i-2]) % c
s = 1
for i in range(m+1):
    s=(s * b[a[i]])%c
print(s)


Measured memory_bytes: 7848
N, A, B, C, D = map(int, input().split())

arr = [[A, B],[C, D]]
result = []
for line in arr:
    cnt = 0
    chg = 0
    while N > cnt:
        cnt += line[0]
        chg += line[1]
    result.append(chg)

print(min(result))



Measured memory_bytes: 5600
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll dp[k+1];
    f(i,n)
        cin>>a[i];
    memset(dp,0,sizeof(dp));
    f(i,k+1)
    {
        f(j,n)
        {
            if(a[j]<=i && dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n, ans = 0, k;
        cin >> n;
        ll a[n];
        ll co[100001] = {0};
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
            co[a[i]]++;
        }
        ll q, b, c;
        for(int i = 0; i < 100001; i++){
            ans += co[i]*i;
        }
        cin >> q;
        while(q--){
            cin >> b >> c;
            ans += c*co[b] - b*co[b];
            co[c] += co[b];
            co[b] = 0;
            std::cout << ans << "\n";
        }
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
	ll n, x;
	cin >> n >> x;

	ll a, b;
	a = 0;
	ll ans = 0;

	rep(i, n) {
		cin >> b;
		if (a + b - x > 0) {
			ans += a + b - x;
			b = x - a;
		}
		a = b;
	}

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

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

long long gcd(long long x, long long y) {
    if(y == 0) return x;
    return gcd(y,x%y);
}

long long lcm(long long x, long long y) {
    if(x == 0 || y == 0) return 0;
    return x / gcd(x,y) * y;
}

int main(){
    int n;
    cin >> n;
    if(n % 10 == 9 || n / 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

int main()
{
    string s1,s2;
    cin>>s1;
    cin>>s2;
    int count = INT_MAX;
    int j=0,i=0;
    int diff = s1.length()-s2.length();
    while(diff>=0)
    {
        int temp_i=i;
        int temp_count = 0;
        while(j<s2.length())
        {
            if(s1[temp_i]!=s2[j])
            {
                temp_count++;
            }
            temp_i++;
            j++;
        }
        if(temp_count<count)
        {
            count = temp_count;
        }
        diff--;
        i++;
        j=0;
    }
    cout<<count<<"\n";
}

Measured memory_bytes: 3600
import Control.Applicative
main = do xs <- lines <$> getContents
          putStr . unlines $ solve xs

solve :: [String] -> [String]
solve ("-":_)  = [] 
solve (s:m:xs) = shuffles s hs : solve rest
                    where (hs',rest) = splitAt (read m) xs
                          hs = map read hs'

shuffles :: String -> [Int] -> String
shuffles s hs = foldr shuffle s hs

shuffle :: Int -> String -> String
shuffle h s = af ++ bf
    where (bf,af) = splitAt h s

Measured memory_bytes: 4100
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  using psi =pair<string,int>;
  pair<psi,int> shop[110];
  for(int i=0;i<N;i++){
    string s;int p; cin >> s >> p;
    shop[i]=make_pair(make_pair(s,-p),i);
  }

  sort(shop,shop+N);

  for(int i=0;i<N;i++){
    cout << shop[i].second+1 << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
dp = [None for _ in range(n+1)]

def fib(i):
    if dp[i] is not None:
        return dp[i]
    if i==0:
        return 1
    if i==1:
        return 1
    dp[i] = fib(i-1) + fib(i-2)
    return dp[i]

print(fib(n))


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

namespace STDquantum {

template <typename T> inline void read(T &x) {
  char ch;
  int f = 1;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') f = -1;
  x = (ch ^ 48);
  while (ch = getchar(), isdigit(ch)) x = x * 10 + (ch ^ 48);
  x *= f;
}

int n;
inline void main() {
  scanf("%d", &n);
  for (int i = 1, x, y, cnt = 0; i <= n; ++i) {
    read(x), read(y);
    if (x == y) {
      ++cnt;
      if (cnt == 3) { return (void)puts("Yes"); }
    } else {
      cnt = 0;
    }
  }
  puts("No");
}

}  // namespace STDquantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("D:\\OI\\STDquantum\\test.in", "r", stdin);
  freopen("D:\\OI\\STDquantum\\test.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("B.in", "r", stdin);
  freopen("B.out", "w", stdout);
#endif
#endif
  STDquantum::main();
  return 0;
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,K=map(int,input().split())
P=tuple(map(int1,input().split()))
C=tuple(map(int,input().split()))
loop=[[-INF,0] for _ in range(N)]
used=[False]*N
for v in range(N):
    stack=[]
    d=0
    cnt=0
    while True:
        if not used[P[v]]:
            v=P[v]
            stack.append(v)
            used[v]=True
            d+=C[v]
            cnt+=1
        else:
            for vv in stack:
                loop[vv][0]=d
                loop[vv][1]=cnt
            break
ans=-INF
for i in range(N):
    d=0
    v=i
    for cnt in range(K):
        v=P[v]
        if loop[v][0]==-INF:
            d+=C[v]
            ans=max(ans,d)
        else:
            break
    loopstart=v
    MAX=-INF
    dd=0
    f=False
    for ccnt in range(1,K-cnt+1):
        loopn=(K-ccnt)//loop[loopstart][1]
        if v!=loopstart or not f:
            dd+=C[v]
            ans=max(ans,d+dd,d+dd+loopn*loop[loopstart][0])
            v=P[v]
        else:
            break
        f=True
print(ans)

Measured memory_bytes: 69732
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
/*union-find*/
const int MAX_N =20010;
int parent[MAX_N];//parent[x]=xの時xが根である
int rank[MAX_N];
void init(int V){
	for(int i= 0;i < V;i++){
		parent[i] = i;
		rank[i] =0;
	}
}

int find(int x){
	if(parent[x] == x)
		return x;
	else{
		return find(parent[x]);
	}
}

void unit(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y)
		return;
	if(rank[x] < rank[y]){
		parent[x] = y;
	}
	else{
		parent[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}
typedef pair<ll,pii> P;
int main(){
	int N,M;
	while(cin>>N>>M,N||M){
		init(N+1);
		priority_queue<P,vector<P>,greater<P> > que;
		for(int i = 0;i < M;i++){
			int t,s,d;
			cin>>t>>s>>d;
			que.push(P(t,pii(s,d)));
		}
		/*cout <<que.top().first<<" "<<que.top().second.first<<" "<<que.top().second.second<<endl;*/
		while(!que.empty()){
			if(que.top().second.first==1){
				unit(1,que.top().second.second);
			}else if(same(1,que.top().second.first)){
				unit(que.top().second.first,que.top().second.second);
			}
			que.pop();
		}
		int cnt = 0;
		for(int i = 1;i <=N;i++){
			if(same(1,i)){
				cnt++;
			}
		}
		cout <<cnt<<endl;
	}
	return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5, M = 109, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


void go(int tc){

    int n;  cin >> n;
    cout << 1000 * ceil(1.0 * n / 1000) - n;

}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

    int t = 1, tc = 1;
//    cin >> t;
    while(t--)  go(tc++);
}

Measured memory_bytes: 3740
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int p = int.Parse(input[0]);
    int q = int.Parse(input[1]);
    int r = int.Parse(input[2]);
    Console.WriteLine(Math.Min(p+q, Math.Min(q+r, r+p)));
  }
}


Measured memory_bytes: 11092
n = int(input())
h = [0] + list(map(int,input().split()))

ans = 0
for i in range(0,101):
    count = 0
    for j in range(n):
        if h[j] - i <= 0 and h[j+1] - i > 0:
            count += 1
    ans += count

print(ans)

Measured memory_bytes: 38896
a,b,k=map(int, input().split())

if (b-a+1)>2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
    

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
	int K, S;
	cin >> K >> S;
	int ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (0 <= z and z <= K) ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def partition(a,p,r):
    x=a[r]
    i=p-1
    for j in range(p,r):
        if(a[j]<=x):
            i+=1
            a[i],a[j]=a[j],a[i]
    a[i+1],a[r]=a[r],a[i+1]
    return i+1

n=int(input())
s=input()
a=list(map(int,s.split()))
m=partition(a,0,n-1)
a=list(map(str,a))
a[m]="[%s]"%(a[m])
print(" ".join(a))

Measured memory_bytes: 18916
#include <iostream>

int main()
{
	int r, c;
	std::cin >> r >> c;
	int a[r+1][c+1] {};
	for (int i=0; i!=r; ++i)
		for (int j=0; j!=c; ++j) {
			std::cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
			a[r][c] += a[i][j];
		}
	for (int i=0; i<=r; ++i) {
		for (int j=0; j<=c; ++j) {
			std::cout << a[i][j];
			if (j!=c) std::cout << ' ';
		}
		std::cout << '\n';
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    vector<int> b(n, 0);

    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            a--;

            b[a] = 1;
        }
    }

    int r = n;
    for (int i = 0; i < n; i++) {
        r -= b[i];
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3632
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 01, 2020 3:53 PM
 *    Problem Name  : B - Count ABC
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc150/tasks/abc150_b
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;
    cin >> s;

    int cnt=0;

    for(int i=0; i<s.length()-2; i++) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            cnt++;
    }

    cout << cnt << endl;
    return 0 ;
}


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

int main() {
  string  s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<pi, ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string s; cin>>s;
ll ans = 0,cnt=0;
for(auto x:s)
{
    if(x=='R')cnt++;
    else cnt=0;
    ans = max(ans,cnt);
}
cout<<ans<<endl;
return 0;
}
/*
23 5
10 3 3
2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22
4 6 3 18 23
*/


Measured memory_bytes: 3600
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(Math.max(a*b,c*d));
    }
}

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

constexpr int inf = 1e9;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), c(m);
    for(int i = 0; i < m; ++i) {
        int b;
        cin >> a[i] >> b;
        for(int j = 0; j < b; ++j) {
            int cc; cin >> cc;
            c[i] |= 1 << (cc - 1);
        }
    }

    vector<int> dp(1 << n, inf);
    dp[0] = 0;
    for(int i = 0; i < m; ++i) {
        auto nxt = dp;
        for(int S = 0; S < 1 << n; ++S) {
            if(dp[S] == inf) continue;
            const int nS = S | c[i];
            nxt[nS] = min(nxt[nS], dp[S] + a[i]);
        }
        dp = move(nxt);
    }

    if(dp.back() == inf) {
        cout << -1 << endl;
    } else {
        cout << dp.back() << endl;
    }
}


Measured memory_bytes: 256
// ABC132-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll mod=pow(10,9)+7;
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>> dp(2010,vector<ll>(2010,0));
    rep(i,2010) dp[i][0]=1;
    for(int i=1;i<2010;i++){
        for(int j=1;j<2010;j++){
            dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%mod;
        }
    }
    for(int i=1;i<=k;i++){
        ll ans=0;
        if(i<=n-k+1) ans=dp[n-k+1][i]*dp[k-1][i-1]%mod;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=55;
const ll M=1e9+7;
const ll inf=1e18;
int n;
ll k;
ll base[55][55];
void multiply(ll mat1[N][N],ll mat2[N][N])
{
	ll temp[N][N];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ll res = 0;
			for(int ii = 0;ii < n;ii++)
			{
				res = (res+mat1[i][ii]*mat2[ii][j])%M;
			}
			temp[i][j] = res;
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j= 0;j<n;j++)
			mat1[i][j] = temp[i][j];
	}
}
void power(ll mat[N][N],ll times)
{
	if(times<2)
		return ;
	power(mat,times/2);
	multiply(mat,mat);
	if(times&1)
		multiply(mat,base);

}

int main()
{
	// in this problem we just have to multiply the matrix k times
	scn(n);
	lscn(k);

	ll mat[N][N];
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			lscn(mat[i][j]);
			base[i][j] = mat[i][j];
		}
	}

	power(mat,k);

	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans = (ans+mat[i][j])%M;
		}
	}
	lpri(ans);

}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

mod = 10 ** 9 + 7
dp = [0] * (k + 1)

dp[0] = 1

for i in a:
    neg = [0] * (k + 1)
    s = 0
    dp2 = [0] * (k + 1)
    
    for j in range(k + 1):
        s += dp[j]
        s %= mod
        dp2[j] = s
        neg[min(k, j + i)] += dp[j]
        s -= neg[j]
    
    dp = dp2

print(dp[-1])

Measured memory_bytes: 118476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int n = sca.nextInt();
	int[] ai = new int[n];
	for(int i = 0; i < n; i++) {
		ai[i] = sca.nextInt();
	}

	boolean bool = true;
	for(int i = 0; i < n; i++) {
		if(ai[i] % 2 == 0) {
			if(ai[i] % 3 == 0 || ai[i] % 5 == 0) {
				continue;
			}
			else {
				bool = false;
				break;
			}
		}
	}

	if(bool == true) {
		System.out.println("APPROVED");
	}
	else {
		System.out.println("DENIED");
	}
	// ArrayList<String> list = new ArrayList<String>();
	// list.add("");

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}



int main(void){
  int n, l;
  cin >> n >> l;

  if (n < 1 - l)
    cout << n*(l-1) + n*(n+1)/2 -n-l+1 << endl;
  else if (l > 0)
    cout << n*(l-1) + n*(n+1)/2 -l << endl;
  else
    cout << n*(l-1) + n*(n+1)/2  << endl;

  

  return 0;
}


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

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

using namespace std;

typedef long long ll;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int sumE[N] = {0};
    int sumW[N] = {0};
    REP(i, N)
    {
        if (i == 0)
        {
            if (S[i] == 'E') sumE[i]++;
            else sumW[i]++;
        }
        else
        {
            sumE[i] = sumE[i - 1];
            sumW[i] = sumW[i - 1];
            if (S[i] == 'E') sumE[i]++;
            else sumW[i]++;
        }
    }

    int ans = N;
    REP(i, N)
    {
        if (i == 0)
        {
            ans = min(ans, sumE[N - 1] - sumE[i]);
        }
        else if (i == N - 1)
        {
            ans = min(ans, sumW[i - 1]);
        }
        else
        {
            ans = min(ans, sumW[i - 1] + sumE[N - 1] - sumE[i]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int i,j,n,m;
    cin >> n;
    cout <<!n<<endl;

    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
  //  cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
    return 0;
}



Measured memory_bytes: 3588