akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    int n,c, max_t = 0;
    cin >> n >> c;
    vector<Pii> programs[c];

    rep(n){
        int s,t,cc;
        cin >> s >> t >> cc;
        programs[cc-1].emplace_back(s*2-1, t*2);
        max_t = max(max_t, max(s*2-1, t*2));
    }

    vector<int> ss, tt;
    rep(c){
        if(programs[i].empty()) continue;
        sort(all(programs[i]));
        int np = (int)programs[i].size();
        if(np == 1){
            ss.push_back(programs[i][0].first);
            tt.push_back(programs[i][0].second);
        }else{
            int  j = 0;
            while(j < np){
                if(j < np-1 && programs[i][j+1].first <= programs[i][j].second + 1){
                    int jj = j+1;
                    while(jj < np && programs[i][jj].first <= programs[i][jj-1].second + 1) jj++;
                    jj--;
                    ss.push_back(programs[i][j].first);
                    tt.push_back(programs[i][jj].second);
                    j = jj+1;
                }else{
                    ss.push_back(programs[i][j].first);
                    tt.push_back(programs[i][j].second);
                    j++;
                }
            }
        }

    }
    sort(all(ss));
    sort(all(tt));

    vector<int> times(200003);
    times[0] = 0;
    int si = 0, ti = 0;
    int sn = (int)ss.size();
    int tn = sn;
    
    reppp(t, 1, max_t){
        times[t] = times[t-1];
        while(ti < tn && tt[ti] == t){
            times[t]--;
            ti++;
        }
        while(si < sn && ss[si] == t){
            times[t]++;
            si++;
        }
    }
    cout << *max_element(all(times)) << endl;
}


Measured memory_bytes: 3156
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

INF = 2**30
n = int(input())
P = tuple(map(int, input().split()))
T = [[] for _ in range(n)]
for i, p in enumerate(P, 1):
  T[p-1].append(i)
X = tuple(map(int, input().split()))
D = [-1]*n
def dfs(v):
  if D[v] != -1:
    return D[v]
  l = len(T[v])
  x = X[v]
  dp = np.full(x+1, INF, dtype=np.int64)
  dp[0] = 0
  for i, nv in enumerate(T[v]):
    k = np.full(x+1, INF, dtype=np.int64)
    d = dfs(nv)
    if x+1 >= X[nv]:
      np.minimum(k[X[nv]:], dp[:x+1-X[nv]]+d, out=k[X[nv]:])
    if x+1 >= d:
      np.minimum(k[d:], dp[:x+1-d]+X[nv], out=k[d:])
    dp = k.copy()
  res = dp.min()
  D[v] = res
  return res
ans = dfs(0)
if ans == INF:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 34156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int C,R,i,j;//iはroad用の変数、
    cin >> C >> R;
    vector<vector<int>> v(R,vector<int>(2)); //2列R行 
    vector<int> citycount(C,0);

     for(i=0;i<R;i++){
        cin >> v.at(i).at(0) >> v.at(i).at(1);   //たて、よこの順
        for(j=0;j<C;j++){
            if(v.at(i).at(0) == (j+1)){
                citycount.at(j) == ++citycount.at(j); //都市の登場回数をそれぞれカウント
                }
            if(v.at(i).at(1) == (j+1)){
                citycount.at(j) == ++citycount.at(j); //都市の登場回数をそれぞれカウント
                }
                }
    }
    
    for(i=0;i<C;i++){
        cout << citycount.at(i)  << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
ll n,a,b;
cin>>n>>a>>b;
vll d(n);
vll v(n+1);
fr(i,1,n)
v[i]=i;


for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      ll dis=j-i;
      dis=min(dis,abs(i-a)+1+abs(j-b));
      dis=min(dis,abs(j-a)+1+abs(i-b));
      d[dis]++;

          }
}
fr(i,1,n){
    cout<<d[i]<<endl;
}



}

