akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  const int N = S.size();
  int X, Y;
  cin >> X >> Y;
  int i;
  for (i = 0; S[i] == 'F'; i++) {
    X--;
  }
  i64 vmax = 0, hmax = 0;
  vector<int> vmove, hmove;
  bool vertical = false;
  for (; i < N;) {
    int turn_count = 0;
    while (i < N && S[i] == 'T') {
      turn_count++;
      i++;
    }
    vertical ^= (turn_count % 2 == 1);
    int walk = 0;
    while (i < N && S[i] == 'F') {
      walk++;
      i++;
    }
    if (vertical) {
      vmove.push_back(walk);
      vmax += walk;
    } else {
      hmove.push_back(walk);
      hmax += walk;
    }
  }

  auto check = [&](const vector<int>& moves, int target) -> bool {
    int M = moves.size();
    int T = 56010;
    int offset = T / 2;
    vector<bool> dp(T);
    dp[offset + 0] = true;
    REP(i, M) {
      vector<bool> tmp(T);
      swap(dp, tmp);
      REP(j, T) {
        if (tmp[j]) {
          if (j + moves[i] < T) dp[j + moves[i]] = true;
          if (j - moves[i] >= 0) dp[j - moves[i]] = true;
        }
      }
    }
    return dp[offset + target];
  };
  if (check(vmove, Y) && check(hmove, X)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, K;
  cin >> N >> K;
  int x = 1;
  
  for (int i = 0;N > i;i++){
    
    cin >> x;
    
    if (x < K){
      x *= 2;
    }
    else{
      x += K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define N 2005
using namespace std;

int m,n,dp[2][N][N],sz[2],ans;
string st[2];

int func(int id,int p,int k,char c){
  int r=0,idr=(id+1)%2;
  if(p+1<sz[id]&&st[id][p+1]!=c){
    if(!dp[id][p+1][k])dp[id][p+1][k]=func(id,p+1,k,st[id][p+1]);
    r=max(r,dp[id][p+1][k]+1);
  }
  if(k<sz[idr]&&st[idr][k]!=c){
    if(!dp[idr][k][p+1])dp[idr][k][p+1]=func(idr,k,p+1,st[idr][k]);
    r=max(r,dp[idr][k][p+1]+1);
  }
  if(r==0&&st[id][p]=='I')r=1;
  return r;
}

int main(){
  cin>>m>>n>>st[0]>>st[1];
  sz[0]=st[0].size();
  sz[1]=st[1].size();
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++){
      if(st[0][i]=='I')dp[0][i][j]=max(dp[0][i][j],func(0,i,j,'I'));
      if(st[1][j]=='I')dp[1][j][i]=max(dp[1][j][i],func(1,j,i,'I'));
    }
  for(int i=0;i<2;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
	if(st[i][j]=='I')ans=max(ans,dp[i][j][k]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 32956
#include<bits/stdc++.h>
using namespace std;
int N, A[2000];
long long dp[2000][2000];

inline int NEXT(int x){ return((x + 1) % N); }
inline int PREV(int x){ return((x + N - 1) % N); }

long long rec(int left, int right, bool which)
{
  if(left == right) {
    return((!which) * A[left]);
  } else if(~dp[left][right]) {
    return(dp[left][right]);
  } else if(which) {
    if(A[left] > A[right]) return(dp[left][right] = rec(PREV(left), right, false));
    return(dp[left][right] = rec(left, NEXT(right), false));
  } else {
    return(dp[left][right] = max(rec(PREV(left), right, true) + A[left], rec(left, NEXT(right), true) + A[right]));
  }
}

int main()
{
  fill_n( *dp, 2000 * 2000, -1);

  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  long long ret = 0;
  for(int i = 0; i < N; i++) {
    ret = max(ret, rec(PREV(i), NEXT(i), true) + A[i]);
  }
  printf("%lld\n", ret);
}

Measured memory_bytes: 32536
# https://atcoder.jp/contests/abc106/tasks/abc106_d
# どうやったら高速に区間[p,q]に完全に入っている区間の数を取得できるか？
# p,qを二次元座標として捉えると電車1本の線は二次元平面上の1点として表せる
# このときp,qの区間に完全に入っている電車の本数というのは、x軸、y軸の両方において[p,q]となる四角形内にある電車の本数
# queryに高速に答えるために二次元累積和を構築する
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


import numpy as np

N, M, Q = read_ints()
LR = read_tuple(M)
pq = read_tuple(Q)

# # 二次元座標上へのプロット
# LR2d = np.zeros((N + 1, N + 1), np.int64)
# for L, R in LR:
#     LR2d[L, R] += 1 #ここがボトルネック


# numpy使わずに再実装
LR2d = [[0] * (N + 1) for _ in range(N + 1)]
for L, R in LR:
    LR2d[L][R] += 1
LR2d = np.array(LR2d)

LR2d_accum = np.zeros((N + 2, N + 2), np.int64)
LR2d_accum[1:, 1:] = LR2d.cumsum(axis=0).cumsum(axis=1)  # 1次元累積和同様半開区間で考える
# つまりインデックスi,jとはもとの配列においてi,jを含まない四角形の領域の合計を出す

# queryに答えていく
for p, q in pq:
    print(LR2d_accum[q + 1, q + 1] - LR2d_accum[q + 1, p] -
          LR2d_accum[p, q + 1] + LR2d_accum[p, p])


Measured memory_bytes: 48896
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b;
  cin >> a >> b;

  if(!((1 <= a && a <= 9) && (1 <= b && b <= 9)))
    cout << -1;
  else cout << a * b;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 1e6 + 5 ; 
int n, a[N], w[10], bk[10] ; 
char s[N] ; 
signed main()
{
	n = gi(), scanf("%s", s + 1 ) ;
	rep( i, 1, n ) a[i] = s[i] - '1', bk[a[i]] = 1 ; 
	rep( i, 1, n ) if( ( ( i - 1 ) & ( n - 1 ) ) == ( i - 1 ) ) w[a[i]] ^= 1 ; 
	if( w[1] ) { puts("1") ; exit(0) ; }
	if( w[2] && ( !bk[1] ) ) { puts("2") ; exit(0) ; }
	puts("0") ; 
	return 0 ;
} 

Measured memory_bytes: 5120
//TrainingCamp.cpp (B)
#include <iostream>
using namespace std;

int main(){
  int N;
  long long Ans = 1;
  cin >> N;
  for(int i = 1; i <= N; i++){
    Ans *= i;
    if(Ans>=1000000007) Ans %= 1000000007;
  }
  printf("%d\n", Ans);

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	public static void main (String[] args) {
		
		Scanner scanner = new Scanner (System.in);
		
		int totalMochi = scanner.nextInt();
		ArrayList <Integer> mochiList = new ArrayList <Integer>();
		
		for (int index=0; index<totalMochi; index++) {
			int mochi = scanner.nextInt();
			
			if (hantei(mochi,mochiList)) {
				mochiList.add(mochi);
			}
		}
		
		System.out.println(mochiList.size());
	}
	
	private static boolean hantei (int mochi, ArrayList <Integer> mochiList) {
		
		boolean hantei = true;
		for (int index=0; index<mochiList.size(); index++) {
			int temp = mochiList.get(index);
			
			if (temp==mochi) {
				hantei=false;
			}
		}
		return hantei;
	}
}

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

//typedef long long LL;
const int MV=1e5+5;
const int MB=20;

struct Edge
{
	int v,c,d;
	Edge(int v=0,int c=0,int d=0)
		:v(v),c(c),d(d){}
};
vector<Edge> g[MV];

int dfn[MV*2],pos[MV];
int n,q;

vector<int> id[MV];
vector<int> sum[MV];
vector<int> cnt[MV];
int ndfn=0;

void init()
{
	for(int i=0;i<=n;i++)
	{
		id[i].push_back(0);
		sum[i].push_back(0);
		cnt[i].push_back(0);
	}
	ndfn=0;
}

int dis[MV];
void dfs(int u,int fa,int c,int d,int nd)
{
	//cout<<u<<" "<<c<<endl;
	dfn[++ndfn]=u;
	pos[u]=ndfn;
	id[c].push_back(ndfn);
	sum[c].push_back(sum[c].back()+d);
	cnt[c].push_back(cnt[c].back()+1);
	dis[u]=nd;
	//cout<<u<<endl;
	for(Edge e:g[u])
	{
		int v=e.v;
		if(v==fa) continue;
		dfs(v,u,e.c,e.d,nd+e.d);
	}
	id[c].push_back(++ndfn);
	sum[c].push_back(sum[c].back()-d);
	cnt[c].push_back(cnt[c].back()-1);
}

int fa[MV][MB],dep[MV];
void dfs_fa(int u,int f,int depth)
{
	dep[u]=depth;
	for(Edge e:g[u])
	{
		int v=e.v;
		if(v==f) continue;
		if(fa[v][0]==-1)
		{
			fa[v][0]=u;
			dfs_fa(v,u,depth+1);
		}
	}
		
}
void init_lca(int root)
{
	memset(fa,-1,sizeof(fa));
	dfs_fa(root,0,0);
	for(int j=1;j<MB;j++)
		for(int i=1;i<=n;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
}
int lca(int a,int b)
{
	if(dep[a]>dep[b]) swap(a,b);
	int k=dep[b]-dep[a];
	for(int i=0;(1<<i)<=k;i++)
		if(k&(1<<i)) b=fa[b][i];
	if(a==b) return a;
	for(int i=MB-1;i>=0;i--)
	{
		if(fa[a][i]!=fa[b][i])
		{
			a=fa[a][i];
			b=fa[b][i];
		}
	}
	return fa[a][0];
}

inline int getsum(int u,int c,int d)
{
	int p=upper_bound(id[c].begin(),id[c].end(),pos[u])-id[c].begin()-1;
	//cout<<p<<endl;
	int ans=dis[u]-sum[c][p]+cnt[c][p]*d;
	//cout<<u<<" "<<dis[u]<<" "<<sum[c][p]<<" "<<cnt[c][p]<<" "<<ans<<endl;
	return ans;
}

int main()
{
	//freopen("F_in.txt","r",stdin);
	scanf("%d%d",&n,&q);
	int u,v,c,d;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%d%d",&u,&v,&c,&d);
		g[u].emplace_back(v,c,d);
		g[v].emplace_back(u,c,d);
	}
	init();
	dfs(1,0,0,0,0);
	// for(int i=1;i<=n;i++)
	// 	cout<<dis[i]<<" ";
	// cout<<endl;
	// for(int i=1;i<=n;i++)
	// 	cout<<pos[i]<<" ";
	// cout<<endl;
	// for(int i=0;i<=n-1;i++)
	// {
	// 	cout<<"id "<<i<<":";
	// 	for(int j:id[i])
	// 		cout<<" "<<j;
	// 	cout<<endl;
	// 	cout<<"sum "<<i<<":";
	// 	for(int j:sum[i])
	// 		cout<<" "<<j;
	// 	cout<<endl;
	// 	cout<<"cnt "<<i<<":";
	// 	for(int j:cnt[i])
	// 		cout<<" "<<j;
	// 	cout<<endl;
	// }
	init_lca(1);
	while(q--)
	{
		scanf("%d%d%d%d",&c,&d,&u,&v);
		int l=lca(u,v);
		//cout<<l<<endl;
		printf("%d\n",getsum(u,c,d)+getsum(v,c,d)-2*getsum(l,c,d));
	}
	return 0;
}

Measured memory_bytes: 42976
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {

    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=(n/(a+b))*a;
    n=n-(n/(a+b))*(a+b);
    if(n>=a)
        ans+=a;
    else
        ans+=n;
    cout<<ans;
}		

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){
	if(b==0)return a;
	return GCD(b,a%b);
}
int main(){
	ll a,b;
	while(cin>>a>>b){
		ll gcd=GCD(a,b);
		cout<<gcd<<" "<<a*b/gcd<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, k;
    cin >> n >> k;

    i64 nin = 1e18;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    for (int i = 0; i < n - k + 1; i++) {
        i64 l = as[i];
        i64 r = as[i + k - 1];

        if (r <= 0) {
            nin = min(nin, -l);
        } else if (l >= 0) {
            nin = min(nin, r);
        } else {
            nin = min(nin, r - l + min(-l, r));
        }
    }
    cout << nin << endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 8)

n, u, v = map(int, input().split())
to = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

def DFS(s, dist, to, d = 0, p = -1):
    dist[s] = d
    for v in to[s]:
        if v == p:
            continue
        DFS(v, dist, to, d + 1, s)
    
def calcDist(s, dist, to):
    DFS(s, dist, to)
    
distU = [0] * (n + 1)
distV = [0] * (n + 1)

calcDist(u, distU, to)
calcDist(v, distV, to)
ans = 0
for i in range(n + 1):
    if distU[i] < distV[i]:
        ans = max(ans, distV[i])
print(ans - 1)


Measured memory_bytes: 122924
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, k;
    cin >> n >> k;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }
    sort(all(v));
    lli sum = 0;
    for (lli i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

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

int main()
{
	string A, B;

	cin >> A >> B;

	int ans = 0;
	
	if( A.size() > B.size() ) {
		ans = 1;
	}
	else if( A.size() < B.size() ) {
		ans = 2;
	}
	else {
		if( A > B ) {
			ans = 1;
		}
		else if( A < B ) {
			ans = 2;
		}
	}

	if( ans == 1 ) {
		cout << "GREATER" << endl;
	}
	else if( ans == 2 ) {
		cout << "LESS" << endl;
	}
	else {
		cout << "EQUAL" << endl;
	}

	return 0;
}


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

int N;
int dfs(int v){
    int a[] ={v*10+3,v*10+5,v*10+7};
    int res = 0;
    for (int i = 0; i < 3; i++) {
        if(a[i] > N) continue;
        string s = to_string(a[i]);
        if(s.find('3')!=-1 && s.find('5')!= -1 && s.find('7')!=-1)res++;
        res += dfs(a[i]);
    
    }
    return res;
}

signed main(void){
    // Your code here!
    cin >> N ;
    cout<<dfs(0)<<endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
	VT<string> s(3);
	REP(i, 3) cin >> s[i];
	cout << "A" << s[1][0] << "C" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>

using namespace std;

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

int main(){
    int n,d,tmp,ans;
    ans=0;
    int v[22][11];
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>tmp;
            v[i][j]=tmp;
        }
    }

    for (int i = 0; i < n; i++){
        for ( int j = i+1 ;j < n; j++){
            int dis=0;
            for (int z = 0; z < d; z++){
                dis+=(v[i][z]-v[j][z])*(v[i][z]-v[j][z]);
            }
            if(!(ceil(sqrt(double(dis)))!=floor(sqrt(double(dis))))){
                ans+=1;
            }
        }   
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
s = int(input())


def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1


d = dict()
d[s] = 1
an = s
i = 2
while True:
    an = f(an)
    if d.get(an) is not None:
        print(i)
        break
    d[an] = i
    i += 1

Measured memory_bytes: 3060
n = int(input())
c = input()

a, b = 0, 0

for i in range(n):
    if c[i] == 'R':
        a += 1

ans = max(a, b)

for i in range(n):
    if c[i] == 'R':
        a -= 1
    else:
        b += 1
    now = max(a, b)
    ans = min(now, ans)

print(ans)

Measured memory_bytes: 9364
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var A = new HashSet<int>();
            for (int i = 0; i < N; ++i)
                A.Add(cin.ReadInt());
            WriteLine(A.Count);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int INF = INT_MAX - 10;
    vector<int> B(N, INF);
    REP(i, N) {
        int k = distance(B.begin(), upper_bound(all(B), -A[i]));
        B[k] = -A[i];
        PRINTA(B, 0, B.size());
    }
    int result = distance(B.begin(), lower_bound(all(B), INF));
    cout << result << endl;


    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

long long N;

int main()
{
    cin >> N;
    long long A;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if(A % 2 == 1)
        {
            cnt++;
        }
    }

    if(cnt % 2 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    vector<int> a[N];
    rep(i, N){
        int num;
        cin >> num;
        for(int j = -1; j <= 1; j++){
            a[i].push_back(num + j);
        }
    }
    map<int, int> mp;
    rep(i, N){
        rep(j, 3){
            if(mp.count(a[i][j]) == 0) mp.insert(make_pair(a[i][j], 1));
            else mp[a[i][j]]++;
        }
    }
    int mx = 0;
    for(auto p : mp){
        mx = max(mx, p.second);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 10112
n = (int)(input())
list=[]
for i in range(n):
    k = input().split(" ")
    a=(int)(k[0])
    b=(int)(k[1])
    list.append([a,b])
list = sorted(list,key=lambda x: x[1])
count=0
time=0
for i in range(n):
    if(time<list[i][0]):
        count+=1
        time=list[i][1]
print(count)



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

int main(){
    int N;
    cin >> N;
    vector <pair<int, int>> v;
    for(int i =1; i <= N; i++){
        int a;
        cin >> a;
        v.push_back(make_pair(a, i));
    }
    sort(v.begin(), v.end());
    for(int i =0; i < N; i++){
        cout << v.at(i).second << " ";
    }
    cout << endl;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
signed main() {
    cin >> N;
    int ans = 1e18;
    for (int i = 1; i < N; i++) {
        int cur = 0;
        int a = i, b = N - i;
        while (a != 0) {
            cur += a % 10;
            a /= 10;
        }
        while (b != 0) {
            cur += b % 10;
            b /= 10;
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,k = gets.chomp.split.map(&:to_i)

# 確率の和を愚直に取る
ans = 0
for i in 1..n
    saikoro_kakuritu = 1.0/n
    if i >= k
        ans += saikoro_kakuritu
    else
        x = k*1.0/i
        kaisuu = (Math.log10(x)/Math.log10(2.0)).ceil
        # p kaisuu
        kakuritu = saikoro_kakuritu * ((1/2.0)**kaisuu)
        ans += kakuritu
    end
end
print ans

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		int firstblasta = 0;
		int firstb = 0;
		int lasta = 0;
		int ans = 0;

		for (int i = 0; i < n; i++) {
			String s = n();
			if (s.charAt(0) == 'B' && !(s.charAt(s.length() - 1) == 'A')) {
				firstb++;
			}
			if (s.charAt(s.length() - 1) == 'A' && !(s.charAt(0) == 'B')) {
				lasta++;
			}
			if (s.charAt(0) == 'B' && s.charAt(s.length() - 1) == 'A') {
				firstblasta++;
			}
			ans += abcount(s);
		}

		if (firstblasta == 0) {
			ans += min(firstb, lasta);
		} else if (firstblasta != 0 && max(firstb, lasta) != 0) {
			ans += firstblasta + min(firstb, lasta);
		} else if (firstb == 0 && lasta == 0) {
			ans += firstblasta - 1;
		}

		out(ans);
	}

	/*
	 * 以下メソッド集
	 */

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 34056
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007

 ll poweMOD(ll a,ll n){
    if(n==0) return 1;
    else{
        ll tmp =poweMOD(a,n/2)%MOD;
        if(n%2==0)return (tmp*tmp)%MOD;
        else {
            return (a*((tmp*tmp)%MOD))%MOD;
        }
    }
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
   ll  n;cin>>n;
   ll ans = poweMOD(10,n) -2*poweMOD(9,n) + poweMOD(8,n) ;
   ans=(ans%MOD+MOD)%MOD;
   cout<<ans;
 
return 0;
}

Measured memory_bytes: 3652
from scipy.sparse.csgraph import floyd_warshall
 
# 下準備
N, M, L = map(int,input().split())
d = [[float("inf") for i in range(N)] for j in range(N)]
answer_d = [[float("inf") for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = map(int,input().split())
    d[A-1][B-1] = d[B-1][A-1] = C
for i in range(N):
    d[i][i] = 0
 
# 燃料補給回数の最小値を求める
d = floyd_warshall(d)
for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            answer_d[i][j] = answer_d[j][i] = 1
d = floyd_warshall(answer_d)
 
# クエリを答える
Q = int(input())
answer = [-1]*Q
for i in range(Q):
    s, t = map(int,input().split())
    if d[s-1][t-1] != float("inf"):
        answer[i] = d[s-1][t-1]-1
 
for i in answer:
    print(i)

Measured memory_bytes: 23652
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((prize(xy[0]) + prize(xy[1]) + (xy.All(x => x == 1) ? 4 : 0)) * 100000);
    }
    static int prize(int rank) => rank == 3 ? 1 : rank == 2 ? 2 : rank == 1 ? 3 : 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		String[] gift = new String[num];

		sc.nextLine();
		for (int i = 0; i < num; i++) {
			gift[i] = sc.nextLine();
		}

		Arrays.sort(gift);

		int cnt = 1;
		for (int i = 0; i < num - 1; i++) {
			if (!gift[i].equals(gift[i + 1])) {
				cnt++;
			}
		}

		System.out.println(cnt);

	}

}


Measured memory_bytes: 73784
#include "bits/stdc++.h"

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define pds(x) printf("%lld ", x)
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end()) 

// Debugging
#define d1(var1) std::cout<<#var1<<" : "<<var1<<"\n"
#define d2(var1, var2) std::cout<<#var1<<" : "<<var1<<"\n"<<#var2<<" : "<<var2<<"\n"
#define d3(var1, var2, var3) std::cout<<#var1<<" : "<<var1<<"\n"<<#var2<<" : "<<var2<<"\n"<<#var3<<" : "<<var3<<"\n"

// Output variables in a single line separated by space
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"

// Input variables
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c

// self max function
template <typename T> void chmax(T& a, T b) {
    a = max(a, b);
}

// Self min function
template <typename T> void chmin(T& a, T b) {
    a = min(a, b);
}

// Generic swap function
template <class X> void swp(X &a, X &b) {
	X c;
	c = a;
	a = b;
	b = c;
}

using ll = long long int;
using ull = unsigned long long int;

ll ModE(ll x, ull y, ll p = MOD) 
{ 
    ll res = 1;
    x = x % p;    
    while (y > 0) 
    {   if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

int main() {
    #ifdef M_DEBUG
    //freopen("input.txt", "r", stdin);
    //freopen("`output.txt", "w", stdout);
    #endif

    fastio
    
	//ll T; cin>>T; while(T--) {}
	
	ll n, k;
	i2(n, k);
	
	ll dp[n + 1][k + 1];
	rep2(i, 0, k)
		dp[0][i] = 0;
	rep2(i, 0, n)
		dp[i][0] = 1;
	
	int p;
	for(int i = 1; i <= n; i++){
		i1(p);
		ll arr[k + 1] = {0};
		
		arr[0] = dp[i - 1][0];
		for(int j = 1; j <= k; j++)
			arr[j] = (arr[j - 1] + dp[i - 1][j]) % MOD;
			
		for(int j = 0; j <= k; j++){
			dp[i][j] = 0;
			int L = j - min(p, j);
			int R = j;
			
			dp[i][j] = (dp[i][j] + arr[R]) % MOD;
			if(L > 0)
				dp[i][j] = (dp[i][j] - arr[L - 1] + MOD) % MOD;
			 //for(int l = 0; l <= min(p, j) && j - l >= 0; l++){
				//dp[i][j] += dp[i-1][j - l];
			 //}
		}
	}
	
	cout<<dp[n][k];
    return 0;
}



Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, m;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
  	if (n == m)cout << "Yes";else cout << "No";
}


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

int kind[1000];

int main() {
	int N;
	string S;
	cin>>N>>S;
	
	set<string>ss;
	ss.insert("");
	for (int i = 0; i < N; i++)
	{
		auto itr = ss.end();
		do{
			itr--;
			string s = *itr;
			string num_s = s + S[i];
			//cerr<<i<<" "<<num_s<<endl;
			if (s.size() < 2)
			{
				ss.insert(num_s);
			}
			else
			{				
				kind[stoi(num_s)] = true;
			}		
		} while (itr != ss.begin());
	}

	int ans = 0;
	for (int i = 0; i <= 999; i++)
	{
		if(kind[i])ans++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main  {
    public static void main(String[] args) {
        Scanner sc =new Scanner (System.in);
        String s=sc.nextLine();
        int length=s.length();
        char c=s.charAt(length-1);
        if(Character.isLowerCase(c))
        {
            if(c=='s')
            {
                System.out.println(s+"es");
            }
            else{
                System.out.println(s+"s");
            }
        }
        sc.close();
    }
}


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

int main() {
    char s[4];
    cin >> s;

    cout << s[0] + s[1] + s[2] - '0' * 3 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramF
    {
        static void Main()
        {
            int n = NextInt;
            var abc = new int[3] {NextInt, NextInt, NextInt};
            var s = Enumerable.Range(0, n).Select(_ => Line).ToArray();
            var stack = new List<char>();

            if (s[0].All(c => abc[c - 'A'] == 0) && abc.Count(x => x == 0) >= 2)
            {
                System.Console.WriteLine("No");
                return;
            }

            for (int i = 0; i < n; i++)
            {
                // 両方とも0
                if (abc[s[i][0] - 'A'] == 0 && abc[s[i][1] - 'A'] == 0)
                {
                    System.Console.WriteLine("No");
                    return;
                }

                // s[i][0]が大きい
                if (abc[s[i][0] - 'A'] > abc[s[i][1] - 'A'])
                {
                    abc[s[i][0] - 'A']--;
                    abc[s[i][1] - 'A']++;
                    stack.Add(s[i][1]);
                }

                // s[i][1]が大きい
                else if (abc[s[i][0] - 'A'] < abc[s[i][1] - 'A'])
                {
                    abc[s[i][0] - 'A']++;
                    abc[s[i][1] - 'A']--;
                    stack.Add(s[i][0]);
                }

                // 数が同じ
                else if (abc[s[i][0] - 'A'] == abc[s[i][1] - 'A'])
                {
                    var intersect = i + 1 < n ? s[i].Intersect(s[i + 1]).ElementAt(0) : s[i][0];
                    abc[intersect - 'A']++;
                    abc[s[i].First(c => c != intersect) - 'A']--;
                    stack.Add(intersect);
                }
            }

            System.Console.WriteLine("Yes");
            System.Console.WriteLine(string.Join("\n", stack));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 44536
/*
Educational DP Contest - D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d
*/

#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll; 
 
int main()  
{ 
    FAST_INP;
    ll n,W,w,v;
    cin >> n >> W;
    ll dp[W+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
    	cin >> w >> v;
    	for(int j=W;j>=w;j--){
    		dp[j]=max(dp[j],dp[j-w]+v);
		}	
	}
	cout << dp[W] << endl;
    return 0;
} 


Measured memory_bytes: 4376
#include <iostream>
#include <vector>

using namespace std;

int main() {
  // input
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }

  int count = 0;
  for (int i=1; i<n-1; i++){
    if ((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1])){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
S = str(input())
L = int(S[:2])
R = int(S[2:])

if L == 0:
    L = 99
if R == 0:
    R = 99

if L > 12 and R > 12:
    print("NA")
elif L <= 12 and R <= 12:
    print("AMBIGUOUS")
elif L > R:
    print("YYMM")
else:
    print("MMYY")


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

int main()
{
  int n, m;
  int i, a1, a2, ans;
  cin >> n;
  cin >> m;
  vector<int> l(n+1,0), h(n+1);
  for(i=1; i<n+1; i++)
  {
    cin >> h[i];
  }
  for(i=0; i<m; i++)
  {
    cin >> a1;
    cin >> a2;
    if(h[a1]>=h[a2])l[a2]++;
    if(h[a1]<=h[a2])l[a1]++;
  }
  ans = 0;
  for(i=1; i<(n+1); i++)
  {
    if(l[i] == 0)ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<ii> point(n);
  set<ii> s;
  for (auto &i : point) {
    cin >> i.fi >> i.sc;
    s.insert(ii(i.fi, i.sc));
  }
  int cnt = 0;
  vector<int> ans(10);
  map<int, map<int, int>> d;
  for (auto &i : point) {
    for (int j = -2; j <= 0; j++)
    for (int k = -2; k <= 0; k++) {
      int x = max(min(i.fi + j, h - 2), 1LL);
      int y = max(min(i.sc + k, w - 2), 1LL);
      if (d[x][y]) continue;
      d[x][y] = 1;
      cnt++;
      int t = 0;
      for (int l = 0; l <= 2; l++)
      for (int g = 0; g <= 2; g++) {
        t += s.count(ii(x + l, y + g));
      }
      ans[t]++;
    }
  }
  ans[0] = (h - 2) * (w - 2) - cnt;
  for (auto &i : ans) cout << i << '\n';
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 95224
//you never give up.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define v32 vector<int>
#define v64 vector<ll>

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll count = 0;

    ll i = 0;
    ll j = n - 1;
    while (i < j)
    {
        while (i < j)
        {
            if (s[i] == 'W')
                break;
            i++;
        }
        if (i == j)
        {
            break;
        }
        while (j > i)
        {
            if (s[j] == 'R')
                break;
            j--;
        }
        if (j == i)
        {
            break;
        }
        count++;
        i++;
        j--;
    }

    cout << count << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

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

using namespace std;

int main()
{
    char A[20];
    cin>>A;
    for(int i=0; i<strlen(A); i++)
    {
      if(A[i]==',')
      {
          cout<<" ";
          continue;
      }
      cout<<A[i];
    }
    cout<<endl;

    return 0;
}



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

int main() {
        long long n;
        cin >> n;
        string ans;
        while (n) {
                n --;
                int a = n % 26;
                ans.push_back('a' + a);
                n /= 26;
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 3608
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// hbi1998氏
// https://atcoder.jp/contests/agc038/submissions/7636692
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int mod = 998244353;
const int N = 1100000;

int a[N], dp[N], r[N];
LL s[N], ss[N];

int main(){
    r[1] = 1;
    for(int i = 2; i < N; i++) r[i] = (LL)r[mod % i] * (mod - mod / i) % mod;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        a[x]++;
    }
    for(int i = 1; i < N; i++) for(int j = i; j < N; j += i) s[i] += (LL)j * a[j], ss[i] += (LL)j * j * a[j];
    for(int i = 1; i < N; i++) s[i] %= mod, ss[i] %= mod;
    int ans = 0;
    for(int i = N - 1; i >= 1; i--){
        dp[i] = (s[i] * s[i] + mod - ss[i]) % mod;
        for(int j = i + i; j < N; j += i){
            dp[i] = dp[i] - dp[j];
            if(dp[i] < 0) dp[i] += mod;
        }
    }
    for(int i = 1; i < N; i++){
        ans = ans + (LL)dp[i] * r[i] % mod;
        if(ans >= mod) ans -= mod;
    }
    if(ans & 1) ans += mod;
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 29952
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--)
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    ll n;
    cin>>n;
    ll k=0,i,j,m=0;
    while(n--){
        cin>>i;
        m=max(m,i);
        k+=m-i;
    }
    cout<<k<<"\n";
}

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

int main(void){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> p(n);
    rep(i,n){
        rep(j,d){
            int x;
            cin >> x;
            p[i].push_back(x);
        }
    }
    int cnt = 0;
    rep(i,n)rep(j,i){
        int sum = 0;
        rep(k,d){
            sum += (p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
        }
        int root = sqrt(sum);
        if (root*root == sum) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> Na;//???????´???????
vector<int> Ma;
vector<int> Nw;//?????¨????????????????????????
vector<int> Mw;
int solve(void){
	int i,j,ans=0,a=0,N=0,M=0;
	scanf("%d %d",&N,&M);
	if(N*M==0){
		return 0;
	}
	Na.push_back(0);
	Ma.push_back(0);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		a+=Na[i];
		Na.push_back(a);
	}
	for(i=0;i<M;i++){
		scanf("%d",&a);
		a+=Ma[i];
		Ma.push_back(a);
	}
	for(i=0;i<=N;i++){
		for(j=i+1;j<=N;j++){
			Nw.push_back(Na[j]-Na[i]);
		}
	}
	for(i=0;i<=M;i++){
		for(j=i+1;j<=M;j++){
			Mw.push_back(Ma[j]-Ma[i]);
		}
	}
	sort(Nw.begin(),Nw.end());
	sort(Mw.begin(),Mw.end());
	for(i=0;i<Nw.end()-Nw.begin();i++){
		ans-=lower_bound(Mw.begin(),Mw.end(),Nw[i])-upper_bound(Mw.begin(),Mw.end(),Nw[i]);
	}
	printf("%d\n",ans);
	Na.clear();
	Nw.clear();
	Ma.clear();
	Mw.clear();
	return 10;
}
int main(void){
	while(solve());
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  int N;
  cin >> N;
  vector<char>S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){
      ans++;
    }
  }
  cout << ans << endl;
  
}
      
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;

vector<int> v;
signed main(){
	int n, t;
	scanf("%lld%lld", &n, &t);
	for(int i = 0;i < n;i++){
		int x;
		scanf("%lld", &x);
		v.push_back(x);
	}
	v.push_back(INF);
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(v[i+1] < v[i]+t){
			ans += v[i+1]-v[i];
		}else ans += t;
	}
	printf("%lld\n", ans);
	return 0;
}


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


int main() {
    string s,t;
    cin >> s;
    cin>>t;

    string z = t.substr(0,s.size());
    if(z==s&&s.size()+1==t.size()) cout <<"Yes" <<endl;
    else cout << "No" <<endl;
  }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> P){
    ll Min = N + 1, cnt = 0;
    rep(i, N) if (chmin(Min, P.at(i))) cnt++;
    cout << cnt << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> P(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&P[i]));
    }
    solve(N, move(P));
    return 0;
}

Measured memory_bytes: 1792