akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  int n=0;
  string s;
  cin>>s;
  rep(i,4){
    if(s[i]=='+') n++;
    else n--;
  }

  cout<<n<<endl;


}

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

void bomber(string MAP[],int x,int y);

int main(){

    string MAP[8];
    int x,y,n,j=1;

    cin >> n;

    while(j <= n){
        for(int i=0; i<8; i++){
            cin >> MAP[i];
        }

        cin >> x >> y;

        bomber(MAP,x-1,y-1);

        cout << "Data " << j << ':' <<endl;

        for(int i=0; i<8; i++){
            cout << MAP[i] <<endl;
        }
        j++;
    }

    return 0;
}

void bomber(string MAP[],int x,int y){

    if(MAP[y][x] == '0'){
        return;
    }

    MAP[y][x] = '0';

    for(int i=1; i<4; i++){
        if(y-i < 0){
            break;
        }
        if(MAP[y-i][x] == '1'){
            bomber(MAP,x,y-i);
        }
    }

    for(int j=1; j<4; j++){
        if(y+j > 7){
            break;
        }
        if(MAP[y+j][x] == '1'){
            bomber(MAP,x,y+j);
        }
    }

    for(int k=1; k<4; k++){
        if(x-k < 0){
            break;
        }
        if(MAP[y][x-k] == '1'){
            bomber(MAP,x-k,y);
        }
    }

    for(int l=1; l<4; l++){
        if(x+l > 7){
            break;
        }
        if(MAP[y][x+l] == '1'){
            bomber(MAP,x+l,y);
        }
    }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int A,B;cin>>A>>B;
  string S;cin>>S;
  int flag=0;
  string ans;
  REP(i,A){
    if(S[i]=='-')flag=1;
  }
  if(S[A]!='-')flag=1;
  for(int i=A+1;i<=A+B;i++){
    if(S[i]=='-')flag=1;
  }
  if(flag)ans="No";
  if(!flag)ans="Yes";
  P(ans);
  return 0;
}


Measured memory_bytes: 256
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
char s[N];
int main()
{
    ll minn = INF,i,j,k;
    scanf("%s",s);
    for(i = 2;s[i];i++)
    {
        ll sum = 0;
        for(j = i-2;j <= i;j++)
        {
            sum = sum*10+(s[j]-'0');
        }
        sum = abs(sum-753);
        minn = min(minn,sum);
    }
    printf("%lld\n",minn);
    return 0;
}

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

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

#include <string>
#include <vector>
#include <algorithm>
int main(){
    int n,k; cin >> n >> k;
    int ans = 0,high;
    rep(i,n) {
        cin >> high;
        if (k <= high) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
# 190503 C
if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    H = list(map(int,input().split()))
    goodlist = [1] * N
    for i in range(M):
        tmpA,tmpB = list(map(int,input().split()))
        if H[tmpA-1] < H[tmpB-1]:
            goodlist[tmpA-1] = 0
        elif H[tmpA-1] > H[tmpB-1]:
            goodlist[tmpB-1] = 0
        else:
            goodlist[tmpA-1] = 0
            goodlist[tmpB-1] = 0
    print(sum(goodlist))


Measured memory_bytes: 19984
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); 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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char m;
  cin >>n ;
  ll max=0;
  ll tmp=0;
  REP(i,n){
    cin >>m;
    if(m=='I'){
      tmp++;
    }else{
      tmp--;
    }
    if(tmp>max) max=tmp;
  }

  cout << max <<endl;
  return 0;
}

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

