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

int main(){
  int N,K;
  cin>>N>>K;
  int n=max(N,K)+1;
  vector<double> p(n,0);
  double prob=1.0;
  int i=n-1;
  while(i>=K){
    p.at(i)=1.0;
    i--;
  }
  while(1){
    K=(K-1)/2+1;
    prob/=2.0;
    while(i>=K){
      p.at(i)=prob;
      i--;
    }
    if(K==1){
      break;
    }
  }

  double sum=0;
  sort(p.begin()+1,p.begin()+N);
  for(int i=1;i<=N;i++){
    sum+=p.at(i);
  }
  sum=sum/(double)N;

  printf("%.10lf\n",sum);
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, k, result = 0;
  cin >> n >> k;
  ll x[n];
  rep(i, n) cin >> x[i];
  rep(i, n) {
    ll a = fabs(k - x[i]);
    if (x[i] > a) result += a * 2;
    else result += x[i] * 2;
  }
  cout << result << endl;
}

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 == 0 && i % 5 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int n, minr, maxdel=-1*INF;
  cin >> n >> minr;
  
  REP(i,n-1) {
    int R;
    cin >> R;
    chmax(maxdel, R-minr);
    chmin(minr,R);
  }
  cout << maxdel << endl;
  
  return 0;
}


Measured memory_bytes: 3096
def pair (inp):
    from collections import Counter
    z=max(inp)
    arr=[1]*(z+1)
    c=Counter(inp)
    c[1]=0
    if max(c.values())>=2:
        return -1
    for i in range(2,z+1):
        if arr[i]==1:
            k=2
            if c[i]>=1:
                f=1
            else:
                f=0
            while k*i<len(arr):
                arr[k*i]=0
                if c[k*i]!=0:
                    f+=c[k*i]
                k+=1
            if f>=2:
                return -1
    return 1
def gcd (a,b):
    if a%b==0:
        return b
    if b%a==0:
        return a
    if a>b:
        return gcd(b,a%b)
    if b>a:
        return gcd(a,b%a)
n=int(input())
arr=list(map(int,input().split()))
if pair(arr)==1:
    print ('pairwise coprime')
else:
    k=arr[0]
    for i in range(1,len(arr)):
        k=gcd(k,arr[i])
        if k==1:
            break
    if k==1:
        print ('setwise coprime')
    else:
        print ('not coprime')


