akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O2,unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;

vi mul(vi a, vi b) {
	int n = a.size();
	vi c(n);
	for(int i = 0; i < n; i++) c[a[i]] = b[i];
	return c;
}
vi normul(vi a, vi b) {
	int n = a.size();
	vi c(n);
	for(int i = 0; i < n; i++) c[i] = b[a[i]];
	return c;
}
vi inv(vi a) {
	int n = a.size();
	vi c(n);
	for(int i = 0; i < n; i++) c[a[i]] = i;
	return c;
}
vi pow(vi a, int n) {//slow, can be done in O(n) by shifting cycles
	vi r(a.size()); iota(all(r), 0);
	while(n) {
		if(n&1) r = normul(r, a);
		n>>=1, a = normul(a, a);
	}
	return r;
}

int x = 100;
vi f[1010];
int n, k;
void read() {
	cin >> n >> k;--k;
	for(int x = 0; x < 2; x++) {
		f[x].resize(n);
		for(auto &i : f[x]) cin >> i, i--;
	}
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void stress() {
	n = 100, k = 0;
	for(int x = 0; x < 2; x++) {
		f[x].resize(n);
		iota(all(f[x]), 0);
		shuffle(all(f[x]), rng);
	}
}
void gen() {
	for(int i = 2; i < x; i++) f[i] = mul(f[i-2], f[i-1]);
}
vi lst;
void print(vi a, int DEBUG = 1) {
	for(auto i : a) cout << i+1 << " ";
	if(DEBUG) {
	cout << " : ";
	int n = a.size();
	vi c(n);
	for(int t = 0, i = 0; i < n; i++) {
		if(c[i]) continue;
		++t;
		int u = i;
		vi v;
		while(!c[u]) {
			c[u] = t;
			u = a[u];
			v.push_back(u);
		}
		cout << "( ";
		for(auto &i : v) cout << i+1 << " ";cout << ") ,";
	}
	cout << " : ";
	if(lst.size()) {
		vi t = mul(inv(lst), a);
		for(auto i : t) cout << i+1 << " ";
	}
	lst = a;
	cout << '\n';
	}
}
void print() {
	//int c = 1;
	//while(mul(inv(f[k%c]), f[c + (k%c)]) != mul(inv(f[c + (k%c)]), f[2*c + (k%c)])) c++;
	for(int i = 0; i < x; i++) cout << i << " :", print(f[i]);
	
}
void solve() {
	int c = 1;
	while(mul(inv(f[k%c]), f[c + (k%c)]) != mul(inv(f[c + (k%c)]), f[2*c + (k%c)])) c++;
	if(k < 48) print(f[k], 0);
	else {
		vi t;
		vi s = mul(inv(f[k%3]), f[3 + (k%3)]);
		vi a = f[k%3];
		k = (k/3)+1;
		if(k&1) {
			t = normul(pow(inv(s), k/2), a);
			t = normul(t, pow(s, k/2));
		} else {
			t = normul(pow(inv(s), k/2 - 1), inv(a));
			t = normul(t, pow(s, k/2));
		}
		print(t, 0);
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	read();
	//stress();
	gen();
	//print();
	solve();
}


Measured memory_bytes: 43256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &m)

	if 2*n >= m {
		fmt.Println(m / 2)
		return
	}

	fmt.Println(n + (m-2*n)/4)
}


Measured memory_bytes: 640
def main():
    H, W = map(int, input().split())
    org = list()
    expand = [[ 0 for w in range(W)] for h in range(2*H) ]

    for _ in range(H):
        l = input()
        org.append(l)

    for i in range(2*H):
        for j in range(W):
            expand[i][j] = org[i//2][j]

    for i in range(2*H):
        for j in range(W):
            print(expand[i][j], end = "")
        print()
        
main()

Measured memory_bytes: 4600
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
      Scanner sc = new Scanner(System.in);
      String s  = sc.nextLine();
      String t = sc.nextLine();
      int cnt = 0;
      for( int  i =0 ; i < s.length()  ; i++)
      
        if( s.charAt(i) != t.charAt(i) )
          cnt++;
      System.out.println(cnt);
    }
      
}    


Measured memory_bytes: 42852
x,y,sx,sy=map(int,raw_input().split())
#print x,y,sx,sy

a=[]
#1st
#Go
for i in range(sy-y):
	a.append("U")
for i in range(sx-x):
	a.append("R")
#Back
for i in range(sy-y):
	a.append("D")
