akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cstring>
using namespace std;
int matrix[101][101], temp[101];

int N;

int kadane(int* start,
           int* finish)
{
    int sum = 0, maxSum = INT_MIN, i;

    *finish = -1;

    int local_start = 0;

    for (i = 0; i < N; ++i)
    {
        sum += temp[i];
        if (sum < 0) {
            sum = 0;
            local_start = i + 1;
        }
        else if (sum > maxSum)  {
            maxSum = sum;
            *start = local_start;
            *finish = i;
        }
    }


    if (*finish != -1)
        return maxSum;

    maxSum = temp[0];
    *start = *finish = 0;

    for (i = 1; i < N; i++)
    {
        if (temp[i] > maxSum)
        {
            maxSum = temp[i];
            *start = *finish = i;
        }
    }
    return maxSum;
}


void findMaxSum()
{
    // Variables to store the final output
    int maxSum = INT_MIN, finalLeft, finalRight,
        finalTop, finalBottom;

    int left, right, i;
    int sum, start, finish;

    // Set the left column
    for (left = 0; left < N; ++left) {
        memset(temp, 0, sizeof(temp));

        for (right = left; right < N; ++right) {


            for (i = 0; i < N; ++i)
                temp[i] += matrix[i][right];

            sum = kadane(&start, &finish);


            if (sum > maxSum) {
                maxSum = sum;
                finalLeft = left;
                finalRight = right;
                finalTop = start;
                finalBottom = finish;
            }
        }
    }
    printf("%d\n", maxSum);
}



int main(){
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) scanf("%d", &matrix[i][j]);
    }
    findMaxSum();

    return 0;
}





Measured memory_bytes: 2764
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  ll cnt1=0,cnt2=0;
  rep(i,n){
    if(s[i]=='a'){
      if(cnt1<a+b){
        cout<<"Yes"<<endl;
        cnt1++;
      }else{
        cout<<"No"<<endl;
      }
    }
    if(s[i]=='b'){
      if(cnt1<a+b && cnt2<b){
        cout<<"Yes"<<endl;
        cnt1++;
        cnt2++;
      }else{
        cout<<"No"<<endl;
      }
    }
    if(s[i]=='c'){
      cout<<"No"<<endl;
    }
  } 
}

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