int main(void){
    int n,m;
    long long ans=1;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
    }else{
        for(int i=1;i<=n;i++) ans = (ans*i)%MOD;
        for(int i=1;i<=m;i++) ans = (ans*i)%MOD;
        ans *= 1 + (n==m);
        ans %= MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 1e3+5;

ll n;
int main() {
	isc;
	cin >> n;
	cout << pow(n,2);
	
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import bisect

d = dict()

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def build_table():
    global d
    for i in range(1, 201):
        for j in range(1, 201):
            d[(i, j)] = gcd(i, j)

def query_gcd_3(a, b, c):
    g = d[(a, b)]
    return d[(g, c)]

def main():
    build_table()
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            for k in range(1, n + 1):
                ans += query_gcd_3(i, j, k)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 12780
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String A = "Sunny";
        String B = "Cloudy";
        String C = "Rainy";
      String N = "a";
      if(S.equals(B)) N = "Rainy";
      if(S.equals(C)) N = "Sunny";
      if(S.equals(A)) N = "Cloudy";
      
        System.out.println(N);
    }
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if( a + b + c >= 22 ) cout << "bust" << endl;
    else cout << "win" << endl;
}

/*

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N; ll K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) --A[i];
    vector<int> ord(N, -1);
    int way = 0, cir = 1;
    vector<int> ans;
    int cur = 0;
    while (ord[cur] == -1) {
        ord[cur] = sz(ans);
        ans.push_back(cur);
        cur = A[cur];
    }
    way = ord[cur];
    cir = sz(ans) - way;
    if (way > K) cout << ans[K] + 1 << '\n';
    else {
        K -= way;
        K %= cir;
        cout << ans[way + K] + 1 << '\n';
    }
    return 0;
}


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

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

    int n;
    cin >> n;
    ll sum = 0;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int t = a[0];
    for(int i = 1; i < n; ++i) {
        t = max(t, a[i]);
        if(a[i] < t) {
            sum += ll(t) - a[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {
	public static int MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long power = 1;
		for(int i = 1; i <= n; i++) {
			power *= i;
			power %= MOD;
		}

		System.out.println(power);
	}
}


Measured memory_bytes: 22612
let nab = readLine()!.characters.split(" ").map { Int(String($0))! }
let s = readLine()!.characters

var count = 0
var foreign = 0
for student in s {
    switch student {
    case "a" where count < nab[1] + nab[2]:
        print("Yes")
        count += 1
    case "b" where count < nab[1] + nab[2] && foreign + 1 <= nab[2]:
        print("Yes")
        count += 1
        foreign += 1
    default:
        print("No")
    }
}


Measured memory_bytes: 4592
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
 
int main(){
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i<8; i += 2){
       if(n >= pow(10, i)) ans += pow(10, i) - pow(10, i-1);
       else if(n >= pow(10, i - 1)) ans += n - pow(10, i-1) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
long long a[200010],mn = 100000000000000;
int main(){
	int i,n;
	cin >> n;
	long long sum = 0;
	for(i=0;i<n;i++){
		cin >> a[i];
		sum += a[i];
	}
	long long ans = 0;
	for(i=0;i<n;i++){
		ans += a[i];
		sum -= a[i];
		mn = min(mn,abs(ans - sum));
	}
	cout << mn << endl;
}

Measured memory_bytes: 1792
// Common Raccoon vs Monster
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    if (H - sum <= 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    
    return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n, W int
	fmt.Scan(&n, &W)
	w := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	sw := n * 3
	dp := make([][]int, n+1)
	for k := 0; k <= n; k++ {
		dp[k] = make([]int, sw+1)
	}
	for i := 0; i < n; i++ {
		for k := n - 1; k >= 0; k-- {
			for u := 0; u+(w[i]-w[0]) <= sw; u++ {
				src := dp[k][u]
				dst := &dp[k+1][u+(w[i]-w[0])]
				if src+v[i] > *dst {
					*dst = src + v[i]
				}
			}
		}
	}
	ans := 0
	for k := 1; k <= n; k++ {
		wmax := W - w[0]*k
		if wmax > sw {
			wmax = sw
		}
		if 0 <= wmax {
			for u := 0; u <= wmax; u++ {
				if ans < dp[k][u] {
					ans = dp[k][u]
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;


int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,mn,mx,sum=0;

    cin>>n;

    vector< ll > arr(n-1),ans;

    for(int i=0;i<n-1;i++)
    {
        cin>>arr[i];
    }

    ans.push_back(arr[n-2]);

    for(int i=n-2;i>=1;i--)
    {
        if(arr[i-1]<arr[i])
        {
            ans.push_back(arr[i-1]);
        }
        else
        {
            ans.push_back(arr[i]);
        }
    }

    ans.push_back(arr[0]);

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

    cout<<sum<<endl;


}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int t, x;
    cin >> t >> x;
    println((double)t/x);
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n;
  std::vector<std::string> xs;
  Solver() {
    S002 reader;
    reader >= n >n>= xs;
  }
  void solve() {
    long count[64][26] = {};
    for(long i = 0; i < n; ++i) {
      for(char c : xs[i]) {
        count[i][c-'a'] += 1;
      }
    }
    for(long i = 0; i < 26; ++i) {
      long t = 100;
      for(long j = 0; j < n; ++j) {
        t = std::min(t, count[j][i]);
      }
      for(long j = 0; j < t; ++j) {
        putchar('a' + i);
      }
    }
    putchar('\n');
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 764
S = input()
T = input()
ls = len(S)
lt = len(T)

m = 0
for i in range(ls-lt + 1):
    x = 0
    for j in range(lt):
        if S[j + i] == T[j]:
            x += 1
    m = max(x, m)
print(lt - m)


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    // 2a + 4b = y
    // a + 2b = y / 2
    // a + b = x

    if (y & 1) {
        cout << "No" << '\n';
        exit(0);
    }
    int hy = y / 2;
    if (hy >= x && (2*x - hy) >= 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3652
import collections

h,w = map(int,input().split())
tizu = [list(input()) for i in range(h)]

dy = [1,0,-1,0]
dx = [0,1,0,-1]

def f(y,x):
    for i in range(4):
        newy = y + dy[i]
        newx = x + dx[i]
        if 0 <= newy and newy < h and 0 <= newx and newx < w:
            if tizu[newy][newx] == ".":
                q.append((newy,newx))
                tizu[newy][newx] = "#"
            
q = collections.deque()
for i in range(h): 
    for k in range(w):
        if tizu[i][k] == "#":
            q.append((i,k))
ans = 0
while True:
    l = len(q)
    if l == 0:
        print(ans-1)
        exit()
    for i in range(l):
        yx = q.popleft()
        f(yx[0],yx[1])
    ans += 1


Measured memory_bytes: 117764
import io.{StdIn => in}

object Main extends App {
  val Array(k, a, b) = in.readLine.split(" ").map(_.toLong)

  def f(acc:Long, k:Int):Long = {
    if(k < 2) acc
    else f(acc - a + b, k-2)
  }

  val res = {
    val k1 = k - (a-1)
    val r = k1 % 2
    f(a,k1.toInt) + r
  }
  val ans = math.max(res, k+1)

  println(ans)
}

Measured memory_bytes: 27420
#include <chrono>
#include <vector>
#include <iostream>

using namespace std;
using namespace std::chrono;

const long long INF = 1e+18;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(n));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      cin >> v[i][j];

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int add = v[i][j];
      for (int k = 0; k < n; ++k) {
        if (i == k || j == k)
          continue;
        if (v[i][k] + v[k][j] < v[i][j])
          ans = -INF;
        if (v[i][k] + v[k][j] == v[i][j])
          add = 0;
      }
      ans += add;
    }
  }

  cout << max(ans, -1LL) << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


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

int main(void) {
  //input
  int A, B;
  cin >> A >> B;
  //calc
  int answer = 0;
  if ( A >=1 && A <= 9 && B >= 1 && B <= 9 ) {
    answer = A * B;
  }
  else {
    answer = -1;
  }
  //output
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    int P[N];
    rep(i,N) cin >> P[i];
    sort(P,P+N);
    int ans=0;
    rep(i,K) ans+=P[i];
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

template<typename T,T MOD = 1000000007>
struct Mint{
    T v;
    vector<Mint> fact;
    vector<Mint> fact_inv;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

    Mint pow(long long k){
        Mint res(1),tmp(v);
        while(k){
            if(k&1) res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }

    static Mint add_identity(){return Mint(0);}
    static Mint mul_identity(){return Mint(1);}

    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

    bool operator==(const Mint a)const{return v==a.v;}
    bool operator!=(const Mint a)const{return v!=a.v;}
    bool operator <(const Mint a)const{return v <a.v;}
    
    Mint comb(long long n,int k){
        Mint res(1);
        for(int i=0;i<k;i++){
            res*=Mint(n-i);
            res/=Mint(i+1);
        }
        return res;
    }
};

Mint<ll> P[200010];
void make(){
    P[0] = P[1] = 1;
    for(ll i=2;i<=200009;i++){
	P[i] = P[i-1]*Mint<ll>(i);
    }
}
Mint<ll> C(ll n , ll k ){
    return (P[n]/P[k])/P[n-k];
}
Mint<ll> func(ll r, ll c ){
 	return C(r+c,r);
}


int main(){
 ll n,a,b;
 cin>>n>>a>>b;
 //make();
 Mint<ll> ans(1);
 vector< Mint<ll> > beki( 32  );
 beki[0] = Mint<ll>(2);
 for(ll i=1;i<32;i++){
  beki[i] = beki[i-1]*beki[i-1];
  //cout<<i<<' '<<beki[i].v<<endl;
 }
 for(ll i=0;i<32;i++){
  if( (n>>i)&1 ){
   ans *= beki[i];
  }
 }
 Mint<ll> c;
 //cout<<ans.v<<endl;
 ans-= Mint<ll>(1);
 ans -= c.comb(n,(int)a);
 ans -= c.comb(n,(int)b);
 cout<<ans.v<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        vector<int> a(n), b(n);
        REP(i, n) cin >> a[i] >> b[i];

        auto dp = make_v(n + 1, h + 1, (int)1e8);

        dp[0][0] = 0;
        REP(i, n)REP(j, h + 1) {
                if (j + a[i] >= h) {
                        dp[i][h] = min(dp[i][h], dp[i][j] + b[i]);
                } else {
                        dp[i][j + a[i]] = min(dp[i][j + a[i]], dp[i][j] + b[i]);
                }

                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }

        cout << dp[n][h] << endl;

        return 0;
}


Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
int odd[200000];
int even[200000];
int main()
{
    int i,j,n,even1=0,even2=0,evennum,odd1=0,odd2=0,oddnum,cou=0,h;
    scanf(" %d",&n);
    h=n/2;
    for(i=1;i<=n;i++){
        if(i%2==1)  scanf(" %d",&odd[(i+1)/2]);
        else if(i%2==0) scanf(" %d",&even[i/2]);
    }
    sort(odd,odd+h+1);
    sort(even,even+h+1);
    for(i=1;i<=(n/2);i++){
        cou++;
        if(odd[i]!=odd[i+1]){
            if(cou>odd1){
                odd2=odd1;
                odd1=cou;
                oddnum=odd[i];
            }
            else if(cou>odd2){
                odd2=cou;
            }
            cou=0;
        }
    }
    cou=0;
    for(i=1;i<=(n/2);i++){
        cou++;
        if(even[i]!=even[i+1]){
            if(cou>even1){
                even2=even1;
                even1=cou;
                evennum=even[i];
            }
            else if(cou>even2){
                even2=cou;
            }
            cou=0;
        }
    }
    if(evennum==oddnum){
        if(even2>odd2)  printf("%d",n-even2-odd1);
        else printf("%d",n-even1-odd2);
    }
    else printf("%d",n-even1-odd1);
    return 0;
}


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

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

  for ( int i = 0; i < 26; i++){
    char moji = 'a' + i;
    bool flag = false;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == moji){
        flag = true;
      }
    }
    if(!flag){
      cout<<moji<<endl;
      return 0;
    }
  }
  cout << "None" <<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll ans = (n*(n-1))/2 + (m*(m-1))/2;
   cout<<ans;
   
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int main(){
	string s; cin >> s;
	int w; cin >> w;
	int len = s.length();
	for (int i = 0; i < len; i += w)cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
#include<unordered_map>


using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i = 0; i < n;i++){
        if(a[i]==b[i]&&c[i]!=a[i])
            cnt++;
            else if(b[i]==c[i]&&c[i]!=a[i])
            cnt++;
            else if(a[i]==c[i]&&b[i]!=a[i])
            cnt++;
            else if(a[i]!=c[i]&&a[i]!=b[i]&&b[i]!=c[i])
                cnt += 2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// void solve(){
      
      
    
// }

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
      cin>>s;
      int cnt=0,max=INT_MIN;
      
      for(int i=0;i<s.size();i++)
      {
            if(s[i] == 'R'){
                cnt++;
                continue;
            }
            else{
                
                if(max<cnt)
                max = cnt;
                cnt=0;
            }
        
      }
      if(max<cnt)
        max = cnt;
      cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n;
    cin >> n;
    int a[2][n + 1];
    fill(a[0], a[1]+n+1, 0);
    for (int i = 0; i <= 1; i++) for (int j = 1; j <= n; j++) {
        cin >> a[i][j];
        a[i][j] += a[i][j-1];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        chmax(ans, a[0][i] + a[1][n] - a[1][i-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a,m=0,c=0;
  scanf("%d",&n);
  while(n--){
    scanf("%d",&a);
    if(m<=a){
      c++;
      m=a;
    }
  }
  printf("%d\n",c);
  return 0;
}
  


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  lint n,x,m;cin>>n>>x>>m;
  vector<lint> a(m+5,0);
  a[1]=x;
  lint c=0;
  map<lint,int> memo;
  memo[a[1]]=0;
  lint key=0;
  bool first=true;
  for(int i=2;i<=m+1;++i){
    a[i]=a[i-1]*a[i-1]%m;
    if(memo.find(a[i])==memo.end()&&first){
      memo[a[i]]=i;//first=false;
    }
    else{
      c=i-memo[a[i]];
      key=memo[a[i]];
      memo[a[i]]=i;
    }
  }
  if(n<=m){
    lint res=0;
    rep1(i,n)res+=a[i];
    cout<<res<<"\n";
    return 0;
  }
  lint sm=0;
  for(int i=key;i<key+c;++i){
    sm+=a[i];
  }
  lint res=0;
  for(int i=1;i<key;++i)res+=a[i];
  res+=sm*((n-key+1)/c);
  for(int i=key;i<key+(n-key+1)%c;++i)res+=a[i];
  cout<<res<<"\n";
  //debug(sm);
  return 0;
}

Measured memory_bytes: 7124
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static boolean [][] grid;
    static int [] bishopr = {-1,1,-1,1};
    static int [] bishopc = {1,1,-1,-1};
    static long H,W,cnt;
    public static void main(String args[]) throws IOException {
            int N = in.nextInt();
            PriorityQueue<Double> q = new PriorityQueue<>();
            for(int i=0;i<N;i++)   
                q.add(in.nextDouble());
            while(q.size()!=1){
                double u = q.poll();
                double v = q.poll();
                q.add((u+v)/2);
            }
            out.println(q.poll());
        out.flush();
        }
       static boolean isValid (int r, int c){
           if(r>=0&&r<H&&c>=0&&c<W){
               return true;
           }
           return false;
       }
        private static void dfs(int r, int c) {
            for(int i=0;i<4;i++){
                int nr = bishopr[i] +r;
                int nc = bishopc[i]+c;
                if(isValid(nr, nc)&&!grid[nr][nc]){
                    cnt++;
                    grid[nr][nc] = true;
                    dfs(nr, nc);
                }
            }
        }

        static boolean isEven(long a) {
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
    

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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

int main(void){
	int x;
	int i=0;

	while(1){
		i++;
		cin >> x;
		if(x){
			printf("Case %d: %d\n", i, x);
		}else{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <sstream>

using hline_t = std::pair<unsigned, unsigned>;

int main(int argc, char const* argv[])
{
	unsigned w, n;
	std::cin >> w >> n ;
	std::vector<hline_t> hlines;
	for (int i = 0; i < n; i++) {
		std::string s;
		hline_t h;
		std::getline(std::cin, s, ',');
		h.first = std::stoi(s);
		std::getline(std::cin, s);
		h.second = std::stoi(s);
		hlines.push_back(h);
	}
	std::vector<unsigned> v(w + 1);
	{
		unsigned n = 0;
		std::generate(v.begin(), v.end(), [&n](){ return n++; });
	}

	for (auto var : hlines) {
		std::swap(v[var.first], v[var.second]);
	}
	std::for_each(v.begin() + 1, v.end(), [&](auto v){ std::cout << v << std::endl; });
	
	return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
long get2power(long n) {
	long result = 0;
	while (n % 2 == 0) {
		n = n / 2;
		result++;
	}
	return result;
}
int main()
{
	long N;
	string s;
	cin >> N >> s;
	vector<long> next(N);
	long ans = 0;
	int two = 2;
	for (int i = 0; i < N; i++)
	{
		next[i] = s[i] - '0' - 1;//abs((s[i] - '0') - (s[i+1] - '0'));
		if (s[i] - '0' - 1 == 1)
		{
			two = 1;
		}
	}
	long p = 0, n = 0;
	for (int i = 0; i < N - 1; i++)
	{
		next[i] = (p == n) ? next[i] : 0;
		p += get2power(N - 1 - i);
		n += get2power(i + 1);
	}
	next[N - 1] = (p == n) ? next[N - 1] : 0;

	for (int i = 0; i < N; i++)
	{
		ans += (two == 2) ? next[i] / 2 : next[i] % 2;// abs(ans - next[i]);
	}

	cout << (ans % 2) * two;;
	return 0;
}


Measured memory_bytes: 9220
#include <stdio.h>
int main(void)
{
    int n;
    int ans;
    scanf("%d", &n);
    int t[n];
    for(int i=0; i<n; i++) scanf("%d", &t[i]);
    int m;
    scanf("%d", &m);
    int p[m], x[m];
    for(int i=0; i<m; i++) scanf("%d%d", &p[i], &x[i]);
    
    int pre=0;
    for(int i=0; i<n; i++) pre+=t[i];
    for(int i=0; i<m; i++)
    {
        ans=ans-t[p[i]]+x[i];
        printf("%d\n", pre-t[p[i]-1]+x[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    pos++;
  } else {
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    int cnt = 0;
    REP(i, strlen(str)) { cnt += str[i] == '('; cnt -= str[i] == ')'; }
    while (cnt != 0);
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

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

int main(int argc, const char * argv[]) {
    // input from txt
    /////////
    //write//
    /////////
    
    ll s, t;
    cin >> s >> t;
    ll p, q, m;
    cin >> p >> q >> m;
    ll y;
    cin >> y;
    
    ll a = 0;
    rep(i, 100000000){
        if(i)a = (a * p + q) % m;
        y ^= a;
    }
    
    cout << y << endl;
    
    
    return 0;
}



Measured memory_bytes: 3120
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

def a():
    N, M = map(int, rl().split())
    li = [[] for _ in range(N)]
    deg = [0] * N
    for _ in range(M):
        a, b = map(int, rl().split())
        a -= 1
        b -= 1
        li[a].append(b)
        deg[b] += 1
    d = collections.deque([i for i in range(N) if deg[i] == 0])
    dp = [0] * N
    while d:
        i = d.popleft()
        for j in li[i]:
            deg[j] -= 1
            if deg[j] == 0:
                dp[j] = max(dp[j] ,dp[i] + 1)
                d.append(j)
    print(max(dp))
a()




        




Measured memory_bytes: 31632
/****************************************

			LostMartian

****************************************/
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	string s;
	cin>>s;
	ll c=1;
	rep(i,1,s.length()) {
		if(s[i]=='R' && s[i-1]=='R') {
			c++;
		}

	}
	ll k=0;
	rep(i,0,s.length()) {
		if(s[i]=='S') {
			k++;
		}
	}
	if(k==3) {
		c=0;
	}
	pn(c);
	















	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}