for i in range(sx-x):
	a.append("L")

#2nd
#Go
a.append("L")
for i in range((sy+1)-y):
	a.append("U")
for i in range(sx-(x-1)):
	a.append("R")
a.append("D")

#Back
a.append("R")
for i in range(sy-(y-1)):
	a.append("D")
for i in range((sx+1)-x):
	a.append("L")
a.append("U")

#print a
print "".join(a)



Measured memory_bytes: 2820
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	W := make([]int, N)
	for i := 0; i < N; i++ {
		var w int
		fmt.Scan(&w)
		W[i] = w
	}
	min := int(1e9)
	for T := 0; T < N; T++ {
		WA := 0
		for i := 0; i <= T; i++ {
			WA += W[i]
		}
		WB := 0
		for i := T + 1; i < N; i++ {
			WB += W[i]
		}
		R := WA - WB
		if R < 0 {
			R = -R
		}
		if min > R {
			min = R
		}
	}
	fmt.Println(min)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


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

int order(int N){
    int ret = 0;
    while(N!=0){
        ++ret;
        N /= 10;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    int o_N = order(N);
    if (o_N < 3) {
        cout << 0 << endl;
        return 0;
    }
    vector<vector<string> > no753(10);
    no753[2] = {"357", "375", "537", "573", "735", "753"};
    string temp_str;
    for(size_t i = 3; i < o_N; i++)
    {
        for (auto str : no753[i-1]){
            for(size_t j = 0; j < i+1; j++)
            {
                temp_str = str;
                no753[i].push_back(temp_str.insert(j, "3"));
                temp_str = str;
                no753[i].push_back(temp_str.insert(j, "5"));
                temp_str = str;
                no753[i].push_back(temp_str.insert(j, "7"));
            }
        }
        sort(no753[i].begin(), no753[i].end());
        no753[i].erase(unique(no753[i].begin(), no753[i].end()), no753[i].end());
    }
    vector<int> sorted_753;
    for(auto vec : no753){
        for (auto no : vec){
            sorted_753.push_back(stoi(no));
        }
    }
    sorted_753.push_back(1000000000);
    sort(sorted_753.begin(), sorted_753.end());
    sorted_753.erase(unique(sorted_753.begin(), sorted_753.end()), sorted_753.end());
    auto itr_upper = upper_bound(sorted_753.begin(), sorted_753.end(), N);
    int ret = distance(sorted_753.begin(), itr_upper);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 10100
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

#[proconio::fastout]
fn main() {
    input!(
        mut s: Chars,
        n: usize,
    );
    let mut rev = 0;
    let mut left: Vec<char> = Vec::with_capacity(n);
    let mut right: Vec<char> = Vec::with_capacity(n);

    for _ in 0..n {
        input!(mode: u8);
        if mode == 1 { rev = 1 - rev; }
        else {
            input!(lr: u8, c: char,);
            if (lr - 1) ^ rev == 0 { left.push(c); }
            else { right.push(c); }
        }
    }
    if rev == 0 {
        left.reverse();
        for cs in [left, s, right].iter() {
            for c in cs { print!("{}", c); }
        }
        println!("");
    } else {
        right.reverse();
        s.reverse();
        for cs in [right, s, left].iter() {
            for c in cs { print!("{}", c); }
        }
        println!("");
    }

}


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

int main() {
  string s;
  int ans;
  cin >> s;
  ans = 0;
  for(int i=0;i<3;i++) {
    if(s[i]=='1') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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 / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

struct UnionFind {
  vector<int> data;
  int sz;
  UnionFind(int _sz) : data(_sz, -1) { sz = _sz; }
  bool connect(int x, int y) {
      if ((x = root(x)) == (y = root(y))) return false;
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x; sz--;
      return true;
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
  int size() { return sz; }
};

// ax + ay + az じゃない !!
// ax + ay + z !!
void solve() {
  int n, m;
  cin >> n >> m;
  UnionFind uni(n);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    uni.connect(x, y);
  }
  cout << sz(uni) << endl;
}


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

int N;

bool calc(int k, string c, int num) {
  if (k == N) cout << c << endl;
  else {
    rep(i, num + 1) {
      if (i == num) calc(k + 1, c + (char)('a' + i), num + 1);
      else calc(k + 1, c + (char)('a' + i), num);
    }
  }
}

int main(){
  cin >> N;
  calc(0, "", 0);
}


Measured memory_bytes: 1536
n, k = map(int, input().split())

ans = []

for i in range(n):
    ans.append(i + 1)

b =[]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        b.append(a[j])

b = list(set(b))

for i in range(len(b)):
    ans.remove(b[i])

print(len(ans))


Measured memory_bytes: 68492
#include<stdio.h>
#include<math.h>

double a,x,h;

int main(){
	scanf("%lf%lf",&x,&h);
	while(x!=0.0 && h!=0.0){
		a=x*x+2*x*sqrt(x*x/4+h*h);
		printf("%f\n",a);
		scanf("%lf%lf",&x,&h);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;


// �񐔂̗�O(n^(1/2))
vector<ll> divisor(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}
// O(log n)
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> f(K + 1);
    for (ll i = K; i >= 1; i--){
        vector<ll> res = divisor(i);
        (f[i] += mod_pow(K/i, N, mod))%=mod;
        
        for (auto x : res){
            //fprintf(stderr, "i = %d, x = %d\n", i, x);
            if (x != i){
                (f[x] += mod - f[i]) %= mod;
            }
        }
        ll tmp = (i * f[i]) %mod;
        (ans += tmp)%=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
#include <queue>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    int p ;
    int ans = 0;
    int max = 0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> p ;
        if (p > max)
        {
            max = p ;
        }
        ans += p ;

    }
    ans -= max / 2 ;
    cout << ans << endl ;
}

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

const int L = 128;

bool cmp(string  a, string  b) {
    return a.size() < b.size();
}

int qall = 0;

int main()
{
    vector<string> all;
    int sz = 0;

    ///find all x
    for (char c = 'a'; c <= 'z'; c++) {
        string q = "";
        for (int i = 0; i < L; i++)
            q += c;
        cout << "? " << q << endl;
        int x;
        cin >> x;
        x = L - x;
        string s = "";
        for (int i = 0; i < x; i++)
            s += c;
        sz += x;
        if (x != 0)
            all.pb(s);
    }
    for (char c = 'A'; c <= 'Z'; c++) {
        string q = "";
        for (int i = 0; i < L; i++)
            q += c;
        cout << "? " << q << endl;
        int x;
        cin >> x;
        x = L - x;
        string s = "";
        for (int i = 0; i < x; i++)
            s += c;
        sz += x;
        if (x != 0)
            all.pb(s);
    }
    for (char c = '0'; c <= '9'; c++) {
        string q = "";
        for (int i = 0; i < L; i++)
            q += c;
        cout << "? " << q << endl;
        int x;
        cin >> x;
        x = L - x;
        string s = "";
        for (int i = 0; i < x; i++)
            s += c;
        sz += x;
        if (x != 0)
            all.pb(s);
    }
    qall = 62;

    while (all.size() > 1) {
        sort(all.begin(), all.end(), cmp);
        string a = all[0], b = all[1];
        all.erase(all.begin());
        all.erase(all.begin());
        string cur = "";
        int bsz = b.size();
        for (int i = 0; i < bsz; i++) {
            char c = b[0];
            b.erase(b.begin());
            while (1) {
                string s = cur + c + a;
                cout << "? " << s << endl;
                qall++;
                int x;
                cin >> x;
                if (x == sz - s.size()) {
                    cur += c;
                    break;
                }
                cur += a[0];
                a.erase(a.begin());
            }
        }
        all.pb(cur + a);
    }
    cout << "! " << all[0];
    return 0;
}


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

using ll = long long;

int main() {

    ll n;

    cin >> n;

    vector<ll> v(n + 1, 2);

    v[1] = 1;

    for(ll i = 2; i * 2 <= n; ++i) {

        for(ll j = 2; i * j <= n; ++j)
            v[i * j]++;

    }

    ll answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer += v[i] * i;
    }

    cout << answer << endl;



}

Measured memory_bytes: 81348
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	string s, t;
	int A, B;
	string c;
	cin >> s >> t;
	cin >> A >> B;
	cin >> c;

	if (c == s)
	{
		cout << A - 1 << " " << B << endl;
	}
	else
	{
		cout << A << " " << B - 1 << endl;
	}
	

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    char ch;ch;cin>>ch;
    if(ch<'a')
        {cout<<'A';}
    else
        cout<<'a';
    return 0;
}

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

using namespace std;

struct edge
{
    int x,y,cost;
};

struct pct
{
    int x,y,ind;
};

bool cmp1(pct a, pct b)
{
    return a.x<b.x;
}

bool cmp2(pct a, pct b)
{
    return a.y<b.y;
}

bool cmp(edge a, edge b)
{
    return a.cost<b.cost;
}

pct P[100005];
vector<edge> Edg;
int Pa[100005],Sz[100005];

int parent(int x)
{
    int cx=x;
    while(Pa[x]!=0)
        x=Pa[x];

    while(Pa[cx]!=0)
    {
        int aux=Pa[cx];
        Pa[cx]=x;
        cx=aux;
    }
    return x;
}

bool unite(int x, int y)
{
    x=parent(x);
    y=parent(y);

    if(x==y)
        return 0;

    if(Sz[x]>=Sz[y])
    {
        Sz[x]+=Sz[y];
        Pa[y]=x;
    }
    else
    {
        Sz[y]+=Sz[x];
        Pa[x]=y;
    }
    return 1;
}

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

    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>P[i].x>>P[i].y;
        P[i].ind=i;
        Sz[i]=1;
    }

    sort(P+1,P+n+1,cmp1);
    for(int i=2; i<=n; i++)
        Edg.push_back({P[i].ind,P[i-1].ind,P[i].x-P[i-1].x});

    sort(P+1,P+n+1,cmp2);
    for(int i=2; i<=n; i++)
        Edg.push_back({P[i].ind,P[i-1].ind,P[i].y-P[i-1].y});

    sort(Edg.begin(),Edg.end(),cmp);

    long long rez=0;
    for(auto edg:Edg)
    {
        if(unite(edg.x,edg.y))
            rez+=edg.cost;
    }

    cout<<rez<<"\n";
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &a : A) {
    cin >> a;
    a--;
  }
  int now = 0;
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == now) {
      now++;
    } else {
      count++;
    }
  }
  if (count == N) {
    count = -1;
  }
  cout << count << endl;

  return 0;
}


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