int main()
{
    long long n, m, down = 0;
    cin >> n >> m;
    if (n > m)
    {
        swap(n, m);
    }
    if (n == 1)
    {
        if (m == 1)
        {
            down = 1;
        }
        else
        {
            down = m - 2;
        }
    }
    else
    {
        down = (n - 2) * (m - 2);
    }
    cout << down;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int MOD = 2019;
int L, R;

int solve() {
    if (R - L + 1 >= MOD) {
        return 0;
    }
    int ret = MOD;
    for (int i = L; i < R; ++i) {
        for (int j = L+1; j <= R; ++j) {
            int tmp = 1LL * i * j % MOD;
            ret = std::min(tmp, ret);
        }
    }
    return ret;
}

int main() {
    scanf(" %d%d", &L, &R);
    printf("%d\n", solve());
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

unordered_map<int, int> factors(int n){
    unordered_map<int, int> d;
    for(int i = 2; i*i <= n; i ++) while(n % i == 0) d[i] ++, n /= i;
    if(n > 1) d[n] ++;
    return d;
}

int main(void){
    Cin(int, n);
    unordered_map<int, int> d;
    for(int i = 2; i <= n; i ++){
        for(auto e : factors(i)) d[e.first] += e.second;
    }
    ll ans = 1;
    for(auto e : d) ans = ans * (e.second + 1) % MOD;
    Cout(ans);
}


Measured memory_bytes: 256
#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);
  const int INF = 1000000007;
  vector<int> dp(N, INF);
  dp.at(0) = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = 1; j <= K; j++) {
      if (i+j < N) {
        dp.at(i+j) = min(dp.at(i+j), dp.at(i) + abs(h.at(i) - h.at(i+j)));
      }
    }
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	map<int, int> wow;
	int n;
	cin >> n;
	REP(i, n) {
		int hoge;
		cin >> hoge;
		wow[hoge]++;
	}
	int ans = 0;
	for (auto i = wow.begin();i != wow.end();++i) {
		if (i->second % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int main(){
    int n, i, x, min, max;
    long long sum = 0;
    min = 1000000, max = -1000000;
    cin>>n;
    for(i = 0; i < n; i++){
        cin >> x;
    if(x > max){
        max = x;
}
    if(x < min){
        min = x;
}
    sum += x;
}
    cout << min << " " << max << " " << sum << endl;
}


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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int n;
	cin >> n;
	int a[100] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i += 2) {
		ans += (a[i] - a[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
w = max((n-k+1) / n, 0)
coin_win = 0
for i in range(1, min(k, n+1)):
    for x in range(1, 18):
        if i * (2 ** x) >= k:
            coin_win += 1 / (2 ** x)
            break
if k != 1:
    print(w + (1-w) * coin_win / min(k-1, n))
else:
    print(w)

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

int main() {
  short int x, y;
  cin >> x >> y;
  if (x == 1 && y == 1) cout << 400000 + 300000 + 300000 << '\n';
  else {
    int s = 0;
    if (x <= 3) s += (4 - x) * 100000;
    if (y <= 3) s += (4 - y) * 100000;
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(m);
  vector<vector<int>> data(110, vector<int>(110,inf));
  rep(i,n){data[i][i]=0;}
  rep(i,m){ 
    cin >> a[i] >> b[i] >> c[i]; 
    a[i]--; b[i]--; 
    data[a[i]][b[i]]=min(c[i],data[a[i]][b[i]]);
    data[b[i]][a[i]]=min(c[i],data[b[i]][a[i]]);
  }

  rep(i,n)rep(j,n)rep(k,n){
    data[j][k] = min(data[j][k],data[j][i]+data[i][k]);
  }
  
  int ans=m;
  rep(i,m){
    rep(j,n)if(data[j][a[i]]+c[i]==data[j][b[i]]){
      ans--;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	string s; cin >> s;
    if(s == "keyence") {
        cout << "YES" << endl;
        return;
    }
    int n = (int)s.size();
    for(int i = 0; i < n; ++i) {
        for(int j = i; j < n; ++j) {
            string t = s.substr(0, i - 0) + s.substr(j + 1);
            if(t == "keyence") {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=250005,mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int k=10;
vector <int> bas(k),ibas(k);
void prework(){
	srand(1233);
	For(i,0,k-1){
		bas[i]=rand()%10000+1;
		ibas[i]=Pow(bas[i],mod-2);
	}
}
struct cmp{
	bool operator () (vector <int> a,vector <int> b){
		assert((int)a.size()==k&&(int)b.size()==k);
		For(i,0,k-1)
			if (a[i]!=b[i])
				return a[i]<b[i];
		return 0;
	}
};
map <vector <int>,int,cmp> cnt;
void Add(pair <int,int> &a,int b){
	Add(a.se,(LL)b*a.fi%mod);
}
void Del(pair <int,int> &a,int b){
	Del(a.se,(LL)b*a.fi%mod);
}
void Mul(int &a,int b){
	a=(LL)a*b%mod;
}
void Mul(pair <int,int> &a,int b){
	Mul(a.fi,b);
}
template <typename T> vector <T> trans(vector <T> x,int op){
	vector <T> a=x;
	if (op==1||op==-2)
		For(i,0,k-1)
			Add(a[i],1);
	else if (op==2||op==-1)
		For(i,0,k-1)
			Del(a[i],1);
	else if (op==3||op==-4)
		For(i,0,k-1)
			Mul(a[i],bas[i]);
	else if (op==4||op==-3)
		For(i,0,k-1)
			Mul(a[i],ibas[i]);
	return a;
}
int n;
char s[N];
map <char,int> op;
vector <int> all(k,0),zero(k,0);
vector <pair <int,int> > a(k,mp(1,0)),b(k,mp(1,0));
vector <int> Calc(vector <pair <int,int> > a,vector <int> x){
	vector <int> b(k);
	For(i,0,k-1)
		b[i]=((LL)a[i].fi*x[i]+a[i].se)%mod;
	return b;
}
int main(){
	prework();
	op['+']=1,op['-']=2,op['>']=3,op['<']=4;
	n=read();
	cin>>(s+1);
	Fod(i,n,1)
		all=trans(all,op[s[i]]);
	LL ans=0;
	cnt[Calc(a,zero)]++;
	Fod(i,n,1){
		a=trans(a,-op[s[i]]);
		b=trans(b,-op[s[i]]);
		ans+=cnt[Calc(b,all)];
		cnt[Calc(a,zero)]++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  
  string s;
  cin >> s;
  
  bool even = true;
  for (char c='a'; c<='z'; c++){
    int cnt = 0;
    
    for (int i=0; i<s.size(); i++){
      if (s[i]==c){
        cnt++;
      }
    }
    if (cnt%2==1) even = false;
  }
  cout << ( even?"Yes":"No") << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>


int main() {
	int height, width; std::cin >> height >> width;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	std::vector<std::vector<int>> min_swap(height, std::vector<int>(width, INT_MAX));
	if (state[0][0] == '.') min_swap[0][0] = 0;
	else min_swap[0][0] = 1;
	for (auto i = 1; i < height; ++i) {
		if (state[i][0] == '#' && state[i - 1][0] == '.') {
			min_swap[i][0] = min_swap[i - 1][0] + 1;
		}
		else {
			min_swap[i][0] = min_swap[i - 1][0];
		}
	}
	for (auto i = 1; i < width; ++i) {
		if (state[0][i] == '#' && state[0][i - 1] == '.') {
			min_swap[0][i] = min_swap[0][i - 1] + 1;
		}
		else {
			min_swap[0][i] = min_swap[0][i - 1];
		}
	}
	for (auto i = 1; i < height; ++i) for (auto j = 1; j < width; ++j) {
		if (state[i][j] == '#' && state[i - 1][j] == '.') {
			min_swap[i][j] = min_swap[i - 1][j] + 1;
		}
		else {
			min_swap[i][j] = min_swap[i - 1][j];
		}
		if (state[i][j] == '#' && state[i][j - 1] == '.') {
			min_swap[i][j] = std::min(min_swap[i][j], min_swap[i][j - 1] + 1);
		}
		else {
			min_swap[i][j] = std::min(min_swap[i][j], min_swap[i][j - 1]);
		}
	}
	std::cout << min_swap.back().back() << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int i;
	for (i=1;i<=3;i++){
		string s;
		cin>>s;
		switch(i){
			case 1:
				cout<<s[0];
				break;
			case 2:
				cout<<s[1];
				break;
			case 3:
				cout<<s[2];
				break;
		}
	}
	cout<<endl;
	return 0;
}

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

int main()
{
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u)
    a--;
  else
    b--;
  
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> node[200005];
bool used[200005]={false},used2[200005]={false},used3[200005]={false};
ll cnt[200005]={0};
bool dfs(ll pos,ll st,bool f){
  if(f&&pos==st) return true;
  for(int i=0;i<node[pos].size();i++){
    int to=node[pos][i].first,idx=node[pos][i].second;
    if(!used2[to]&&!used[idx]){
      used[idx]=true;
      used2[to]=true;
      if(dfs(to,st,true)) {
        used[idx]=true;
        return true;
      }
      else{
        used[idx]=false;
      }
    }
  }
  return false;
}
bool dfs2(ll pos,ll st,bool f){
  //cout<<pos<<" "<<st<<" "<<(f?"O":"X")<<endl;
  if(f&&pos==st) return true;
  for(int i=0;i<node[pos].size();i++){
    int to=node[pos][i].first,idx=node[pos][i].second;
    if(!used2[to]&&!used3[idx]&&!used[idx]){
      used3[idx]=true;
      used2[to]=true;
      if(dfs2(to,st,true)) {
        used3[idx]=true;
        return true;
      }
      else{
        if(!used[idx]) used3[idx]=false;
      }
    }
  }
  return false;
}
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<=max(n,m);i++){
    used[i]=false;
    used2[i]=false;
    used3[i]=false;
  }
  vector<P> qr;
  qr.push_back(P(0,0));
  for(int i=1;i<=m;i++){
    ll a,b;
    cin>>a>>b;
    qr.push_back(P(a,b));
    node[a].push_back(P(b,i));
    node[b].push_back(P(a,i));
    cnt[a]++;
    cnt[b]++;
  }
  ll cnt4=0;
  vector<ll> c4;
  for(int i=1;i<=n;i++){
    if(cnt[i]%2==1) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=1;i<=n;i++){
    if(cnt[i]>=6){
      cout<<"Yes"<<endl;
      return 0;
    }
    else if(cnt[i]==4) {
      cnt4++;
      c4.push_back(i);
    }
  }
  if(cnt4<2){
    cout<<"No"<<endl;
    return 0;
  }
  if(cnt4>2){
    cout<<"Yes"<<endl;
    return 0;
  }
  else if(cnt4==2){
    dfs(c4[0],c4[1],false);
    for(int i=1;i<=max(n,m);i++){
      used2[i]=false;
    }
    dfs2(c4[0],c4[1],false);
    for(int i=1;i<=max(n,m);i++){
      used2[i]=false;
      used[i]=used[i]|used3[i];
      used3[i]=false;
    }
    cout<<(dfs2(c4[0],c4[1],false)?"No":"Yes")<<endl;
  }
}


Measured memory_bytes: 15216
#include<stdio.h>
#include<math.h>
int main(){
  double x1,y1,x2,y2,x3,y3,x4,y4,a,b;
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
	  &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
    if(fabs(x1-x2)<0.0000001||fabs(x3-x4)<0.0000001){
      if(fabs(x1-x2)<0.0000001&&fabs(x3-x4)<0.0000001)printf("YES\n");
      else printf("NO\n");
    }
    else{
      a=(y1-y2)/(x1-x2);
      b=(y3-y4)/(x3-x4);
      if(fabs(a-b)<0.0000001)printf("YES\n");
      else printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll n;
  cin>>n;
  
  ll ans=1;
  ll now=0; //1,0,-1
  ll mae;
  cin>>mae;

  repo(i,n){
    int x;
    cin>>x;
    if(now==0){
      if(mae<x) {
        now=1;
        mae=x;
      }
      if(mae>x){
        now=-1;
        mae=x;
      }
    }
    if(now==1){
      if(mae<=x) mae=x;
      else {
        ans++;
        mae=x;
        now=0;
      }
    }
    if(now==-1){
      if(mae>=x) mae=x;
      else {
        ans++;
        mae=x;
        now=0;
      }
    }    
  }

  cout << ans << endl;

}


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

int main(void)
{
    double a, b, C;

    scanf("%lf%lf%lf", &a, &b, &C);
    
    if (C == 90){
        printf("%lf\n", (a * b) / 2);
        printf("%lf\n", a + b + sqrt(a * a + b * b));
        printf("%lf\n", b);
    }
    else {
            
        C = C * M_PI / 180;
        
        printf("%lf\n", (a * b * sin(C)) / 2);
        printf("%lf\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(C)));
        printf("%lf\n", b * sin(C));
    }
    
    return (0);
}

    


Measured memory_bytes: 2100
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

/*ここからmain関数*/

int main()
{
	int A, B=0, T=0;
	cin >> A>>B>>T;

	int M = 0;
	while (M*A <= T)
		M++;

	cout << (M - 1)*B;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <stdlib.h>
#include <cmath>
using namespace std;

int d, c[29], s[409][29], p[409], cp[29], rs;
set<int> st[29];

int cc()
{
	for (int i = 0; i < 26; i++)
		cp[i] = 0;
	int ans = 0;
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++) {
			if (p[i] == j) {
				cp[j] = i;
				ans += s[i][j];
			}
			else
				ans -= (i - cp[j]) * c[j];
		}
	}
	return ans;
}

void rm(int n, int k)
{
	auto pi = st[k].find(n);
	auto l = pi; l--;
	auto r = pi; r++;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].erase(n);
	rs -= s[n][k];
	rs += pl * (pl + 1) / 2 * c[k]; rs += pr * (pr + 1) / 2 * c[k];
	rs -= plr * (plr + 1) / 2 * c[k];
}

void ins(int n, int k)
{
	auto r = st[k].lower_bound(n);
	auto l = r; l--;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].insert(n);
	rs += s[n][k];
	rs -= pl * (pl + 1) / 2 * c[k]; rs -= pr * (pr + 1) / 2 * c[k];
	rs += plr * (plr + 1) / 2 * c[k];
}

void up(int n, int k)
{
	rm(n, p[n]);
	p[n] = k;
	ins(n, p[n]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> d;
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		st[i].insert(0); st[i].insert(d + 1);
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++)
			cin >> s[i][j];
		p[i] = rand() % 26;
		st[p[i]].insert(i);
	}
	rs = cc();
	double k = 300, sc = 350, kt = 0.99925;
	for (int i = 0; i < 1000000; i++) {
		double e1 = rs;
		int n = (rand() % d) + 1, kp = (rand() % 25) + 1;
		int hk = p[n], tk = (hk + kp) % 26;
		up(n, tk);
		int e2 = rs;
		double pb = exp((e2 - e1) / (k * sc));
		if (pb < rand() / (double)RAND_MAX)
			up(n, hk);
		k *= kt;
	}
	for (int i = 1; i <= d; i++)
		cout << p[i] + 1 << '\n';
	return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);


void solve(){
  ll a, b;cin>>a>>b;
  cout<<a*b/__gcd(a,b);
}

int main(){
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}


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

int main() {
 UL A; cin >> A;
 cout<<A+A*A+A*A*A<<endl;
 return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

int main(int argc, char **argv)
{
    int N, M;
    std::cin >> N >> M;

    std::priority_queue<int, std::vector<int>, std::less<int>> queue;

    for(int i = 0; i < N; i++){
        int a;
        std::cin >> a;
        queue.push(a);
    }

    for(int i = 0; i < M; i++){
        int a = queue.top();
        queue.pop();
        //std::cout << "use: " << a << std::endl;
        queue.push(a / 2);
    }

    long long sum = 0;
    while(!queue.empty()){
        sum += queue.top();
        queue.pop();
    }

    std::cout << sum << std::endl;
    
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll p[200005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	ll count = 0;
	for (int i = 1; i <= n; i++) {
		if (i == p[i - 1]) {
			count++;
			if (p[i - 1] + 1 == p[i] && i != n) {
				
				i++;
			}
		}
		
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputted = Console.ReadLine();
            var a = int.Parse(inputted.Split(' ')[0]);
            var b = int.Parse(inputted.Split(' ')[1]);

            var area = a * b;
            var around = a + a + b + b;

            Console.WriteLine(area + " " + around);
        }
    }
}

Measured memory_bytes: 9148
N = gets.chomp.to_i
ab = Array.new(N){Array.new(2)}
str = ""
for x in 0...N
    str = gets.split
    ab[x][0],ab[x][1] = str[0].to_i, str[1].to_i
end
ab.sort_by! {|x| x[1]}
sum = 0
for x in 0...N do
    sum += ab[x][0]
    if ab[x][1] < sum
       puts "No"
       exit
    end
end
puts "Yes"

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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

typedef long long ll;

bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////
bool has(char c) {

    if(c == 'A' || c == 'C' || c == 'G' || c == 'T') {

        return true;
    }

    return false;
}
int main() {

    //FAST_IO();
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    string s;

    cin >> s;
    int cnt = 0, mx = 0;
    for(int i = 0; i < s.size(); i++) {

        if(has(s[i])) {

            cnt++;
        }

        else cnt = 0;

        if(cnt > mx) mx = cnt;
    }



     cout << mx << endl;



    return 0;
}

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.14159265
using namespace std;



int main(){
	double a,b,v;
	cin>>a>>b>>v;
	double ans=0,x=0,inv=0;
	if(v>=(a*a*b)/2){
	    v=(a*a*b)-v;
		x=(2*v)/(a*a*a);
		ans=(atan(x)*180)/PI;
	}
	else{
		x=(a*b*b)/(2*v);
		ans=((atan(x)*180)/PI);
	}
	cout<<fixed<<setprecision(9)<<ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,p;cin>>n>>k;
  double prob=0.0,tmp;
  for(ll i=1;i<=n;++i) {
    tmp=1.0/n;
    if(i>k-1) {prob+=tmp;continue;}
    p=i;
    while(p<k) {p*=2;tmp*=0.5;}
    prob+=tmp;
  }
  printf("%.10f",prob);
  return 0;
}

Measured memory_bytes: 3752
import math

n = int(input())
a = []
num = 0
while n != 0:
    if n % (2 ** (num + 1)) == 0:
        a.append(0)
    else:
        a.append(1)
        n -= (-2) ** num
    num += 1
a.reverse()
if a:
    a = map(str, a)
    print("".join(a))
else:
    print(0)

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] l = new int[n];
		int i = 0;
		for(i = 0; i < n; i++) {
			l[i] = scan.nextInt();
		}
		Arrays.sort(l);
		int snake = 0;
		for(i = 1; i <= k; i++) {
			snake = snake + l[n - i];
		}
		System.out.println(snake);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int h,w,s,t;
signed main(){
	cin>>h>>w>>s>>t;
	bool b=false;
	if(h*w%2)b=true;
	if(b&&(s+t)%2)puts("No");
	else if(b)puts("Yes");
	else puts("Yes");
    return 0;
}




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

int main() {
    cin.tie(0)->sync_with_stdio(false);

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

    int cnt = 0;
    REP(i, n) if (s[i] == 'o') cnt++;

    if (15 - n + cnt >= 8) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())


def q(i):
    print(i)
    r = input()[0]
    if r == 'V':
        exit()
    return r


z = q(0)


def is_ok(k):
    s = q(k)
    if k % 2:
        return z != s
    else:
        return z == s


ok = 0
ng = n
while ng - ok > 1:
    m = (ok + ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> int inf<int> = 1e9;
template <> ll inf<ll> = 1e18;
 
class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) {
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

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

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};

int main() {
    string S;
    int N;
    cin >> S >> N;
    int const M = S.size();
    vector<int> b(M);
    b[0] = (S[0] - 'a');
    for(int i = 0; i + 1 < S.size(); ++i) {
        b[i + 1] = (S[i + 1] - S[i] + 26) % 26;
    }
    b.push_back((-(S.back() - 'a') + 26) % 26);
    //for(int i = 0; i <= M; ++i) {
    //    cout << b[i] << endl;
    //}

    union_find uf(M + 1);
    for(int i = 0; i < N; ++i) {
        int l, r;
        cin >> l >> r;
        l--;
        uf.unite(l, r);
    }
    for(int i = 0; i <= M; ++i) {
        uf.unite(i, M - i);
    }

    vector<int> sum(M + 1);
    for(int i = 0; i <= M; ++i) {
        (sum[uf.root(i)] += b[i]) %= 26;
    }

    bool ok = true;
    for(int i = 0; i < M; ++i) {
        //cout << "sum[i]: " << sum[i] << endl;
        ok &= sum[i] == 0;
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}




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

using namespace std;

int main()
{
    int n,k,i,ans;
    long x=0;
    cin >> n >>k;
    vector<int> arr(k) ;
    for(i=0;i<k;i++){
        cin >> arr[i];
        x+=arr[i];
    }
    if(n>=x){
        cout << (n-x);
    }
    else
    cout<<-1;

    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n, m;
int p[100005];
string s[100005];
bool ok[100005];
int wa[100005];
void solve() {
    cin >> n >> m;
    rep(i, m) { cin >> p[i] >> s[i]; --p[i]; }

    rep(i, m) if (s[i] == "AC") ok[p[i]] = true; else if (!ok[p[i]]) ++wa[p[i]];

    int ans = 0, ans2 = 0;
    rep(i, n) if (ok[i]) {
        ++ans;
        ans2 += wa[i];
    }

    cout << ans << " " << ans2 << endn;

}

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


Measured memory_bytes: 6656
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

struct position{
  int hh, ww;
};

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

  int h, w, d; cin >> h >> w >> d;
  int a[h][w];

  position v[90909];

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
      v[a[i][j]].hh = i, v[a[i][j]].ww = j;
    }
  }
  int q; cin >> q;
  int l[q], r[q];
  for (int i = 0; i < q; ++i) cin >> l[i] >> r[i];

  int cost[90909] = {};

  for (int i = d + 1; i <= h * w; ++i){
    cost[i] = cost[i - d] + abs(v[i - d].hh - v[i].hh) + abs(v[i - d].ww - v[i].ww);
  }

  for (int i = 0; i < q; ++i) {
    print(cost[r[i]] - cost[l[i]]);
  }

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<ll>
#define vpi vector< pi >
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=200010;
int p[N],don[N];
int main()
{
  int n,m,x,cor=0,pen=0;
  cin>>n>>m;
  string s;
  for(int i=1;i<=m;i++)
  {
  	cin>>x>>s;
  	if(don[x]) continue;
  	if(s[0]=='A')
  	{
  		don[x]=1;
  		pen+=p[x];
  		cor++;
  	}
  	else
  		p[x]++;

  }
  cout<<cor<<" "<<pen;
  
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    cout<<n*(n+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    A.at(s-1) = i;
  }
  for (int i = 0; i < N - 1; i++) {
    cout << A.at(i) + 1 << ' ';
  }
  cout << A.at(N-1) + 1<< endl;
  return 0;
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int N, M;
  cin >> N;
  string s[N];
  rep(i, 0, N)cin >> s[i];
  cin >> M;
  string t[M];
  rep(i, 0, M)cin >> t[i];

  string A[100];A[0] = s[0];
  int ans[100] = {};ans[0] = 1;
  int cnt = 0;

  rep(i, 1, N){
    rep(j, 0, 100){
      if (s[i] == A[j])
      {
        ans[j]++;
        break;
      }
      if (j == 99)
      {
        cnt++;
        A[cnt] = s[i];
        ans[cnt]++;
      }
    }
  }
  rep(i, 0, M){
    rep(j, 0, 100){
      if (t[i] == A[j])
      {
        ans[j]--;
      }
    }
  }
  sort(ans, ans+100, greater<int>());
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,x,y = LI()
X = LI()
Y = LI()
mx = max(X)
my = min(Y)
for i in range(x+1,y+1):
    if mx < i <= my:
        print('No War')
        quit()
print('War')

Measured memory_bytes: 38384
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  long i, j, temp, n, cnt = 0, cnt2 = 0;
  cin >> n;
    long long a[n];
  long long b[n];
cnt2=0;
cnt=0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    b[i] = a[i];
  }
  sort(a,a+n);
  for (i = 0; i < n; i++) {
    if (a[i] == b[i]) {
      cnt++;
    } else
      cnt2++;
  }
  if (cnt2-1==1 || cnt==n) {
     cout<<"YES"<<endl;
  } else
    cout<<"NO"<<endl;
  return 0;
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

vector<ll> a, b, c, d;
int N, M, Q;

ll score(const vector<int> &A) {
    ll res = 0;
    REP(i, Q) {
        if (A[b[i]] - A[a[i]] == c[i]) {
            res += d[i];
        }
    }
    return res;
}

ll dfs(vector<int> &A) {
    if (A.size() == N) {
        return score(A);
    }
    long long res = 0;
    int prev_last = (A.empty() ? 0 : A.back());
    for (int add = prev_last; add < M; ++add) {
        A.push_back(add);
        res = max(res, dfs(A)); // 再帰呼出しながら、スコア最大値を更新
        A.pop_back();
    }
    return res;
}

int main() {
    /* code */
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    REP(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> A;
    cout << dfs(A) << endl;
    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc133/tasks/abc133_b

import itertools
n, d = [int(x) for x in input().split()]
x = []
cnt = 0
for _ in range(n):
    x.append([int(x) for x in input().split()])
for a, b in itertools.combinations(x, 2):
    d = sum([(x1 - x2)**2 for x1, x2 in zip(a, b)])**0.5
    if d.is_integer():
        cnt += 1
print(cnt)


Measured memory_bytes: 3188
#include <cstdio>

/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)

(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]

[z^N] (N f(z) - z * f'(z))/(1-z)

log f = \sum_{i=2}^{N/2}

*/

int n, m;

int dp[5001];

int main(){
  scanf("%d%d", &n, &m);

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

  for(int i = 2; i <= n/2; i++){
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
  }

  if(n & 1){
    for(int j = (n+1)/2; j <= n; j++){
      dp[j] += dp[j-(n+1)/2];
      if(dp[j] >= m) dp[j] -= m;
    }
  }

  int c = 0;
  for(int i = 0; i <= n; i++){
    c = (c + (long long) (n - i) * dp[i]) % m;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
bool he[maxn];
int f[60];
void dp(int cnt)
{
	for (int i = 1; i <= cnt; i++)
	{
		for (int j = cnt; j >= i; j--)
		{
			f[j] = max(f[j], f[j - i] + 1);
		}
	}
}
bool check(ll n)
{
	if (n == 1)
		return 0;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
int main()
{
	ll n, ans = 0;
	cin >> n;
	if (n == 1LL)
	{
		cout << 0 << endl;
		return 0;
	}
	for (ll i = 2; i * i <= n; i++)
	{
		if (he[i])
			continue;
		for (ll j = i * 2; j * j <= n; j += i)
		{
			he[j] = true;
		}
	}
	dp(55);
	ll m = n;
	while (n != 1LL)
	{
		for (ll i = 2; i * i <= n; i++)
		{
			if (he[i] || n % i)
				continue;
			int cnt = 0;
			while (m % i == 0 && m)
			{
				cnt++;
				m /= i;
			}
			ans += f[cnt] * 1LL;
		}
		if (n == m)
			break;
		n = m;
	}
	if (check(n))
		ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4544