akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> p;

bool check(int a, int b, string s){ //a文字目からb文字目までについて(0-index)
  bool f = true; 
  for(int i = a; i<b; i++){
    if(s.at(i)=='#' && s.at(i+1)=='#'){
      f= false;
      break;
    }
  }
  return f;
}
bool check2(int a, int b, string s){ //d文字目の前後について(0-index)
  bool f = false;
  for(int i = a; i<b+1;i++){
  if(s.at(i-1)=='.' && s.at(i)=='.' && s.at(i+1)=='.') {
    f = true;
  }
}
  return f;
}

int main(){
  
	int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  bool f = true;
  f = check(b-1, d-1, s);
  if(f){f=check(a-1, c-1, s);}
  if(f&&c>d){
  f = check2(b-1, d-1, s);
  }
  
  
  if(f) cout <<"Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3824
#include <iostream>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define vre(x) reverse( x.begin() , x.end() ) ;
#define aso(x) sort( x , x + x.size() )
#define are(x) reverse( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h = 798568968205 ; srand(h) ;
    //int t ; cin >> t ; while(t--){}

    ll a , b , c , k ; cin >> a >> b >> c >> k ;
    if ( k > (a+b) ) 
    {
        cout << a - ( k - (a+b) ) << "\n" ;
    }
    else cout << min(a,k) << "\n" ;
}

Measured memory_bytes: 3176
#include<stdio.h>
#include<stdlib.h>
void fun(char *);
void fun(char *s)
{
    int i;
    for(i=1;s[i]!='\0';i++)
    {
        if(s[i-1]==s[i])
        {
            printf("%d %d\n",i,i+1);
            return;
        }
    }
    for(i=2;s[i]!='\0';i++)
    {
        if(s[i-2]==s[i])
        {
            printf("%d %d\n",i-1,i+1);
            return;
        }
    }
    printf("-1 -1\n");
}
int main()
{
    char a[100005];
    scanf("%s",a);
    fun(a);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import  java.util.*;

import static java.lang.System.in;

class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        int ans = solve(a, n);
        System.out.println(ans);
    }
    static int solve(int[] a, int n){
        int[] mask = new int[31],rec = new int[31];
        for(int i=0;i<31;i++) mask[i]=1<<i;
        boolean[] vis = new boolean[n];
        int ans = 0;
        for(int w:a){
            for(int i=0;i<31;i++) rec[i] += (mask[i]&w)>0?1:0;
        }
        for(int i=30;i>=0;i--){
            if(rec[i]%2==0) continue;
            boolean flag = false;
            for(int j=0;j<n;j++){
                if(vis[j]) continue;
                if((a[j]&mask[i])==0) continue;
                if((a[j]|(mask[i]-1))!=a[j]+(mask[i]-1)) continue;
                flag = true;
                vis[j]=true;
                for(int k=i-1;k>=0;k--) rec[k] += 1;
                ans += 1;
                break;
            }
            if(!flag) return -1;
        }
        return ans;
    }
}