int main(){
    ll t=1;
  /// cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())

As = np.array([["." for n in range(N)] for nn in range(N)])
for n in range(N):
  As[n,:] = np.array(list(input()))
  
Bs = np.array([["." for n in range(M)] for nn in range(M)])
for m in range(M):
  Bs[m,:] = np.array(list(input()))
  
ok = False
for i in range(N-M+1):
  for j in range(N-M+1):
    if (As[i:i+M,j:j+M] == Bs).all():
      ok = True
      break
if ok:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 13020
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct Dango
{
	int number;
	int color;
	
	Dango() {}
	Dango(int num, int col) : number(num), color(col) {}
};

// return delete block number
int rensa(vector<Dango>& dango, int index)
{	
	if(0 < index && index < dango.size() && dango[index - 1].color == dango[index].color && 4 <= dango[index - 1].number + dango[index].number)
	{
		int ret = dango[index - 1].number + dango[index].number;
		
		dango.erase(dango.begin() + index - 1);
		dango.erase(dango.begin() + index - 1);
		
		return rensa(dango, index - 1) + ret;
	}
	
	if(0 <= index && index < dango.size() && 4 <= dango[index].number)
	{
		int ret = dango[index].number;
		
		dango.erase(dango.begin() + index);
		
		return rensa(dango, index) + ret;
	}
	
	if(0 < index && index <= dango.size() && 4 <= dango[index - 1].number)
	{
		int ret = dango[index - 1].number;
		
		dango.erase(dango.begin() + index - 1);
		
		return rensa(dango, index - 1) + ret;
	}
	
	return 0;
}

int main()
{
    for(int n; cin >> n && n;)
	{
		vector<Dango> dango;
		
		int m = 0;
		rep(i, n)
		{
			int color;
			cin >> color;
			
			if(i != 0 && dango[m - 1].color == color) dango[m - 1].number++;
			else dango.push_back(Dango(1, color)), m++;
		}
		
		int res = n;
		
		// ツ前ツづ可債づュツつケツづ古」ツづォツつェツ陛渉つヲツづゥ
		rep(i, m - 1) // if(dango[i + 1].number == 3)
		{
			vector<Dango> v(dango);
			
			v[i].number--;
			v[i + 1].number++;
			
			if(v[i].number == 0) v.erase(v.begin() + i);
			
			chmin(res, n - rensa(v, i + 1));
		}
		
		// ツ古」ツづォツづ可債づュツつケツづ前ツつェツ陛渉つヲツづゥ
		REP(i, 1, m) // if(dango[i - 1].number == 3)
		{
			vector<Dango> v(dango);
			
			v[i].number--;
			v[i - 1].number++;
			
			if(v[i].number == 0) v.erase(v.begin() + i);
			
			chmin(res, n - rensa(v, i));
		}
		
		cout << res << endl;
	}
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
vector<int>lk[N];
int fa[N],deep[N];
int s[N];
int np[N],p1[N],p2[N];

void dfs(int x,int fr)
{
	fa[x]=fr;deep[x]=deep[fr]+1;
	for(auto y:lk[x])
	if(y!=fr)dfs(y,x);
}

int main()
{
	int n;
	cin>>n;
	rep(i,1,n)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].push_back(y);lk[y].push_back(x);
	}
	dfs(1,0);
	int x=1;
	rep(i,2,n)
	if(deep[i]>deep[x])x=i;
	dfs(x,0);
	int y=1;
	rep(i,2,n)
	if(deep[i]>deep[y])y=i;
	for(int i=y;i;i=fa[i])s[i]=1;
	rep(i,1,n)
	if(!s[i]&&++s[fa[i]]==1)
	{
		puts("-1");
		exit(0);
	}
	vector<int>a;
	for(int i=y;i;i=fa[i])a.push_back(s[i]);
	int top=0;
	for(auto i:a)
	{
		np[top+1]=top+i;
		rep(j,1,i-1)np[top+1+j]=top+j;
		top+=i;
	}
	rep(i,1,n)p1[np[i]]=i;
	top=0;
	for(auto it=a.end();--it>=a.begin();)
	{
		int i=*it;
		np[top+1]=top+i;
		rep(j,1,i-1)np[top+1+j]=top+j;
		top+=i;
	}
	rep(i,1,n)p2[np[i]]=i;
	int i=1;
	while(p1[i]==p2[i]&&i<=n)++i;
	if(p1[i]<p2[i])
	{
		rep(i,1,n)printf("%d ",p1[i]);
	}
	else
	{
		rep(i,1,n)printf("%d ",p2[i]);
	}
}

Measured memory_bytes: 13816
n = int(input())
a = list(map(int, input().split()))

