akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main(){
  std::string S, T;
  std::cin>>S>>T;
  int ans = 0;
  
  for(int i = 0; i < S.size(); ++i){
    if(S[i] != T[i]) ++ans;
  }
  
  std::cout<<ans;
  return 0;
}

Measured memory_bytes: 3916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		
		int pasta[] = new int[3];
		int juice[] = new int[2];
		int cost = 2000 * 2000;
		
		for(int i = 0; i < 3; i++) pasta[i] = Integer.valueOf(reader.readLine());
		for(int i = 0; i < 2; i++) juice[i] = Integer.valueOf(reader.readLine());
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				cost = Math.min(cost, pasta[i] + juice[j] - 50);
			}
		}
		System.out.println(cost);
		reader.close();
	}
}

Measured memory_bytes: 24412
#include<bits/stdc++.h>
    using namespace std;
    int main() {
      long long n, d;
      cin >> n >> d;
      long long x, y;
      int cnt = 0;
      while (n--) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) cnt++;
      }
      cout << cnt;
      return 0;
    }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define inf -100000000000007
using namespace std;
int read()
{
	int x=0,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();}
	return x*f;
}
int n;
int a[300007];
set<pair<int,int> > s1,s2,s3;
set<pair<int,int> >::iterator it;
long long ans1,ans2,ans;
int main()
{
	n=read();
	for (int i=1;i<=3*n;i++) a[i]=read();
	s1.clear();
	s2.clear();
	s3.clear();
	for (int i=1;i<=n;i++)
		s1.insert(make_pair(a[i],-i));
	for (int i=n+1;i<=3*n;i++)
	{
		s2.insert(make_pair(a[i],-i));
		if (s2.size()>n)
		{
			it=s2.end();
			--it;
			s3.insert(make_pair((*it).first,(*it).second));
			s2.erase(it);
		}
	}
	ans1=0,ans2=0;
	for (int i=1;i<=n;i++) ans1+=a[i];
	for (it=s2.begin();it!=s2.end();it++) ans2+=(*it).first;
	ans=ans1-ans2;
	for (int i=n+1;i<=2*n;i++)
	{
		s1.insert(make_pair(a[i],-i));
		ans1+=a[i];
		it=s1.begin();
		ans1-=(*it).first;
		s1.erase(it);
		it=s3.find(make_pair(a[i],-i));
		if (it!=s3.end()) s3.erase(it);
		it=s2.find(make_pair(a[i],-i));
		if (it!=s2.end())
		{
			ans2-=a[i];
			s2.erase(it);
			it=s3.begin();
			s2.insert(make_pair((*it).first,(*it).second));
			s3.erase(it);
			ans2+=(*it).first;
		}
		ans=max(ans,ans1-ans2);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 15488
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
const long long mod=1000000007;
long long a,b;
int main(){
	cin>>a>>b;
	if(abs(a-b)>1){
		cout<<0<<endl;
	}else{
		long long ans1=1,ans2=1;
		for(long long i=1;i<=a;i++){
			ans1=ans1*i%mod;
		}
		for(long long i=1;i<=b;i++){
			ans2=ans2*i%mod;
		}
		if(a==b){
			cout<<ans1*ans2%mod*2%mod<<endl;
		}else{
			cout<<ans1*ans2%mod<<endl;
		}
	}
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

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

int main()
{
	int x;
    cin>>x;
    int p=x,sum=0;
    while (p>0)
    {
        sum+=p%10;
        p/=10;
    }
    if(x%sum==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string s;
int n,k;

bool vIs0(int i){
  if((s[0]=='0' && i%2==0) || (s[0]=='1' && i%2==1))return true;
  else return false;
}

int main(){
  cin >> n >> k;
  cin >> s;
  vector<ll> v;
  bool Is0=true;
  ll length=0;
  if(s[0]=='1')Is0=false;
  rep(i,n){
    if(s[i]=='0' && Is0){
      length++;
    }
    else if(s[i]=='0' && !Is0){
      v.push_back(length);
      length=1;
      Is0=true;
    }
    else if(s[i]=='1' && Is0){
      v.push_back(length);
      length=1;
      Is0=false;
    }
    else if(s[i]=='1' && !Is0){
      length++;
    }
    if(i==n-1)v.push_back(length);
  }
  ll ans=0;
  if((s[0]=='1' && v.size()/2<=k) || (s[0]=='0' && (v.size()+1)/2<=k)){
    cout << n << endl;
    return 0;
  }
  ll sum[(int)v.size()]={};
  sum[0]=v[0];
  rep(i,v.size()-1){
    sum[i+1]=sum[i]+v[i+1];
  }
  for(int i=0;i<v.size();i++){
    ll subsum=0;
    int range=0;
    int m=(int)v.size()-1;
    if(i==0 && vIs0(i)){
      range=min(2*k-1,m);
      subsum=sum[range];
    }
    else if(i==0 && !vIs0(i)){
      range=min(2*k,m);
      subsum=sum[range];
    }
    else if(!vIs0(i)){
      int right=min(m,i+2*k);
      int left=i-1;
      subsum=sum[right]-sum[left];
    }
    ans=max(ans,subsum);
  }
  cout << ans << endl;
return 0;}

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

int main(){
    int n, k; cin >> n >> k;
    ll ans = 0;
    for(int i = k+1; i <= n; i++){
        int p = n / i;
        ans += p*max(0, (i-k)) + max(0, (n % i +1 -k));
        if(k == 0){
            ans -= 1;
        }
        //cout << p*max(0, (i-k)) << " " << max(0, (n % i +1 -k)) << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include <iomanip>
#include <queue>
#include <map>

using namespace std;

map <int,int> ans;

int main(){
    priority_queue<int> res;
    int n;
    scanf("%d",&n);
    for (int i = 0;i < n;i++){
        int k;
        scanf("%d",&k);
        ans[k]++;
        if (ans[k] == 2){
            res.push(k);
        }
        else if(ans[k] == 4){
            res.push(k);
        }
    }
    long long result = 1;
    for (int  i = 0;i<2;i++){
        if (res.empty()){
            printf("0\n");
            return 0;
        }
        else{
            result = result*res.top();
            res.pop();
        }
    }
    printf("%lld\n",result);
    return 0;
}


Measured memory_bytes: 4992
r, s, p = map(int, input().split())
ps = [None] * p
for k in range(p):
    i, j = map(int, input().split())
    if j <= s:
        j -= 1
    ps[k] = r + 1 - i + abs(s - j)
ans = 0
for t, p in enumerate(sorted(ps)[::-1]):
    ans = max(ans, t + p)
print(ans)



Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;

template <typename UnaryPredicate>
int64_t binsearch_max(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    ++ r;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;  // avoid overflow
        (p(m) ? l : r) = m;
    }
    return l;
}

struct doubling_table {
    vector<vector<int> > table;
    doubling_table() = default;
    doubling_table(vector<int> const & next, int size = -1) {
        int n = next.size();
        {
            auto it = minmax_element(ALL(next));
            assert (0 <= *(it.first) and *(it.second) <= n);
        }
        if (size == -1) {
            size = max<int>(1, ceil(log2(n)));
        }
        table.resize(size);
        table[0] = next;
        REP (k, size - 1) {
            table[k + 1].resize(n, n);
            REP (i, n) if (table[k][i] != n) {
                table[k + 1][i] = table[k][table[k][i]];
            }
        }
    }
};

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); REP (i, n) scanf("%d", &a[i]);
    int l; scanf("%d", &l);
    // prepare
    vector<int> next(n);
    REP (i, n) {
        next[i] = binsearch_max(i, n - 1, [&](int j) {
            return a[j] - a[i] <= l;
        });
    }
    doubling_table doubling(next);
    // serve
    int queries; scanf("%d", &queries);
    while (queries --) {
        int a, b; scanf("%d%d", &a, &b);
        -- a; -- b;
        if (a > b) swap(a, b);
        int result = 0;
        REP_R (k, doubling.table.size()) {
            if (doubling.table[k][a] < b) {
                a = doubling.table[k][a];
                result += 1 << k;
            }
        }
        while (a < b) {
            a = next[a];
            result += 1;
        }
        // output
        printf("%d\n", result);
    }
    return 0;
}


Measured memory_bytes: 8320
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int get10timesVal(int x) {
    return (x + 9) / 10 * 10;
}

int getDiff(int x) {
    return get10timesVal(x) - x;
}

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int sum = get10timesVal(A) + get10timesVal(B) + get10timesVal(C) + get10timesVal(D) + get10timesVal(E);
    sum -= max({getDiff(A), getDiff(B), getDiff(C), getDiff(D), getDiff(E)});

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
N = gets.to_i 
hoge = gets.split.map(&:to_i)
#ここまで入力
hoge.sort! #小さい順にソート
hoge.reverse! #それを逆順にひっくり返すことによって実質大きい順ソートに
s = 0 #これが偶数の時はAliceの番で、奇数の時はBobの番
Alice = 0
Bob = 0
while s < N
  if(s%2==0)
    Alice += hoge[s]
  else
    Bob += hoge[s]
  end
  s+=1
end
puts Alice - Bob

Measured memory_bytes: 1788
N=int(input())
A=list(map(int, input().split()))
M=[0]*N
maxi=sum(A)

M[0]= maxi-2*sum(A[1::2])
for i in range(1,N):
  M[i]= 2*(A[i-1]-M[i-1]//2)
print(*M)

Measured memory_bytes: 14028
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    std::array<int, 10> height;
    for (auto i = 0; i < 10; i++) {
        std::cin >> height.at(i);
    }

    std::sort(height.begin(), height.end());

    for (auto i = 9; i > 6; i--) {
        std::cout << height.at(i) << std::endl;
    }

    return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

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

  for (i32 i = 0; i < 10001; i++) {
    if ((i32)(i * 0.08) == a && (i32)(i * 0.1) == b) {
      cout << i;
      return 0;
    }
  }

  cout << -1;

  return 0;
}


Measured memory_bytes: 3632
from collections import deque
S = list(input())
q_num = int(input())
d = deque(S)
rev = True
for _ in range(q_num):
  query = list(input().split())
  if(query[0] == "1"):
    rev = not rev
  if(query[0] == "2"):
    if(rev):
      if(query[1] == "1"):
        d.appendleft(query[2])
      else:
        d.append(query[2])
    else:
      if(query[1] == "1"):
        d.append(query[2])
      else:
        d.appendleft(query[2])
if(rev):
  print("".join(d))
else:
  d.reverse()
  print("".join(d))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 998244353;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

ll dp[M],f[M];

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

	ll i,n,m,k,r,v,g,ans = 0;

	cin >> n >> m >> k;

	f[0] = 1;
	for(i=1;i<=2*n;++i)
		f[i] = 1ll*f[i-1]*i%md;
	r = pwr(f[n],md-2,md);

	for(i=n-k;i<=n;++i)
	{
		v = 1ll*m*pwr(m-1,i-1,md)%md;
		g = 1ll*f[n-1]*pwr(f[n-i],md-2,md)%md;
		g = 1ll*g*pwr(f[i-1],md-2,md)%md;
		ans = (ans + 1ll*v*g)%md;
	}

	cout << ans << "\n";
}


	

Measured memory_bytes: 6764
#include<iostream>
#include<vector>
#include<algorithm>
#define N 2

using namespace std;

void swap(int&, int&);

int main(){
  int i, j, n, m, l, x, y, score[N];
  vector<int> data[N];

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> m;
      data[0].push_back(m);
    }
    sort(data[0].begin(), data[0].end());

    for(i=1, j=0; i<=N*n; ++i){
      if(data[0][j] == i) ++j;
      else data[1].push_back(i);
    }

    x = 0;
    y = 1;
    m = 0;
    while(1){
      l = -1;
      for(i=0; i<data[x].size(); ++i){
	if(data[x][i] > m){
	  l = i;
	  m = data[x][i];
	  break;
	}
      }

      if(l == -1)
	m = 0;
      else
	data[x].erase(data[x].begin()+l);

      if(data[x].size() == 0){
	score[x] = data[y].size();
	score[y] = 0;
	break;
      }else{
	swap(x, y);
      }
    }

    for(i=0; i<N; ++i){
      cout << score[i] << endl;
      data[i].clear();
    }
  }

  return 0;
}

void swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;

vector<ll> getScores(
		const vector<ll> &x,
		const vector<ll> &y,
		const vector<ll> &z,
		ll sx,
		ll sy,
		ll sz
) {
	vector<ll> res(x.size(), 0);
	for (ll i=0;i<x.size();++i) {
		res[i] = sx*x[i] + sy*y[i] + sz*z[i];
	}
	return res;
}

int main() {
	int N,M;
	cin >> N >> M;
	vector<ll> x(N,0),y(N,0),z(N,0);
	for(ll i=0;i<N;++i) {
		scanf("%lld %lld %lld", &x[i],&y[i],&z[i]);
	}
	// summing up the vectors by M and making points,
	// find the point which is furthest from origin in 3D space 
	// 
	// (x,y,z): 求める点は, 各軸ごとに正負いずれかの領域にある.
	// ex. x軸:正, y軸:負, z軸:正
	// この場合, x - y + z が最大となるM点の組合せを求めればよい.
	// 点(x, y, z)に対するスコアが x - y + z という1次元の量になる.
	//
	ll ans = - 1000000000000; 
	for (ll sx : {-1,1}) {
		for (ll sy : {-1,1} ) {
			for (ll sz : {-1,1} ) {
				vector<ll> temp = getScores(x, y, z, sx, sy, sz);
				sort(temp.begin(), temp.end());
				//for (ll i=0; i<temp.size(); ++i) cout << temp[i] << endl;
				// 最大から和を取る. M個.
				ll val = accumulate(temp.rbegin(), temp.rbegin() + M, 0LL);
				//cout << "val = " << val << endl;
				//cout << "---" << endl;
				ans = max(ans,val);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(void) {
    string str;
    cin>>str;

    int S = str.size();
    int n = str.size();

    for(int i = 0;i < n-1;i++) {
        if(str[i] != str[i+1]) {
            S = min(S,max(i+1,n-(i+1)));
        }
    }

    cout<<S<<endl;

    return 0;
}



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

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

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    long long M, A, R, C, H;
    M = 0;
    A = 0;
    R = 0;
    C = 0;
    H = 0;
    for (int i = 0; i < N; i++) {
        if (S[i][0] == 'M') {
            M++;
        }
        else if (S[i][0] == 'A') {
            A++;
        }
        else if (S[i][0] == 'R') {
            R++;
        }
        else if (S[i][0] == 'C') {
            C++;
        }
        else if (S[i][0] == 'H') {
            H++;
        }
    }

    cout << M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H << endl;
}

Measured memory_bytes: 6144
n = int(input())
data = list(map(int, input().split()))
q = int(input())
d = {}
big = 10**5+100

for i in range(big):
  d[i+1] = []
for i in data:
  d[i].append(i)

ans = sum(data)
for i in range(q):
  a, b = map(int, input().split())
  #print(len(d[a]))
  ans += len(d[a]) * (b-a)
  d[b] = d[b] + d[a]
  d[a] = []
  print(ans)

Measured memory_bytes: 190196
#include <stdio.h>

int main(void)
{
	
	int i, j, n, sum;
	int a[11][10];
	
	scanf("%d", &n);
	
	while (n != 0){
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &a[j][i]);
			}
		}
		
		for (i = 0; i < n; i++){
			sum = 0;
			for (j = 0; j < n + 1; j++){
				if (j == n){
					a[j][i] = sum;
					printf("%5d", sum);
				}
				else {
					sum += a[j][i];
					printf("%5d", a[j][i]);
				}
			}
			printf("\n");
		}
		
		for (i = 0; i < n + 1; i++){
			sum = 0;
			for (j = 0; j < n; j++){
				sum += a[i][j];
			}
			printf("%5d", sum);
		}
		printf("\n");
		scanf("%d", &n);
	}
	
	
	return (0);
}

Measured memory_bytes: 616
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n / 100 == 7){
            System.out.println("Yes");
        }else if(n % 100 / 10 == 7){
            System.out.println("Yes");
        }else if(n % 10  == 7){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35744
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (s[n-1] == 's') cout << s + "es" << endl;
  else cout << s + 's' << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h> 
int main () {
    int a;
    int b;
    do{
      scanf("%d",&a);
      scanf("%d",&b);

    }while(a<1||b<1||100<a||100<b);
    int c;
    if(b<10){//bがひとけたの時
      c=10*a+b;
    }else if(b<=99){
      c=100*a+b;
    }else{
      c=1000*a+b;
    }
    int i=1;
    while(i<=100100){
      if(c==i*i){
          printf("Yes");
        exit(0);
      }
      i++;
    }
    printf("No");
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int N, A, B;
	cin>>N;
	cin>>A;
	cin>>B;
	if (N*A < B)
	{
		cout<<N*A<<endl;
	}
	else 
	{
		cout<<B<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*Raihan Kabir
  University of Chittagong
  Bangladesh
  */
#include<iostream>
#include<vector>
#include<set>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<array>
using namespace std;
typedef long long ll;
#define endl '\n'
int main(){
    int r;
    cin>>r;
    cout<<2*3.1416*r;


    return 0;
}


Measured memory_bytes: 3772
a = []
for i in range(4):
	a.append(int(input()))

add = 0
if a[0] > a[1]:
	add += a[1]
else:
	add += a[0]
if a[2] > a[3]:
	add += a[3]
else:
	add += a[2]
print(add)

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pii pair <int, int>
#define pll pair <ll, ll>
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
using namespace std;

int n, k;
int main () {
	IOS;
	
	cin >> n >> k;
	vector <int> snack(n + 1, 1);
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			if (snack[a]) {
				snack[a]--;
			} 
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += snack[i];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3608
n, m = (int(_) for _ in input().split())
a = [int(input()) for _ in range(m)]
ai, p1, p2 = (0, 0, 1)

for i in range(1, n+1):
    if ai < m and i == a[ai]:
        p = 0
        ai += 1
    else:
        p = p1 + p2
    p1 = p2
    p2 = p

print(p%1000000007)


Measured memory_bytes: 7080
#include <iostream>

int main()
{
    int A,B,C;
    
    std::cin >> A >> B >> C;
    
    if( A*B*C==5*5*7 && A>1 && B>1 && C>1 )
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
    
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    ll p[200010];
    char c;

    cin >> c;

    if (c - 'a' >= 0){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,m,k,i;
int main(){ 
    cin>>n>>m>>k;
    for(i=1;i<=n;i++){
        int Q=k-i*m;
        int F=n-(i*2);
        if(Q==0||F&&(Q>>31&1)==(F>>31&1)&&Q%F==0&&Q/F<=m){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
// Author : Bisma Kho (ビスマコー)
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb(a) push_back(a)
#define fi first
#define se second
#define rep(a,b,c) for(int a = b ;a<=c;a++)
#define repn(a,b,c) for(int a = b ; a>=c ; a--)
#define FOR(a,b,c) for(int a = b ; a<c ;a++)
#define mem(a,b) memset(a,b , sizeof(a))
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define size(a) ((int)a.size())
#define ii int
#define umap unordered_map
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a * b / gcd(a,b)
const int INF=0x3f3f3f3f;
const int maxn=5e5+10;
const int maxk=30;
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  max(a,b) (a > b) ? a : b;
#define  min(a,b) (a > b) ? b : a;




void solve(){

	ll a;
	cin>>a;

	ll ans = a / 2;

	if(a % 2 ==0 ) ans -=1;

	cout<<ans<<endl;

}


int main() { 
	fastio

	solve();

	
   exit(0); 
} 	


Measured memory_bytes: 256
(_,k),*t=[map(int,t.split())for t in open(0)]
A,F=map(sorted,t)
o=10**12
g=-1
while~g+o:
 m,l=o+g>>1,k
 for a,f in zip(A,F[::-1]):l-=max(0,a-m//f)
 if l<0:g=m
 else:o=m
print(o)

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

const int N = 1e5 + 100;

int n, a[N], b[N], c[N];
long long ans;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    	cin >> a[i] >> b[i];
    iota(c, c + n, 0);
    sort(c, c + n, [](int A, int B) {
    	return (a[A] + b[A] > a[B] + b[B]);
    });
    for (int i = 0; i < n; i++)
    	ans += (i & 1?  -b[c[i]]: a[c[i]]);
    cout << ans;
    return 0;
}

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

using ll = long long;

// 各桁の数の和
int DigitSum(ll x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  string s = to_string(n);
  
  cout << max<int>(DigitSum(n), (s.size() - 1) * 9 + s[0] - '1') << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define size(x) int(x.size())
typedef long long ll;
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];
    vector<int> A(N);
    int ans = 0;
    if(N==1){ans = 0;}
    else{
    if(H[0] >= H[1]){A[0] = 1;}
    for(int i  = 1; i < N-1;i++){
        if(H[i]<H[i+1]){A[i] = 0;}
        else{
            A[i] = A[i-1] + 1;
        }
    }
    }
    sort(ALL(A));
    ans = A[N-1];
    cout << ans <<endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> monster;

    int finalmonster;
    for (int i = 0; i < N; i++){
        int A;
        cin >> A;
        monster.push_back(A);
    }
    while(1){
        sort(monster.begin(), monster.end(), greater<int>());
        
        for (auto itr = monster.begin(); itr != monster.end(); itr++){
            if(*itr == 0) {
                monster.erase(itr, monster.end());
                break;
            }
        }
        if (monster.size() == 1) {
            finalmonster = monster.front();
           break;
        }
        for (auto itr = monster.begin(); itr != monster.end() - 1; itr++){
            *itr = *itr % monster.back();
        }
    }
    
    cout << finalmonster << endl;
    
    return 0;

}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	string ans;
	if (x - r < 0 || W < x + r || y - r < 0 || H < y + r)
		ans = "No";
	else
		ans = "Yes";
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):

    if abs(A - B) == 0:
        print(0)
    elif (A + B) % 2 == 0:
        print(int((A + B) / 2))
    else:
        print("IMPOSSIBLE")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif

int32_t main() 
{
	IAMSPEED
	unsigned ll in; cin >> in;
	__int128 x = 100;
	__int128 lim = in;
	int day = 0;
	while(x < lim) {
		++day;
		x*=101;
		x/=100;
	}
	cout<<day;
}



Measured memory_bytes: 3660
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))

total = sum(s)

if total % 10 != 0:
    print(total)

else:
    s.sort()    
    min_s = total
    
    for si in s:
        if si % 10 != 0:
            min_s = si
            break
        
    print(total - min_s)

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

int main(){
    int n;
    cin >> n;
    set<int> s;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 7748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int n=s.length();
  if(s[n-1]=='s')s+="es";
  else s+='s';
  cout<<s<<"\n";
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{


ll n;
cin>>n;

vector<ll>a(n);

map<ll,ll>m;
for(auto &e:a)cin>>e,m[e]++;
ll ans=1;
for(auto x:m)
{
	if(n%2==0)
	{
		if(x.first==0)
		{
			cout<<0;
			return;
		}
	}
	if(x.first%2!=n%2)
	{	
		if(x.first==0)continue;
		if(x.second!=2)
		{
			cout<<0;
			return;
		}
		else
		{
			ans=ans*2;
			ans=mod(ans);
		}
	}
	else
	{
		cout<<0;
		return;
	}
}

cout<<ans;



	

 
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 7924
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    var a = 1
    var b = n + 1
    val col = ask(sc, a, n)
    val res = Array(2 * n) { false }
    while (b - a > 1) {
        val c = (b + a) / 2
        if (col != ask(sc, c, n)) b = c
        else a = c
    }

    var red = 0
    var blue = 0
    val t = mutableListOf<Int>()
    for (x in 1..2 * n) {
        if (x in a + 1 until a + n) continue

        val ans = ask(sc, x, a, n) == "Red"
        res[x - 1] = ans
        if (ans && red < n / 2) {
            red += 1
            t.add(x)
        }
        if (!ans && blue < n / 2) {
            blue += 1
            t.add(x)
        }
    }

    for (x in a + 1 until a + n) {
        val ans = ask(sc, x, n, t) == "Red"
        res[x - 1] = ans
    }

    println("! ${res.joinToString("") { if (it) "R" else "B" }}")


}

fun ask(sc: FastScanner, x: Int, n: Int, t: List<Int>): String {
    println("? $x " + t.joinToString(" "))
    System.out.flush()
    return sc.next()
}

fun ask(sc: FastScanner, x: Int, a: Int, n: Int): String {
    println("? $x " + (a + 1 until a + n).joinToString(" "))
    System.out.flush()
    return sc.next()
}

fun ask(sc: FastScanner, x: Int, n: Int): String {
    println("? " + (x until x + n).joinToString(" "))
    System.out.flush()
    return sc.next()
}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 38800
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.next().toCharArray();
        int n = s.length;
        int m = 0;
        for (char c : s)
            m += c == 'o' ? 1 : 0;
        writer.println(m + (15 - n) >= 8 ? "YES" : "NO");
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }

const long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    //mizu
    set<int>mizu;
    rep(i,F){
        rep(j,F){
            if(i*100*A+j*100*B <= F){
                mizu.insert(i*100*A+j*100*B);
            }
        }
    }

    //satou
    set<int>satou;
    rep(i,F){
        rep(j,F){
            if(i*C+j*D <= F){
                satou.insert(i*C+j*D);
            }
        }
    }

    int s =0;
    int sm = 100*A; 
    for(auto i : mizu){
        for(auto j: satou){
            if(i+j <= F && (float)  j /(i+j) <= (float) E/(100+E) ){
                if((float) s/sm  < (float) j /(i+j) ){
                    s = j;
                    sm = i+j;
                }        
            }
        }
    }

    cout << sm << " " << s << endl;


}

Measured memory_bytes: 384
s = input()

xx = int(s[0:2])
yy = int(s[2:4])

if 1 <= xx <= 12:
    if 1 <= yy <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 1 <= yy <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include <iostream>

int main() {
    int n, k;
    std::cin >> n >> k;
    int h[n];
    for(int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    int ok = 0;
    for(int i = 0; i < n; i++) {
        if(h[i] >= k) {
            ok++;
        }
    }

    std::cout << ok << std::endl;
}


Measured memory_bytes: 640
N = int(input())
W = []
for i in range (0,N):
    W.append(input())
ans = "Yes"
d = dict()
count = 0
for j in W:
    if j in d.keys():
        ans = "No"
    else:
        d[j] = 1
    if count != 0:
        if j[0] != W[count - 1][-1]:
            ans = "No"
    count += 1
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-10;

typedef complex<double> Point;

double dot(const Point& p,const Point& q){
  return real(conj(p)*q);
}

double det(const Point& p,const Point& q){
  return imag(conj(p)*q);
}

bool on_seg(const Point& p1,const Point&p2,
	    const Point& q){
  return abs(det(p1-q,p2-q)) <= EPS && dot(p1-q,p2-q) < EPS;
}

Point compute_intersection(const Point& p1,const Point& p2,
			   const Point& q1,const Point& q2) {
  return p1 + (p2-p1) * det(q2-q1,q1-p1) / det(q2-q1,p2-p1);
}

int ccw(Point a,Point b,Point c) {
  b -= a; c -= a;
  if (det(b, c) > 0)   return +1;       // counter clockwise
  if (det(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const Point& p1, const Point& p2,
		 const Point& q1, const Point& q2) {
  return (ccw(p1,p2,q1) *
	  ccw(p1,p2,q2) <= 0 &&
	  ccw(q1,q2,p1) *
	  ccw(q1,q2,p2) <= 0);
}

double compute_distance(const Point& p,const Point &q){
  return abs(q-p);
}

int compute_location(int owner,int location){
  //owner 1:me 0:other
  //location 1:high way 0:under ground
  if(owner == 1){
    return location;
  }
  else if(owner == 0){
    return !location;
  }
}

int main(){
  int total_dataset = 0;
  while(~scanf("%d",&total_dataset)){
    for(int dataset_idx=0;dataset_idx<total_dataset;dataset_idx++){
      int xa,ya,xb,yb;
      scanf("%d %d %d %d",&xa,&ya,&xb,&yb);
      Point p1(xa,ya);
      Point p2(xb,yb);

      int n;
      scanf("%d",&n);
	
      vector<pair<double,int> > intersections;
      for(int i=0;i<n;i++){
	int xs,ys,xt,yt,owner,location;
	scanf("%d %d %d %d %d %d",&xs,&ys,&xt,&yt,&owner,&location);
	Point p3(xs,ys);
	Point p4(xt,yt);

	if(!intersectSS(p1,p2,p3,p4)) continue;

	Point intersection = compute_intersection(p1,p2,p3,p4);
	double dist = compute_distance(p1,intersection);
	int next_location = compute_location(owner,location);

	pair<double,int> tmp(dist,next_location);
	intersections.push_back(tmp);
      }

      sort(intersections.begin(),intersections.end());
      int prev = intersections.size() == 0 ? -1 : intersections[0].second;
      int res = 0;
      for(int i=1;i<intersections.size();i++){
	if(prev != intersections[i].second) res++;
	prev = intersections[i].second;
      }
      printf("%d\n",res);

    }
  }
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 505

int main(){

    ll n;
    cin >> n;
    ll ans = 2*(n/11);
    n%=11;
    //cout << ans << endl;
    //cout << n << endl;

    bool flag = true;
    while(n > 0){

        if(flag){
            n-=6;
            flag = !flag;
            ans++;
        }else{
            n-=5;
            flag = !flag;
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
N,M= map(int,input().split())

tempP = ""
ac = []
wa = []

for count in range(N):
    ac.append(0)
    wa.append(0)

for count in range(M):
    P,S = input().split()
    P = int(P)
    P -= 1
    
    if ac[P] == 0:
        if S == "AC":
            ac[P] = 1
        else:
            wa[P] +=1



a = 0
b = 0
 
for i in range(N):
    if ac[i] == 1:
        a += 1
        b += wa[i]
 
print(*[a, b])

    

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

using namespace std;

int dp[100001];
int dfs(int *arr,int index,int n,int k)
{
  if(index>=n)
    return 1e7;
  
  if(index==n-1)
    return 0;
  
  if(dp[index]!=-1)
    return dp[index];
  
  int ans = INT_MAX,res;
  for(int i=1;i<=k;i++)
  {
    if(index+i<n)
      res = abs(arr[index]-arr[index+i])+dfs(arr,index+i,n,k);
    ans = min(ans,res);
  }
  
  return dp[index] = ans;
  
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  memset(dp,-1,sizeof(dp));
  int ans = dfs(arr,0,n,k);
  
  cout<<ans<<endl;
    
}

Measured memory_bytes: 13796
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAX=10;
char tab[MAX][MAX];
char pom[MAX][MAX];
int32_t main()
{
  BOOST;
  int h,w,k;
  cin>>h>>w>>k;
  for (int i=0;i<h;i++)
    for (int j=0;j<w;j++)
      cin>>tab[i][j];
  int ans=0;
  for (int i=0;i<(1<<h);i++)
  {
  	for (int j=0;j<(1<<w);j++)
  	{
  		
  		for (int a=0;a<h;a++)
  		  for (int b=0;b<w;b++)
  		    pom[a][b]=tab[a][b];
  		for (int a=0;a<h;a++)
  		{
  			if ((1<<a)&i)
  			{
  				for (int now=0;now<w;now++)pom[a][now]='@';
  			}
  		}
  		
  		for (int b=0;b<w;b++)
  		{
  			if ((1<<b)&j)
  			{
  				for (int now=0;now<h;now++)pom[now][b]='@';
  			}
  		}
  		
  		int ile=0;
  		for (int a=0;a<h;a++)
  		  for (int b=0;b<w;b++)
  		    if (pom[a][b]=='#')ile++;
  		if (ile==k)ans++;
  	}
  }
  cout<<ans;
  return 0;
}


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

#define si(n) scanf("%d",&n)
#define f first
#define s second
#define mp(a,b) make_pair(a,b)

int main()
{
    //freopen("input.txt","r",stdin);
    int i,j;
    int n,t,x,y;
    si(n);
    bool flag=true;
    int sx=0,sy=0,t1=0;
    for(int cs=1;cs<=n;cs++){
        si(t);si(x);si(y);
        int dist=abs(x-sx)+abs(y-sy);
        if(dist>t-t1)flag=false;
        dist-=(t-t1);
        if(dist%2)flag=false;
        t1=t;
        sx=x,sy=y;
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
}


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

int main()
{
	int N, M, Q,count = 0;
	string S;
	cin >> S;
	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
		cout << "ABC" << endl;
	//vector<int> A(N);
	
	//cout << "" << endl;
}


Measured memory_bytes: 3624
from string import ascii_lowercase


def main():
    str_num = int(input())
    strings = [list(input()) for _ in range(str_num)]
    answer = ""
    for lowercase in ascii_lowercase:
        count = float("inf")
        for string in strings:
            count = min(count, string.count(lowercase))
        answer += lowercase * count
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3832
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    K = I()
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += math.gcd(math.gcd(i, j), k)
    print(ans)


main()


Measured memory_bytes: 73872
n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int,input().split())))
ans = [arr[0][::]]
for i in range(1,n):
	temp = ans[-1]
	x = max(temp[1]+arr[i][0],temp[2]+arr[i][0])
	y = max(temp[0]+arr[i][1],temp[2]+arr[i][1])
	z = max(temp[0]+arr[i][2],temp[1]+arr[i][2])
	ans.append([x,y,z])
print(max(ans[-1]))

Measured memory_bytes: 74200
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e10],A[m:r]+[1e10]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1
  else:A[k]=R[j];j+=1
  c+=1
def s(A,l,r):
 if l+1<r:
  m=(l+r)//2
  s(A,l,m);s(A,m,r)
  g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(*A)
print(c)


Measured memory_bytes: 63704
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int a[100005], b[100005];

int main(){
  int n;
  cin>>n;
  rep(i,n) scanf("%d %d", a+i, b+i);
  vector<int> vec(100005,0);
  rep(i,n){
    vec[a[i]]++;
    vec[b[i]+1]--;
  }
  rep(i,n+1) vec[i+1] += vec[i];

  int res=0;
  for(int i=n+1; i>1; i--) if(vec[i]>=i-1){res=i-1; break;}
  cout<<res<<endl;

  return 0;
}

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


int main() {
  int N ; 
  cin >> N ; 
  for (int i = 1 ; i < 10 ; i++){
    for(int j = 1 ; j < 10 ; j++ ){
      if(N == i*j){
        cout << "Yes" <<endl ;
        return 0 ; 
      }
    }
  }
  
  cout << "No" << endl ; 
  
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  X -= Y + 2 * Z;
  int ans = 1 + X / (Y + Z);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256