Measured memory_bytes: 51604
#include <bits/stdc++.h>
#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, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * (last[d][old] - last[i+1][old]);
  }
  FOR(i,d,D){
    if(t[i]==q) break;
    s += C[q] * ((d+1) - last[i+1][q]);
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = max(base+score(tmp), 0LL);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = max(base + score_2(T, max_score, d, old, q), 0LL);
    if(max_score<tmp){
      max_score = tmp;
      FOR(i,d,D){
        if(T[i]==old) break;
        last[i+1][old] = last[d][old];
      }
      FOR(i,d,D){
        if(T[i]==q) break;
        last[i+1][q] = (d+1);
      }
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  ll h[n];
  rep(i, n) cin >> h[i];

  vector<bool> ans(n-1, false);
  rep(i, n-1)
  {
    if (h[i] >= h[i + 1])
    {
      ans[i] = true;
    }
  }

  int cnt = 0;
  int mx = 0;
  rep(i, n){
    if (ans[i]){
      cnt++;
    } else {
      mx = max(cnt, mx);
      cnt = 0;
    }
  }

  cout << mx << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int m,d;
  cin >> m >> d;
  int kotae=0;

  if (d < 22){
    cout << kotae << endl;
    return 0;
  }
  for (int i=22; i<=d; i++){
    
    if (i%10!=0 and i%10!=1 and (i/10)*(i%10) <= m){
      kotae += 1;
    }
  }
  cout << kotae <<endl;
  return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

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

  int m, d;

  cin >> m >> d;

  int ans = 0;
  for(int i = 22; i <= d; i++) {
    for(int j = 1; j <= m; j++) {
        if(i % 10 < 2)
            continue;
        if(i / 10 < 2)
            continue;
        if(i / 10 * (i % 10) == j) {
            ans++;
        }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
/*
      بسم اللہ الرحمن الرحیم
    Bismillahir Rahmanir Raheem.
    In the name of Allah, Most Gracious, Most Merciful.
*/
/*
    Masum
    RUET
    CSE-19
    #1903086
    NDC
    #11901058
*/

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

#define int long long
#define ld long double
#define endl '\n'
int recur_depth = 0;
#ifndef ONLINE_JUDGE
#define dbg(x)                                                   \
    {                                                            \
        ++recur_depth;                                           \
        auto x_ = x;                                             \
        --recur_depth;                                           \
        cout << string(recur_depth, '\t') << __func__ << ":"     \
             << __LINE__ << "\t" << #x << " = " << x_ << "\n\n"; \
    }
#else
#define dbg(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type
operator<<(Ostream& os, const Cont& v) {
    os << "[";
    for (auto& x : v) {
        os << x << ", ";
    }
    return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
    return os << "{" << p.first << "," << p.second << "}";
}
/*________________________________________________________________*/

void sol();
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    /* Test cases */
    bool isT = 0;
    if (isT) {
        int t;
        cin >> t;
        while (t--)
            sol();
    } else
        sol();
    return 0;
}
void sol() {
    /* Remember about test cases --> exits or not */

    int a;
    cin >> a;
    cout << a * a + a + a * a * a << endl;
}
/*
        Self_Motivation:
    First think, then code.
    Do not jump between problems
*/


Measured memory_bytes: 3640
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main(){
    char s[3];
    int k[3] = {0, 0, 0};
    cin>>s;
    for(int i=0; i<3; i++){
        if(s[i] == 'a'){
            k[0]++;
        }
        else if(s[i]=='b'){
            k[1]++;
        }
        else if (s[i]=='c'){
            k[2]++;
        }
    }

    if(k[0]==1 && k[1]==1 && k[2]==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (105)
#define INF (1LL << 60)
const int MOD = (int)1e9;
typedef pair<int,int> Pii;
typedef pair<double,double> Pdd;

 
signed main() {
    int m, d;
    cin >> m >> d;

    int cnt=0;
    for(int i=1; i<=m; i++){
        //DEBUG(i);
        for(int j=1; j<=d; j++){
            int d1 = j%10;
            int d0 = j/10;
            
            //DEBUG3(j,d1,d0);
            if(d1>=2 && d0>=2 && d1*d0 == i){
                cnt++;
            }
        }
    }

    cout << cnt << endl;


}

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

using namespace std;
using ll = long long;
int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> va(n), vb(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i] >> vb[i];
  }

  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end(), greater<ll>());

  if (n % 2 == 0) {
    int mid_idx = n / 2 - 1;
    int mid_idx2 = n / 2;
    ll a = va[mid_idx] + va[mid_idx + 1];
    ll b = vb[mid_idx] + vb[mid_idx + 1];
    ll ans = abs(b - a) + 1;
    cout << ans << '\n';
  } else {
    int mid_idx = (n + 1) / 2 - 1;
    ll ans = abs(vb[mid_idx] - va[mid_idx]) + 1ll;
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    double p=3.14159265359,a,b,r;
    cin >> r;
    a=r*r*p;
    b=2*r*p;
    printf("%f %f\n",a,b);
    return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
int main(){
	int n,m,i,j,k,y,w;
	int _money,money,charge;
	double inter;
	int moneyMax;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&_money);
		scanf("%d",&y);
		scanf("%d",&m);
		moneyMax=-1;
		for(j=0;j<m;j++){
			money=_money;
			scanf("%d %lf %d",&w,&inter,&charge);
			if(w){
				for(k=0;k<y;k++)
					money=money*(1.0+inter)-charge;
			}
			else{
				int interSum=0;
				for(k=0;k<y;k++){
					interSum+=money*(inter);
					money-=charge;
				}
				money+=interSum;
			}
			if(moneyMax<money)moneyMax=money;
		}
		printf("%d\n",moneyMax);
	}
	return 0;
}

Measured memory_bytes: 0
N, K = map(int,input().split())

sunuke = [1 for i in range(N)]

for i in range(K):
    di = int(input())
    tmp = [int(t)-1 for t in input().split()] # int(t)-1 することでインデックス調整
    for t in tmp:
        sunuke[t] = 0
print(sum(sunuke))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e18))