Measured memory_bytes: 3804
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N; ll X;
    cin >> N >> X;
    ++N;

    ll p[N+1];
    p[0] = 0;
    REP(i, N+1) {
        p[i+1] = p[i] * 2 + 1;
    }

    ll r = p[N] * 2 - 1;
    ll l = 0;

    ll ans = p[N];
    debug(N, ans)
    debug(l, r)
    cout << endl;

    while(1) {
        ll bn = r - l;
        ll mid = (bn + 2 - 1) / 2 + l;
        N = max(0, N-1);
        if (X > mid) {
            l = mid;
            --r;
        } else {
            ans -= p[N];

            if (X == mid) break;
            --ans;
            ++l;
            r = mid - 1;
        }
        debug(N, ans)
        debug(p[N])
        debug(l, r, bn)
        cout << endl;

        if (l >= r) break;
    }

    cout << fixed << setprecision(20);
    cout << ans << endl;

}


Measured memory_bytes: 256
/* ex 3_3
  kt125 */

#include<stdio.h>

int main(void){
  int n, k;
  scanf("%d %d", &n, &k);
  
  int q, ans = 0; //quotient,answer
  while(1){ 
    q = n / k;
    if (n/k == 0){ //break if quotient is 0
      ans++;
      break;
    }
    n = q;
    ans ++;
  }
  printf("%d\n", ans);
  return 0;
}
    

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

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

  int N;
  int X;
  cin >> N >> X;
  set<int> s;
  int x;
  rep(i, 0, N) {
    cin >> x;
    s.insert(x);
  }
  s.insert(X);

  vector<int> A;
  for (auto it: s) {
    A.pb(it);
  }

  sort(All(A));
  int g = -1;
  rep(i, 0, A.size()-1) {
    int cur = A[i];
    int nxt = A[i+1];
    if (g == -1) {
      g = A[i+1] - A[i];
    } else {
      g = __gcd(g, A[i+1]-A[i]);
    }
  }

  cout << g << endl;

  return 0;
};


Measured memory_bytes: 5632
#include <stdio.h>

int main(void){
  int i,j,k,dis,ans=0;
  int n,d;

  scanf("%d%d",&n,&d);

  int x[n+1][d+1];

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

  for(i=1;i<n;i++){
    for(j=i+1;j<=n;j++){
      dis=0;
      for(k=1;k<=d;k++){
        dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(k=1;;k++){
        if(k*k==dis){
          ans++;
          break;
        }else if(k*k>dis){
          break;
        }
      }
    }
  }

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

	return 0;
}


Measured memory_bytes: 128
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int n, a, b;
int p[MAX];

int main(void) {
	// in = fopen("B.in", "rt");
	
	fscanf(in, "%d", &n);
	fscanf(in, "%d %d", &a, &b);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d", &p[i]);
	sort(p, p + n);
	
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for (int i = 0; i < n; i++) {
	    if (p[i] <= a) cnt1++;
	    else if (p[i] <= b) cnt2++;
	    else cnt3++;
    }
    fprintf(out, "%d\n", min(cnt1, min(cnt2, cnt3)));
	return 0;
}

Measured memory_bytes: 128