ans = 0
mp = {}

for i in range(n):
    sa = i - a[i]
    if sa in mp:
        ans += mp[sa]
    wa = i + a[i]
    if wa in mp:
        mp[wa] += 1
    else:
        mp[wa] = 1

print(ans)



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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<char> s(n + 2);
  for(int i = 0; i < n; i++) cin >> s[i];
  s[n] = s[0];
  s[n + 1] = s[1];
  
  vector<char> a(n + 2);
  for(int b = 0; b < (1 << 2); b++){
    a[0] = (b & 1) ? 'W' : 'S';
    a[1] = (b & (1 << 1)) ? 'W' : 'S';
    for(int i = 2; i <= n + 1; i++){
      if(s[i - 1] == 'o'){
        if(a[i - 1] == 'S'){
          a[i] = a[i - 2];
        }else{
          a[i] = (a[i - 2] == 'S') ? 'W' : 'S';
        }
      }else{
        if(a[i - 1] == 'W'){
          a[i] = a[i - 2];
        }else{
          a[i] = (a[i - 2] == 'S') ? 'W' : 'S';
        }
      }
    }
    if(a[0] == a[n] && a[1] == a[n + 1]){
      for(int i = 0; i < n; i++){
        cout << a[i];
      }
      cout << '\n';
      break;
    }
  }
  
  if(a[0] != a[n] || a[1] != a[n + 1]) cout << -1 << '\n';
  
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define mCalc(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll dp[MAX];

ll rec(ll n) {
    if(n==0) return 0;
    if(dp[n]!=-1) return dp[n];
    
    ll i;
    ll res=INF;
    for(i=1; i<=N && n-i>=0; i*=6)
        res=min(res, rec(n-i)+1);
    
    for(i=1; i<=N && n-i>=0; i*=9)
        res=min(res, rec(n-i)+1);
    
    
    return dp[n]=res;
}


int main(void) {;
    cin >> N;
    memset(dp, -1, sizeof(dp));
    
    pt(rec(N));
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define mod 1000000007ll
	#define sz 1111
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

ll fac[sz],_fac[sz];
void init(){_fac[0]=fac[0]=1;rep(i,1,sz-1) _fac[i]=inv(fac[i]=fac[i-1]*i%mod);}
ll C(int n,int m){return n>=m&&m>=0?fac[n]*_fac[m]%mod*_fac[n-m]%mod:0;}

int n,K;
int a[sz];

ll dp[22][sz];

int main()
{
	file();
	init();
	read(n,K);
	rep(i,1,K) read(a[i]);
	dp[0][0]=1;
	rep(i,0,K-1) rep(j,0,n) if (dp[i][j]) rep(k,0,n-j) (dp[i+1][j+k]+=dp[i][j]*C(n-k,a[i+1]-k)%mod*C(n-j,k)%mod)%=mod;
	cout<<dp[K][n];
	return 0;
}

Measured memory_bytes: 512
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
using namespace std;

int main() {
      int a, b, c,d,e;
    cin >> a >> b >> c >> d;
  e = min(a,b) + min(c,d);
  cout << e << '\n';
}
  

Measured memory_bytes: 256
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define MP make_pair
#define PB push_back
#define FST first
#define SND second
#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define REP(i,x,y) for(int i=(x);i<=(y);i++)

using namespace std;

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

const int INF=1e9+7;
const int maxn=1e5+5;

int n;
int a[maxn],b[maxn],sum[maxn],ord[maxn];

class FenwickTree{
	private:
		ll dat[maxn<<1];
	public:
		ll query(int x){
			ll ret=0;
			++x;
			while(x) ret+=dat[x],x-=x&(-x);
			return ret;
		}
		void init(){memset(dat,0,sizeof(dat));}
		void update(int x){
			++x;
			while(x<=n+1) ++dat[x],x+=x&(-x);
			return;
		}
}fTree;

//inline bool cmp(const pii &a,const pii &b){return (a.FST!=b.FST)?(a.FST<b.FST):(a.SND>b.SND);}

bool check(int x){
	vector<pii> vec;
	REP(i,0,n){
		if(!i){
			sum[i]=0;
			vec.PB(MP(sum[i],i));
			continue;
		}
		if(a[i]>=x) b[i]=1;
		else b[i]=-1;
		sum[i]=sum[i-1]+b[i];
		vec.PB(MP(sum[i],i));
	}
/*	puts("b:");
	REP(i,0,n) printf("%d ",b[i]);
	puts("");
	puts("sum:");
	REP(i,0,n) printf("%d ",sum[i]);
	puts("");
*/	sort(vec.begin(),vec.end());
	REP(i,0,n) ord[vec[i].SND]=i;
/*	puts("ord:");
	REP(i,0,n) printf("%d ",ord[i]);
	puts("");
*/	fTree.init();
	ll res=0;
	REP(i,0,n){
		ll tmp=fTree.query(ord[i]);
//		printf("ind=%d add=%d\n",i,tmp);
		res+=tmp;
		fTree.update(ord[i]);
	}
//	printf("x=%d res=%lld need=%lld\n",x,res,(1ll*(n+1)*n/2)/2);
	return (res>=(1ll*(n+1)*n/2)/2);
}

int main(){
	scanf("%d",&n);
	int mx=0;
	REP(i,1,n) scanf("%d",a+i),mx=max(mx,a[i]);
/*	if(n==1){
		printf("%d\n",a[0]);
		return 0;
	}
*/	int lb=0,rb=mx+1;
	while(lb+1<rb){
		int md=(lb+rb)>>1;
		if(check(md)) lb=md;
		else rb=md;
	}
	printf("%d\n",lb);
	return 0;
}


Measured memory_bytes: 5236
#include <stdio.h>

int judge(char x[3][3], char c){
	int res=0;
	int i, j;
	
	for(i=0; i<3; i++) {
		for(j=0; j<3; j++) {
			if(x[i][j] == c) res=1;
			else{res=0; break;}
		}
		if(res==1) return res;
	} 
	
	for(i=0; i<3; i++) {
		for(j=0; j<3; j++) {
			if(x[j][i] == c) res=1;
			else{res=0; break;}
		}
		if(res==1) return res;
	} 
	
	for(i=0; i<3; i++) {
		if(x[i][i] == c) res=1;
		else{res=0; break;}
	}
	if(res==1) return res;

	for(i=0; i<3; i++) {
		if(x[i][2-i] == c) res=1;
		else{res=0; break;}
	}
	if(res==1) return res;
	
	return res;
} 

int main(void){
	while(1){
		int i, j, flag=0;
		char f[3][3];
	
		for(i=0; i<3; i++){
			for(j=0; j<3; j++){
				scanf(" %c", &f[i][j]);
				if(f[i][j]=='0') {
					flag=1;
					break;
				}
			}
			if(flag==1)break;	
		}
		if(flag==1) break;
	
		if(judge(f, 'b')==1)  printf("b\n");
		else if(judge(f, 'w')==1)	 printf("w\n");
		else printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x = x2 - x1, y = y2 - y1;

  int x3 = x2 - y;
  int y3 = y2 + x;
  int x4 = x1 - y;
  int y4 = y1 + x;
  cout << x3 << EMP << y3 << EMP << x4 << EMP << y4 << endl;
  return 0;
}


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

"""
if N >= 2 and M >= 2:
    ans = (N - 2) * (M - 2)
elif N == 1 and M >= 2:
    ans = M - 2
elif N >= 2 and M == 1:
    ans = N - 2
else:
    ans = 1
"""

ans = abs(N - 2) * abs(M - 2)

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  ll sum = 0, ans1 = 0, ans2 = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (i % 2 == 0 && sum <= 0) {
      ans1 += abs(1 - sum);
      sum = 1;
    } else if (i % 2 == 1 && sum >= 0) {
      ans1 += abs(-1 - sum);
      sum = -1;
    }
  }

  sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (i % 2 == 0 && sum >= 0) {
      ans2 += abs(-1 - sum);
      sum = -1;
    } else if (i % 2 == 1 && sum <= 0) {
      ans2 += abs(1 - sum);
      sum = 1;
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include<stdlib.h>
#include <sysexits.h>
#include <math.h>
#include <string.h>

int main(void){
  int A,B,ans_a,ans_b;
  char S[10],T[10],U[10];
  if(scanf("%s %s",S,T)>2){
    printf("error");
   exit(0);
  }
  if(scanf("%d %d",&A,&B)>2){
    printf("error");
   exit(0);
  }
  if(scanf("%s",U)>1){
    printf("error");
   exit(0);
  }
  ans_a=A;
  ans_b=B;
  if(strcmp(S,U)==0){
    ans_a--;
  }
  else{
    ans_b--;
  }
  printf("%d %d",ans_a,ans_b);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int A, int B, int C) {
        return A + B >= C;
    }
}

Measured memory_bytes: 23892
s = list(map(int, list(input())))
s.reverse()
ss = [s[0]]
n = len(s)
mod_digit = 10
for i in range(1, n):
    ss.append((s[i]*mod_digit+ss[i-1])%2019)
    mod_digit = mod_digit*10%2019
keys = [i for i in range(2019)]
counter = {key:0 for key in keys}
for i in range(n):
    counter[ss[i]] += 1
def mC2(m):
    return m*(m-1)//2
ans = 0
for key, item in counter.items():
    ans += mC2(item)
ans += counter[0]
print(ans)

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

int main(){
    string s,t; cin>>s>>t;
    int n = s.size(),m = t.size();
    vector<vector<int>> moji(26);
    rep(i,n) moji[s[i]-'a'].push_back(i);
    rep(i,n) moji[s[i]-'a'].push_back(i+n);
    ll ans = 0;
    int p = 0;
    rep(i,m){
        int c = t[i] - 'a';
        if(moji[c].size()==0){
            cout << -1 << endl;
            return 0;
        }

        p = *lower_bound(moji[c].begin(),moji[c].end(),p)+1;
        if(p>=n){
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4660
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
C = []
num = 0
for i in range(N):
    num += A[i]
    C.append(num)
A.reverse()
D = []
num = 0
for i in range(N):
    num += A[i]
    D.append(num)
D.reverse()
ans = float('inf')
for i in range(0, N - 1):
    ans = min(ans, abs(C[i] - D[i + 1]))
print(ans)

Measured memory_bytes: 28576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,R; cin >> N >> R;
    if(N >= 10){
        cout << R << endl;
    }
    else{
        cout << R+100*(10-N) << endl;
    }
}

    



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

int main() {

	string s;
	cin >> s;
	for (ll i = 0; i < s.length(); i++) {
		if (s[i] == '?') {
			if (i == 0) {
				if (s[i + 1] == 'D') {
					s[i] = 'P';
				} else
					s[i] = 'D';
			}
			else if (i == s.length() - 1) {
				s[i] = 'D';
			} else {
				if (s[i - 1] == 'P' and s[i + 1] == 'D') {
					s[i] = 'D';
				} else if (s[i - 1] == 'D' and s[i + 1] == 'P') {
					s[i] = 'D';
				} else if (s[i - 1] == 'D' and s[i + 1] == 'D') {
					s[i] = 'P';
				} else
					s[i] = 'D';
			}
		}
	}
	cout << s;
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];

        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        sc.close();

        Arrays.sort(l);

        int sum = 0;
        int max = l[l.length - 1];
        for (int i = 0; i < n - 1; i++) {
            sum += l[i];
        }

        if (max < sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21716
using System;

namespace abc060
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var ans = 
                str[0][str[0].Length - 1] == str[1][0] &&
                str[1][str[1].Length - 1] == str[2][0] ? "YES" : "NO";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	int a, b=0;
	cin >> a;
	for(int i=0; i<a; i++)
	{
		cin >> arr[i];
	}
	for(int i=0; i<a; i++)
	{
		for(int j=0; j<i; j++)
		{
			for(int k=0; k<j; k++)
			{
				int p=0;
				if(arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k])
				{
					if(arr[i]+arr[j] > arr[k])
					{
						p++;
					}
					if(arr[i]+arr[k] > arr[j])
					{
						p++;
					}
					if(arr[j]+arr[k] > arr[i])
					{
						p++;
					}
				}
				if(p==3)
				{
					b += 1;
				}
			}
		}
	}
	cout << b;
}



Measured memory_bytes: 3660
import itertools

n,m = map(int, input().split())

even = [i for i in range(2, 333, 2)]

odd = [i for i in range(1, 333, 2)]


seq = []


for i in range(n):
    seq.append(even[i])

for i in range(m):
    seq.append(odd[i])



cnt = 0

for v1, v2 in itertools.combinations(seq,2):
    tmp = int(v1) + int(v2)
    if tmp % 2 == 0:
        cnt += 1

print(cnt)


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

int main(){
  int i,j,count=0,ans=0;
  char a[3],b[3];
  cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
  if(a[0]==b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define db(x) cerr << #x << " = " << x << endl;

typedef long long   ll;
typedef long double ld;

const ll   MOD       = 1000000007;
const ll   INF       = 1000000007;
const ll   N         = 1000002;
const ll   logN      = 20;
const ld   PI        = acos(-1);
const ll   HashPrime = 31;

inline void No() {
    cout << "NO\n";
}
inline void Yes() {
    cout << "YES\n";
}

#define fi first
#define se second

ll n;

void solve() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

int main() {
  ll t = 1;
//  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 764
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", if a < 10 && b < 10 { a * b } else { -1 });
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  int count[] = {0, 0};
  REP(i, n){
    if(s[i] == '0') count[0]++;
    else count[1]++;
  }
  cout << 2*min(count[0], count[1]) << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);

    int[] temp = new int[6];
    for (int i = 0; i < 6; i++) {
      temp[i] = reader.nextInt();
    }

    int n = reader.nextInt();
    for (int i = 0; i < n; i++) {
      int t = reader.nextInt();
      int f = reader.nextInt();
      Dice dice = new Dice(temp);

      if (t == dice.number[1]) {
        dice.roll('N');
      }
      else if (t == dice.number[2]) {
        dice.roll('W');
      }
      else if (t == dice.number[3]) {
        dice.roll('E');
      }
      else if (t == dice.number[4]) {
        dice.roll('S');
      }
      else if (t == dice.number[5]) {
        dice.roll('W');
        dice.roll('W');
      }

      while (dice.number[dice.surface[1]] != f) {
        dice.roll('r');
      }
      System.out.println(dice.number[dice.surface[2]]);
    }
  }
}

class Dice {
  int[] number = new int[6];
  int[] surface = new int[3];

  public Dice(int[] number) {
    for (int i = 0; i < 6; i++) {
      this.number[i] = number[i];
    }
    this.surface[0] = 0;
    this.surface[1] = 1;
    this.surface[2] = 2;
  }

  public void roll(char order) {
    int temp;
    if (order == 'N') {
      temp = this.surface[0];
      this.surface[0] = this.surface[1];
      this.surface[1] = 5 - temp;
    }
    else if (order == 'S') {
      temp = this.surface[1];
      this.surface[1] = this.surface[0];
      this.surface[0] = 5 - temp;
    }
    else if (order == 'E') {
      temp = this.surface[2];
      this.surface[2] = this.surface[0];
      this.surface[0] = 5 - temp;
    }
    else if (order == 'W') {
      temp = this.surface[0];
      this.surface[0] = this.surface[2];
      this.surface[2] = 5 - temp;
    }
    else if (order == 'r') {
      temp = this.surface[1];
      this.surface[1] = this.surface[2];
      this.surface[2] = 5 - temp;
    }
  }
}

Measured memory_bytes: 26228
a = []
for i in range(5):
    a.append(input())
minn = 9
flag = 1
sumtime = 0
for i in range(5):
	if(minn > a[i]%10 & a[i]%10 > 0):
		minn = a[i]%10
		flag = 0
	elif(a[i]%10 == 9):
		flag = 0
	if(a[i]%10 == 0):
		sumtime += a[i]
	else:
		a[i] = a[i] + 10 - a[i]%10
		sumtime += a[i]
if(flag == 1):
	print(sumtime)
else:
	print(sumtime - 10 + minn)

Measured memory_bytes: 2692
#!/usr/bin/env python
# coding: utf-8

# In[40]:


S = input()


# In[41]:


ans = [0 for i in range(len(S))]
count_r = 0
for i, si in enumerate(S):
    if si == 'R':
        count_r += 1
    elif si == 'L':
        ans[i-1] += (count_r+1)//2
        ans[i] += count_r//2
        count_r = 0
    #print(ans)

#print('left')
count_l = 0
for i, si in enumerate(S[::-1]):
    #print(count_l)
    #print(i)
    if si == 'L':
        count_l += 1
    elif si == 'R':
        ans[-(i+1)+1] += (count_l+1)//2
        ans[-(i+1)] += count_l//2
        count_l = 0
    #print(ans)


# In[42]:


print(' '.join(map(str, ans)))


# In[ ]:






Measured memory_bytes: 10484
/* ex3_2
   kento_titech*/
#include<stdio.h>
int main(void){
    int N,r;//N,rを変数とする。Ｎは入力、rは剰余
    scanf("%d",&N);
    r=N%10;
    if(r==2||r==4||r==5||r==7||r==9){//orとif文を使って条件分岐
        printf("hon\n");
    }else if(r==0||r==1||r==6||r==8){
        printf("pon\n");
    }else{
        printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define MOD 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"
#define setbit(n) __builtin_popcount(n)
#define all(x) x.begin() , x.end()
#define clr(x) memset(x,0,sizeof(x))
ll power(ll a, ll b);
ll dp[101][100001];




int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	jaldi_chal
	ll t = 1, i;
	// cin >> t;
	while (t--)
	{
		ll n, w;
		cin >> n >> w;

		ll weight[n + 1], val[n + 1];

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

			for (ll j = 1; j <= 100000; j++)
			{

				dp[i][j] = inf;


			}
		}

		REW(i, 1, n) cin >> weight[i] >> val[i];




		dp[1][val[1]] = weight[1];

		for (ll i = 2; i <= n; i++)
		{
			dp[i][0] = 0;

			for (ll j = 1; j <= 100000; j++)
			{

				if (j < val[i]) dp[i][j] = dp[i - 1][j];

				else {

					dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - val[i]] + weight[i]);
				}

			}
		}



		for (ll i = 100000; i >= 1; i--)
		{
			if (dp[n][i] <= w)
			{
				cout << i;
				break;
			}
		}












	}


	return 0;
}


ll power(ll a, ll b) {
	ll res = 1;
	while (b)
	{
		if (b % 2) b-- , res = res * a;
		else b = b / 2 , a *= a;
	}
	return res;
}

Measured memory_bytes: 81772
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC132
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__




void solve(void){
  
  int N;
    
  cin >> N;
  
  vector<int> d(N);
  
  REP(i,N){
    cin >> d[i];
  }
  
  sort(ALL(d));
  
  int count=0;
  
//  cout << d[N-1] << endl;
  
  for (int i=0; i<=d[N-1]; i++){
//    cout << N/2 << " " << d.end()-lower_bound(ALL(d), i) << endl;
    if(N/2 == d.end()-lower_bound(ALL(d), i)){count++;}
  }
 
  cout << count << endl;
  
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,ans;
    cin >> a >> b;
    ans = a + b;
    if (ans >=24) {
        ans -= 24;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int now = (n-1)*(n-2)/2-k;
        if(now < 0){
            System.out.println(-1);
            return;
        }else if(now == 0){
            System.out.println(n-1);
            for(int i = 2; i <= n; i++){
                System.out.println("1 "+i);
            }
        }else{
            System.out.println(n-1+now);
            for(int i = 2; i <= n; i++){
                System.out.println("1 "+i);
            }
            for(int i = 2; i <= n; i++){
                for(int j = i+1; j <= n; j++){
                    System.out.println(i+" "+j);
                    now--;
                    if(now == 0){
                        return;
                    }
                }
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21332
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[10];
int flag[MAXN],num[MAXN];
int main()
{
	int n=read(),m=read(),ans1=0,ans2=0;
	for (int i=1;i<=m;i++)
	{
		int x=read(); scanf("%s",st);
		if (st[0]=='A')
		{
			if (!flag[x]) flag[x]=1,ans1++,ans2+=num[x];
		} 
		else num[x]++;
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<vector<bool>> seen(H,vector<bool>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      seen.at(i).at(j) = false;
    }
  }
  
  int64_t ans = 0;
  pair<int,int> P;
  queue<pair<int,int>> Q;
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(seen.at(i).at(j)){
        continue;
      }
      if(vec.at(i).at(j) == '#'){
        seen.at(i).at(j) = true;
        int64_t white = 0;
        int64_t black = 1;
        for(int x=0; x<4; x++){
          int xx = i + dx.at(x);
          int yy = j + dy.at(x);
          if(xx >= 0 && xx < H && yy >= 0 && yy < W){
            if(seen.at(xx).at(yy)){
              continue;
            }
            if(vec.at(xx).at(yy) == '.'){
              white++;
              seen.at(xx).at(yy) = true;
              P = make_pair(xx,yy);
              Q.push(P);
            }
          }
        }
        int q_size = white;
        int cnt = 0;
        bool kuro = false;
        while(Q.size()){
          P = Q.front();
          Q.pop();
          cnt++;
          int a = P.first;
          int b = P.second;
          for(int k=0; k<4; k++){
            int nx = a + dx.at(k);
            int ny = b + dy.at(k);
            if(nx >= 0 && nx < H && ny >= 0 && ny < W){
              if(seen.at(nx).at(ny)){
                continue;
              }
              if(kuro){
                if(vec.at(nx).at(ny) == '.'){
                  P = make_pair(nx,ny);
                  Q.push(P);
                  seen.at(nx).at(ny) = true;
                  white++;
                }
              }
              else{
                if(vec.at(nx).at(ny) == '#'){
                  P = make_pair(nx,ny);
                  Q.push(P);
                  seen.at(nx).at(ny) = true;
                  black++;
                }
              }
            }
          }
          if(cnt == q_size){
            q_size = Q.size();
            cnt = 0;
            if(kuro){
              kuro = false;
            }
            else{
              kuro = true;
            }
          }
        }
      ans += black * white;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
str s;
ll K, n, dp[310][310][310];

int main(){
	IOS;
	cin >> s;
	cin >> K;
	ll n = s.size();
	if (n == 1) return cout << 1, 0;
	s = "." + s;
	//cout << n << '\n';
	for (int i = 1; i <= n; i++){
		dp[i][i + 1][0] = 1;
	}
	for (int i = 2; i <= n; i++){
		for (int j = 1; j <= n - i + 1; j++){
			for (int k = 0; k <= K; k++){
				if (k == 0){
					if (s[j] == s[j + i - 1]){
						dp[j][i + j][0] = dp[j + 1][i + j - 1][0] + 2;
					}
					dp[j][i + j][k] = max(dp[j][i + j][k], max(dp[j + 1][i + j][k], dp[j][i + j - 1][k]));
					
				}
				
				
				
				else if (k >= i - 1){
					dp[j][i + j][k] = i;
				}else{
					dp[j][i + j][k] = dp[j][i + j][k - 1];
					if (s[j] == s[i + j - 1]){
						dp[j][i + j][k] = dp[j + 1][i + j - 1][k] + 2;
					}
					dp[j][i + j][k] = max(dp[j][i + j][k], max(dp[j + 1][i + j][k], dp[j][i + j - 1][k]));
					dp[j][i + j][k] = max(dp[j][i + j][k], 2 + dp[j + 1][i + j - 1][k - 1]);
				}
				//cout << j << ' ' << j + i - 1 << ' ' << k << ' ' << dp[j][j + i][k] << '\n';	
			}
			
			
			
		}
		
		
	}
	cout << dp[1][n + 1][K];
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 226816
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
const int MAXN=int(1e8);
LL H,W,N,x,y;
LL ans[10],tl=0;
LL no[MAXN],cxh=1e9+7;
int main()
{
	scanf("%lld%lld%lld",&H,&W,&N);
	ans[0]=(H-2)*(W-2);
	for(int t=1;t<=N;t++) {
		scanf("%lld%lld",&x,&y);
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				if(1<=x-i&&x-i<=H-2&&1<=y-j&&y-j<=W-2)
					no[++tl]=cxh*(x-i)+(y-j);
	}
	sort(no+1,no+tl+1);
	int sum=1;
	for(int i=1;i<=tl;i++) {
		if(no[i]==no[i+1])
			sum++;
		else {
			ans[sum]++;
			sum=1;
			ans[0]--;
		}
	}
	/*
	for(int i=1;i<=N;i++)
		Build(i);
	*/
	for(int j=0;j<=9;j++)
		printf("%lld\n",ans[j]);
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,m; cin >> n >> m;
    ll mn = INF;
    vl a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        mn = min(mn, a[i]);
        sum += a[i];
    }
    cout << (m-sum)/mn + n << endl;
}

Measured memory_bytes: 256