akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define db double
#define RE register
#define ll long long
#define P 1000000007
#define INF 1000000000
#define get(x) x=read()
#define PLI pair<ll,int>
#define PII pair<int,int>
#define pb(x) push_back(x)
#define ull unsigned long long
#define put(x) printf("%d\n",x)
#define getc(a) scanf("%s",a+1)
#define putl(x) printf("%lld\n",x)
#define rep(i,x,y) for(RE int i=x;i<=y;++i)
#define fep(i,x,y) for(RE int i=x;i>=y;--i)
#define go(x) for(int i=link[x],y=a[i].y;i;y=a[i=a[i].next].y)
using namespace std;
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
inline int ceil(int a,int b)
{
	if(a%b==0) return a/b;
	else return a/b+1;
}
int main()
{
//	freopen("1.in","r",stdin);
	int a,b,c,d;
	get(a);get(b);get(c);get(d);
	int t1=ceil(a,d),t2=ceil(c,b);
	if(t1>=t2) puts("Yes");
	else puts("No");
	return 0;
}





Measured memory_bytes: 3636
#include <cstdio>


typedef long long int ll;

const int MAXN=2e5+10;
ll N,K;
int A[MAXN];
int dist[MAXN];
bool visited[MAXN];

int loop_start,final_dist;
void explore(int cur,int d){
    if (visited[cur]){
        loop_start=cur;
        final_dist=d;
        return;
    }

    dist[cur]=d;
    visited[cur]=true;
    explore(A[cur],d+1);
}