#define MAX ((long long)1000000000)

int main() {
    long long H, N;

    cin >> H >>  N;

    long long A[N];
    long long B[N];
    long long i;
    
    for(i=0; i<N; ++i) {
	long long a, b;

	cin >> a >> b;
	A[i] = a;
	B[i] = b;
    }

    long long X[H+1];
    for(i=1; i<H+1; ++i) {
	X[i] = MAX;
    }
    X[0] = 0;

    for(i=0; i<N; ++i) {
	long long a = A[i];
	long long b = B[i];

	for(long long  j=1; j<H+1; ++j) {
	    long long x = 0;
	    if (j >= a) {
		x = X[j-a];
	    }
		
	    x += b;
        
	    if (X[j] > x) {
		X[j] = x;
	    }
	}
    }

    cout << X[H] << endl;

    return 0;
}


Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c = sc.nextInt
    if ((a == b && b == c) || (a != b && b != c && c != a)) println("No")
    else println("Yes")
  }
}


Measured memory_bytes: 27464
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll N,A[100010];

ll merge_count(vector<ll> &a){
	ll n = a.size();
	if(n<=1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(),a.begin() + n/2);
	vector<ll> c(a.begin() + n/2, a.end());
	cnt += merge_count(b);
	cnt += merge_count(c);
	ll ai = 0,bi = 0,ci = 0;
	while(ai<n){
		if(bi<b.size() && (ci == c.size() || b[bi] <= c[ci])){
			a[ai++] = b[bi++];
		}else{
			cnt += n/2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

ll median(ll x){
	vector<ll> B(N+1,0);
	for(int i=1;i<=N;i++){
		if(A[i-1]>=x) B[i] = 1;
		else B[i] = -1;
		B[i] += B[i-1];
	}
	return N*(N+1)/2-merge_count(B);
}

int main(){
	cin >> N;
	ll ma = 0,mi = 1e9+1;
	for(int i=0;i<N;i++){
		cin >> A[i];
		ma = max(ma,A[i]);
		mi = min(mi,A[i]);
	}
	if(N==1){
		cout << A[0] << endl;
		return 0;
	}
	ll l = 0,r = 1e9+1;
	while(l+1<r){
		ll m = (l+r)/2;
		if(median(m)>=(N*(N+1)/2+1)/2) l = m;
		else r = m;
	}
	if(l<mi) cout << mi << endl;
	else if(l>ma) cout << ma << endl;
	else cout << l << endl;
}

Measured memory_bytes: 3424
#include <iostream>
#include <string>
#include <vector>

enum face {
  TOP,
  FRONT,
  RIGHT,
  LEFT,
  BACK,
  BOTTOM,
};

class dice {
  public:
    dice();
    void setDice(int spot, int eye);
    int getSpot(int top);
    void rollNorth();
    void rollSouth();
    void rollEast();
    void rollWest();
    void rollRight();
    void rollLeft();
    std::vector<dice> all_rolls();

    int& operator[] (face f) {return id[f];}
    const int& operator[] (face f) const {return id[f];}
    bool operator==(const dice &b) const {
      const dice &a = *this;
      return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
             a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
             a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
    }

    bool equivalent_to(const dice &di);

  private:
    void roll(face a, face b, face c, face d);
    std::vector<int> id;
};

dice::dice() {
  id.resize(6);
}

void dice::setDice(int spot, int eye) {
  switch(eye) {
    case TOP:
      id[TOP] = spot;
      break;
    case BOTTOM:
      id[BOTTOM] = spot;
      break;
    case FRONT:
      id[FRONT] = spot;
      break;
    case BACK:
      id[BACK] = spot;
      break;
    case LEFT:
      id[LEFT] = spot;
      break;
    case RIGHT:
      id[RIGHT] = spot;
      break;
  }
}

int dice::getSpot(int top) {
  return id[top];
}

void dice::rollNorth() {
  roll(TOP, FRONT, BOTTOM, BACK);
}

void dice::rollSouth() {
  roll(TOP, BACK, BOTTOM, FRONT);
}

void dice::rollEast() {
  roll(TOP, LEFT, BOTTOM, RIGHT);
}

void dice::rollWest() {
  roll(TOP, RIGHT, BOTTOM, LEFT);
}

void dice::rollRight() {
  roll(FRONT, LEFT, BACK, RIGHT);
}

void dice::rollLeft() {
  roll(FRONT, RIGHT, BACK, LEFT);
}

std::vector<dice> dice::all_rolls() {
  std::vector<dice> ret;
  for(int k = 0; k < 6; (k&1 ? rollEast(): rollNorth()), ++k) {
    for(int i = 0; i < 4; rollRight(), ++i) {
      ret.push_back(*this);
    }
  }
  return ret;
}

bool dice::equivalent_to(const dice &di) {
  for(int k = 0; k < 6; (k & 1 ? rollEast(): rollNorth()), ++k) {
    for(int i = 0; i < 4; rollRight(), ++i) {
      if(*this == di) {
        return true;
      }
    }
  }
  return false;
}


void dice::roll(face a, face b, face c, face d) {
  int tmp = id[a];
  id[a] = id[b];
  id[b] = id[c];
  id[c] = id[d];
  id[d] = tmp;
}

int main() {
  int d;
  dice di;
  for(int i = 0; i < 6; ++i) {
    std::cin >> d;
    di.setDice(d, i);
  }
  dice di2;
  for(int i = 0; i < 6; ++i) {
    std::cin >> d;
    di2.setDice(d, i);
  }

  bool isIdentical = di.equivalent_to(di2);
  if(isIdentical) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		if(a.equals("D")) {
			if(b.equals("H")) {
				 b = "D";
			} else {
				b = "H";
			}
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 21204
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<3;i++)
    {
        if(n%10==7)
        {
            printf("Yes");
            return 0;
        }
        n/=10;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1728
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = sc.nextInt();
		long integers[] = new long[num];
		for(int i = 0; i < num; i ++) {
			integers[i] = sc.nextLong();
		}
		Arrays.sort(integers);

		long change[][] = new long[count][2];
		for(int i = 0; i < count; i ++) {
			change[i][0] = sc.nextLong();
			change[i][1] = sc.nextLong();
		}
		Arrays.sort(change, (a, b) -> Long.compare(b[1], a[1]));
		int crtIndex = 0;
		int crtCount = 0;
		for(int i = 0; i < num; i ++) {
			if(change[crtIndex][1] < integers[i]) { break; }
			integers[i] = change[crtIndex][1];
			crtCount ++;
			if(crtCount >= change[crtIndex][0]) { crtCount = 0; crtIndex ++; }
			if(crtIndex >= count) { break; }
		}

		long ans = 0;
		for(int i = 0; i < num; i ++) {
			ans += integers[i];
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 98796
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>

using namespace std;

#define endl '\n'

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n, k; cin >> n >> k;
  vector<ll> s(k+1), dp(k+1, 1e9 + 10);
  ++k;
  dp[1] = 0;
  cin >> s[1];
  for (int i = 2; i <= n; ++i) {
    cin >> s[i%k];
    dp[i%k] = 1e9 + 10;
    for (int l = 1; l < k and l < i; ++l) {
      dp[i%k] = min(dp[(i-l)%k] + abs(s[(i-l)%k] - s[i%k]), dp[i%k]);
    }
  }

  cout << dp[n%k] << endl;

  return 0;
}


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

using namespace std ;

const int sz = 1e5 + 7 ;

set<int> st[sz] ;
set< pair<int,int> > container ;
set<int>::iterator it ;
set<int>::iterator it2 ;
vector< pair<int,int> > qu ;
int par[sz] , qu_siz ;

int find_par(int u)
{
	if(u == par[u]) return u ;

	return par[u] = find_par(par[u]);
}

void add(int u,int v)
{
	it = st[u].find(v) ;

	if(it == st[u].end()) st[u].insert(v) ;

	else
	{
		st[u].erase(v);

		if(v<u)
			swap(u,v);

		if(container.find(make_pair(u,v)) == container.end())
		{
			container.insert(make_pair(u,v));
			qu.push_back(make_pair(u,v));
			qu_siz++;
		}
	}
}

int main()
{
	int n , u , v , edge ;

	scanf("%d",&n);

	edge = n-1 ;
	edge = edge*2 ;

	for(int i=0 ; i<edge ; i++)
	{
		scanf("%d %d",&u,&v);
		add(u,v);
		add(v,u);
	}

	pair<int,int> temp ;

	for(int i=1 ; i<=n ; i++) 
		par[i] = i ;

	for(int i=0 ; i<qu_siz ; i++)
	{
		temp = qu[i] ;

		u = temp.first ;
		v = temp.second ;

		u = find_par(u);
		v = find_par(v);

		if(u == v)
			continue ;

		if(st[u].size()>st[v].size()) swap(u,v);

		par[u] = v ;

		for(it2 = st[u].begin() ; it2 != st[u].end() ; it2++)
		{
			st[*it2].erase(u);
			add(*it2,v);
			add(v,*it2);
		}

		st[u].clear();
	}

	if(qu_siz + 1 == n) puts("YES");

	else puts("NO");

	return 0 ;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

const int MP = 100100;
vector<int> pr;
vector<ull> bpr;

void first() {
    bool used[MP] = {};
    for (int i = 2; i < MP; i++) {
        if (used[i]) continue;
        pr.push_back(i);
        ull x = ((__int128(1)<<64) + i-1 ) / i;
        bpr.push_back(x);
        for (int j = 2*i; j < MP; j += i) {
            used[j] = true;
        }
    }
}

map<ll, int> fact(ll n) {
    int pc = (int)pr.size();
    map<ll, int> mp;
    for (int i = 0; i < pc; i++) {
        ll d = pr[i]; ull rd = bpr[i];
//        if (n < d*d) break;
        while (true) {
            ll nd = __int128(n)*rd >> 64;
            if (nd * d != n) break;
            n = nd;
            mp[d]++;
        }
    }
    if (n > 1) mp[n]++;
    return mp;
}

ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}

int main() {
    first();
    using P = pair<ll, ll>;
    map<P, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        if (i % 1000 == 0) {
//            cout << i << " " << gc << endl;
        }
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[P(d0, d1)].first++;
        } else {
            g[P(d1, d0)].second++;
        }
    }

    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}


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

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

using pii = pair<int, int>;

double kyori(pii x, pii y) {
  return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

inline void Main() {
  // code
  int n,v[50];
  double c;
  cin>>n;
  rep(i,n) cin>>v[i];
  sort(v,v+n);
  c = v[0];
  rep(i,n) {
    c = (c + v[i]) / 2.0;
  }
  cout << c << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



q = I()


def sieve(r):
    not_prime = [0] * r
    not_prime[0] = 1
    not_prime[1] = 1
    for i in range(2, r):
        if not_prime[i] == 0:
            for j in range(i*2, r, i):
                not_prime[j] = 1
    return [k for k in range(r) if not not_prime[k]]



primes = sieve(100)
n = len(primes)
multiple_cnt = [0] * n
for m in range(len(primes)):
    ret = q
    p = primes[m]
    while ret:
        ret //= p
        multiple_cnt[m] += ret


multiple_cnt.sort()
ans = 0
ans += (n - bisect_left(multiple_cnt, 74))
ans += (n - bisect_left(multiple_cnt, 24)) * (n - bisect_left(multiple_cnt, 2) - 1)
ans += (n - bisect_left(multiple_cnt, 14)) * (n - bisect_left(multiple_cnt, 4) - 1)
ans += (n - bisect_left(multiple_cnt, 4)) * (n - bisect_left(multiple_cnt, 4) - 1) // 2 * (n - bisect_left(multiple_cnt, 2) - 2)


print(ans)

Measured memory_bytes: 39832
#include<stdio.h>

int main (void)
{
        int a, b, k, m[100], i, d, s;

        scanf("%d%d%d",&a,&b,&k);
        d = 0;
        if(a<b)s=a;
        else   s=b;
        for(i=s;i>0;i--){
                if((a%i==0)&&(b%i==0)){
                        m[d]=i;
                        d=d+1;
                }
        }
        printf("%d\n",m[k-1]);
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int ans=0;
ll n;
void check(ll x){
	int k3=0,k5=0,k7=0;
	if(x>n){
		x=0;
	}
	while(x){
		int s=x%10;;
		if(s==3){
			k3=1;
		}else if(s==5){
			k5=1;
		}else if(s==7){
			k7=1;
		}
		
		x/=10;
	}
	if((k3+k5+k7)==3){
			ans++;
		}
}
void dfs(ll x){
	check(x);
	if(x<=1e9&&x<=n){
		dfs(10*x+3);
		dfs(10*x+5);
		dfs(10*x+7);
	}
	
}
int main(){
	cin>>n;
	dfs(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
hs = gets.split.map(&:to_i)

dp = [0, (hs[0] - hs[1]).abs]

(2...n).each do |i|
  cost1 = dp[i-1] + (hs[i] - hs[i-1]).abs
  cost2 = dp[i-2] + (hs[i] - hs[i-2]).abs
  dp[i] = [cost1, cost2].min
end

puts dp[n-1]


Measured memory_bytes: 11396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;

    return 0;
}


Measured memory_bytes: 888
#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(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	double r; cin >> r;
	cout << r * r * M_PI << " " << 2 * r * M_PI << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

ll gcd(ll a, ll b){
  ll x = max(a, b);
  ll y = min(a, b);
  if ( y == 0){
    return x;
  }

  return gcd(x%y, y);
}

ll lcm(ll a, ll b){
  ll gcdV = gcd(a,b);
  return  gcdV * max(a/gcdV, (ll)1) * max(b/gcdV, (ll)1);
}

int main(){
  int n;
  cin >> n;
  ll t, ans = 0;
  for ( int i = 0; i < n; i++){
    cin >> t;
    ans = lcm(t, ans);
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    //int ma = *max_element(a.begin(), a.end());
    //int nh = h+ma;
    ivec dp(h+1);
    dp[0] = 0;
    for (int i = 1; i < h+1; i++){
        dp[i] = b[0]*(1+i/a[0] - !(i%a[0]));
        for (int j = 1; j < n; j++) dp[i] = fmin(dp[i], dp[fmax(0, i-a[j])] + b[j]);
    }
    //cout << *min_element(dp.begin()+h, dp.end()) << endl;
    cout << dp[h] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
    string str;
    int A,B,C,D;
    cin >> str;
    A = stoi(str) / 1000;
    B = stoi(str) / 100 % 10;
    C = stoi(str) / 10 % 10;
    D = stoi(str) % 10;

 
    REP(i,8){
        int tmp = A;
        char op1,op2,op3;
        if(i & 1){
            tmp += B;
            op1 = '+';
        }else{
            tmp -= B;
            op1 = '-';
        }
        if(i & 2){
            tmp += C;
            op2 = '+';
        }else{
            tmp -= C;
            op2 = '-';
        }
        if(i & 4){
            tmp += D;
            op3 = '+';
        }else{
            tmp -= D;
            op3 = '-';
        }
        if(tmp == 7){
            cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
int main() {
	string s;
	cin >> s;
	char n = s[0];
	ll cnt = 0;
	rep(i, 0, s.size()) {
		if (s[i] != n) {
			n = s[i];
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

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

int main(){
  int n;string s;cin>>n>>s;
  vector<int> e(n+1,0),w(n+1,0);
  rep(i,n-1)e[i+1]=e[i]+(s[i]=='W');
  rep(i,n-1)w[i+1]=w[i]+(s[n-1-i]=='E');
  int mn=1000000,p;
  rep(i,n){
    p=e[i]+w[n-1-i];
    mn=min(mn,p);
  }
  cout<<mn;
}

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

const ll mod=1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> p(n);
  r(i,m){
    int a,b;
    cin >> a >> b;
    a--;	b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  int ans[n];
  r(i,n)ans[i]=-1;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    vector<int> v=p[a];
    for(auto&& e : v){
      if(ans[e]<0){
        ans[e]=a+1;
        q.push(e);
      }
    }
    }

  cout<<"Yes"<<endl;
  r(i,n){
    if(i)cout<<ans[i]<<endl;
  }
}


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

int main(){
  ll A,V,B,W,T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  
  if(W>=V){
    cout << "NO";
    return 0;
  }
  
  ll diff = abs(A-B);
  ll v_diff = abs(V-W);
  
  if(T*v_diff>=diff) cout << "YES";
  else cout << "NO";
  
  return 0;
}

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

public class Main {


    public static void main(String args[] ) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] origin = br.readLine().split("");
        String[] serch = br.readLine().split("");
        int plusi = PlusI(serch);

       // System.out.println( SameString(serch) );
        for(int i = 0; i < origin.length; ){
        	 //System.out.println(i);

           if( i + serch.length  <= origin.length && SearchWord(origin , serch, i)){
              System.out.println(i);
              //i++;


              if(SameString(serch)){
            	  i = i + plusi ;
              }else{
                i++;
              }
           }else{

        	   i++;

           }



        }







    }


    public static int PlusI(  String[] Serch ){


    	for(int j = 0; j < Serch.length; j++ ){

    	    if( Serch[j].equals(Serch[0]) && 0 < j){
    	    	return j;
    	    }

    	}


        return Serch.length;


    }


    public static boolean SearchWord(String[] Origin , String[] Serch , int i){


    	boolean SerchCheck = false;
    	for(int j = i , k = 0; k < Serch.length; j++ , k++){

    	    if( Serch[k].equals(Origin[j]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }


    public static boolean SameString(String[] Serch ){


    	boolean SerchCheck = false;
    	for(int i = 0 ; i < Serch.length; i++){

    	    if( Serch[0].equals(Serch[i]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }



}

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

using namespace std;

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;
  vector<int> cnt(100005);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    cnt[a]++;
    cnt[a + 1]++;
    if (a > 0) cnt[a - 1]++;
  }
  int ans = 0;
  for (int i = 0; i <= 100000; i++) {
    chmax(ans, cnt[i]);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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


int main(){
    int n,m,c;
    int b[100],a[100][100];
    cin>>n>>m>>c;
    rep(i,m) cin>>b[i];
    rep(i,n){
        rep(j,m){
            cin>>a[i][j];
        }
    }
    int ans=0;
    rep(i,n){
        int tmp=0;
        rep(j,m){
            tmp+=a[i][j]*b[j];
            
        }
        tmp+=c;
        if(tmp>0)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
u=sorted(lis)
medl=u[n//2-1]
medu=u[n//2]
for i in range(n):
    if lis[i]>=medu:
        ans=medl
        print(ans)
    elif lis[i]<=medl:
        ans=medu
        print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ff(i,a,b) for(int i = a; i < b; i++)
#define fb(i,a,b) for(int i = a; i > b; i--)
#define MOD 1000000007


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



/*void solve(){
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	int x[3];
	x[0]=a; x[1]=b; x[2]=c;
	sort(x,x+3);
	//cout<<x[0]<<" "<<x[1]<<" "<<x[2];
	int m=n/x[0];
	fb(i,m,-1){
		ff(j,0,n/x[1]+1){
			ff(k,0,n/x[2]+1){
				//cout<<x[0]*i+x[1]*j+x[3]*k<<"\n";
				if(((x[0])*i+(x[1])*j+(x[3])*k)==n){
					cout<<(i+j+k)<<"\n";
					return;
				}
			}
		}
	}
}*/

void solve(){
	string s;
	cin>>s;
	if((s[0]==s[1])&&(s[1]==s[2])&&s[0]=='R') cout<<3;
	else if(((s[0]==s[1])||(s[1]==s[2]))&&s[1]=='R') cout<<2;
	else if((s[0]=='R')||(s[1]=='R')||(s[2]=='R')) cout<<1;
	else cout<<0;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	//int t;
    //cin>>t;
	//while(t--)
		solve();
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3824