akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,A,B,ans=0;
  scanf("%lld%lld%lld",&N,&A,&B);
  ans+=(N/(A+B))*A;
  ans+=N%(A+B)<A?N%(A+B):A;

  printf("%lld\n",ans);
	return 0;
}


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

using ll = long long; 
const int N = 1e5 + 5;
const int base = 1e9 + 7;

ll latte[N], malta[N];

int main() {
    string s;
    cin >> s;
    int n = s.size();

    ll mul = 1;
    for(int i = 0; i < n; ++i) {
        if(s[i] == '?' or s[i] == 'A') {
            latte[i] = mul;
        } 

        if(s[i] == '?') {
            (mul *= 3) %= base;
        }
    }

    mul = 1;
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == 'C' or s[i] == '?') {
            malta[i] = mul;
        }

        if(s[i] == '?') {
            (mul *= 3) %= base;
        }
    }


    for(int i = 1; i < n; ++i) {
        latte[i] += latte[i - 1] * (s[i] == '?' ? 3 : 1) % base;
        latte[i] %= base;
    }

    for(int i = n - 2; i >= 0; i--) {
        malta[i] += malta[i + 1] * (s[i] == '?' ? 3 : 1) % base;
        malta[i] %= base;
    }

    ll res = 0;
    for(int i = 1; i < n - 1; i++) {
        if(s[i] == 'B' or s[i] == '?') {
            res += latte[i - 1] * malta[i + 1] % base;
            res %= base;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL A,B,C;
    cin>>A>>B>>C;
    LL ans=LLMAX;
    ans=min(ans,(A-A/2*2)*B*C);
    ans=min(ans,(B-B/2*2)*A*C);
    ans=min(ans,(C-C/2*2)*B*A);
    cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, a, b;
    cin >> w >> a >> b;
    int ans = 1e9;
    if(a+w < b) chmin(ans, b - (a+w));
    else if(b+w < a) chmin(ans, a - (b+w));
    else ans = 0;
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> t(n);
    int sum=0;
    for(int i=0; i<n; i++){
        cin >> t[i];
        sum += t[i];
    }
    
    int m;
    cin >> m;
    vector<int> s(m);
    for(int i=0; i<m; i++){
        int p, s;
        cin >> p >> s;
        cout << s - t[p-1] + sum << endl;
    }
    return 0;
}


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

int main()
{
    int x, y,sum = 0;
    cin >> x >> y;

    if (2 * x <= y && y <= 4 * x && y % 2 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
Graph G;
vector<int> c,ans;
int ct;

void dfs(int v,int p){
    ans[v] = c[ct];
    --ct;
    
    for(auto e : G[v]){
        if(e.first == p) continue;
        else dfs(e.first, v);
    }
}

int main(){
    cin >> N;
    G.assign(N,vector<Edge>());
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(Edge(b,1));
        G[b].pb(Edge(a,1));
    }
    
    c.assign(N,int());
    rep(i,N) cin >> c[i];
    sort(ALL(c));
    
    ans.assign(N,int());
    ct = sz(c)-1;
    dfs(0,-1);
    
    int sum = accumulate(ALL(c),0) - *max_element(ALL(c));
    
    pr(sum);
    cout << ans[0];
    rep1(i,N-1) cout << " " << ans[i];
    cout << '\n';
}

Measured memory_bytes: 1664
double ave;
arr[8][2];

main(){
	int n, i, j;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) scanf("%d %d", &arr[i][0], &arr[i][1]);
	
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
			ave+=sqrt(pow(arr[i][0]-arr[j][0],2)+pow(arr[i][1]-arr[j][1],2));
	
	printf("%.7lf\n", ave*2/n);
}

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

int n;
string s;
set<string> st;
int main() {
	cin >> n;
	while(n--) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
	return 0;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin >> x >> y;

  if ((2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int i = (2 * x - y) / 3;
  int j = (2 * y - x) / 3;

  COMinit();
  cout << COM(i + j, i) << endl;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

const int MAX = 2100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll cal(int r, int c){
  return COM(r+c+2, r+1);
}

int main(){
  COMinit();
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2  >> c2;
  ll ans = cal(r2, c2) - cal(r2, c1-1) - cal(r1-1, c2) + cal(r1-1, c1-1);
  ans %= mod;
  if(ans < 0){
    ans += mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 52840
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 1000005
int dp[3001][3001];
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,x,y,z,s=0;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)cin>>a[i],s+=a[i];
    for(int i=0;i<n;i++)dp[i][i]=a[i];
    for(int i=0;i+1<n;i++)
        dp[i][i+1]=max(a[i],a[i+1]);
    for(int gap=2;gap<n;gap++){
        for(int i=0,j=gap;j<n;i++,j++){
            x=dp[i+2][j],y=dp[i+1][j-1],z=dp[i][j-2];
            dp[i][j]=max(a[i] + min(x,y),a[j]+min(y,z));
        }
    }
    cout<<2*dp[0][n-1]-s;
    return 0;
}

Measured memory_bytes: 70016
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
bool cmp(string a,string b)
{
    return a+b<b+a;
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(11);
    for(int i=1;i<=k;i++)
    {
        int x;
        cin>>x;
        a[x]=1;
    }
    for(int i=n;;i++)
    {
        int q=i;
        bool flag=true;
        while(q)
        {
            if(a[q%10]) {flag=false;break;}
            q/=10;
        }
        if(flag)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int index = 1;
    int cnt = 0;

    while(cnt <= n) {
      	int tmp = index;
        index = a[tmp-1];
        if(index == 2) {
            cout << cnt+1 << endl;
            return 0;
        }
        cnt++;
    }

    cout << -1 << endl;

    return 0;
}


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

int compare_int(const void*a,const void*b){
    return *(int*)a - *(int*)b;
}
int main() {
    int k, x;
    cin >> k >> x;
    if (x <= 500 * k) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(calc(n));
        sc.close();
    }

    public static int calc(int n){
        if(n % 1000 == 0){
            return 0;
        }else{
            return 1000 - n % 1000;
        }
    }
}

Measured memory_bytes: 35568
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int s = 0;
        for(int i = 1; i <= n; i++){
            s = s + l + i - 1;
        }
        int a = 0;
        for(int i = 1; i <= n; i++){
            if(l - 1 + i == 0){
                a = i;
            }
        }
        if(a == 0){
            if(l * l > (l + n - 1) * (l + n - 1)){
                a = n;
            }else{
                a = 1;
            }
        }
        System.out.println(s - l + 1 - a);
        sc.close();
    }
}

Measured memory_bytes: 35656
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


const int N = 1e6 + 11;
int mn[N] = {};
inline void precalc () {
    for (int i = 2; i < N; i++) {
        if (!mn[i]) {
            mn[i] = i;
            for (int j = i + i; j < N; j += i) {
                if (!mn[j]) mn[j] = i;
                else umin(mn[j], i);
            }
        }
    }
}

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    precalc();
    int n;
    cin >> n;
    vector <int> a(n);
    int g = 0;
    for (auto &i : a) {
        cin >> i;
        g = __gcd(g, i);
    }
    bool ans = true;
    vector <int> used(N);
    for (int i = n - 1; i >= 0; i--) {
        bool ok = true;
        int x = a[i];
        while (x > 1) {
            if (used[mn[x]]) {
                ok = false;
                break;
            }
            used[mn[x]] = 1;
            int y = mn[x];
            while (x % y == 0) x /= y;
        }
        if (!ok) {
            ans = false;
            break;
        }
    }
    if (ans) {
        cout << "pairwise coprime\n";
    }
    else if (g == 1) {
        cout << "setwise coprime\n";
    }
    else cout << "not coprime\n";
}


Measured memory_bytes: 14868
#!/use/bin/env python3

from collections import defaultdict

n = int(input())
x_n = [int(s) for s in input().split()]

s = sorted(x_n)

ans = 1e18
for p in range(1, 101):
    l = sum([pow(x - p, 2) for x in s])

    if l < ans:
        ans = l

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, d;
	cin >> n >> d;
	int x[n][d];
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> x[i][j];
		}
	}

	vector<int> v;
	for(int i=0; i<200; i++) v.push_back(i*i);

	int ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int sum=0;
			for(int k=0; k<d; k++){
				sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			for(int k=0; k<200; k++){
				if(sum==v[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;

int32_t main()
{
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#endif
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5])puts("Yes");
	else puts("No");
	
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cstdio>
#include <set>

const int N = 200050;

int n;
std::multiset<int> S;

int main() {
  scanf("%d", &n);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    S.insert(x);
  }
  int ans = 0;
  while (!S.empty()) {
    std::multiset<int>::iterator it = --S.end();
    int x = *it; S.erase(it);
    int k = 1;
    while (x >= k) k <<= 1;
    it = S.find(k - x);
    if (it != S.end()) ++ans, S.erase(it);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int, char**)
{
uint n;
	unsigned long long ans = 0;
	std::cin >> n;

if (n == 3 || n == 5 || n==7)
	std::cout << "YES" << std::endl;
else
       cout << "NO" << endl;
	return 0;

}


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

using namespace std;

#define int long long

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

    int n;

    std::vector<int> v, ru;

    cin >> n;

    v.resize(n);
    ru.resize(n);

    int sum = 0;

    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        sum += v[i];
        ru[i] = sum;
    }

    int ans = 1000000000000;

    for (int i = 1; i < n; ++i)
    {
        ans = std::min(ans, abs( ru[i - 1] - (ru[n-1]- ru[i-1])));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
# import math
N = int(input())

# Nが奇数の場合は-2していくと全て奇数になるので答えは0
# Nが偶数の場合を検討するべし
# Nが偶数の場合、明らかに2の倍数より5の倍数の方が少ないので5の倍数がいくつかで考える
if (N % 2 == 1):
    print(0)
    exit()

bunbo = 0
sum_5 = 0
while (10 * 5 ** bunbo) <= N:
    sum_5 += N // (10 * 5**bunbo)
    bunbo += 1

print(sum_5)


Measured memory_bytes: 9168
use proconio::{
    input,
    marker::{Chars, Usize1},
};

fn main() {
    input!(n: usize, uv: [(Usize1, Usize1); n - 1], wb: Chars);
    let mut g = vec![vec![]; n];
    for (u, v) in uv {
        g[u].push(v);
        g[v].push(u);
    }
    println!(
        "{}",
        if let Some(r) = wb.iter().enumerate().find(|&(_, &c)| c == 'W').map(|p| p.0) {
            let mut alive = vec![false; n];
            fn dfs(x: usize, p: usize, alive: &mut [bool], wb: &[char], g: &mut [Vec<usize>]) {
                let gx_before = g[x].clone();
                let mut gx_after = vec![];
                for y in gx_before.iter().copied().filter(|&y| y != p) {
                    dfs(y, x, alive, wb, g);
                    if alive[y] {
                        gx_after.push(y);
                    }
                }
                g[x] = gx_after;
                if wb[x] != 'B' || !g[x].is_empty() {
                    alive[x] = true;
                    if x != p {
                        g[x].push(p);
                    }
                }
            }
            dfs(r, r, &mut alive, &wb, &mut g);

            if alive.iter().filter(|&&b| b).count() == 1 {
                1
            } else {
                let is_odd = |i: usize| alive[i] && ((g[i].len() % 2 == 1) ^ (wb[i] == 'W'));
                let is_odd_ref = |&i: &usize| is_odd(i);

                let mut t = r;
                let mut dist = vec![];
                for _ in 0..2 {
                    let s = t;
                    dist = vec![std::u32::MAX; n];
                    dist[s] = if is_odd(s) { 1 } else { 0 };
                    let mut que = std::collections::VecDeque::from(vec![s]);
                    while let Some(x) = que.pop_front() {
                        for &y in &g[x] {
                            if dist[y] != std::u32::MAX {
                                continue;
                            }
                            if is_odd(y) {
                                dist[y] = dist[x] + 1;
                                que.push_back(y);
                            } else {
                                dist[y] = dist[x];
                                que.push_front(y);
                            }
                        }
                    }
                    t = dist
                        .iter()
                        .copied()
                        .enumerate()
                        .filter(|&(_, d)| d != std::u32::MAX)
                        .max_by_key(|&(_, d)| d)
                        .unwrap()
                        .0;
                    assert!(dist[t] != std::u32::MAX);
                }

                g.iter().map(|v| v.len() as u64).sum::<u64>()
                    + (0..n).filter(is_odd_ref).count() as u64
                    - 2 * dist
                        .iter()
                        .copied()
                        .filter(|&d| d != std::u32::MAX)
                        .max()
                        .unwrap() as u64
            }
        } else {
            0
        }
    );
}


Measured memory_bytes: 34288
package main

import "fmt"

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)
	var c [6][6]bool

	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		for j := 0; j < w; j++ {
			if s[j] == '#' {
				c[i][j] = true
			}
		}
	}

	ans := 0
	for i := 0; i < (1 << h); i++ {
		for j := 0; j < (1 << w); j++ {
			cnt := 0
			for x := 0; x < h; x++ {
				if (i>>x)&1 == 1 {
					continue
				}
				for y := 0; y < w; y++ {
					if c[x][y] && (j>>y)&1 == 0 {
						cnt++
					}
				}
			}
			if cnt == k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    cout << ( k%2 ? b-a : a-b ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int sum[1123][1123],sumd[1123][1123],lose[1123][1123],n,m,t;

int Sum(int y,int x){
  int re=sum[y][x];
  //cout<<pii(x,y)<<endl;
  if(x-t-2>=0)
    re+=sumd[y+1][x-t-2];
  //cout<<re<<",";
  if(y-t>=0){
    if(y-t)re-=sum[y-t-1][x];
    if(x)re-=sumd[y-t][x-1];
  }else{
    if(x-t+y)re-=sumd[0][x-t+y-1];
  }
  //cout<<re<<endl;
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k;
  cin>>n>>m>>t;
  vector<string> mp(n);
  rep(i,n)
    cin>>mp[i];
  rep(j,m)rep(i,n){
    if(Sum(i,j)==0&&mp[i][j]=='.'){
      lose[i][j]=1;
      ++sum[i][j];
      ++sumd[i][j];
    }
    sumd[i][j+1]+=sumd[i][j];
    if(i){
      sumd[i-1][j+1]+=sumd[i][j];
      sumd[i-1][j+2]-=sumd[i][j];
    }
    sum[i+1][j]+=sum[i][j];
    sum[i][j+1]+=sum[i][j];
    sum[i+1][j+1]-=sum[i][j];
  }
  //rep(i,n){rep(j,m)cout<<lose[i][j];cout<<endl;}
  //rep(i,n){rep(j,m)cout<<sum[i][j]<<",";cout<<endl;}
  //rep(i,n){rep(j,m)cout<<sumd[i][j]<<",";cout<<endl;}
  cout<<(lose[n-1][m-1]?"Cacao":"Chieno")<<endl;
  return 0;
}


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

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

LL x[5];

LL ans;

void solve(){
	for(int i=0;i<5;i++){
		if(x[i]==0){
			ans = i+1;
			return;
		}
	}
}

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

    solve();

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

Measured memory_bytes: 3192
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    ll ans = 0;
    for(ll n = 1; n <= N; n++){
        ans += n * (N / n) * (N / n + 1) / 2;
    }
    pt(ans);
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,h[maxn];
int f[maxn];
int kq;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&h[i]);
  f[n]=1;
  for(int i=n-1;i>=1;i--)
    if (h[i]>=h[i+1]) f[i]=f[i+1]+1;
    else f[i]=1;
  kq=0;for(int i=1;i<=n;i++) kq=max(kq,f[i]);
  cout<<kq-1;
}


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

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

int n,m;
int t[102],s[102];
int sumT,sumS;

void solve(){
  int ti=0,si=0;

  while(ti < n && si < m){
    int swapT = sumT - t[ti] + s[si];
    int swapS = sumS - s[si] + t[ti];
    if(swapT == swapS){
      cout<<t[ti]<<" "<<s[si]<<endl;
      return;
    }

    if(si == m-1 || swapS < swapT && ti != n-1){
      ti++;
    }
    else{
      si++;
    }
  }
  cout<<-1<<endl;
}

int main(){
  while(cin>>n>>m,n||m){
    sumT = sumS = 0;
    rep(i,n){
      cin>>t[i];
      sumT += t[i];
    }
    rep(i,m){
      cin>>s[i];
      sumS += s[i];
    }

    sort(t,t+n);
    sort(s,s+m);

    solve();
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long ans,a,b,c,d,n;
int main()
{
    scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&n);
    d=min(d,c*2);
    d=min(d,b*4);
    d=min(d,a*8);
    c=min(c,b*2);
    c=min(c,a*4);
	printf("%lld",((n/2)*d)+((n%2)*c));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
#include<numeric>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int bitCount(int bits) {
	int cnt = 0;
	for (int mask = 1; mask != 0; mask <<= 1) {
		if ((bits & mask) != 0)
			++cnt;
	}
	return cnt;
}

int main() {
	int n, m, ans=0, s[10], p[10];
	fill(s, s + 10, 0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			a--;
			s[i] += (1 << a);
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < (1 << n); i++) {



		bool flg = true;
		for (int j = 0; j < m; j++) {
			if (bitCount(s[j] & i) % 2 != p[j]) {
				flg = false;
				break;
			}
		}
		if (flg)ans++;
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        List<Integer> list = new ArrayList<Integer>();
        int c = 1;
        for (int i = 0 ; i < n -1 ; i++) {
            if (s[i] == s[i + 1]) {
                c++;
            }else {
                list.add(c);
                c = 1;
            }
        }
        list.add(c);
        int[] a = new int[n];
        for (int i = 0 ; i < n - 1 ; i++) {
            if (s[i] == 'R' && s[i + 1] == 'L') {
                if (list.get(0) % 2 == 0) {
                    a[i] += list.get(0)/2;
                    a[i + 1] += list.get(0)/2;
                } else {
                    a[i] += list.get(0)/2 + 1;
                    a[i + 1] += list.get(0)/2;
                }
                if (list.get(1) % 2 == 0) {
                    a[i] += list.get(1)/2;
                    a[i + 1] += list.get(1)/2;
                } else {
                    a[i] += list.get(1)/2;
                    a[i + 1] += list.get(1)/2 + 1;
                }
                list.remove(0);
                list.remove(0);
            }
        }
        for (int i = 0 ; i < n ; i++) {
            System.out.print(a[i] + " ");
        }

    }

}

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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    int a, b;
    cin >> a >> b;
    
    for(int i = 1; i <= 1000; ++i) {
		if(floor(i * 0.08) == a &&  floor(i * 0.1) == b) {
			cout << i;
			return 0;
		}
	}
    
    cout << -1;
    
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

class Program {

    static int Main(string[] args) {
        List<string[]> list = new List<string[]>();

        while (true) {
            string v = Console.ReadLine();
            if (string.IsNullOrEmpty(v) == true) { break; }

            string[] vs = v.Split(' ');
            list.Add(vs);
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(Check(list[i]));
        }

        return 0;
    }

    static int InputN() {
        string v = Console.ReadLine();
        return int.Parse(v);
    }

    static decimal[] InputDecimal() {
        string v = Console.ReadLine();
        string[] vs = v.Split(' ');

        decimal[] vd = new decimal[vs.Length];
        for (int i = 0; i < vs.Length; i++) {
            vd[i] = decimal.Parse(vs[i]);
        }

        return vd;
    }

    static string Check(string[] v) {
        Stack<string> s = new Stack<string>();
        decimal a, b;

        for (int i = 0; i < v.Length; i++) {
            switch (v[i]) {
                case "+":
                    b = decimal.Parse(s.Pop());
                    a = decimal.Parse(s.Pop());
                    s.Push((a + b).ToString());
                    break;
                
                case "-":
                    b = decimal.Parse(s.Pop());
                    a = decimal.Parse(s.Pop());
                    s.Push((a - b).ToString());
                    break;
                
                case "*":
                    b = decimal.Parse(s.Pop());
                    a = decimal.Parse(s.Pop());
                    s.Push((a * b).ToString());
                    break;

                case "/":
                    b = decimal.Parse(s.Pop());
                    a = decimal.Parse(s.Pop());
                    s.Push((a / b).ToString());
                    break;

                default:
                    s.Push(v[i]);
                    break;
            }
        }

        return s.Pop();
    }
}

Measured memory_bytes: 11012
import sys
sys.setrecursionlimit(10 ** 8)
MOD = 10 ** 9 + 7
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M = ZZ()
    MAX_E = 50

    fact = [1] * (N+MAX_E+1) # fact[n] = n!
    ifact = [1] * (N+MAX_E+1)

    for i in range(1, N+MAX_E+1):
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N+MAX_E] = pow(fact[N+MAX_E], MOD-2, MOD)
    for i in range(N+MAX_E)[::-1]: ifact[i] = ((i+1) * ifact[i+1]) % MOD

    def combination(n, r):
        if r < 0 or r > n: return 0
        return (fact[n] * ifact[n-r] * ifact[r]) % MOD

    def prime_factor(num):
        i = 2
        ret = []
        while i*i <= num:
            if num%i != 0:
                i += 1
                continue
            cc = 0
            while num%i == 0:
                num //= i
                cc += 1
            ret.append([i, cc])
            i += 1
        if num != 1: ret.append([num, 1])
        return ret

    ps = prime_factor(M)
    ans = 1
    for p, e in ps:
        ans *= combination(N + e - 1, N - 1)
        ans %= MOD
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 10868
// Copyright 2017 wu_qing
#include <cstdio>
#include <cstring>
const int N = 1e3 + 10;
int n;
char a[N], b[N];
int main() {
    scanf("%d%s%s", &n, a, b);
    for (int i = n; i >= 0; i--) {
        bool flag = true;
        for (int j = 0; j < i; j++)
            if (a[n - i + j] != b[j]) {
                flag = false;
                break;
            }
        if (flag) {
            printf("%d\n", n * 2 - i);
            break;
        }
    }
    return 0;
}


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

int main(){

  int A,B;
  int answer=0;
  int count=0;

  cin >> A >> B;


  while(count<2){
    if(A>=B){
      answer += A;
      A -= 1;
    }
    else{
      answer += B;
      B -= 1;
    }

    count++;
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  int input;
  cin >> input;
  int nums[4];
  nums[0] = input / 1000 % 10;
  nums[1] = input / 100 % 10;
  nums[2] = input / 10 % 10;
  nums[3] = input / 1 % 10;
  int sum;
  string str = "";
  int strategy = 0;
  for (int strategy = 0; strategy < 1 << 3; ++strategy) {
    int sum = nums[0];
    string ans = "";
    ans += to_string(nums[0]);
    for(int k = 0; k < 3; k++) {
      if(strategy >> k & 1) {
        sum += nums[k+1];
        ans += "+"; 
      } else {
        sum -= nums[k+1];
        ans += "-";
      }
      ans += to_string(nums[k + 1]);
    }
    // cout << ans << endl;
    if (sum == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N = 1e5 + 5;
ll dp[2][N];
int main()
{
	int n, W;
	scanf("%d%d", &n, &W);
	vi val(n + 1), cap(n + 1);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &cap[i], &val[i]);

	for (int i = 0; i < n; i++) {
		int idx = i % 2;
		for (int j = 0; j <= W; j++) {
			dp[idx][j] = dp[!idx][j];
			if (j - cap[i] >= 0) {
				dp[idx][j] = max(dp[idx][j], dp[!idx][j - cap[i]] + val[i]);
			}
		}
	}
	n--;
	printf("%lld", dp[n % 2][W]);

	return Accepted;
}

Measured memory_bytes: 1792
import sys
perm = sys.stdin.readline().strip()
total = 0

# Add n * '+' to inp
def addPlus(inp, n):
    total = 0
    possible = [inp]
    orig = inp

    for i in range(1, len(orig)):
        possible.append(orig[:i] + '+' + perm[i:])

    for i in range(1, n):
        curr = possible[:]
        for item in curr:
            for j in range(1, len(item)):
                processed = item[:j] + '+' + item[j:]
                if processed not in possible:
                    if '++' not in processed:
                        possible.append(processed)

    for item in possible:
        total += eval(item)

    return total


print(addPlus(perm, len(perm) - 1))


Measured memory_bytes: 3064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll p[100010];
    string s[100010];
    rep(i,0,M) cin >> p[i] >> s[i];
    bool is_ac[100010] = {};
    ll wa[100010] = {};
    ll ans = 0;
    ll ac = 0;
    rep(i,0,M){
        if(s[i] == "AC"){
            if(is_ac[p[i]] == false){
                is_ac[p[i]] = true;
                ac++;
                ans += wa[p[i]];
            }
        }else{
            wa[p[i]]++;
        }
    }
    print(ac, ans);

    

}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    string str;
    cin >> str;
    int r = 0;
    rep(i, 3){
        if(str[i] == 'R') r++;
    }
    if(r == 0) cout << 0 << endl;
    else if(r == 1) cout << 1 << endl;
    else if(r == 3) cout << 3 << endl;
    else {
        if(str[1] == 'S') cout << 1 << endl;
        else cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int N; cin >> N;
    map<char, int> mp;
    for(int i = 0; i < N; i++){
        string S; cin >> S;
        if(S[0] == 'M' || S[0] == 'A' || S[0] == 'R' || S[0] == 'C' || S[0] == 'H'){
            mp[S[0]]++;
        }
    }
    
    ll ans = 0;
    string S = "MARCH";
    for(int i = 0; i < S.size(); i++){
        for(int j = i + 1; j < S.size(); j++){
            for(int k = j + 1; k < S.size(); k++){
                ans += (ll)mp[S[i]] * mp[S[j]] * mp[S[k]];
            }
        }
    }
    cout << ans << endl;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x;
	int i = 1;
	while(1) {
		
		scanf("%d", &x);
		
		if (x == 0) break;
		
		printf("Case %d: %d\n", i, x);
		i++;
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  
  int L[M], R[M];
  rep(i,M) {
    int r,l;
    cin >> l >> r;
    L[i] = l;
    R[i] = r;
  }
  
  int maxL = 1;
  int minR = N;
  rep(i,M) {
    maxL = max(maxL,L[i]);
    minR = min(minR,R[i]); 
}
  
   int ans = minR - maxL+1;
   ans = max(ans,0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
ten = li()
t = input()
lis = ["a"]*n
for i in range(k,n):
    lis[i] = t[i-k]
ans = 0

for i in range(n):
    if t[i] == lis[i]:
        if i+k<n:
            lis[i+k] = "a"
        continue
    if t[i] == "s":
        ans += ten[0]
    elif t[i] == "p":
        ans += ten[1]
    else:
        ans += ten[2]
print(ans)


Measured memory_bytes: 4084
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
    char s[101],t[101];
    int l,i,j,k,g;
    scanf("%d",&l);
    scanf("%s",s);

    if(l%2==0)
    {
        for(i=0;i<l/2;i++)
        {
            t[i]=s[i];

        }
        for(j=0,i=l/2;i<l,j<l/2;i++,j++)
        {
            t[i]=t[j];
        }
        t[l]='\0';

        g=strcmp(s,t);
        if(g==0)
            printf("Yes\n");
        else
            printf("No\n ");
    }
    else
        printf("No\n");

}


Measured memory_bytes: 1668
#include<iostream>
using namespace std;
int main()
{
	int W;
	while(cin>>W)
	{
		bool flag=0;
		for(int i=1;i<=W;i*=2)
		{
			if(W/i%2>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2960
function main(input) {
  var expect = input.split('\n')[0];
  var actual = input.split('\n')[1];

  var count = 0;
  for(var i=0; i<3; i++){
    if(expect[i] === actual[i]){
      count++;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int n;
    string e,f,g;
    cin >> n;
    int d = n%10;
    n/=10;
    int c = n%10;
    n/=10;
    int b = n%10;
    n/=10;
    int a = n%10;
    if(a+b+c+d == 7){
        e = "+";
        f = "+";
        g = "+";
    }
    else if(a+b+c-d == 7){
        e = "+";
        f = "+";
        g = "-";
    }
    else if(a+b-c+d == 7){
        e = "+";
        f = "-";
        g = "+";
    }
    else if(a+b-c-d == 7){
        e = "+";
        f = "-";
        g = "-";
    }
    else if(a-b+c+d == 7){
        e = "-";
        f = "+";
        g = "+";
    }
    else if(a-b+c-d == 7){
        e = "-";
        f = "+";
        g = "-";
    }
    else if(a-b-c+d == 7){
        e = "-";
        f = "-";
        g = "+";
    }
    else if(a-b-c+d == 7){
        e = "-";
        f = "-";
        g = "+";
    }
    cout << a << e << b << f << c << g << d << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)
ans = A[0]
if N >= 3:
    a = (N - 2) // 2
    b = (N - 2)  % 2
# print(a)
# print(b)
    if b == 0:
        for i in range(a):
            ans += (A[i+1] * 2)
    else:
        for i in range(a):
            ans += (A[i+1] * 2)
        ans += A[a+1]
print(ans)

Measured memory_bytes: 31360
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,m,T,tot,pw[N],ans[N];
struct {int ch[3],id,tag;} tr[N];
char s[N];
void build(int &o, int d, int x) {
	o=++tot;
	if (d==n) { 
		return tr[o].id=x,void();
	}
	REP(i,0,2) build(tr[o].ch[i],d+1,x+pw[d]*i);
}
void rev(int o) {
	tr[o].tag ^= 1;
	swap(tr[o].ch[1],tr[o].ch[2]);
}
void pd(int o) {
	if (tr[o].tag) REP(i,0,2) rev(tr[o].ch[i]),tr[o].tag=0;
}
void add(int o, int d) {
	if (d==n) return;
	pd(o);
	swap(tr[o].ch[1],tr[o].ch[2]);
	swap(tr[o].ch[0],tr[o].ch[1]);
	add(tr[o].ch[0],d+1);
}
void dfs(int o, int d, int x) {
	if (d==n) return ans[tr[o].id]=x,void();
	pd(o);
	REP(i,0,2) dfs(tr[o].ch[i],d+1,x+pw[d]*i);
}
int main() {
	scanf("%d%s", &n, s+1);
	pw[0] = 1;
	REP(i,1,n) pw[i] = pw[i-1]*3;
	build(T,0,0);
	m = strlen(s+1);
	REP(i,1,m) {
		if (s[i]=='S') rev(T);
		else add(T,0);
	}
	dfs(T,0,0);
	REP(i,0,pw[n]-1) printf("%d ", ans[i]);hr;
}









Measured memory_bytes: 21876