using namespace std;

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

const int MAX_N = (int)1e5;

vector<LI> G[MAX_N]; // P(cost,to)

ll dist[MAX_N];

int N;
void dijkstra (int s){
	priority_queue<LI, vector<LI>, greater<LI> > que;
	fill (dist, dist + N, INF);
	
	dist[s] = 0LL;
	que.push(LI(0,s));

	while(!que.empty()){
		LI p = que.top(); que.pop();
		ll d = p.first;
		int v = p.second;
		if (dist[v] < d) continue;
		rep (i, (int)G[v].size()){
			ll cost = G[v][i].first;
			int to  = G[v][i].second;
			if (dist[to] > dist[v] + cost){
				dist[to] = dist[v] + cost;
				que.push(LI(dist[to], to));
			} // end if
		} // end rep
	} // end while
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	rep (i, N - 1){
		int a, b; ll c; cin >> a >> b >> c;
		--a, --b;
		G[a].push_back(LI(c,b));
		G[b].push_back(LI(c,a));
	} // end rep

	int Q, K; cin >> Q >> K;
	--K;
	vector<int> x(Q, 0), y(Q, 0);
	rep (i, Q){
		cin >> x[i] >> y[i];
		--x[i], --y[i];
	} // end rep

	dijkstra(K);
	rep (i, Q){
		cout << dist[x[i]] + dist[y[i]] << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 11888
#include "bits/stdc++.h"
using namespace std;
 
int main(){
	string s;
	cin>>s;
	long long int kai=0;
	long long int n=s.size();
	
	map<char,int> mp;
	for(int i=0;i<26;i++){
		mp['a'+i]=0;
	}
	
	for(int i=0;i<n;i++){
		mp[s[i]]++;
	}
	
	for(int i=0;i<26;i++){
		if(mp['a'+i]>1){
			long long int kait=0;
			for(int j=1;j<mp['a'+i]+1;j++)kait+=(j-1);
			kai+=kait;
		}
	}
	
	//cout<<kai<<endl;
	cout<<s.size()*(s.size()-1)/2+1-kai<<endl;
	
	return 0;
}

Measured memory_bytes: 640
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n
    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True
    def same(self, x, y):
        return self.root(x) == self.root(y)
    def size(self, x):
        return -self.d[self.root(x)]
    def num_union(self):
        return self.u


import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())
uf = UnionFind(N)
for _ in [0]*M:
    a, b = map(int, input().split())
    a -= 1; b -= 1
    uf.unite(a, b)

print(max(uf.size(i) for i in range(N)))

Measured memory_bytes: 78244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 100000000

int checkall(vector<vector<int>>A, int x){
    for(int i = 1; i < A.size()-1; i++)
    {
        //cout<<"x"<<x<<":i"<<i<<";"<<count(A[i].begin(),A[i].end(),x)<<endl;
        if(!count(A[i].begin(),A[i].end(),x)){
            return 0;
        }
    }
    return 1;
}

int main(){
    int N,M;cin>>N>>M;
    vector<int> K(N);
    vector<vector<int>> A;
    A.emplace_back(); // 空のvector<int> を一個追加
    for(int i = 0; i < N; i++)
    {
        cin>>K[i];
        for(int j = 0; j < K[i]; j++)
        {
            int aij;cin>>aij;
            A[i].push_back(aij);
        }
        A.emplace_back();
    }

    int count_type = 0;
    for(int i = 0; i < A[0].size(); i++)
    {
        count_type += checkall(A,A[0][i]);
    }
    cout<<count_type<<endl;
}

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

int main(){
  string S, T, U;
  int s, t;
  cin >> S >> T;
  cin >> s >> t;
  cin >> U;
  if(U==S) --s;
  if(U==T) --t;
  cout << s << " " << t;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

VI G[100010];
int reached[100010];
int color[100010];

bool ck[2019];

int main(){
    ll l,r;cin>>l>>r;
    int x=l;int y=r;
    while(l%2019!=r%2019){
        ck[l%2019]=1;
        ++l;
    }
    ck[r%2019]=1;
    if(y-x>=2018){
        cout<<0<<endl;
        exit(0);
    }
    ll ans=1e9+7;
    rep(i,2019) rep(j,2019){
        if(!ck[i]||!ck[j])continue;
        if(i==j)continue;
        chmin(ans,(ll)i*j%2019);
    }
    cout<<ans<<endl;
}


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


int main(){
	int K, N;
	cin >> K >> N;
	int diff = 0;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	for(int i = 1; i < N; i++){
		diff = max(diff, A[i] - A[i-1]);
	}
	diff  = max(diff, A[0] + K - A[N-1]);
	cout << K - diff << endl;


}














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

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x; cin >> x;
  cout << !x << endl;
  
  return (0);
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 3e2 + 5;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, k, mod, C[N][N], f[N][N], s[N][N];
signed main() {
	n = read(); k = read(); mod = read();
	for(int i = 0; i <= n; ++ i) {
		C[i][0] = 1;
		for(int j = 1; j <= i; ++ j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	for(int i = 0; i <= k; ++ i) f[1][i] = 1, s[1][i] = k - i + 1;
	for(int i = 2; i <= n + 1; ++ i) {
		for(int j = 0; j <= k; ++ j) for(int l = 1; l < i; ++ l) f[i][j] = (f[i][j] + f[i - l][j] * s[l][j + 1] % mod * C[i - 2][l - 1] % mod) % mod;
		for(int j = k; j; -- j) (s[i][j] = s[i][j + 1] + f[i][j]) %= mod;
	}
	printf("%lld\n", f[n + 1][0]);
	return 0;
}

Measured memory_bytes: 2432
//2904 GuruGuru
#include<stdio.h>
#include<string.h>
//余りが北で0、時計回りに+1
int main()
{
	char s[1024];
	int p,i,r=0;
	p=0;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		if(s[i]=='R'){
			p++;
		}else{
			p--;
		}
		if(p==4){
			p=0;
			r++;
		}
		if(p==-4)p=0;
	}
	printf("%d\n",r);
	return 0;
}



Measured memory_bytes: 2748
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	bool ss=false, nn=false, ee=false, ww=false;
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='S')ss=true;
		if(s[i]=='N')nn=true;
		if(s[i]=='E')ee=true;
		if(s[i]=='W')ww=true;
	}
	if((ss^nn)|(ee^ww))puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
  string S;
  cin >> S;
  ll N;
  
 rep(i,S.size()){
if(S.at(i) =='?'){
     S.at(i) = 'D';
   }

 }
  cout << S << endl;
  
}

 