int main(){
    scanf("%lld%lld",&N,&K);
    for(int i=1;i<=N;i++) scanf("%d",A+i);
    explore(1,0);

    if (K<=dist[loop_start]){
        for(int i=1;i<=N;i++)
            if (dist[i]==K){
                printf("%d\n",i);
                return 0;
            }
    }else{
        K-=dist[loop_start];
        int loop_len=final_dist-dist[loop_start];
        ll remain=K%(ll)(loop_len);
        int ans=loop_start;
        for(ll i=0;i<remain;i++) ans=A[ans];
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 3440
#include <cstdio>
#include <vector>

std::vector<int> e[100000];

int solve(int a, int p){
  int c=0;
  for(auto b: e[a]){
    if(b == p) continue;
    int x = solve(b, a);
    if(x<0) return -1;
    if(x==0){
      if(c) return -1;
      c = 1;
    }
  }
  return c;
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i=0;i<n-1;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    e[a-1].push_back(b-1);
    e[b-1].push_back(a-1);
  }
  if(solve(0, -1) == 1) puts("Second");
  else puts("First");
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 998244353;
const ll INF = 1000000000000000;
ll N, M, ans, x[100010], amari[100010];
ll mp[100010], kumi[100010];

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll pow_ll(ll x, ll y)
{
	if (y == 0) return 1;
	return x * pow_ll(x, y - 1);
}

ll div(ll x)
{
	return pow(x, mod - 2);
}



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

	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		mp[x[i]]++;
	}
	
	for (int i = 0; i < 100005; i++)
	{
		kumi[i % M] += mp[i] / 2;

		amari[i % M] += mp[i];
	}
	
	for (int i = 1; i <= M / 2; i++)
	{
		if (M % 2 == 0 && i == M / 2)
		{
			ans += amari[i] / 2;
		}
		else
		{
			ll u = min(amari[i], amari[M - i]);
			ans += u;
			ans += (kumi[i] * 2 + u > amari[i] ? (amari[i] - u) / 2 : kumi[i]);
			ans += (kumi[M - i] * 2 + u > amari[M - i] ? (amari[M - i] - u) / 2 : kumi[M - i]);
		}
	}

	ans += amari[0] / 2;

	cout << ans << endl;

	int xxx;
	cin >> xxx;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#define mod (10000)
#define rep(i,n)for(int i=0;i<n;i++)
int dp[100][3][4][4],ps[100];
int n,k,a,b;
int main() {
	scanf("%d %d",&n,&k);
	memset(ps,-1,sizeof(ps));
	rep(i,k) {
		scanf("%d %d",&a,&b);
		ps[a-1]=b-1;
	}
	if(ps[0]!=-1) {
		dp[0][ps[0]][3][3]=1;
	}else {
		rep(i,3)dp[0][i][3][3]=1;
	}
	if(ps[1]!=-1) {
		rep(i,3)dp[1][ps[1]][i][3]+=dp[0][i][3][3];
	}else {
		rep(i,3)rep(j,3)dp[1][i][j][3]+=dp[0][j][3][3];
	}
	if(ps[2]!=-1) {
		rep(i,3)rep(j,3) {
			if(!(i==j && i==ps[2]))
			dp[2][ps[2]][i][j]+=dp[1][i][j][3];
		}
	}else {
		rep(i,3)rep(j,3)rep(k,3) {
			if(!(i==j && i==k))
			dp[2][i][j][k]+=dp[1][j][k][3];
		}
	}
	for(int i=3;i<n;i++) {
		if(ps[i]!=-1) {
			rep(j,3)rep(k,3) {
				if(!(j==ps[i] && j==k))
				rep(l,3) dp[i][ps[i]][j][k]+=dp[i-1][j][k][l];
				dp[i][ps[i]][j][k]%=mod;
			}
		}else {
			rep(j,3)rep(k,3)rep(l,3) {
				if(!(j==k && k==l))
				rep(m,3) dp[i][j][k][l]+=dp[i-1][k][l][m];
				dp[i][j][k][l]%=mod;
			}
		}
	}
	int sum=0;
	rep(i,3)rep(j,3)rep(k,3) {
		sum+=dp[n-1][i][j][k];
		sum%=mod;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 1040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

int n;
vec<pair<string, pair<int, int>>> r;

bool cmp(pair<string, pair<int, int>> l, pair<string, pair<int, int>> r) {
  if (l.first == r.first) {
    return l.second.first > r.second.first;
  } else {
    return l.first < r.first;
  }
}

void solve() {
  sort(r.begin(), r.end(), cmp);
  rep(i, n) {
    cout << r[i].second.second << endl;
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    string x; int y;
    cin >> x >> y;
    r.emplace_back(x, pair<int, int>(y, i + 1));
  }
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=200005;
const int mod=1e9+7;
int fac[maxn],facinv[maxn];
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
inline void prprpr(){
	fac[0]=1;
	rep(i,1,200000)fac[i]=1ll*fac[i-1]*i%mod;
	facinv[200000]=powmod(fac[200000],mod-2);
	per(i,199999,0)facinv[i]=1ll*facinv[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	return 1ll*fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
int main(){
	int res=0;
	prprpr();
	int n,m,a,b;read(n);read(m);read(a);read(b);
	rep(i,b,m-1){
		res=(res+1ll*C(n-a+i-1,i)*C(m+a-i-2,a-1))%mod;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj2[v]){if(!visit[x.F])dfs(x.F);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();q.pop();for(auto x:adj[u]){if(!visit[x])q.push(x);}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(!!a){pl("Yes");}else{pl("No");}}
void filesin(void){freopen("input.txt","r",stdin);}
void filesout(void){freopen("output.txt","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///AtCoder Beginner Contest 159
int main(void){
    fastio;
    string s;
    c(s);
    bool ok = 1;
    ll last = s.size()-1;
    f(i,0,s.size()){
        if(s[i] != s[last]){
            ok = 0;
        }
        last--;
    }
    ll n = s.size();
    last = ((n-1)/2)-1;
    f(i,0,((n-1)/2)){
        if(s[i] != s[last]){
            ok = 0;
        }
        last--;
    }
    last = n-1;
    f(i,((n+3)/2)-1,n){
        if(s[i] != s[last]){
            ok = 0;
        }
        last--;
    }
    YESNO(ok);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
#define forn(i,n) for (int i=0; i<int(n); ++i)
#define pb push_back

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll mod=MOD) {
    ll ans=1;
    for (; n; n/=2) {
        if (n%2) ans=ans*x%mod;
        x=x*x%mod;
    }
    return ans;
}

ll fact(int n) {
    static vi cache{1};
    for (ll i=cache.size(); i<=n; i++)
        cache.pb(cache.back()*i%MOD);
    return cache[n];
}

ll invfact(int n) {
    static vi cache{1};
    for (ll i=cache.size(); i<=n; i++)
        cache.pb(modpow(fact(i), MOD-2, MOD));
    return cache[n];
}

ll binomial(ll n, ll k) {
    if (k<0 || k>n) return 0;
    return fact(n)*invfact(k)%MOD*invfact(n-k)%MOD;
}

int main() {
    cxxio();
    ll n, a, b, k;
    cin>>n>>a>>b>>k;
    ll ans=0;
    forn(x, n+1) {
        ll y=k-x*a;
        if (y>=0 && y%b==0)
            ans=(ans+binomial(n, x)*binomial(n, y/b))%MOD;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 4720
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

const int MOD = 1000000007;

const int MAX = 1510000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0)
        return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll res = 0;
    combination_init();
    if ((X + Y) % 3 == 0) {
        ll a = (-X + 2 * Y) / 3;
        ll b = (X * 2 - Y) / 3;
        if (a >= 0 && b >= 0)
            res = combination(a + b, a);
    }

    cout << res << endl;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
string ans;
string s,t;
int dp[3004][3004];
void path(int i,int j)
{
    if(i<1 || j<1)
    return;
    if(dp[i][j] == 1+dp[i-1][j-1] && s[i-1]==t[j-1])
    {
        ans+=s[i-1];
        path(i-1,j-1);        
    }
    else
    {
        if(dp[i-1][j] > dp[i][j-1])
            path(i-1,j);
        else
            path(i,j-1);
    }
    
}
int main()
{
    fast;
    
    cin>>s>>t;
    int l=s.length(),m=t.length();
    
    for(int i=1;i<=l;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            
        }
    }
    // for(int i=0;i<=l;i++)
    // {
    //     for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";
    // }
    path(l,m);
    reverse(ans.begin(),ans.end());
    cout<<ans;
    // cout<<dp[l][m];
return 0;
}

Measured memory_bytes: 35456
declare function require(x: string): any;

var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");

const s = input.shift();
const n = s.length;

let result = 0;
for(let i=0; i<n; i++){
	if(s[i] == "p"){
		result -= 1;
	}
	else if(s[i] == "g"){
		result += 1;
	}
}
result = Math.floor(result/2);
console.log(result);



Measured memory_bytes: 7372
try:
    while True:
        a,b,c,d,e,f = map(float,input().split())
        if  a - d == 0:
            y = (c - f) / (b - e)
            x = (c - b*y) / a
        else:
            A = a*d
            D = d*a
            B = b*d
            C = c*d
            E = e*a
            F = f*a
            if C < F :
                y = (C - F) / (B - E)
                x = (c - b*y) / a
            else: 
                y = (F - C) / (E - B)
                x = (c - b*y) / a
        
        print(f'{round(x,3):.03f}',f'{round(y,3):.03f}')
        
except EOFError:
    pass


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[21111111];
signed main(){
    int n; scanf("%lld",&n); int tot=0;
    int pw=1;
    for (;n!=0;){
        pw*=-2;
        if (n%pw!=0){
            a[tot]=1;
            n-=(pw/-2);
        }
        tot++;
    }
    for (int i=tot-1;i>=0;i--) printf("%lld",a[i]);
    if (tot==0) printf("%d",0);
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int dat[100000];
int now[100000];
using namespace  std;
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int b,c;
		scanf("%d%d",&b,&c);
		for(int i=0;i<b;i++){
			scanf("%d",dat+i);
		}
		std::sort(dat,dat+b);
		int sum=dat[b-1]-dat[0];
		for(int i=1;i<b;i++)now[i-1]=dat[i]-dat[i-1];
		std::sort(now,now+b-1);
		for(int i=0;i<c-1;i++){
			sum-=now[b-2-i];
		}
		printf("%d\n",sum);
	}
}

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

int main()
{
 int n,l,a;
 cin >> n >> l;
 if(l<=-n+1){
   a=l+n-1;
 }else if((l>=-n)&&(l<=0)){
   a=0;
 }else{
   a=l;
 }
 cout<<(2*l+n-1)*n/2-a;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val S = next()
    val p = (S.count { it == 'g' } - S.count { it == 'p' }) / 2
    println(p)
}

Measured memory_bytes: 37132
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll,ll> P;
template <typename T> std::string tostr(const T& t){std::ostringstream os; os<<t; return os.str();}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main(){
    int s;
    cin>>s;
    set<int> v;
    int i=1;
    while(1){
        if(v.count(s)){
            cout<<i<<endl;
            break;
        }
        v.insert(s);
        if(s%2==0){
            s/=2;
        }else{
            s=s*3+1;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001,INF=1<<30;

int main(){

    int N,W;cin>>N>>W;
    vector<vector<int>> dp(N+1,vector<int>(W+1,0));
    for(int i=1;i<=N;i++){
        
        for(int j=0;j<=W;j++){
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
        
        int v,w,m;cin>>v>>w>>m;
        
        for(int k=0;(1<<k)<=m;k++){
            m-=(1<<k);
            for(int j=W;j>=w*(1<<k);j--){
                dp[i][j]=max(dp[i][j],dp[i][j-w*(1<<k)]+v*(1<<k));
            }
        }
        
        for(int j=W;j>=w*m;j--){
            dp[i][j]=max(dp[i][j],dp[i][j-w*m]+v*m);
        }
        
    }
    
    int ans=0;
    
    for(int i=0;i<=W;i++){
        ans=max(ans,dp[N][i]);
    }
    
    cout<<ans<<endl;
}




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

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 ll int A,B,K;
 cin >> A >> B >> K;

 if ( A < K){
	 if ( K-A >B){
		 cout << "0 0";
	 }
	 else{
		 cout << "0 " << B+A-K;
	 }
 }
 else{
	 cout << A-K << " " << B;
 }











	return 0;

}



Measured memory_bytes: 256
N=int(input())
res={}
for dummy in range(N):
  s=input()
  if s not in res.keys():
    res[s]=1
  else:
    res[s]+=1
M=int(input())
for dummy in range(M):
  s=input()
  if s not in res.keys():
    res[s]=-1
  else:
    res[s]-=1
tmp=max(res.values())
if tmp<0:print('0')
else: print(tmp)

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

// #define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
// #define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;

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

   int N;
   while (cin >> N, N) {
       bool gem[21][21] = {};

       REP(i, 1, N+1) {
           int x, y; cin >> x >> y;
           gem[y][x] = true;
       }

       int M; cin >> M;
       int get_n = 0;

       int cur_x = 10, cur_y = 10;
       if (gem[cur_y][cur_x]) {
           ++get_n;
           gem[cur_y][cur_x] = false;
       }

       REP(i, 1, M+1) {
           string dir; int len; cin >> dir >> len;
           int dx = 0, dy = 0;
           if (dir == "N") dy = 1;
           else if (dir == "S") dy = -1;
           else if (dir == "E") dx = 1;
           else if (dir == "W") dx = -1;
           else cout << "error1" << endl;

           REP(j, 1, len+1) {
               cur_x += dx; cur_y += dy;
               if (gem[cur_y][cur_x]) {
                   ++get_n;
                   gem[cur_y][cur_x] = false;
               }
           }
       }

       if (get_n == N) cout << "Yes" << endl;
       else cout << "No" << endl;
//       cout << get_n << " " << N << endl;
   }

   return 0;
}



Measured memory_bytes: 3192
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from math import floor

def solve():
    a, b = MI()

    for i in range(10000):
        x = floor(i * 0.08)
        y = floor(i * 0.1)
        if x == a and y == b:
            print(i)
            return
    print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
n=int(input())
d=[int(input()) for _ in range(n)]
from collections import deque
d.sort()
a=deque(d)

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

res=ans
import copy
d.sort(reverse=True)
a= deque(copy.deepcopy(d))

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

print(max(ans,res))




            




Measured memory_bytes: 14860
#include <climits>
#include <iostream>

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

    long long ans = LONG_LONG_MAX;
    for (int color = 0; color < 2; color++) {
        std::string copied_s = s;
        long long temp_ans = 0;
        for (int i = 0; i < copied_s.size(); i++) {
            if (s[i] - '0' != (i + color) % 2) {
                temp_ans++;
            }
        }
        ans = std::min(ans, temp_ans);
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u8,
        s: chars,
        t: chars,
    }
    for i in 0..n {
        print!("{}{}", s[i as usize], t[i as usize]);
    }
    println!();
}


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

int main(){
	string W, S;
	int cnt = 0;
	cin >> W;
	for(int i=0;i<W.size();i++) W[i]=tolower(W[i]);
	while(1){
		cin >> S;
		if(S == "END_OF_TEXT") break;
		for(int i=0;i<S.size();i++) S[i]=tolower(S[i]);
		if(S == W) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1192
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]

import math
dist = 0
for i in range(n):
    for j in range(n):
        dist += math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)

print(dist/n)


Measured memory_bytes: 9188
#22:10
a,b,q = map(int,input().split())
s = []
for _ in range(a):
  s.append(int(input()))
t = []
for _ in range(b):
  t.append(int(input()))
import bisect
st = []
for i in range(a):
  tmp = bisect.bisect_left(t,s[i])
  if tmp == 0:
    st.append(abs(s[i]-t[tmp]))
  elif tmp == b:
    st.append(abs(s[i]-t[tmp-1]))
  else:
    st.append(min(abs(s[i]-t[tmp-1]),abs(s[i]-t[tmp])))
ts = []
for j in range(b):
  tmp = bisect.bisect_left(s,t[j])
  if tmp == 0:
    ts.append(abs(t[j]-s[tmp]))
  elif tmp == a:
    ts.append(abs(t[j]-s[tmp-1]))
  else:
    ts.append(min(abs(t[j]-s[tmp-1]),abs(t[j]-s[tmp])))
'''
print(s)
print(t)
print(st)
print(ts)
'''
for _ in range(q):
  x = int(input())
  can = []
  xs = bisect.bisect_left(s,x)
  xt = bisect.bisect_left(t,x)
  try:
    can.append(abs(x-s[xs-1]) + st[xs-1])
  except:
    pass
  try:
    can.append(abs(x-s[xs])   + st[xs])
  except:
    pass
  try:
    can.append(abs(x-t[xt-1]) + ts[xt-1])
  except:
    pass
  try:
    can.append(abs(x-t[xt])   + ts[xt])
  except:
    pass
  print(min(can))

Measured memory_bytes: 20028
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int L, A[202020];

ll ls[202020], rs[202020], dp1[2][202020], dp2[2][202020];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> L;
    for (int i = 1; i <= L; ++i) cin >> A[i];

    for (int i = 1; i <= L; ++i) ls[i] = ls[i-1] + A[i];
    for (int i = L; i >= 1; --i) rs[i] = rs[i+1] + A[i];

    dp1[0][0] = dp1[1][0] = 0;
    dp2[0][L+1] = dp2[1][L+1] = 0;

    for (int i = 1; i <= L; ++i) {
        dp1[0][i] = min(ls[i], dp1[0][i-1] + (A[i] == 0 ? 2 : A[i] % 2));
        dp1[1][i] = min(dp1[0][i-1], dp1[1][i-1]) + (A[i] + 1) % 2;
    }

    for (int i = L; i >= 1; --i) {
        dp2[0][i] = min(rs[i], dp2[0][i+1] + (A[i] == 0 ? 2 : A[i] % 2));
        dp2[1][i] = min(dp2[0][i+1], dp2[1][i+1]) + (A[i] + 1) % 2;
    }

    ll ans = 1LL << 60;
    for (int i = 0; i <= L; ++i) {
        ans = min(ans, dp1[0][i] + dp2[0][i+1]);
        ans = min(ans, dp1[1][i] + dp2[0][i+1]);
        ans = min(ans, dp1[0][i] + dp2[1][i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11128
def main():
    """連鎖行列積を求める.    
    """
    n = int(input())
    inf = 10**10
    if n == 0 or n == 1:
        print(0)
        return
    if n > 1:
        p = [int(input().split()[0]) for _ in range(n-1)]
    p.extend(list(map(int, input().split())))
    m = [[inf*(i!=j) for i in range(n)] for j in range(n)]
    for l in range(1, n):
        for i in range(n-l):
            j = i+l
            for k in range(i, j):
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1])
    print(m[0][-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 6180
from array import array

size = 300000
s = array('i', range(size + 1))
for i in range(size+1):
    if i % 7 != 1 and i % 7 != 6:
        s[i] = 0
s[1] = 0
sqrtn = int(round(size ** 0.5))
for i in range(6, sqrtn + 1):
    if s[i]:
        s[i * i: size + 1: i] = array('i', [0] * len(range(i*i, size+1, i)))
primes = list(filter(None, s))

while True:
    n = int(input())
    if n == 1: break
    i = 0
    ls = []
    for p in primes:
        if p > n: break
        if n % p == 0:
            ls.append(p)
    print(n, end="")
    print(':', end=" ")
    print(*ls)

Measured memory_bytes: 9820
from math import sqrt
N = int(input())
ans = 0
# if N // i = p, N % i = p, 
# N = pi + p = p(i+1)
# p < sqrt(N) and p < i 
for p in range(1,N):
  if p > N/p - 1:
    break
  if N % p > 0:
    continue
  i = N//p - 1
  if p >= i:
    break
  ans += i
    
print(ans)

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

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

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

  long long ans = 0;
  long long maxV = 0;
  for (int i = 1; i < N; i++) {
    maxV = max(maxV,A[i-1]);
    ans += max(0LL,maxV - A[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
int main(void)
{
	string Slimes;
	int N;
	scanf("%d",&N);
	cin>>Slimes;
	int ans=0;
	char last='0';
	for(int i=0;i<N;i++)
	{
		if(Slimes[i]!=last)
		{
			ans++;
			last=Slimes[i];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

struct edge {
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

void dfs(int now_ind, int now_color, int color[], vector<vector<edge>>& G) {
  for (auto e : G[now_ind]) {
    if (color[e.to] != -1) continue;
    int next_color;
    if (e.cost % 2 == 0) {
      next_color = now_color;
    } else {
      next_color = 1 - now_color;
    }
    color[e.to] = next_color;
    dfs(e.to, next_color, color, G);
  }
}

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

  vector<int> u(N - 1), v(N - 1), w(N - 1);
  rep(i, N - 1) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--;
    v[i]--;
  }

  vector<vector<edge>> G(N);

  rep(i, N - 1) {
    G[u[i]].pb(edge(v[i], w[i]));
    G[v[i]].pb(edge(u[i], w[i]));
  }

  int color[N];
  color[0] = 0;
  repp(i, 1, N - 1) { color[i] = -1; }
  dfs(0, 0, color, G);

  rep(i, N) { cout << color[i] << endl; }
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

// [l, r), l and r is 0-indexed.
template<typename T>
using Interval = tuple<int, int, T>;
template<typename T>
struct Imos {
    int n;
    vector<T> s;
    Imos(int n, const vector<Interval<T>> &intervals) : n(n) {
        s.resize(n + 1, 0);
        for (auto interval : intervals) {
            T v = std::get<2>(interval);
            s[std::get<0>(interval)] += v;
            s[std::get<1>(interval)] -= v;
        }
        for (int i = 0; i < n; ++i) s[i + 1] += s[i];
    }
    int size() {
        return n;
    }
    T get(int i) {
        return s[i];
    }
};

void Main() {
	ll N, K; cin >> N >> K;
	vl A(N);
	REP(i, N) cin >> A[i];
    REP(_i, K) {
        vector<Interval<long long>> intervals(N);
        bool check = true;
        REP(i,N) {
            if (A[i] != N) check = false;
            intervals[i] = make_tuple(max(0ll, i - A[i]), min(N, i + A[i] + 1), 1);
        }
        if (check) {
            REP(j, N) {
                cout << N;
                if (j == N - 1) {
                    cout << endl;
                } else {
                    cout << " ";
                }
            }
            return;
        }
        Imos<long long> imos(N, intervals);
        A = imos.s;
    }
    REP(i, N) {
        cout << A[i];
        if (i == N - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

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


Measured memory_bytes: 11056
n,k=gets.split.map(&:to_i)
s=gets.chomp
c=0
(n-1).times do |i|
  if s[i]==s[i+1]
    c+=1
  end
end
if (n-1-c)/2>=k
  c+=2*k
else
  c+=n-1-c
end
p c




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


typedef pair<int,int> P;
const int MAX = 10001;
const int INF = 1<<29;

struct edge { int u, v, cost;};

bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}

edge es[MAX];
int V,E,ed;
int par[MAX];
int rank[MAX];
vector<int>v;


void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res = 0;
 
  for(int i=0; i<E; i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      ed++;
      unite(e.u,e.v);
      res += e.cost;
      v.push_back(e.cost);
    }
  }

  return res;

}
int main(){
  while(cin >> V >> E,V|E){

    for(int i=0; i<E; i++){
      int from,to,cost;
      cin >> from >> to >> cost;
      from--,to--;
      es[i].u = from;
      es[i].v = to;
      es[i].cost = cost;
    }

    v.clear();

    int c = kruskal();
    sort(v.begin(),v.end());
    cout << v[v.size()/2] << endl;

  }
  return 0;
}

Measured memory_bytes: 1368
const Main = input => {
    input = input.split("\n");
    const hwk = input[0].split(" ").map(value => parseInt(value, 10));

    const h = hwk[0];
    const w = hwk[1];
    const k = hwk[2];

    const table = [];
    for(let i = 0; i < h; i++) {
        const row = input[i + 1].split("");
        table.push(row);
    }

    // !行と列を複数赤く塗ることも可!

    // nを2進数の文字列にして返す
    const toBinary = (n) => {
        return n.toString(2);
    }

    // true...skipする
    const skip = (num, digit) => {
        // 2進数に変換し，n桁になるように0パディング
        const bin = toBinary(num).padStart(digit, "0");
        
        const arr = [];
        for(let i = 0; i < bin.length; i++) {
            if(bin.charAt(i) === "1") {
                arr.push(true);
            } else {
                arr.push(false);
            }
        }

        return arr;
    }

    let result = 0;
    let blackNum;
    for(let bi = 0; bi < 2 ** h; bi++) {
        for(let bj = 0; bj < 2 ** w; bj++) {
            // スキップする行，列を設定
            const skipI = skip(bi, h);
            const skipJ = skip(bj, w);

            blackNum = 0;

            // 黒マスの数を調べる(スキップすることもある)
            for(let i = 0; i < h; i++) {
                for(let j = 0; j < w; j++) {
                    if(skipI[i] || skipJ[j]) continue;

                    if(table[i][j] === "#") blackNum++;
                }
            }

            if(blackNum === k) result++;
        }
    }

    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33364
#include<stdio.h>
#include<math.h>
int main()
{
    double x;
    scanf("%lf",&x);
    double n=100;
    int sum=0;
    while(n<x)
    {
        n=floor(n*1.01);
        sum++;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 1744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0; i < n; i++){
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int ret = 0;
        for (int i = 0; i < k; i++) {
            ret += arr[i];
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 33040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> pen(n);
  vector<bool> done(n);
  rep(i, m) {
    int p; string s;
    cin >> p >> s;
    if(!done[--p]) {
      if(s == "WA") pen[p]++;
      else done[p] = true;
    }
  }
  int ans = 0;
  rep(i, n) if(done[i]) ans += pen[i];
  cout << accumulate(all(done), 0) << ' ' << ans << "\n";
  return 0;
}


Measured memory_bytes: 3664
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string S;
	int Q;
	cin >> S >> Q;

	int revcount = 0; // これが偶数ならそのまま、奇数なら逆転しているイメージ
	rep(i, Q)
	{
		int r;
		cin >> r;

		if (r == 1)
			revcount++;
		else
		{
			char t;
			cin >> r >> t;
			if ((r == 1 && revcount % 2 == 0) || (r == 2 && revcount % 2 == 1))
			{
				S.insert(S.begin(),t);
			}
			else
			{
				S.insert(S.end(), t);
			}
		}
	}

	if (revcount % 2 == 1)
		reverse(S.begin(), S.end());
	cout << S << '\n';
	return 0;
}


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

const int Inf = 1e9 + 7;
int N, A[3];
int l[8];

int solve(int m) {
  int mp = 0;
  int sum[3] = {0, 0, 0};
  rep(i, N) {
    int type = (m >> 2*i) & 0b11;
    if (type == 3) continue;
    if (sum[type]) mp += 10;
    sum[type] += l[i];
  }
  rep(i, 3) {
    mp += abs(A[i] - sum[i]);
    if(!sum[i]) return Inf;
  }
  return mp;
}

int main() {
  cin >> N;
  rep(i, 3) cin >> A[i];
  rep(i, N) cin >> l[i];

  int ans = Inf;
  for (int i = 0; i < (1 << 2*N); ++i) {
    ans = min(ans, solve(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }


// To count Number of ones in a binary number
// int count_one(int x){
//     x = (x & (0x55555555)) + ((x >> 1) & (0x55555555));
//     x = (x & (0x33333333)) + ((x >> 2) & (0x33333333));
//     x = (x & (0x0f0f0f0f)) + ((x >> 4) & (0x0f0f0f0f));
//     x = (x & (0x00ff00ff)) + ((x >> 8) & (0x00ff00ff));
//     x = (x & (0x0000ffff)) + ((x >> 16) & (0x0000ffff));
//     // cout << x << endl;
//     return x;
// }


void solve(){
    int n , W;
    cin >> n >> W;
    vl dp(W+1 , 0);
    // vi w(n , 0) , v(n,0);
    ll value = 0;

    f( i , 0 , n){
        ll value ;
        int weight;
        cin >> weight >> value;
        for (int j = W - weight ; j >= 0 ; j--){
            dp[j+weight] = max(dp[j+weight] , dp[j]+ value);
        }
    }
    ll ans = 0;
    f( j , 0 , W+1){
        ans = max(ans , dp[j]);
    }
    cout << ans << endl;

	return ;
    
}

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

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

int	main() {
	string S;
	vector<bool> c(26, false);
	cin >>S;
	if ("zyxwvutsrqponmlkjihgfedcba"==S) {
		cout <<-1 <<endl;
		return 0;
	}
	for (int i=0; i<S.size(); i++)
		c.at(S.at(i)-'a')=true;
	int i=S.size()-1;
	if (i<25) {
		int j;
		for (j=0; j<26; j++) {
			if (c.at(j))
				continue;
			else
				break;
		}
		S.push_back('a'+j);
		cout <<S <<endl;
		return 0;
	}
	while(true) {
		int C=S.at(i)-'a';
		c.at(C)=false;
		C++;
		while(C<26)
			if (c.at(C))
				C++;
			else
				break;
		if (26==C) {
			S.erase(S.begin()+i, S.end());
			i--;
		} else {
			S.at(i)=C+'a';
			cout <<S <<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <iterator>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef long double lld;
typedef pair<int,int> pi;
#define lli 			long long int
#define mod				(ll) 1000000007
#define pb 				push_back
#define f(i,s,n) 		for (int i=s;i<n;i++)
#define vii				vector<int>
#define seti      set<int>
#define mapi      map<int,int>
#define mapv      map<int,vii>
#define vll				vector<ll>
#define vpp				vector<pp>
#define vss				vector<string>
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define all(a)			a.begin(),a.end()
#define abs(a) 			a>0?a:-1*a
#define all(a)			a.begin(),a.end()
#define fo(i,a)       for(auto &i:a)
#define bs(v,x)			binary_search(all(v),x)
#define sort(ans)    sort(ans.begin(),ans.end());
#define sortrev(ans) sort(a.begin(), a.end(), greater<int>());
#define vii2d       vector<vector<int>>
#define ms          multiset<int>
void solve()
{
  string s;
  cin>>s;
  int ans=0;
  int cur=0;
  f(i,0,s.size())
  {
    if (s[i]=='R')
      cur+=1;
    else
    {
      ans=max(ans,cur);
      cur=0;
    }
  }
  if (cur>0)
  ans=max(ans,cur);
  cout<<ans<<endl;
}
int main()
{
    int t=1;
    //cin>>t;
    int count=1;
    while(t--)
    {
      solve();
      count+=1;
    }
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,M;
int POW[11],p[10];
vector<int> ADJ[10];


int main(){

	POW[0] = 1;
	for(int i = 1; i <= 10; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d",&N,&M);

	int num,tmp;

	for(int i = 0; i < M; i++){

		scanf("%d",&num);
		for(int k = 0; k < num; k++){

			scanf("%d",&tmp);
			tmp--;

			ADJ[i].push_back(tmp);
		}
	}

	for(int i = 0; i < M; i++){

		scanf("%d",&p[i]);
	}

	int ans = 0;
	bool check[10];

	for(int state = 0; state < POW[N]; state++){

		//スイッチのON:OFF
		for(int loop = 0; loop < N; loop++){

			if(state&POW[loop]){

				check[loop] = true;
			}else{

				check[loop] = false;
			}
		}

		bool FLG = true;
		for(int i = 0; i < M; i++){

			int count = 0;
			for(int k = 0; k < ADJ[i].size(); k++){

				if(check[ADJ[i][k]]){
					count++;
				}
			}

			if(count%2 != p[i]){
				FLG = false;
				break;
			}
		}
		if(FLG){
			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256