akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MSET(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio                  \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535
#define vll vector<ll>

vll prim;

void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));

  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p])
      prim.PB(p);
}

int32_t main() {
  fastio;
  ll n;
  cin >> n;
  SieveOfEratosthenes((ll)1e6);
  ll cnt = 0;
  for(auto itr : prim) {
    ll fn = 0;
    while(n%itr == 0) {
      fn++;
      n /= itr;
    }
    cnt += (-1 + sqrt(1+8*fn)) / 2;
  }
  if(n != 1) {
    cnt++;
  }
  cout<<cnt<<endl;
}


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

int main() {

  int X;
  cin >> X;

  int ans = 0;
  int current = 0;
  bool flg = false;

  while (!flg) {
    ans++;
    current += X;
    if (current % 360 == 0) {
      flg = true;
    }
  }

  cout << ans << endl;
  
  return 0;

}

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

using namespace std;
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;

  vector<vector<int>> G(N);
  int x, y;

  vector<int> h(N);
  rep(i, N) h[i] = 0;

  rep(i, M){
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    h[y]++;
  }

  stack<int> st;

  rep(i, N) if(h[i] == 0) st.push(i);

  vector<int> topo;

  while(st.size()){

    int i = st.top();
    st.pop();
    topo.push_back(i);

    for(auto j : G[i]){
      h[j]--;

      if(h[j] == 0) st.push(j);

    }

  }

  vector<int> dp(N);

  rep(i, N){
    dp[i] = 0;
  }

  rep(i, N){

    for(auto j : G[topo[i]]){

      chmax(dp[j], dp[topo[i]] + 1);

    }
  }

  int ans = 0;

  rep(i, N){
    chmax(ans, dp[i]);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, M; cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    x = I()
    print(1 - x)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int n, m, q; cin >> n >> m >> q;
    int a[550][550];
    int s[550][550];

    rep(i,m){
        int l, r; cin >> l >> r; l--;r--;
        a[l][r]++;
    }

    rep(i,n){
        rep(j,n){
            s[i+1][j+1] = s[i+1][j] + s[i][j+1] -s[i][j] + a[i][j];
        }
    }

    rep(i,q){
        int a, b; cin >> a >> b; a--; b--;
        cout << s[b+1][b+1] - s[b+1][a] - s[a][b+1] + s[a][a] << endl;
    }
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

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

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

    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    int itr[3] = {0};
    int now = 0;
    while(true) {
        if(itr[now] >= int(S[now].size())) {
            cout << char(now+'A') << endl;
            return 0;
        }
        int next = S[now][itr[now]] - 'a';
        itr[now]++;
        now = next;
    }

}


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

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
    int n;
    cin>>n;

    vector<int> A(n);

    long int sum =0;

    for(int i=0;i<n;i++){
    	
    	cin>>A[i];

    	sum+=A[i];

    	sum%=MAX;

    }
    long long int ans =0;
    for(int i=0;i<n;i++){
    	sum-=A[i];
    	if(sum<0){
    		sum	+=MAX;
    	}
    	ans+=A[i]*sum;
		ans%=MAX;    	
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4000
#include <iostream>

int main(){
    using namespace std;

    int a,b;

    cin >> a >> b;

    if(a < b){
        cout << "a < b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3104
N, M, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())

A_parts = [0 for _ in range(N+1)]
B_parts = [0 for _ in range(M+1)]

for i in range(N):
  A_parts[i+1] = A_parts[i] + A[i]

for i in range(M):
  B_parts[i+1] = B_parts[i] + B[i]

a_ind = 0
b_ind = M
best = 0

while a_ind <= N and b_ind >= 0:
  while b_ind >= 0 and A_parts[a_ind] + B_parts[b_ind] > K:
    b_ind -= 1
  if b_ind < 0:
    break
  best = max(best, a_ind + b_ind)
  a_ind += 1

print best

Measured memory_bytes: 120572
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n,m,s;
  char c;
  cin >> n >> m;
  string str = "";
  rep(i,n){
    str += "0";
  }
  rep(i,m){
    cin >> s >> c;
    if(s == 1&&c == '0'&&n!=1){
      cout << "-1" << endl;
      return 0;
    }else{
      if(str[s-1]!='0'&&str[s-1]!=c){
        cout << "-1" << endl;
        return 0;
      }else{
        str[s-1]=c;
      }
    }
  }
  if(n == 1 || str[0]!='0'){
    cout << str << endl;
  }else{
    str[0]='1';
    cout << str << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int count(int N)
{

        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int A, B, C, X, Y;
        cin >> A >> B >> C >> X >> Y;
        int ans = 1000000000;
        if (X>Y)
        {
                ans = min(2 * Y * C + (X - Y) * A, ans);
        } else{
                ans = min(2 * X * C + (Y - X) * B, ans);
        }
        ans = min(C * max(X, Y) * 2, ans);
        ans = min(A * X + B * Y,ans);
        cout << ans << endl;



        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<ll> h(N);
  for(int i=0;i<N;++i){
    cin>>h[i];
  }
  
  bool flag=true;
  
  for(int i=N-2;i>=0;--i){
    if(h[i]-h[i+1]>1){
      flag=false;
      break;
    }
    if(h[i]-h[i+1]==1)
      --h[i];
  }
  
  if(N==1)
    flag=true;
  
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

using namespace std;
typedef long long ll;

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

    vector<int> o(N+1,true);
    for(int i=0;i<M;i++){
        int tmp;
        cin>>tmp;
        o[tmp] = false;
    }

    const int mod = 1e9+7;
    vector<ll> dp(N+1);
    dp[0]=1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=min(i+2,N);j++){
            if(o[j]){
                dp[j] += dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[N];
}

Measured memory_bytes: 1408
// luogu-judger-enable-o2
#include<cstdio>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
const int N=100011;
template<typename TP>inline void read(TP &kk)
{
	TP ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	kk=ret*f;
}
int n,fa[N];
int find(int x)
{
	if(fa[x]!=fa[fa[x]]) find(fa[x]);
	return fa[x]=fa[fa[x]];
}
struct shino{int x,y;shino(){}shino(int x,int y):x(x),y(y){}};
queue<shino> q;
set<int> to[N];
set<int>::iterator it,it2;
int counter;

int xi,yi,ti;
int main()
{
	read(n);for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=3;i<=n*2;i++)
	{
		read(xi),read(yi);
		if(to[xi].find(yi)!=to[xi].end())
			q.push(shino(xi,yi));
		else to[xi].insert(yi),to[yi].insert(xi);
	}
	while(!q.empty())
	{
		shino g=q.front();q.pop();
		xi=g.x,yi=g.y;
		xi=find(xi),yi=find(yi);
		if(xi==yi) continue;
		to[xi].erase(yi),to[yi].erase(xi);
		counter++;
		if(to[xi].size()<to[yi].size()) swap(xi,yi);
		for(it=to[yi].begin();it!=to[yi].end();it++)
		{
			ti=*it;to[ti].erase(yi);
			if(to[xi].find(ti)!=to[xi].end())
				q.push(shino(xi,ti));
			else to[xi].insert(ti),to[ti].insert(xi);
		}
		fa[yi]=xi;
	}
	// counter=0;
	// for(int i=1;i<=n;i++) counter+=find(i)==i;
	if(counter==n-1) puts("YES");
	else puts("NO");
	return 0;
}

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

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<pair<int, int>> Query(Q);
    vector<int> xs1, xs2;
    for (int i = 0; i < Q; i++)
    {
        cin >> Query.at(i).first >> Query.at(i).second;
        if (Query.at(i).first == 1)
        {
            xs1.push_back(Query.at(i).second);
        }
        else
        {
            xs2.push_back(Query.at(i).second);
        }
    }
    sort(xs1.rbegin(), xs1.rend());
    sort(xs2.rbegin(), xs2.rend());

    int64_t ans = (int64_t)(N - 2) * (N - 2);
    int idx1 = 0, idx2 = 0;
    int r = N, b = N;
    for (int i = 0; i < Q; i++)
    {
        int x = Query.at(i).second;
        if (Query.at(i).first == 1)
        {
            if (idx1 >= (int)xs1.size())
                continue;
            if (x > xs1.at(idx1))
                continue;
            while (x != xs1.at(idx1))
            {
                ans -= b - 2;
                idx1++;
            }
            ans -= b - 2;
            idx1++;
            r = x;
        }
        else
        {
            if (idx2 >= (int)xs2.size())
                continue;
            if (x > xs2.at(idx2))
                continue;
            while (x != xs2.at(idx2))
            {
                ans -= r - 2;
                idx2++;
            }
            ans -= r - 2;
            idx2++;
            b = x;
        }
    }
    cout << ans << endl;
}


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

#define MOD 1e+9;

using namespace std;

auto f=[](){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
};

int main()
{
	f();
	int N;
	cin>>N;
	int i=0;
	bool approved=true;
	while(i<N){
		int num;
		cin>>num;
		if(num%2==0 && (num%3!=0 && num%5!=0)){
			approved=false;
			break;
		}
	++i;
	}
	cout<<(approved?"APPROVED\n":"DENIED\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> da(n);
  for(int i=0;i<n;i++){
    cin >> da[i];
  }
  sort(da.begin(),da.end());
  cout << da[n-1]-da[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
ll color[222222];
//-1 black 1 white
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;
    E[a].pb(b);
    E[b].pb(a);
  }
  queue<pair<ll,ll>>que;
  que.push(mp(1,-1));
  que.push(mp(n,1));
  color[1]=-1;
  color[n]=1;
  while(!que.empty()){
    pair<ll,ll>now=que.front();
    que.pop();
    for(auto a:E[now.F]){
      if(color[a]==0){
	color[a]=now.S;
	que.push(mp(a,now.S));
      }
    }
  }
  ll now=0;
  for(int i=1;i<=n;i++){
    // cout<<now<<endl;
    now+=color[i];
  }
  //cout<<now<<endl;
  if(now<0)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}

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


int main()
{
    int i,j,a,b,c=0,n,t=0;
    char ch[10];
    scanf("%d%d",&a,&b);
    scanf("%s",ch);
    n = strlen(ch);
    //printf("%d\n",n);
    for(i=0; i<n; i++)
    {
        if(ch[i]>='0' && ch[i]<='9' && i<a)
        {
            ++t;
            if(t==a)
            {
                ++c;
                //printf("c1 = %d\n",c);
                t=0;
            }
        }
        else if(ch[i]=='-' && i==a)
        {
            ++t;
            if(t==1)
            {
                ++c;
                //printf("c2 = %d\n",c);
                t = 0;
            }
        }
        else if( ch[i]>='0' && ch[i]<='9'  )
        {
            ++t;
            if(t==b)
            {

                ++c;
                //printf("c3 = %d\n",c);
                t=0;
            }
        }

    }
    if(c==3)
        printf("Yes\n");
    else
        printf("No\n");
}

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

int main () {
  int N , K;
  cin >> N >> K;
  string S;
  cin >> S;
  for(int i = 0; i < N; i++){
    if(i + 1 == K){
      S.at(i) += 32;
    }
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod 1000000007
using namespace std;

ll n,dp[200005],a[200005],c,q[200005],l,r;
ll sqr(ll x){
	return x*x;
}
bool m(ll a1,ll a2,ll now){
	if ((dp[a2]+sqr(a[a2]))-(dp[a1]+sqr(a[a1])) < 2*a[now]*(-a[a1]+a[a2]))
	return true;
	return false;
}
bool m2(ll a1,ll a2,ll a3){
	if ((double)((dp[a2]+sqr(a[a2]))-(dp[a1]+sqr(a[a1])))/(double)(-a[a1]+a[a2]) < (double)((dp[a3]+sqr(a[a3]))-(dp[a2]+sqr(a[a2])))/(double)(-a[a2]+a[a3]))
	return true;
	return false;
}
int main(){ 
	ios::sync_with_stdio(false);
	cin >> n >> c; 
	for (int i=1;i<=n;i++){
		cin >> a[i];
	}
	q[1]=1; l=1; r=1;
	for (int i=2;i<=n;i++){
		while (r-l >= 1 && m(q[l],q[l+1],i)){
			l++;
		}
		dp[i]=dp[q[l]]+sqr(a[i]-a[q[l]])+c;
		while (r-l >= 1 && m2(i,q[r],q[r-1])){
			r--;
		}
		r++;
		q[r]=i;
	}
	cout << dp[n] << "\n";
    return 0; 
} 

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

bool isKaibun(string tmp)
{
    for (ll i = 0; i < tmp.size() / 2; i++)
    {
        if (*(tmp.begin() + i) != *(tmp.end() - 1 - i))
        {
            return false;
        }
    }
    return true;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;

    if (isKaibun(s) && isKaibun(s.substr(0, (s.size() - 1) / 2)) && isKaibun(s.substr((s.size() + 3) / 2 - 1)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{ 
ll n,k;
cin >> n>>k;
if(k==0){
    cout << n*n << endl;
return 0;
}

rep1(i,n+1){
    if(i<=k)ans+=n;
    else {
        ans+=k*(n/i)-1;
        if(n%i<k-1)ans+=n%i+1;
        else ans+=k;
    }
}
ans=n*n-ans;
cout << ans << endl;
return 0;
} 

Measured memory_bytes: 256
MOD = 10 ** 9 + 7


def main(S, T):
  l = len(T) + 1
  dp = [0] * l
  # sdp = [[0] * (len(T) + 1) for _ in range(len(S) + 1)]

  # for i, s in enumerate(S):
  #  for j, t in enumerate(T):
  #    v = sdp[i][j + 1] + sdp[i + 1][j] + (1 if s == t else -sdp[i][j])
  #    sdp[i + 1][j + 1] = v % MOD
  for i, s in enumerate(S):
    tmp = [0] * l
    for j, t in enumerate(T):
      v = dp[j + 1] + tmp[j] + (1 if s == t else -dp[j])
      tmp[j + 1] = v % MOD
    dp = tmp

  # return (sdp[-1][-1] + 1)
  return dp[-1] + 1


if __name__ == '__main__':
  if True:
    _, _ = map(int, input().strip().split())
    S = input().strip().split()
    T = input().strip().split()
  else:
    S = range(1000)
    T = range(1000)
  print(main(S, T))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
string f(int64_t n, string s)
  {--n;
  if (n < 26) {return char(n + 'a') + s;}
  return f(n / 26, char(n % 26 + 'a') + s);}
int main()
  {int64_t N; cin >> N;
  cout << f(N, "") << endl;}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,sum=0,i,j,k,l,mul=1,flag =0,maxi=LONG_LONG_MIN,mini =LONG_LONG_MAX;
    string s,ss="",s1="";
    cin>>s;
    l=s.size();
    ss= s;
    reverse(ss.begin(),ss.end());
    if(s!= ss)
        flag =1;
    ss= s.substr(0,(l-1)/2);
    s1=ss;
    reverse(s1.begin(),s1.end());
    if(s1!=ss)
        flag =1;
    ss= s.substr((l + 3)/2-1,l-(l+3)/2+1 );
    s1= ss;
    //cout<<s1<<endl;
    reverse(s1.begin(),s1.end());
    if(s1!=ss)
        flag =1;
    if(flag == 0)
        puts("Yes");
    else
        puts("No");
}


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

static const int MAX=100000;
int n,A[MAX+1],L[MAX];

int lis(){
    L[0]=A[0];
    int length=1;
    
    for(int i=1;i<n;i++){
        if(L[length-1]<A[i]){
           L[length++]=A[i];
        }else{
            *lower_bound(L,L+length,A[i])=A[i];
        }
    }
    return length;
}

int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    
    cout<<lis()<<endl;
    
    return 0;
}



Measured memory_bytes: 3868
#include<iostream>
#include<stdio.h>
#include<cstring>
int main(){
    char s[201],t[101],r[101];
    scanf("%s %s",s,r);
    strcpy(t,s);
    strcat(s,t);
    if(strstr(s,r)==NULL) printf("No\n");
    else printf("Yes\n");
    return 0;
}



Measured memory_bytes: 3152
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        double sum = 0;
        for (int i = 0; i < n; i++) {
            String xs = sc.next();
            String us = sc.next();

            if (us.equals("JPY")) {
                sum += Long.parseLong(xs);
            } else {
                sum += 380000.0 * Double.parseDouble(xs);
            }
        }
        System.out.println(String.format("%.9f", sum));

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    ll n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    for(int i = 1; i <= n; i++) {
        cout << mp[i] << endl;
    }
}


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

int main() {
	string S;
	cin >> S;
	vector<char> vec(26);
	bool finished = false;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < S.size(); j++) {
			if (S.at(j) == 97 + i) {
				finished = true;
				break;
			}
		}
		if (finished == false)
			vec.at(i) = 97 + i;
		else
			finished = false;
	}
	finished = false;
	sort(vec.begin(), vec.end());
	for (int i = 0; i < 26; i++) {
		if (vec.at(i) != 0) {
			cout << vec.at(i) << endl;
			finished = true;
			break;
		}
	}
	if (finished == false)
		cout << "None" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
 char a,b;

 scanf("%c %c",&a,&b);

 if((a=='H')&&(b=='H'))printf("H");
 else if((a=='H')&&(b=='D'))printf("D");
 else if((a=='D')&&(b=='H'))printf("D");
 else if((a=='D')&&(b=='D'))printf("H");

 return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	const N = 1_000_000_007

	n := sc.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
	}

	sum := 0
	sqSum := 0
	for _, ai := range a {
		sum += ai
		sum %= N

		sqSum += ai * ai % N
		sqSum %= N
	}
	sumSq := sum * sum % N
	df := ((sumSq - sqSum) + N) % N
	if df%2 == 0 {
		fmt.Println(df / 2)
	} else {
		fmt.Println((df + N) / 2)
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<int64_t>>& edges, const vector<int64_t>& d,
         vector<int64_t>& colors, int64_t v) {
    colors[v] = -2;  // visiting and color is not determined yet.
    for (const auto& u : edges[v]) {
        if (d[u] > d[v]) {
            continue;
        }

        if (colors[u] == -2L) {
            continue;
        }

        if (colors[u] == /* not visited */ -1L) {
            dfs(edges, d, colors, u);
        }

        if (colors[v] == -2L) {
            colors[v] = 1 - colors[u];
        }
    }

    if (colors[v] == -2L) {
        colors[v] = 0L;
    }
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> d(n);
    for (auto&& dd : d) {
        cin >> dd;
    }

    vector<vector<int64_t>> edges(n);
    vector<int64_t> weights(m), colors(n, -1L);
    vector<bool> ok(n, false);
    for (auto i : irange(0L, m)) {
        int64_t u, v;
        cin >> u >> v;
        --u;
        --v;

        auto weight = max(d[u], d[v]);

        edges[u].push_back(v);
        edges[v].push_back(u);
        weights[i] = weight;

        if (d[u] >= d[v]) {
            ok[u] = true;
        }
        if (d[v] >= d[u]) {
            ok[v] = true;
        }
    }

    if (find(ok.begin(), ok.end(), false) != ok.end()) {
        cout << -1 << endl;
        return 0;
    }

    for (auto v : irange(0L, n)) {
        if (colors[v] < 0) {
            dfs(edges, d, colors, v);
        }
    }

    for (auto v : irange(0L, n)) {
        cout << (colors[v] ? "B" : "W");
    }
    cout << endl;

    for (auto w : weights) {
        cout << w << "\n";
    }
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define f first
#define s second
#define pb push_back
#define ipair pair<int,int>
#define INF INT_MAX
using namespace std;

int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int n1=a/d;
        if(a%d!=0)
            n1+=1;
        int n2=c/b;
        if(c%b!=0)
            n2+=1;
        if(n1>=n2)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}







Measured memory_bytes: 3652
#1st: ARC007-B
if False:
    N,M=map(int,input().split())
    case=[i for i in range(N+1)]
    for _ in range(M):
        now=int(input())
        i=case.index(now)
        case[i]=case[0]
        case[0]=now
        # print(case)
    for i in range(1,N+1):
        print(case[i])

#2nd: ABC004-C (0408)
if False:
    N=int(input())-1
    N=N%30
    ans=list(range(1,7))
    for i in range(N+1):
        ans[i%5],ans[i%5+1]=ans[i%5+1],ans[i%5]
        # print(ans)
    print(''.join(map(str,ans)))

#3rd: AGC011-A (0408)
if False:
    N,C,K=map(int,input().split())
    T=[int(input()) for _ in range(N)]
    T.sort()
    cnt=1
    pas=1 # 乗客数
    tim=K+T[0] # departure time
    # print(T)
    for i in range(1,N):
        t=T[i]
        if tim<t or pas>=C:
            cnt+=1
            tim=t+K
            pas=1
        else:
            pas+=1
        # print(tim,pas,cnt)
    print(cnt)

#4th: ABC072-D (0408)
if False:
    N=int(input())
    P=[int(i) for i in input().split()]
    ans=0
    cnt=0
    for i in range(N-1):
        if P[i]==i+1:
            P[i],P[i+1]=P[i+1],P[i]
            cnt+=1
    if P[N-1]==N:
        P[N-1],P[N-2]=P[N-2],P[N-1]
        cnt+=1
    print(cnt)

#5th: AGC009-A (0408)
if True:
    N=int(input())
    A=[]
    B=[]
    for _ in range(N):
        a,b=map(int,input().split())
        A.append(a)
        B.append(b)
    cnt=0
    for i in reversed(range(N)):
        if (A[i]+cnt)%B[i]!=0:
            cnt+=B[i]-(A[i]+cnt)%B[i]
        # print(cnt)
    print(cnt)
        

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

int push(int a){
  cout<<a<<endl;
  a--;
}

int main(){
  int a,b;
  int sum = 0;
  cin>>a >>b;
  for(int i = 0; i < 2;i++){
    if(a>b){
      sum += a;
      a--;
    }else if(a<b){
      sum += b;
      b--;
    }else{
      sum += a;
      a--;
    }
  }
  cout<<sum<<endl;
}
    

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

double noudo(int a,int b){
  return double(100 * b) / double(a + b);
}

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

  double maxnoudo = 0;
  int x,y;

  FOR(i,1,f) FOR(j,1,f){ // i:水,j:砂糖
    if(i % 100 != 0 or i + j > f) continue;
    // iを作れるか
    bool f = false;
    rep(k,(i/100)+1)
      if(i >= a*k*100 and (i - a * k * 100) % (b * 100) == 0) f = true;
    if(!f) continue;
    f = false;
    // jが作れるか
    rep(k,j+1)
      if(j >= c * k and (j - c * k) % d == 0) f = true;
    if(!f) continue;
    if(noudo(i,j) <= noudo(100,e) and noudo(i,j) > maxnoudo){
      maxnoudo = noudo(i,j);
      x = i;
      y = j;
    }
  }

  if(maxnoudo == 0) cout << 100 * a << " " << 0 << endl;
  else cout << x+y << " " << y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
using namespace std;


int main(){

  int n,k;
  cin >> n >> k;

  vector<int> d(k);
  for(int i=0;i<k;i++){
    cin >> d[i];
  }

  vector<int> a;

  for(int i=0;i<10;i++){
    for(int j=0;j<k;j++){
      if(i == d[j] )break;
      if(j==k-1) a.push_back(i);
    }
  }


  for(int i=n;i<=100000;i++){
    string tmp = to_string(i);
    for(int j=0;j<tmp.size();j++){
      bool flag = false;

      for(int k=0;k<a.size();k++){
        if(tmp[j]-'0' == a[k]) flag = true;
      }

      if( flag == false ) goto AAA;
    }
    cout << tmp << endl;
    return 0;

    AAA: ;
  }



  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    cout << (N - 1) / 2 << '\n';
}

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


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

int main(){

    pair<long long,long long> p[3];
    long long w,a,b;
    cin >> w >> a >> b;

    p[1].first = a;
    p[2].first = b;
    p[1].second = a + w;
    p[2].second = b + w;

    if(p[1].first > p[2].first){

        pair<long long,long long> temp = p[1];
        p[1] = p[2];
        p[2] = temp;
    }

    if(p[1].second >= p[2].first && p[1].second <= p[2].second){

        cout << 0 << endl;
    }
    else{

        cout << p[2].first - p[1].second << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h> 
int main( ) 
{   int num;   
int i = 0 ;     
while(1)     
{       
	++i;               
	scanf("%d", &num);       
	if( num == 0)
	{     
	break; 
	}        
	printf("Case %d: %d\n", i, num);       
}       
return 0;     
}

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

long long facctorialMethod(long long k){
    long long sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long permutationMethod(long long n,long long r){
    long long n_sum,r_sum;
    n_sum = facctorialMethod(n);
    r_sum = facctorialMethod(r);
    r = n - r;
    r_sum *= facctorialMethod(r);
    return n_sum/r_sum;
}

int main(){
  long long N,K;
  cin >> N >> K;
  if(K==0){
    cout << N*N << endl;
    return 0;
  }
  long long count=0;
  for(int i=2;i<=N;i++){
    long long c = N/i;
    long long cc = (i-1)-K+1;
    if(cc>0)count += c*cc;
    if(N%i==0)continue;
    long long r = (i-1)-(i-N%i-1);
    if(K<=r){
      count += r-K+1;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

class program{
  static void Main(string[] args){
    program p= new program();
      p.Run();
  }
  void Run(){
    int[] ap=Readint();
    int p=ap[0]*3+ap[1];
    p=(int)(p/2);
    WriteLine(p.ToString());
  }
  int[] Readint(){
    string[] inp= ReadLine().Split();
    int n=inp.Length;
    int[] res=new int[n];
    for(int i=0;i<n;i++){
      res[i]=int.Parse(inp[i]);
    }
    return res;
  }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    vector<int> dp(100010);
    for(int i = 0; i < 100010; i++){
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

typedef long long ll;
typedef pair<int, int> pii;


bool pal(string s) {
    string rs = s;
    reverse(all(rs));
    return s == rs;
}

int main()
{
    //freopen("input.txt", "r", stdin);


    string s;
    cin >> s;
    if (pal(s) && pal(s.substr(0, (sz(s) - 1) / 2)))
        cout << "Yes\n";
    else
        cout << "No\n";

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[110000], n, sum;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n]);
    for (int i = 0; i < n; i++) {
        cout << sum - abs(a[i + 2] - a[i + 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 2] - a[i]) << endl;
    }
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String inputText = scan.nextLine();
            String[] nums = inputText.split(" ",0);
            int num=Integer.parseInt(nums[0])+Integer.parseInt(nums[1]);
            System.out.println(num);
        }
        
    }
}

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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }


int main(){
    int n;
    cin>>n;
    vl v(n);
    map <int,int> ii;
    ll ans=0;
    pan(i,n) cin>>v[i];
    pan(i,n)
        ii[i+v[i]]++;
    pan(j,n)
        ans+=ii[j-v[j]];
    cout<<ans;
}

Measured memory_bytes: 22004
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	// if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

int cnt[N], used[N];
void solve()
{	
	int res = 0, sum = 0;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int x;
		string s;
		cin >> x >> s;
		if(used[x]) continue;
		if(s[0] == 'W') cnt[x]++;
		else{
			used[x] = 1;
			sum += cnt[x];
			res++;
		}
	}
	cout << res << " " << sum << endl;
}

 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#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--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll x,y ; cin>>x>>y ;
 if(x<y&&(y<=0 || 0<= x)) cout<< y-x<<endl ;
 else if(x*y<0) cout<< abs( abs(x)- abs(y))+1 <<endl ;
 else if(x>y&&(0>x || 0<y)) cout<< abs(abs(x)-abs(y))+2 <<endl ;
 else cout<< abs(abs(x)-abs(y)) +1 <<endl ;
  
 return 0 ; 
}



Measured memory_bytes: 3592
function main(input) {
  const lines = input.trim().split("\n");
  const [N, K] = lines[0].split(' ').map(Number);

  const a = new Set();
  const limit = K * 2;
  for (let i = 2; i <= limit; i += 2) {
    const as = lines[i].split(' ').map(Number);
    as.forEach(_a => a.add(_a) );
  }
  const res = N - a.size;
  
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29864
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  bool ans = true;
  int xi, yi;
  vector<int> N(n);
  vector<int> M(m);
  for(int i = 0; i < n; ++i)
    cin >> N[i];
  for(int i = 0; i < m; ++i)
    cin >> M[i];

  for(int z = x + 1; z <= y; ++z) {
    ans = true;
    for(int i = 0; i < N.size(); ++i) {
      if(N[i] >= z) ans = false;
    }
    for(int i = 0; i < M.size(); ++i) {
      if(M[i] < z) ans = false;
    }
    if(ans) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if (500 * a + 100 * b + 50 * c == X):
        ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
	public static int sum = 0;
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int[] S = new int[n];
		
		for(int i = 0; i < n; i++) {
			S[i] = scan.nextInt();
		}
		
		margeSort(S, 0, n);

		for(int i = 0; i < n; i++) {
			System.out.print(S[i]);
			
			if(i < n - 1) System.out.print(" ");
		}

		System.out.println();
		System.out.println(sum);
		
		scan.close();
	}
	
	static void marge(int[] A, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;

		int L[] = new int[n1 + 1];
		int R[] = new int[n2 + 1];
		
		for(int i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		
		for(int i = 0; i < n2; i++) {
			R[i] = A[mid + i];
		}
		
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		
		int i = 0;
		int j = 0;
		
		for(int k = left; k < right; k++) {
			sum++;
			if(L[i] <= R[j]) {
				A[k] = L[i];
				i++;
				
			} else {
				A[k] = R[j];
				j++;
			}
		}
	}
	
	 static void margeSort(int[] A, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			
			margeSort(A, left, mid);
			margeSort(A, mid, right);
			marge(A, left, mid, right);
		}
	}
}

Measured memory_bytes: 169180
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s = sc.next();
        if(n%2==0){
            //System.out.println(s.substring(0,n/2)+" "+s.substring(n/2,n));
            if(s.substring(0,n/2).equals(s.substring(n/2,n))){

                System.out.println("Yes");
                return;
            }
            System.out.println("No");
        }else{
            System.out.println("No");
        }



    }

}


Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; ++i) {
    if ((int)(i * 1.08) == n) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts(":(");
}


Measured memory_bytes: 128
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b;
    if(a>=10)cout<<b;
    else cout<<b-100*a+1000;
    return 0;
}


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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}

template<typename T>
int UBS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}

	if (mas[l] >= val)
		return l;
	if (mas[r] >= val)
		return r;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main()
{
	IOS
	ll k,a,b;
	cin >> k >> a >>b;
	if(a >= b-1 || k <= a)
		cout << k + 1;
	else{
		ll res = 0;
		if((k -a) %2 == 0)
			cout << (((k - a)/2) - 1)  * (b -a) + b + 1;
		else
			cout << ((k - a)/2) * (b - a) + b;
	}
	return 0;
}


Measured memory_bytes: 256