Measured memory_bytes: 3752
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
  int x;
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  int i = 1; 
  while(true){
    x = Integer.parseInt(br.readLine());  
    if(x==0) break;   
    System.out.println("Case "+ i +": "+ x); 
    i++;
  }
 }
}

Measured memory_bytes: 31496
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl; return 0;
#define NO_ cout<<"No"<<endl; return 0;


int main() {

	int N, M;
	vector<string> set;
	cin >> N;
	REP(i, N) {
		string s;
		cin >> s;
		set.push_back(s);
	}
	cin >> M;
	REP(i, M) {
		string s;
		cin >> s;
		auto itr = find(ALL(set), s);
		if (itr == set.end()) { continue; }
		set.erase(itr);
	}
	int max = 0;
	REP(i, SZ(set)) {
		int a = count(ALL(set), set[i]);

		if (a > max) {
			max = a;
		}
	}
	
	cout << max << endl;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		int nam = s.length();
		char[] chars = s.toCharArray();
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0;i < nam ;i++){
		    if(chars[i] == '0'){
		       sb.append('0');
		    }else if(chars[i] == '1'){
		       sb.append('1');
		    }else{
		       if (sb.length() >= 1) {
                sb.setLength(sb.length()-1);
            }
		        
		    }
		}

		System.out.print(sb);

	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin>>str;
  long aa,nagasa,k,cou,ans;
  nagasa=str.size();
  vector<long> vec(nagasa);
  k=1;
  for(long i=nagasa-1; -1<i; i--){
    //vec.at(i)=k*(nagasa.at(i)-48);
    aa=str.at(i);
    aa=aa-48;
    vec.at(i)=k*aa;
    k=k*10;
    k=k%2019;
  }
  for(long i=nagasa-2; -1<i; i--){
    vec.at(i)=(vec.at(i)+vec.at(i+1))%2019;
  }
  sort(vec.begin(), vec.end());
  cou=1;
  ans=0;
  for(long i=1; i<nagasa; i++){
    if(vec.at(i)==vec.at(i-1)){
      cou=cou+1;
    }
    else if(cou>1){
      ans=ans+cou*(cou-1)/2;
      cou=1;
    }
  }
  ans=ans+cou*(cou-1)/2;
  for(long i=0; i<nagasa; i++){
    if(vec.at(i)==0){
      ans=ans+1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 5184
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		var s = Console.ReadLine();
        var r = s == "Sunny"? "Cloudy": s== "Cloudy"?"Rainy":"Sunny";
      Console.WriteLine(r);
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
	int N;
	cin >> N;
	vector<double> A(N);
	double sum = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum += (1 / A[i]);
	}
	double ans = 1 / sum;
	printf("%.11f\n", 1/sum);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long long>
#define vvi vector<vector<long long>>
int main(void){
    int n;
    cin>>n;
    int ans = 0;
    int i,k;
    for(i = 1,k=1; i<=n; i*=10,k++){
        //cout<<i<<endl;
        if(k%2 && i*10<=n)
            ans += 9*i;
    }
    i/=10;k--;
    if(k%2==0){
        cout<<ans<<endl;
    }
    else{
        ans += n-i+1;
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
  int s1;
  int s2;
  int s3;
  
  cin >> s1 >> s2 >> s3;
  
  int n = s1 * 100 + s2 * 10 + s3;
  
  cout << n % 9 << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/



signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n,m,k;
        cin >> n >> m >> k;
        vector<vector<bool>> a(n, vector<bool>(m,0));
        rep(i,0,n){
            string s;
            cin >> s;
            rep(j,0,m){
                if(s[j] == '#') a[i][j] = 1;
            }
        }
        int ans = 0;
        rep(i,0,1<<n){
            rep(j,0,1<<m){
                int cnt = 0;
                rep(i1,0,n){
                    rep(j1,0,m){
                        if(a[i1][j1]){
                            if(i&(1<<i1)) continue;
                            if(j&(1<<j1)) continue;
                            cnt++;
                        }
                    }
                }
                if(cnt==k) ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3608
import math
import time

start=time.time()

N=int(input())
ls=[int(s) for s in input().split()]
M=max(ls)
SQRT_M=int(math.sqrt(M))+1
#素数のリスト作成
prime=[1 for i in range(SQRT_M+1)]
prime[0]=0
prime[1]=0
primels=[]
primedic={}
for i in range(2,SQRT_M+1):
  if prime[i]==1:
    primels.append(i)
    primedic[i]=0
    a=1
    while a*i<=SQRT_M:
      prime[a*i]=0
      a+=1

for e in ls:
  for p in primels:
    if e%p==0:
      primedic[p]+=1
      while e%p==0:
        e//=p
    if e==1:
      break
  else:
    if e in primedic:
      primedic[e]+=1
    else:
      primedic[e]=1
  if time.time()-start>1.9:
    break
    

A=max(primedic.values())

if A==len(ls):
  print('not coprime')
elif A>1:
  print('setwise coprime')
else:
  print('pairwise coprime')

      

Measured memory_bytes: 197156
#include<bits/stdc++.h>
using namespace std;
int mod(int n,int k){
    if(n%k<0) return n-(n/k+1)*k;
    else return n%k;
}
int n,f,k=-2;
string ans;
int main(){
    cin>>n;
    if(n==0){cout<<0;return 0;}
    while(n!=0)
    {
        char a=mod(n,k)+48;
        ans+=a;
		f++;
        if(n%k<0) n=n/k+1;
        else n/=k;
    }
    for(int i=f-1;i>=0;i--) cout<<ans[i];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAX 100000
#define NMAX 20

struct Node{
    int n_node;
    int parent;
    int depth;
    vector<int> child;
};

Node N[MAX];

void addDepth(int id, int depth){
    N[id].depth = depth;
    for(int i = 0; i < N[id].child.size(); i++){
        addDepth(N[id].child[i], depth+1);
    }
}

int main(void){
    int n, root;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        N[i].parent = -1;
        N[i].depth = 0;
    }
    
    for(int i = 0; i < n; i++){
        int id, num;
        cin >> id >> num;
        
        N[id].n_node = id;
        for(int j = 0; j < num; j++){
            int id_c;
            
            cin >> id_c;
            N[id_c].parent = N[id].n_node;
            N[id_c].depth = N[id].depth + 1;
            
            N[id].child.push_back(id_c);
        }
    }
    
    root = n;
    for(int i = 0; i < n; i++){
        if(N[i].parent == -1){
            root = N[i].n_node;
            break;
        }
    }
    addDepth(root, 0);
    
    for(int i = 0; i < n; i++){
        cout << "node " << N[i].n_node << ": parent = " << N[i].parent << ", depth = " << N[i].depth << ", ";
        if(N[i].parent >= 0){
            if(N[i].child.size() > 0) cout << "internal node";
            else cout << "leaf";
        }
        else cout << "root";
        cout << ", [";
        for(int j = 0; j < N[i].child.size(); j++){
            if(j) cout << ", ";
            cout << N[i].child[j];
        }
        cout << "]" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 7820
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;


int main()
{
    int a, b, c;
    cin>>a>>b>>c;

    if (a != b || a != c) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
    string n, n2 ;
    cin >> n;
    
    int count = 0;
    
    while(1){
        cin >> n2;
        
        if(n2 == "END_OF_TEXT") break;
        
        for(int i = 0; i < n2.size(); i++){
            if(65 <= n2[i] && n2[i] <= 90){
                n2[i] += 32;
            }
        }
        
        if(n == n2){
            count++;
        }
    }
    
    cout << count << endl;
}



Measured memory_bytes: 3192
import collections

n,p = map(int, input().split())
ans=1
#nを素因数分解したリストを返す
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
x=prime_decomposition(p)
x = collections.Counter(x)
x = x.most_common()


for i in range(len(x)):
    if x[i][1]>=n:
        ans*=x[i][0]**(x[i][1]//n)
    else:
        break
print(int(ans))


Measured memory_bytes: 38768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
   int n;
   cin >> n;
   int a,b,c;
   if(n%10 == 1) a = 9;
   else a = 1;
   n/=10;
   if(n%10 == 1) b = 9;
   else b = 1;
   n/=10;
   if(n%10 == 1) c = 9;
   else c = 1;
   cout << c*100+b*10+a <<endl;

}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h> 
typedef struct{
  char type;
  int value;
}card;

void bubble(card *,card *,int );
void select(card *,card *,int );
void hantei(card *,card *,int);
void output(card *,int);

int main(){
  int i,j,n;
  scanf("%d",&n);
  card hai[n];
  card hai1[n];
  for(i=0;i<n;i++){
    scanf(" %c%d",&hai[i].type,&hai[i].value);
    hai1[i]=hai[i];
  }
  
  bubble(hai,hai,n);
  select(hai,hai1,n);

  return 0;
}




void bubble(card *haiin,card *hai,int n){
  int i,j,hozon;
  char hoz;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(hai[j].value<hai[j-1].value){
	hozon=hai[j-1].value;
	hoz=hai[j-1].type;
	hai[j-1].value=hai[j].value;
	hai[j-1].type=hai[j].type;
	hai[j].value=hozon;
	hai[j].type=hoz;
      }
    }
  }
  output(hai,n);
  printf("Stable\n");
}

void select(card *haiin,card *hai,int n){
  int i,j,hozon,min;
  char hoz;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(hai[j].value<hai[min].value){
	min=j;
      }
    }
    hozon=hai[i].value;
    hoz=hai[i].type;
    hai[i].value=hai[min].value;
    hai[i].type=hai[min].type;
    hai[min].value=hozon;
    hai[min].type=hoz;
  }
  output(hai,n);
  hantei(haiin,hai,n);
}

void hantei(card *haiin,card *haiout,int n){
  int i,j,a,b,flag=0;
  for(i=0;i<n;i++){
    if(haiin[i].type==haiout[i].type && haiin[i].type==haiout[i].type){
      flag=1;
    }else{
      flag=0;
      break;
    }
  }
  if (flag==0) printf("Not stable\n");
  else printf("Stable\n");
}

void output(card *hai,int n){
  int i,j;
  for(i=0;i<n;i++){
    printf("%c%d",hai[i].type,hai[i].value);
    if(i==n-1) printf("\n");
    else printf(" ");
  }
}
  

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

int main(int argc, char const *argv[])
{
	int n,x;
	cin>>n>>x;
	int l[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>l[i];
	}
	int now=0,ans=1;
	for (int i = 0; i < n; ++i)
	{
		now+=l[i];
		if (now<=x)
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,x,y;
vector<ll>v[100009];
ll dp[100009];

ll f(ll N){
	if (v[N].empty())return 0;
	if(dp[N]!=-1)return dp[N];
	ll z=0;
	for(int i=0; i<v[N].size(); i++){
		z=max(z,f(v[N][i])+1);
	}
	dp[N]=z;
	return dp[N];
}

int main(){
	cin >> n >> m;
	memset(dp,-1,sizeof dp);
	for(int i=1; i<=m; i++){
		cin >> x >> y;
		v[x].push_back(y);
	}
	ll jwb=0;
	for(int i=1; i<=n; i++){
		jwb=max(jwb,f(i));
	}
	cout << jwb << endl;
}//z

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
string s;
int n,r,g,b;
void solve(){
    cin>>n>>s;
    for(auto i:s){
    	if(i=='R') r++;
    	if(i=='G') g++;
    	if(i=='B') b++;
    }
    int ans=r*g*b;
    rep(i,0,n){
    	rep(j,1,n){
    		int l=i-j;
    		int rr=i+j;
    		if(l>=0 and l<n and rr>=0 and rr<n and s[l]!=s[i] and s[rr]!=s[i] and s[l]!=s[rr]) ans--;
    	}
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
package main

import "fmt"

func main() {
  var A, B, N int
  
  fmt.Scanf("%d %d %d\n", &A, &B, &N)
  
  x := B - 1
  if x > N {
    x = N
  }
  
  fmt.Println( int(float64(A*x)/float64(B))-A*int(float64(x)/float64(B)) )
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007

int main(){
  ll h, w;
  cin>>h>>w;
  char a[h][w];
  for(ll i=0; i<h; i++){
    for(ll j=0; j<w; j++){
      cin>>a[i][j];
    }
  }
  ll dp[h][w];
  memset(dp, 0, sizeof(dp));
  dp[h-1][w-1]=1;
  for(ll i=h-1; i>=0; i--){
    for(ll j=w-1; j>=0; j--){
      if(a[i][j]=='.'){
      	if(i<h-1)dp[i][j] =(dp[i][j]+ dp[i+1][j])%mod;
        if(j<w-1)dp[i][j] =(dp[i][j]+ dp[i][j+1])%mod;
      }
    }
  }
  

  cout<<dp[0][0]%mod<<"\n";
  return 0;
}


Measured memory_bytes: 12364
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	ll n;
	cin >> n;

	vector<pair<ll, int>> fs;
	for (ll i = 2; i*i <= n; ++i)
	{
		int x = 0;
		while (n%i == 0)
		{
			n /= i;
			++x;
		}
		fs.emplace_back(i, x);
	}
	
	if (n != 1) fs.emplace_back(n, 1);

	int ans = 0;
	for (auto p : fs)
	{
		int x = p.second;
		int b = 1;
		while (b <= x)
		{
			x -= b;
			b++;
			++ans;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19776
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

vector<pair<char, int>> boxes;

int n, m;

int main()
{
	scanf("%d %d", &n, &m);
	boxes.emplace_back('r', 1);
	for (int i = 1; i < n; ++i)
	{
		boxes.emplace_back('w', 1);
	}
	for (int j = 0; j < m; ++j)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		--x; --y;
		char col = boxes[x].first;
		--boxes[x].second;
		if (boxes[y].second == 0)
		{
			boxes[y].first = col;
		}
		else
		{
			if (boxes[y].first != col)
			{
				boxes[y].first = '?';
			}
		}
		++boxes[y].second;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (boxes[i].first == 'r' || boxes[i].first == '?')
		{
			if (boxes[i].second != 0)
			{
				++ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dx[] = {-1,1,-4,4,1,-1,-1,1};

inline bool value(int x,int w){
  return x >= 0 && x < w;
}
const string ans = "01234567";
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string v = ans;
  queue<pair<string,pair<int,int>>> q;
  map<string,int> m;
  q.push(mp(ans,mp(0,0)));
  m[ans] = 0;
  while(q.size()){
    auto Q = q.front();q.pop();
    auto tmp = Q.fi;
    int P = Q.se.fi;
    int C = Q.se.se;
    rep(i,4){
      tmp = Q.fi;
      if(value(P+dx[i],8)){
        if((P != 3 && P != 4) || (P == 3 && dx[i] != 1) || ( P == 4 && dx[i] != -1)){
          swap(tmp[P],tmp[P+dx[i]]);
          if(m.count(tmp) == 0){
            m[tmp] = C+1;
            q.push(mp(tmp,mp(P+dx[i],C+1)));
          }
        }
      }
    }
  }
  char c;
  while(cin >> c){
    v[0] = c;
    rep(i,7){
      cin >> c;
      v[i+1] = c;
    }
    cout << m[v] << endl;
  }
  return 0;
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (N); i++)
#define rep2(i, j, N, M) rep(i, N) rep(j, M)
#define rep3(i, j, k, N, M, L) rep(i, N) rep(j, M) rep(k, L)
#define REP(i, init, N) for (int i = (init); i < (N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int N, W;
VI vs;

double solve() {
    VI ts(15);
    for (auto v : vs) {
        ts[v / W]++;
    }

    int WW = 0;
    {
        rep(i, 15) {
            if (ts[i]) {
                WW = i;
            }
        }
    }

    int H = *max_element(ALL(ts));

    double ans = 0.01;
    rep(i, WW + 1) {
        double c = 1. * (WW - i) / WW;
        double v = 1. * ts[i] / H;
        ans += c * v;
    }

    return ans;
}

int main(void) {
    while (cin >> N >> W, N) {
        vs = VI(N);
        for (auto &v : vs) cin >> v;
        printf("%.9f\n", solve());
    }

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
using P=pair<int64_t,int64_t>;

P maxmin(int64_t H, int64_t W){//2つに分割。小さい方を最大化
  if(H%2==0||W%2==0){
    return P(H*W/2,H*W/2);
  }else{
    if(H<W) swap(H,W);//then H>=W
    return P((H/2)*W,(H/2+1)*W);
  }
}

int main(){
  int64_t H,W;
  cin>>H>>W;
  int64_t ans=1000000;
  for(int64_t h=1;h<H;h++){
    int64_t S1,S2;
    tie(S1,S2)=maxmin(H-h,W);
    int64_t Smax = max({h*W,S1,S2});
    int64_t Smin = min({h*W,S1,S2});
    ans=min(ans,Smax-Smin);
  }
  swap(H,W);
  for(int64_t h=1;h<H;h++){
    int64_t S1,S2;
    tie(S1,S2)=maxmin(H-h,W);
    int64_t Smax = max({h*W,S1,S2});
    int64_t Smin = min({h*W,S1,S2});
    ans=min(ans,Smax-Smin);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
h,w,d = map(int,input().split())
arr = []
for i in range(h):
    tmp_list = list(map(int,input().split()))
    arr.append(tmp_list)
q = int(input())
querry = []
for i in range(q):
    querry.append(list(map(int,input().split())))
num_list = [[0]*2 for i in range(h*w + 1)]
for i in range(h):
    for j in range(w):
        num_list[arr[i][j]] = [i,j]
cost_list = [0]*(h*w + 1)
for i in range(1,h*w):
    for r in range(h*w):
        if i > h*w - d:
            break
        if cost_list[i + d] == 0:
            x0 = num_list[i][0]
            x1 = num_list[i + d][0]
            y0 = num_list[i][1]
            y1 = num_list[i + d][1]
            cost_list[i + d] += cost_list[i] + abs(x0-x1) +  abs(y0-y1)
        else:
            break
        i += d
for l,r in querry:
    print(cost_list[r] - cost_list[l])

Measured memory_bytes: 87004