Measured memory_bytes: 134632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		char[][] ch = new char[8][8];
		Scanner sc = new Scanner(System.in);
		String str;
		for(int i=0;i<8;i++){
			str = sc.next();
			for(int j=0;j<8;j++){
				ch[i][j] = str.charAt(j);
			}
		}
		
		System.out.println(90);
		for(int j=0;j<8;j++){
			for(int i=7;i>=0;i--){
				System.out.print(ch[i][j]);
			}
			System.out.println();
		}
		
		System.out.println(180);
		for(int i=7;i>=0;i--){
			for(int j=7;j>=0;j--){
				System.out.print(ch[i][j]);
			}
			System.out.println();
		}
		
		System.out.println(270);
		for(int j=7;j>=0;j--){
			for(int i=0;i<8;i++){
				System.out.print(ch[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17144
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n){
    cin>>h[i];
  }
  vector<ll> cost(n,INF);
  cost[0]=0;
  if(n==2){
    cout << abs(h[0]-h[1]) << endl;
    return 0;
  }
  else if(n==3){
    cout << min(abs(h[0]-h[1]),abs(h[0]-h[2])) << endl;
    return 0;
  }

  rep(i,n-1){
    if(i==n-2){
      cost[i+1] = min(cost[i+1],cost[i]+abs( h[i+1]-h[i] ));
    }
    else{
      cost[i+1] = min(cost[i+1],cost[i]+abs( h[i+1]-h[i] ));
      cost[i+2] = cost[i] + abs(h[i+2] - h[i]);
    }

  }
  /*
  rep(i,n){
    cout << cost[i] << endl;
  }
  */
  cout << cost[n-1] << endl;

  return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld n,i,j,k;cin>>n>>k;
   vector<string>s;string st;
    rep(i,0,n)
    {
    	cin>>st;s.PB(st);
    }
    sort(s.begin(), s.end());
    rep(i,0,n)
    cout<<s[i];
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int INF = 10010010;

int main() {
	int N, M;
	cin >> N >> M;

	vector <int> a(M);
	vector <int> dec(M);	//ベクタc[ii]をinteger値に変換したもの
	for (int ii = 0; ii < M; ++ii){
		int b;
		cin >> a[ii] >> b;
		for (int jj = 0; jj < b; ++jj){
			int c;
			cin >> c;
			c--;
			dec[ii] += (1<<c);
		}
	}

	int stateNum = (1<<N);
	vector <int> dp(stateNum, INF);	//最小値
	vector <bool> visit(stateNum, false);
	visit[0] = true;
	dp[0] = 0;
	for (int state = 0; state < stateNum; ++state){
		if (!visit[state]) continue;
		for (int jj = 0; jj < M; ++jj){
			int newState = state | dec[jj];
			visit[newState] = true;
			dp[newState] = min(dp[newState], dp[state] + a[jj]);
		}
	}

	if (visit[stateNum-1]){
		cout << dp[stateNum-1] << "\n";
	} else {
		cout << -1 << "\n";		
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BRACK 2

void bfc(int);
void enqueue(int);
int dequeue(void);

int n,M[N][N],p[N],head,tail,color[N];
int d[N];

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

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

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

bfc(0);

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


return 0;
}

void bfc(int s){
 int i,j;
  for(i = 0;i < n;i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  enqueue(s);
  while(head != tail){
    i = dequeue();
    for(j = 0;j < n;j++){
      if(color[j] == WHITE && M[i][j] == 1){
        color[j] = GRAY;
        d[j] = d[i] + 1;
        enqueue(j);
      }
    }
    color[i] = BRACK;
  }
}




void enqueue(int x){
p[tail] = x;
tail++;
}

int dequeue(void){
	int x;
	x = p[head];
	head++;
	return x;  
}

Measured memory_bytes: 636
def ans(H):
  if len(H) == 2:
    return (H[0]+H[1])/2
  else:
    n = len(H)
    return (ans(H[0:n-1])+H[n-1])/2

N = int(input())
H = [int(x) for x in input().split()]
H.sort()

print(ans(H))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
const int MOD = 1000000007;
//------------------------------------------------------------------------------
void _main()
{
    int N;
    string S;
    int K;
    cin >> N >> S >> K;
    rep(i, 0, N)
    {
        if (S[i] != S[K - 1])
        {
            S[i] = '*';
        }
    }
    cout << S << endl;
}


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

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

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,s,i,j;
string st,st1;
long long ans;
int main()
{
	cin>>st;st=" "+st;
	for(i=1;i<st.length();i++){
		if(st[i]=='B'&&st[i+1]=='C'){
			st1+="D";i++;
		}
		else{
			st1.push_back(st[i]);
		}
	}
	for(i=0;i<st1.size();i++){
		if(st1[i]=='A'){
			s++;
		}
		else if(st1[i]=='D'){
			ans+=s;
		}
		else{
			s=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 832
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int N, A;
    cin >> N >> A;
    cout << N*N - A << endl;
}

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

int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int cnt=0;
    while(A>=B){
        B=B*2;
        cnt++;
    }
    while(B>=C){
        C=C*2;
        cnt++;
    }
    if(cnt<=K){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vsort(a);
	rv(a);
	int suma = 0;
	int sumb = 0;
	rep(i, n) {
		if (i % 2 == 0) suma += a[i];
		else sumb += a[i];
	}
	cout << suma - sumb << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c;
cin>>a>>b>>c;
if(a%2 == 0 || b%2 == 0 || c%2 == 0) cout<<0<<endl;
else cout<<min(a*b,min(a*c,b*c))<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

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


using namespace std;

int main(void){
    int n;
    int t, f, r;
    int tt , ff , rr;
    int s;
    string str;
    while (cin>>n && n){
        t=1,f=2,r=3;
        s=1;
        REP(i,n){
            cin >> str;
            if (str=="North"){
                tt=f;
                ff=7-t;
                t=tt;
                f=ff;
            }else if (str=="East"){
                tt=7-r;
                rr=t;
                t=tt;
                r=rr;
            }else if (str=="South"){
                tt=7-f;
                ff=t;
                t=tt;
                f=ff;
            }else if (str=="West"){
                tt=r;
                rr=7-t;
                t=tt;
                r=rr;
            }else if (str=="Right"){
                ff=r;
                rr=7-f;
                f=ff;
                r=rr;
            }else if (str=="Left"){
                ff=7-r;
                rr=f;
                f=ff;
                r=rr;
            }
            s+=t;
//            cout << s << endl;
        }
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#define NMAX 100000
int main(void)
{
  int i, n, lcnt = 1, lsz = 2, ans = 0, lgrp[NMAX+2] = {0};
  char light[NMAX];
  scanf("%d%*c", &n);
  for (i = 0; i < n; i++) {
    light[i] = getchar_unlocked();
    getchar_unlocked();
  }
  for (i = 1; i < n; i++) {
    if (light[i] == light[i-1]) {
      lgrp[lsz++] = lcnt;
      lcnt = 0;
    }
    lcnt++;
  }
  lgrp[lsz++] = lcnt;
  for (i = 2; i < lsz; i++) {
    int tans = lgrp[i-2] + lgrp[i-1] + lgrp[i];
    if (ans < tans) ans = tans;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2284
#include <bits/stdc++.h>
#include <string>
 
using namespace std;
 
int main() {
  long long N;
  long long SUM = 0;
  string input;
  cin >> N;
  cin >> input;
  
  if (N < 3) {
    cout << 0 << endl;
  }
  else {
  	for (long long i = 0; i <= N - 3; i++) {
  	  string sub = input.substr(i, 3);
      if (!sub.compare("ABC")) SUM += 1;
    }
    cout << SUM << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
 
int p[100001],s[100001],l,r;
long long f[100001];
int main(){
	int n,e,t;scanf("%d%d%d",&n,&e,&t);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	long long z=2e9;
	for(int i=1;i<=n;i++){
		s[++r]=i;
		for(;2*(p[i]-p[s[l]])>=t;l++)
			z=min(z,f[s[l]-1]-2*p[s[l]]);
		f[i]=f[s[l]-1]+t;
		f[i]=min(f[i],2*p[i]+z);
	}
	cout<<f[n]+e;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl a(n), s(n+1);
    rep(i,n) cin >> a[i];
    rep(i,n) s[i+1] = s[i] + a[i];

    map<ll,ll> mp;
    mp[0] = 1;
    rep(i,n){
        if(mp.count(s[i+1])) mp[s[i+1]]++;
        else mp[s[i+1]] = 1;
    }

    ll ans = 0;
    for(auto p : mp){
        ll x = p.se;
        ans += x*(x-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18644
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	int widthCount = 0, heightCount = 0;
	string tmp;

	cin >> widthCount >> heightCount;

	vector<int> width(widthCount);
	for(int i = 0; i < widthCount; i++){
		width[i] = i + 1;
	}
	
	pair<int,int> height;
	/*height.first = vector<int>(heightCount,0);
	height.second = vector<int>(heightCount,0);*/

	char *a = new char[4];
	char *tp;

	for(int i = 0; i < heightCount; i++){
		cin >> tmp;
		
		strcpy(a,tmp.c_str());
		
		tp = strtok(a,",");
		height.first = atoi(tp);
		tp = strtok(NULL,",");
		height.second = atoi(tp);

		swap(width[height.first - 1],width[height.second - 1]);

	}

	for(int i = 0; i < widthCount; i++){
		cout << width[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nmq = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var q = new IntegerPair[nmq[2]];
            for (var i = 0; i < nmq[2]; i++)
            {
                var abcd = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                q[i] = new IntegerPair { A = abcd[0], B = abcd[1], C = abcd[2], D = abcd[3] };
            }

            var max = 0;
            void Dfs(IEnumerable<int> items)
            {
                var list = items.ToList();
                if (items.Count() == nmq[0])
                {
                    var current = 0;
                    current = q.Where(x => list[x.B - 1] - list[x.A - 1] == x.C).Sum(x => x.D);
                    max = Math.Max(max, current);
                    return;
                }

                var last = list.LastOrDefault();
                list.Add(last != 0 ? last : 1);
                while (list.LastOrDefault() <= nmq[1])
                {
                    Dfs(list);
                    list[list.Count() - 1]++;
                }
            }

            Dfs(new int[] { 1 });
            Console.WriteLine(max);
        }

        public struct IntegerPair
        {
            public int A { get; set; }
            public int B { get; set; }
            public int C { get; set; }
            public int D { get; set; }

        }
    }
}


Measured memory_bytes: 41056
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int n;
	cin >> n;
	int ans = 0;
	
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			if (i - 1 != 0 && n / (i - 1) == n % (i - 1)) {
				ans += i;
				ans--;
			}
			//cout << i << endl;
			if (i*i != n)
			{
				if (n / i - 1 != 0 && n / (n / i - 1) == n % (n / i - 1)) {
					ans += n / i;
					ans--;
				}
				//cout << n / i << endl;
			}
		}
	}
	cout << ans << endl;

	return 0;
}



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

int main(){
  int n, a, b;
  cin>>n>>a>>b;
  string ans;
  for(int i=0;i<n;i++){
    if (a+1 == b){
      ans="Borys";
      break;
    }else{
      a++;
    }
    if (b-1==a){
      ans="Alice";
      break;
    }else{
      b--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <unordered_set>
#include <stack>
#include <iomanip>
using namespace std;

#define ii pair<int, int>

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

    int n;
    long long x; 
    unordered_map<long long, int> freq;
    vector<int> occurence;
    vector<long long> a;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        if(freq.count(x))
            freq[x]++;
        else freq[x] = 1;
    }
    for(auto& it : freq){
        a.push_back(it.first);
        occurence.push_back(it.second);
    }
    if(a.size()==1 && a[0]==0){
        cout << "Yes\n";
        return 0;
    }
    if(a.size()==2){
        if((a[0]==0 && occurence[1]==2*occurence[0])
        || (a[1]==0 && occurence[0]==2*occurence[1]))
            cout << "Yes\n";
        else cout << "No\n";
        return 0;
    }
    if(a.size()!=3){
        cout << "No\n";
        return 0;
    }
    if(occurence[0]!=occurence[1] || occurence[1]!=occurence[2] || occurence[2]!=occurence[0]){
        cout << "No\n";
        return 0;
    }
    if((a[0]^a[1])!=a[2]){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#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++)

int64_t gcd(int64_t a, int64_t b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int64_t lcm(int64_t a, int64_t b)
{
   return a * b / gcd(a, b);
}

int main() {
    int64_t A, B;
    cin >> A >> B;
    cout << lcm(max(A, B), min(A, B)) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int f=0;
	int V, E;	
	cin >> V >> E;
	
	int s, t;
	int A[V][V];
	int B[V][V];
	int C[V][V];
	for(int i=0; i<V; i++){
		for(int j=0; j<V; j++){
			A[i][j] = 0;
			C[i][j] = 0;
		}}
	for(int i=0; i<E; i++){
		cin >> s >> t;
		A[s][t] = 1;
		C[s][t] = 1;
	}

	for(int cnt=1; cnt<=V; cnt++){
		for(int i=0; i<V; i++){
			if(C[i][i] >= 1){
				f = 1;
				break;
			}
		}

		for(int i=0; i<V; i++){
			for(int j=0; j<V; j++){
				B[i][j]=0;
				for(int k=0; k<V; k++){
					B[i][j] += A[i][k]*C[k][j];
				}
			}
			for(int j=0; j<V; j++){
				if(1<B[i][j]) B[i][j] = 1;
				C[i][j] = B[i][j];
			}
		}
	}

	if(f==1){
		cout << 1 << endl;
	} else{ cout << 0 << endl; }
	
	return 0;
}



Measured memory_bytes: 3212
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int N, M; cin >> N >> M;
  int A[N+1]; FOR(i,1,N+1) cin >> A[i];
  FOR(k,1,M+1) {
    int j = 1;
    while(j != N) {
      if(A[j]%k>A[j+1]%k) swap(A[j], A[j+1]);
      j = j + 1;
    }
  }
  FOR(i,1,N+1) cout << A[i] << '\n';
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define mod 1000000007  
#define int long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

signed main(){
  fast_cin();
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++){
          cin>>arr[i];
        }
        int stool=0;
        for(int i=0;i<n;i++){
          if(i+1!=n){
            if(arr[i]>arr[i+1]){
              int a=arr[i]-arr[i+1];
              stool+=a;
              arr[i+1]=a+arr[i+1];

            }
          }
        }
        cout<<stool;


          
          
      }
          

    

      
        


      
       
    
    
  
      

      




Measured memory_bytes: 5192
n,m = map(int,input().split())
S = []
C = []
for i in range(m):
  s,c = map(int,input().split())
  S.append(s)
  C.append(c)
ans =[0]*n
dic =[0]*n
if 1 in S :
  if C[S.index(1)] == 0 and n!=1:
    print(-1)
    exit()

    
for i in range(m):
  if dic[S[i]-1] == 0:
    ans[S[i]-1] = C[i]
    dic[S[i]-1] +=1
  elif ans[S[i]-1] !=C[i]:
    print(-1)
    exit()
if n!=1:
  result = max(1,ans[0])*10**(n-1)
  for i in range(1,n):
    result += ans[i]*10**(n-1-i)
else:
  result = max(0,ans[0])

print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
// #include<vor>
using namespace std;
typedef long long int ll;
#define pb push_back
ll mod = 1e9+7;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

ll gcd(ll a , ll b)
{
  if(a == 0)
  return b;
  return gcd(b%a , a);
}

vector<int>adj[1000001] , ans;
int dis[1000001] , cnt[1000001];
bool vis[1000001];



int freq[1000001];
void solve()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[m];
    long sum = 0;
    for(int i = 0;i<m;i++)
    {
      cin>>a[i];
      sum += a[i];
    }
    if(sum <= n)
    cout<<n-sum<<"\n";
    else cout<<"-1\n";

}

int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if ( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H ){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 3080
hw = list(map(int, input().split()))
h = hw[0]
w = hw[1]

if (h == 1) or (w == 1):
    print(1)
elif (h % 2 == 0) or (w % 2 == 0):
    print(int(h*w/2))
else:
    print(int(h*w/2)+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main(){
    speed;
    int n;
    int maxn=0;
    int temp=0;
    cin >> n;
    vector <int>vc(n);
    for ( int i=0;i<n;i++){
        cin >> vc[i];
    }
        for ( int i = 0; i < n-1;i++){
            if (vc[i] >= vc[i+1]){
                temp++;
            }else{
                temp=0;
            }
        maxn=max(temp,maxn);
        }
    cout << maxn;
}





Measured memory_bytes: 640
a,b,c=map(int,input().split())
x = max(a,b,c)
z = min(a,b,c)
y =a+b+c-x-z
if (y-z)%2 == 0:
  result = x-y+(y-z)/2
else:
  result = x-y+(y-z)/2+2
print(int(result))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k, a[100008], x, x_modify, ans;

int main(){
	cin >> n >> k;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	
	x = 0; ll digit = 0;
	for(ll j = 0; j <= 40; j++){if(k&(1LL<<j)){digit = j;}}
	//cout << digit << k << endl;
	for(ll j = 0; j <= 40; j++){
		ll vote = 0;
		for(ll i = 1; i <= n; i++){if(!(a[i]&(1LL<<j))){vote++;}}
		if(vote >= n-vote){
			x |= (1LL<<j);
		}
	}
	//modify
	ll ans = 0;
	for(ll j = digit; j >= -1; j--){
		x_modify = 0;
		ll ansbuf = 0;
		if(j == digit+1 || j == -1 || k&(1LL<<j)){
			for(ll jj = digit; jj >= j+1; jj--){if(k&(1LL<<jj)){x_modify |= (1LL<<jj);}}
			for(ll jj = j-1; jj >= 0; jj--){if(x&(1LL<<jj)){x_modify |= (1LL<<jj);}}
			for(ll i = 1; i <= n; i++){ansbuf += x_modify^a[i];}
			ans = max(ansbuf, ans);
		}
	}
	
	//cout << x_modify << endl;
	if(k == 0){ans = a[1];}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k; cin>>n>>k;
    string s; cin>>s;
    s[k-1]+=32;
    cout<<s<<endl;
}


Measured memory_bytes: 3580
N, M = map(int, input().split())
mod = 1e+9+7
flags = [True  for i in range(N+1)]
for i in range(M):
    tmp = int(input())
    flags[tmp-1] = False
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 2

if not flags[0]:
    dp[0] = 0
    dp[1] = 1
if not flags[1]:
    dp[1] = 0
for i in range(2, N):
    if flags[i]:
        dp[i] = int((dp[i-1] + dp[i-2]) % mod)
print(dp[N-1])
    
    

Measured memory_bytes: 7832
n,m=map(int,input().split())
Y=[0]*m
P=[0]*m
for i in range(m):
    P[i],Y[i]=map(int,input().split())
yp=list(zip(Y,P,range(m)))
yp.sort()
underdigit=[0]*(n+1)
ans=[""]*m
for y,p,i in yp:
    underdigit[p]+=1
    ans[i]="%06d%06d" %(p,underdigit[p])
for a in ans:
    print(a)


Measured memory_bytes: 31380
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));
const ld eps = 0.0000000001;

ld f(ld a, ld b, ld x){
    ld ans=0;
    if(a*a*b/2.0 <= x){
        ans=atan(2*(a*a*b-x)/(a*a*a));
    }else{
        ans=pi/2-atan(2*x/(a*b*b));
    }
    return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a,b,x;
  cin >> a >> b >> x;
    
  cout << f(a,b,x)*180.0/pi << endl;
}

Measured memory_bytes: 384
while 1:
  H,W = map(int,input().split())
  if H == W == 0:
    break
  else:
    for i in range(H):
      for j in range(W):
        if  (i + j) % 2 == 0:
          print("#",end='')
        else:
          print(".",end='')
      print()
    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
public:
	using size_type = std::size_t;
	
	UnionFind(size_type n) : n(n), size_(n, 1) {
		par.resize(n);
		std::iota(par.begin(), par.end(), 0);
	}
	
	size_type size(size_type x) { return size_[find(x)]; }
	
	size_type find(size_type x) {
		assert(x < n);
		while (par[x] != x) {
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	void unite(size_type x, size_type y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size(x) > size(y)) std::swap(x, y);
		par[x] = y;
		size_[y] += size_[x];
	}
	
	bool issame(size_type x, size_type y) { return find(x) == find(y); }
	
private:
	size_type n;
	std::vector<size_type> size_, par;
};

int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	REP(i, N) scanf("%d %d", &X[i], &Y[i]);
	
	vector<int> ord(N);
	iota(ALL(ord), 0);
	sort(ALL(ord), [&](int x, int y) { return X[x] < X[y]; });
	
	UnionFind uf(N);
	set<pii> ss; // y 座標, idx
	
	int mn = INF, mnidx = INF;
	for (int i : ord) {
		int y = Y[i];
		while (true) {
			auto it = ss.lower_bound({y, -INF});
			if (it == ss.begin()) break;
			auto pr = prev(it);
			uf.unite(i, pr->second);
			if (pr != ss.begin()) {
				uf.unite(i, prev(pr)->second);
				ss.erase(pr);
			}
			else break;
		}
		ss.emplace(y, i);
	}
	
	REP(i, N) printf("%d\n", uf.size(i));
	return 0;
}


Measured memory_bytes: 12732
from collections import deque
def bfs(S,H,W,sh,sw):
    dist=[[-1]*W for i in range(H)]
    dist[sh][sw]=0

    d=deque()
    d.append([sh,sw])
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    lo=0
    while(len(d)!=0):
        h=d[0][0]
        w=d[0][1]
        d.popleft()
        for dir in range(4):
            nh=h+dx[dir]
            nw=w+dy[dir]
            if(nh>H-1 or nh<0 or nw>W-1 or nw<0):
                continue
            if(dist[nh][nw]!=-1 or S[nh][nw]=='#'):
                continue
            dist[nh][nw]=dist[h][w]+1
            lo=max(lo,dist[nh][nw])
            S[nh][nw]=='#'
            d.append([nh,nw])
    return lo

H,W=map(int,input().split())
S=[input() for i in range(H)]
ans=-1
for i in range(H):
    for j in range(W):
        if(S[i][j]!='#'):
            ans=max(ans,bfs(S,H,W,i,j))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n;
char s[maxn];

int main(){
	scanf("%s", s + 1);
	int ans = 0, x = 0;
	for(int i = 1;i <= 3;i++){
		if(s[i] == 'R') x++;
		else ans = max(ans, x), x = 0;
	}
	printf("%d", max(ans, x));
}

Measured memory_bytes: 3752
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#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>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int n;
    cin >> n;
    vector <int> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int m = inf;
    for (int i = 0; i < 100; ++i)
    {
      int s = 0;
      for (int j = 0; j < v.size(); ++j)
      {
        s += (v[j]-i)*(v[j]-i);
      }
      m = min(s,m);
    }
    cout << m;
  	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a = 0;
    int w = 0;
    int t = 0;

    int r = 0;
    string s;
    REP(i, n)
    {
        cin >> s;
        if (s == "AC")
            a++;
        else if (s == "WA")
            w++;
        else if (s == "TLE")
            t++;
        else if (s == "RE")
            r++;
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}


Measured memory_bytes: 3652
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#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 int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  string s; cin >> s;
  int c = 0, ans = 0;
  for(auto i : s) {
    if(i == 'R') c++;
    else {
      ans = max(ans, c);
      c = 0;
    }
  }
  ans = max(ans, c);
  cout << ans << '\n';
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

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

int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	vector<int> x(n);
	for(int i=0;i<n;i++) cin>>x[i];
	long long int res=0;
	for(int i=0;i<n-1;i++){
		res+=min(b,a*(x[i+1]-x[i]));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define int long long

using namespace std;

const int M=1000000007;

int ksm(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=res*a%M;
		b>>=1,a=a*a%M;
	}
	return res;
}

signed main()
{
	int n;
	scanf("%lld",&n);
	printf("%lld\n",((ksm(10,n)-ksm(9,n)*2+ksm(8,n))%M+M)%M);
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
bool isprime(int n,int k=2){if(n==1){return false;}if(n<k*k){return true;}if(n%k==0){return false;}return isprime(n,k+1);}int main(){int a,d,n,c;while(true){std::cin>>a>>d>>n;if(n==0){break;}c=0;while(c<n){if(isprime(a)){c++;}a+=d;}std::cout<<a-d<<std::endl;}}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const long double pi = 3.14159265358979323;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	ll a, b;
	cin >> a >> b;
	cout << (a * b) - (a) - (b) + 1;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int n = in();
  vector<Int> A(n);
  map<Int, int> M;
  for (int i = 0; i < n; ++i) {
    A[i] = lin();
    M[A[i]]++;
  }

  const auto del = [&] (const Int v) {
    --M[v];
    if (M[v] == 0) {
      M.erase(v);
    }
  };

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (M.count(A[i]) == 0) continue;
    del(A[i]);
    Int target = 1;
    while (target <= A[i]) target *= 2;
    if (M.count(target - A[i]) > 0) {
      ++res;
      del(target - A[i]);
    }
  }

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

  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  vl a(m);
  ll sum=0;
  rep(i,m){
    cin >> a[i];
    sum +=a[i];
  }
  if(sum>n){
    cout << -1 << endl;
  }
  else
    cout << n-sum << endl;
}


Measured memory_bytes: 3708
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i, N) for (int i = 0; i < N; ++i)
typedef long long int LL;

int N, M, a[100], b[100];
std::vector<int> G[100];
int S[100], D[100], ans;

void dfs(int p, int d, int pr)
{
	D[p] = d;
	for (auto i : G[p])
	{
		if (pr == i)
		{
			continue;
		}
		if (!D[i])
		{
			dfs(i, d + 1, p);
			if (!S[i])
			{
				++ans;
			}
			S[p] += S[i];
		}
		else if (D[p] > D[i])
		{
			S[i]--, S[p]++;
		}
	}
}
int main()
{
	in >> N >> M;
	rep(i, M) { in >> a[i] >> b[i]; }

	rep(i, M)
	{
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	dfs(1, 1, -1);
	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
b = na()
c = na()

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

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n; cin >> n;
    vector<ll> c(n);
    rep(i,n){
        cin >> c[i];
        c[i]--;
    }

    vector<ll> dp(n+1,0);
    dp[0] = 1;
    unordered_map<int,int> mp;
    for(int i=0;i<n;i++){
        // see c[i]
        if(i>=1 and c[i] == c[i-1]){
            dp[i+1] = dp[i];
            dp[i+1] %= mod;
        }
        else if(mp.count(c[i])){
            dp[i+1] = dp[i] + dp[mp[c[i]]+1];
            dp[i+1] %= mod;
        }
        else{
            dp[i+1]= dp[i];
            dp[i+1] %= mod;
        }
        mp[c[i]] = i;
    }
    cout << dp[n]<< endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    int si = s.size();
    reverse(ALL(s));

    rep(i, s.size())
    {
        if (si - i >= 5 && s.substr(i, 5) == "maerd")
            i += 4;
        else if (si - i >= 5 && s.substr(i, 5) == "esare")
            i += 4;
        else if (si - i >= 6 && s.substr(i, 6) == "resare")
            i += 5;
        else if (si - i >= 7 && s.substr(i, 7) == "remaerd")
            i += 6;
        else
        {
            OP("NO");
            return 0;
        }
    }
    OP("YES");
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int L = S.size();
  int l = T.size();
  
  int ans = l;

  
  for(int i=0; i<=L-l; i++){
    int count = 0;
    for(int j=0; j<l; j++){
      if(S.at(i+j) != T.at(j)){
        count++;
        
      }
    }
    ans = min(ans, count);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3588