akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, H, W, A, B);

    int ans[1005][1005] {};

    rep(i, 0, H) {
        rep(j, 0, W) {
            int p = (j < A);
            if (i < B) p = 1 - p;
            ans[i][j] = p;
        }
    }

    vector<int> cntrow(H);
    vector<int> cntcol(W);
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (ans[i][j]) ++cntrow[i], ++cntcol[j];
        }
    }

    if (
        !all_of(all(cntrow), [&](int e) { return min(e, W-e) == A; }) ||
        !all_of(all(cntcol), [&](int e) { return min(e, H-e) == B; })) {
        print("No");
    } else {
        rep(i, 0, H) {
            rep(j, 0, W) cout << ans[i][j];
            cout << "\n";
        }
    }

    return 0;
}


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

int main(){
    int A,B,C;
    cin >> A >> B;
    cout <<max(max(A+B,A-B),A*B) << endl;

}

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


int main() {
   int n, m;
   cin>>n>>m;
   vector<pair<ll, ll> > p(n);
   for(int i=0;i<n;i++)
        cin>>p[i].first>>p[i].second;
    sort(p.begin(), p.end());
    
    ll sum = 0;
    int j = 0;
    priority_queue<ll> pq;
    for(ll i=1;i<=m;i++) {
        for(; j<n; j++) {
            if(p[j].first > i)break;
            pq.push(p[j].second);
        }
        if(!pq.empty()) {
            sum += pq.top();
            pq.pop();
        }
    }
    
    cout<<sum<<endl;
}

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

int main(){
	long long N;
	string S;
	cin >> N;
	cin >> S;
	if (N % 2 == 1){
		cout << "No";
		return 0;
	}

	bool is_ok = true;
	for (int i = 0; i < N / 2; i++){
		if (S[i] != S[N / 2 + i]){
			is_ok = false;
		}
	}

	if (is_ok){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}

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

int main(){
	// sengen
	long n,k;

	// nyuryoku
	cin >> n >> k;
	// keisan
	if(n%k == abs(n%k-k)){
		cout << n%k;
	}else{
		cout << min(n%k,abs(n%k-k));
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int ans = 0, b = 0;
	if (a[0] > 0)
	{
		printf("-1\n");
		return 0;
	}
	for (i = n - 1; i >= 0; i--)
	{
		if (a[i] < b && b>0)
		{
			printf("-1\n");
			return 0;
		}
		if (a[i] > b || b <= 0)
		{
			b = a[i];
			ans += b;
		}
		b--;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int H,W; cin >> H >> W; 
		int K; cin >> K; 
		vector<vector<char>>c(H,vector<char>(W));
		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){
				cin >> c[i][j];
			}
		}
		int ans = 0; 
		for(int maskH = 0; maskH < (1 << H); maskH++){
			for(int maskW = 0; maskW < (1 << W); maskW++){
				int black = 0; 
				for(int i=0; i<H; i++){
					for(int j=0; j<W; j++){
						if(c[i][j] != '#')continue;
						if((maskH & ( 1 << i) )!= 0 ||  (maskW & (1 << j) )!= 0 )continue;
						if(c[i][j] == '#')black++;
					}
				}
				if(black == K)ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {

	int a = 0;
	int b = 0;
	int c = 0;
	int count = 0;

	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {

		if (c % i == 0) {

			count++;

		}

	}

	cout << count << endl;

	return 0;

}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int a[200010] = {};
vector<int> subt;

int main() {
	cin >> n;
	forn(i) {
		cin >> a[i];
		subt.push_back(a[i] - i - 1);
	}
	sort(subt.begin(), subt.end());
	int ind = n / 2;
	ll ans = 0;
	forn(i)ans += abs(a[i] - i - 1 - subt[ind]);
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    bool exists[30] = {false};
    string s;
    cin >> s;
    rep(i, s.size()) {
      exists[s[i]-'a'] = true;
    }

    int ans = -1;
    rep(i, 'z'-'a'+1) {
      if(!exists[i]) {
        ans = i;
        break;
      }
    }

    if(ans == -1) {
      cout << "None" << endl;
    } else {
      printf("%c\n", 'a'+ans);
    }

    return 0;
}


Measured memory_bytes: 512
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) <= abs(x - b))
		print("A");
	else
		print("B");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

int n;
ll a[100000];
vector<int> vec[100000];

bool C(ll x){
	for(int i = 0;i < n;i++) vec[i].clear();
	int l = 0,r = 0;
	ll sum = 0;
	while(1){
		while(sum < x && r < 2 * n){
			sum += a[r++ % n];
		}
		if(sum < x) break;
		vec[l % n].push_back(r);
		sum -= a[l++ % n];
	}
	int pos = 0;
	bool flag = false;
	for(int i = 0;i < n;i++){
		pos = i;
		int j = 0;
		for(;j < 3;j++) {
			if(vec[pos % n].empty()) break;
			if(pos >= vec[pos % n][0]) break;
			pos = vec[pos % n][0];
			//if(x >= 213) cout << pos << endl;
		}
		//if(x >= 213) cout << i << " " << j << " " << pos << endl;
		if(j == 3 && pos <= i + n) {
			flag = true;
			//if(x >= 213) cout << " " << i << endl;
		}
	}
	return flag;
}

int main(){
	ll sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll low = 0,up = sum / 3;
	while(up - low > 1){
		ll mid = (low + up) / 2;
		//cout << mid << endl;
		if(C(mid)) low = mid;
		else up = mid;
	}
	cout << low << endl;
	return 0;
}

Measured memory_bytes: 9404
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();

		int[] pList = new int[m];
		int[] yList = new int[m];
		Map<Integer, Integer> yearTree = new TreeMap<Integer, Integer>();


		for (int i = 0; i < m; i++) {
			pList[i] = scanner.nextInt();
			yList[i] = scanner.nextInt();
			yearTree.put(yList[i], pList[i]);
		}

		int[] pCounter = new int[n];
		for (int yi : yearTree.keySet()) {
			yearTree.put(yi, ++pCounter[yearTree.get(yi)-1]);
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%06d%06d", pList[i], yearTree.get(yList[i])));
		}

	}

}

Measured memory_bytes: 161096
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
using namespace std;

void solve()	{
	string s;
	cin >> s;
	int ans=0;
	for(int i=0; i<3; )	{
		if(s[i]=='R')	{
			while(i<3 && s[i]=='R')	{ans++; i++;}
		}
		else {
			if(ans>0)	break;
			else i++;
		}
	}
	cout << ans << endl;
}

int main()	
{
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdbool.h>
//union find木(グループわけができる)
int par[100005];
int unifind(int n) {
	for (int i = 1; i <= n; i++) {
		par[i] = i;
	}
}
//木の根を求める
int unifind_root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = unifind_root(par[x]);
	}
}
//同じグループか判定
bool unifind_same(int x, int y) {
	return unifind_root(x) == unifind_root(y);
}
//グループ併合
int unifind_unite(int x, int y) {
	x = unifind_root(x);
	y = unifind_root(y);
	if (x == y) {
		return 0;
	}
	par[x] = y;
}
int main() {
	int p[100005] = {};
	int q[100005] = {};
	int result = 0;
	int xy[100005][2] = {};
	int m;
	int n;
	scanf("%d%d", &n,&m);
  	unifind(n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p[i]);
		q[p[i]] = i;
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &xy[i][0], &xy[i][1]);
		 unifind_unite(xy[i][0] , xy[i][1]);
	}
	for (int i = 1; i <= n; i++) {
		if (unifind_same(i, q[i])) {
			result++;
		}
	}
	printf("%d", result);
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main() {
  ll n;
  cin>>n;
  rep(i,0,n){
    ll a,b;
    cin>>a>>b;
    d[a]++;
    d[b+1]--;
  }
  rep(i,1,100050){
    d[i]+=d[i-1];
  }
  ll ans = 0;
  rep(i,0,100100){
    ans+=d[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int p[50], q[50];
    for(int i=0;i<N;i++)
        cin >> p[i];
    
    for(int i=0;i<N;i++)
        q[i] = i+1;
    int count = 0;
    for(int i=0;i<N;i++){
        if(p[i] != q[i])
            count++;
    }
        
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if (b-a==c-b) cout << "YES";
  else cout <<"NO";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    D=divisors(sum(A))
    def check(d):
        P=[]
        N=[]
        for i in range(n):
            r=A[i]%d
            if(not r): continue
            P.append(d-r)
        P.sort()
        l=len(P)
        N=[d-p for p in P]
        N.reverse()
        PS=[0]*(l+1)
        NS=[0]*(l+1)
        for i in range(l):
            PS[i+1]=PS[i]+P[i]
            NS[i+1]=NS[i]+N[i]
        NS.reverse()
        res=INF
        for i in range(l):
            res=min(res,max(PS[i],NS[i+1]))
        return res<=k
    ans=1
    for d in D:
        if(check(d)): ans=d
    print(ans)
resolve()

Measured memory_bytes: 43356
/*
AIZU ONLINE JUDGE ??????
Bubble Sort ???????????????
--------------------------------------------------------*/


/*????????????????????????????????????*/
#include<iostream>
using namespace std;


/*???????????????????????¢??°?????????*/
int bubblesort(int A[],int N){
	
	/*?????°??????*/
	int count=0;//??????????????°??¨?????°????????????
	bool flag=1;//???????????¨bool???????????????
	
	/*??????????????????*/
	for(int i=0;flag;i++){
	
		/*?????????????????????????????????*/
		flag=0;
		
		/*?????????*/
		for(int j=N-1;j>=i+1;j--){
		
			if(A[j]<A[j-1]){
			
				swap(A[j],A[j-1]);
				flag=1;
				count++;//??????A[j]<A[j-1]?????£?????´??????A[j]??¨A[j-1]??????????????????????????????????????¨??????????????°???????¢???????
				
			}
		}
		
		
	}
	
	return count;//????????????????????°?????????
	
}



/*???????????¢??°*/
int main(){

	/*?????°?????????*/
	int A[100],N,count;
	cin>>N;
	for(int i=0;i<N;i++){cin>>A[i];}//???????????°????????\???
	
	/*?????????*/
	count=bubblesort(A,N);
	
	/*??????*/
	for(int i=0;i<N;i++){
	
		if(i){cout<<" ";}
		cout<<A[i];
		
	}
	
	cout<<"\n";
	cout<<count<<"\n";
	
	return 0;//??????

}

Measured memory_bytes: 1164
#double underscore makes a class variable or a class method private
mod = 1000000007
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
c=0
for i, j in zip(si(),si()):
    c+=(i==j)
print(c)

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

#define ll long long
#define ld long double
#define pr pair<ll,ll>
#define loop(i,n) for(ll i=0 ; i<n ; ++i)
#define rep(i,x,n) for(ll i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
const ll N=2e2 + 5;
int a,b,c,n;
int ans,as,bs;
string str;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "rt" , stdin);
    // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
    cin>>n;
    bool ba=true;
    loop(i,n){
        cin>>str;
        loop(j,str.size()-1){
            if(str[j]=='A' && str[j+1]=='B')ans++;
        }
        if(str[0]=='B')bs++;
        if(str[str.size()-1]=='A')as++;
        if(str[0]=='B' && str[str.size()-1]!='A'){
            ba=false;
        }
        if(str[0]!='B' && str[str.size()-1]=='A'){
            ba=false;
        }
    }
    if(ba && bs && as)ans--;
    cout<<ans+min(as,bs)<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Pair>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		edges = new ArrayList[n];
		for(int i=0;i<n;++i) edges[i] = new ArrayList<>();
		for(int i=0;i<n;++i) {
			int a = sc.nextInt();
			for(int j=0;j<a;++j) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt();
			edges[i].add(new Pair(x,y));
			}
		}
		
		int ans = 0;
		for(int i=0;i<(1<<n);++i) {
			boolean found = true;
			for(int j=0;j<n;++j) {
				if((i&(1<<j))!=0) {
					for(Pair p : edges[j]) {
						if(p.y != ((i>>p.x)&1)) found = false;
					}
				}
			}
			if(found) ans = Math.max(ans, Integer.bitCount(i));
			
		}
		out.print(ans);
		out.close();
	}
	static class Pair{
		int x;
		int y;
		Pair(int x,int y){
			this.x = x;
			this.y = y;
		}
	}
	
}

Measured memory_bytes: 30420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int power(int a,int b){
    if(b==0)return 1;
    int res=1;
    while(b){
        if(b%2)res*=a;
        a=a*a;
        b/=2;
    }
    return res;
}

int main(){
    int n,k;cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        int a=ceil((log(k*1.0/i)/log(2)));
        if(i>=k)a=0;
      //  else if(i>k)a=0;
      //  cout<<a<<endl;
        ans+=1.0/power(2,a);
    }
    cout.precision(18);
    cout<<ans*1.0/n;
}

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

typedef long long LL;
const int N = 100005;

int head[N], tot, n;
struct edge { int to, nxt, cost; } e[N << 1];
void link(int x, int y, int z) {
	e[++tot] = (edge) {y, head[x], z}, head[x] = tot;
	e[++tot] = (edge) {x, head[y], z}, head[y] = tot;
}

bool qaq = 0;
LL ans; int qwq = -0x3f3f3f3f, centroid;
int dfs(int x, int f = 0) {
	int sum = 1, max = 0;
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f) {
		int ret = dfs(e[i].to, x); sum += ret, max = std::max(max, ret);
		ans += std::min(ret, n - ret) * 2LL * e[i].cost;
		if (ret << 1 == n) qaq = 1, qwq = -e[i].cost;
	}
	max = std::max(max, n - sum);
	if (max << 1 < n) centroid = x;
	return sum;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, x, y, z; i < n; ++i)
		std::cin >> x >> y >> z, link(x, y, z);
	dfs(1);
	if (!qaq)
		for (int i = head[centroid]; i; i = e[i].nxt)
			qwq = std::max(qwq, -e[i].cost);
	std::cout << ans + qwq << '\n';
	return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=1, tmp1=0, tmp2=0;
queue<ll> Q;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        a--;
        a /= 2;
        Q.push(a);
        //cout << a << " ";
    }
    while(!Q.empty()) {
        ll num = Q.front();
        //cout << tmp1 << " " << num << " " << tmp2 << endl;
        if(tmp1-num>tmp2) {
            ans *= (tmp1+1-tmp2);
            ans %= MOD;
            //cout << (tmp1+1-tmp2) << endl;
            tmp2++;
        }
        else {
            tmp1++;
            Q.pop();
        }
    }
    tmp2 = N-tmp2;
    while(tmp2>0) {
        ans *= tmp2;
        ans %= MOD;
        tmp2--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4024
# coding: utf-8
# Your code here!
n=int(input())
S=list(map(int,input().split()))
S1=set(S)


q=int(input())
T=list(map(int,input().split()))
count=0

for j in range(q):
    if T[j] in S1:
        count+=1
    
        
print(count)


Measured memory_bytes: 6556
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "?": break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        print(a // b)
    





Measured memory_bytes: 5596
S_prime = input()
T = input()

S_prime_r = list(S_prime[::-1])
T_r = list(T[::-1])

for i in range(len(S_prime)-len(T)+1):
    for j in range(len(T)):
        if T_r[j] != S_prime_r[i+j] and S_prime_r[i+j] != "?":
            break
    else:
        for j in range(len(T)):
            S_prime_r[i+j] = T_r[j]
        for k in range(len(S_prime)):
            if S_prime_r[k] == "?":
                S_prime_r[k] = "a"
        print("".join(S_prime_r[::-1]))
        break
        
else:
    print("UNRESTORABLE")

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

int main(){
    int n,r=0,b=0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < n;i ++){
        if(s[i]=='R') r ++;
        else if(s[i]=='B') b ++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int mp[128];
bool dic[ 2 + 1 << 24 ];

int encode(const char s[])
{
   int ret = 1;
   for(int i=0; s[i] != '\0'; ++i){
      ret <<= 2;  // *= 4;
      ret += mp[ s[i] ];
   }
   return( ret );
}

int main()
{
   mp['C'] = 1,
   mp['G'] = 2,
   mp['T'] = 3;
   int N;
   char com[8], str[16];
   scanf("%d", &N);

   while(N--){
      scanf("%s %s", com, str);
      if(com[0] == 'i')
         dic[ encode(str) ] = true;
      else
         puts( dic[ encode(str) ] ? "yes": "no" );
   }
}



Measured memory_bytes: 3888
import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
a=0
b=0
left=0
right=0
res=0
while(left<N):
    while(right<N and a+A[right]==b^A[right]):
        a+=A[right]
        b^=A[right]
        right+=1
    res+=(right-left)
    a-=A[left]
    b^=A[left]
    left+=1
print(res)


Measured memory_bytes: 72396
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N);
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  vector<int> B(N,-1);
  queue<int> Q;
  B[0]=0;
  Q.push(0);
  while(!Q.empty()){
    int I=Q.front();
    Q.pop();
    for(int i:A[I])
      if(B[i]==-1){
        B[i]=(B[I]+1)%2;
        Q.push(i);
      }
  }
  int n=0,m=0;
  for(int i=0;i<N;i++){
    if(B[i]==0)n++;
    else m++;
  }
  int a,b,c;
  bool bo=false;
  if(n>=(N+2)/3 && m>=(N+1)/3)a=1,b=2,c=3,n=(N+2)/3,m=(N+1)/3,bo=true;
  else if(n>=(N+1)/3 && m>=(N+2)/3)a=2,b=1,c=3,n=(N+1)/3,m=(N+2)/3,bo=true;
  if(bo){
    for(int i=0;i<N;i++){
      if(B[i]==0){
        if(n>0){
          cout<<a;
          n--,a+=3;
        }else{
          cout<<c;
          c+=3;
        }
      }else{
        if(m>0){
          cout<<b;
          m--,b+=3;
        }else{
          cout<<c;
          c+=3;
        }
      }
      if(i==N-1)cout<<endl;
      else cout<<' ';
    }
    return 0;
  }
  vector<int> ans(N);
  if(n<=N/3){
    int a=1,b=2,c=3;
    for(int i=0;i<N;i++)
      if(B[i]==0){
        ans[i]=c;
        c+=3;
      }
    for(int i=0;i<N;i++)
      if(B[i]==1){
        if(a<=N){
          ans[i]=a;
          a+=3;
        }else if(b<=N){
          ans[i]=b;
          b+=3;
        }else{
          ans[i]=c;
          c+=3;
        }
      }
  }else{
    int a=1,b=2,c=3;
    for(int i=0;i<N;i++)
      if(B[i]==1){
        ans[i]=c;
        c+=3;
      }
    for(int i=0;i<N;i++)
      if(B[i]==0){
        if(a<=N){
          ans[i]=a;
          a+=3;
        }else if(b<=N){
          ans[i]=b;
          b+=3;
        }else{
          ans[i]=c;
          c+=3;
        }
      }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i];
    if(i==N-1)cout<<endl;
    else cout<<' ';
  }
}

Measured memory_bytes: 18536
N = int(input())
S = input()

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

li = []
sli=list(S)
for i in range(len(S)):
    if(alpha2num(sli[i])+N<=26):
        li.append(alpha2num(sli[i])+N)
    if(alpha2num(sli[i])+N>26):
        li.append(alpha2num(sli[i])+N-26)

ans= []
for i in li:
    ans.append(num2alpha(i))

ansstr= ''
for x in ans:
    ansstr += x
print(ansstr)

Measured memory_bytes: 43228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int h,w,k; cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<int> prev(h,0);
    vector<int> now(h,0);

    ll ans = LLONG_MAX;

    // 横にいくつわるかのパターン
    for (int bit = 0; bit < (1<<h-1); bit++) {
        rep(i, h) {
            prev[i] = 0;
            now[i] = 0;
        }
        ll tmpans = 0;
        for (int div = 0; div < h; div++) {
            if (bit & (1<<div)) tmpans++;
        }
        // 横にみていく
        bool ng_div = false;
        rep(j, w) {
            int i = 0;
            for (int div = 0; div < h; div++) {
                now[i] += s[div][j] - '0';
                if (bit & (1<<div)) i++;
            }
            bool div_flag = false;
            rep(c, i+1) {
                if(now[c] > k) {
                    ng_div = true;
                    break;
                }
                if(now[c]+prev[c] > k) {
                    div_flag = true;
                    break;
                }
            }
            if(ng_div) break;
            if(div_flag) {
                tmpans++;
                rep(c, h) {
                    prev[c] = now[c];
                    now[c] = 0;
                }
            } else {
                rep(c, h) {
                    prev[c] += now[c];
                    now[c] = 0;
                }
            }
        }

        if(!ng_div) {
            chmin(ans, tmpans);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
X, Y = map(int, input().split())

a = (4 * X - Y) / 2
b = (Y - 2 * X) / 2

if (0 <= a) and (0 <= b):
  if (a % 1 == 0) and (b % 1 == 0):
    print("Yes")
    quit()
    
print("No")

Measured memory_bytes: 9244
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n, j, i;
  cin>>n;
  int a[n];
  int b[n];
  for(i = 0; i<n; i++)
  {
      cin>>a[i];
      b[a[i]-1] = i+1;
  }
  for(i = 0; i<n; i++)
  {
      cout<<b[i]<<" ";
  }

return 0;
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		int inCnt = 0;
		while ((s = stdIn.readLine()) != null) {
			String[] se = s.split(" ");
			int in1 = Integer.valueOf(se[0]);
			int in2 = Integer.valueOf(se[1]);
			// int in3 = Integer.valueOf(se[2]);
			if (in1 == 0 && in2 == 0)
				break;
			doMain(++inCnt, in1, in2);
		}
		System.exit(0);
	}

	private static void doMain(int inCnt, int in1, int in2) {
		int x = in1 / in2;
		int y = in1 % in2;
		double z = (double) in1 / in2;
		System.out.print(x + " " + y + " ");
		System.out.printf("%f\n", z);

	}
}

Measured memory_bytes: 24696
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, K, i, p[200001], sum=0, sum_max=0, maxi=0;
    double a, ans=0;

    cin >> N >> K;

    for(i=1; i<=N; i++){
        cin >> p[i];
    }

    // sumの初期化
    for(i=1; i<=K; i++){
        sum += p[i];
        if(sum>sum_max){
            sum_max = sum;
            maxi = i;
        }
    }

    if(K<N){
        for(i=K+1; i<=N; i++){
            sum -= p[i-K];
            sum += p[i];
            if(sum>sum_max){
                sum_max = sum;
                maxi = i-K+1;
            }
        }
    }
    else{
        maxi = 1;
    }

    for(i=maxi; i<=maxi+K-1; i++){
        a = (double)(1+p[i])/2;
        ans += a;
    }

    cout << setprecision(20) << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, *d = (int(x) for x in sys.stdin.read().split())
    print(len(set(d)))


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int top,S[1000];

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	
	return S[top+1];
}



int main(void){

	int a,b;
	char s[100];
	top = 0;
	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}else{
			push(atoi(s));
		}
		
	}
	
	printf("%d\n",pop());
	return 0;

}





Measured memory_bytes: 2040
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long

	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'


	// Debug //

	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


	using namespace std;
	

	
	int main()
	{

	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);cout.tie(NULL);
		

		
		
		ll n;
		ll i,j;
		cin>>n;
		ll a[n];
		ll lcs[n];
		rep(i,0,n)
		{
			cin>>a[i];
			lcs[i]=1;
		}
		for(i=n-2;i>=0;i--)
		{
			if(a[i]>=a[i+1])
			{
				lcs[i]=1+lcs[i+1];
			}

		}
		ll ans=0;
		for(i=0;i<n;i++)
		{
			ans=max(ans,lcs[i]);
		}
		cout<<ans-1<<endl;

		return 0;
		}
	











Measured memory_bytes: 1792
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<"\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  set<string> SET;
  for (int i = 0; i < N; i++)
  {
    string str;
     cin>>str;
     SET.insert(str);
  }
  cout<<SET.size()<<endl;

   
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 19244
n,m=map(int,input().split())
lst=[]
for i in range(m):
  p,y=map(int,input().split())
  lst.append([i,p,y])
lst.sort(key=lambda x:(x[1],x[2]))
j=1
Lst=[]
for i in range(m):
  if lst[i][1]==lst[min(m-1,i+1)][1]:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j+=1
    Lst.append([lst[i][0],u])
  else:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j-=j-1
    Lst.append([lst[i][0],u])
Lst.sort(key=lambda x:x[0])
for k in range(m):
  print(Lst[k][1])
  


Measured memory_bytes: 41376
#include<stdio.h>
#define N 10000

int linerSearch(int [],int,int);
int main(){
    int A[N],i,n,q,key,x,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        x= linerSearch(A,n,key);
        if(x!=n+1) count++;
    }
    printf("%d\n",count);
    
    return 0;
}
 
    
  int  linerSearch(int A[],int n, int key){
        int i=0;
        A[n]=key;
        while(A[i]!=key){
            i++;
        }
        if(i==n) return n+1;
        else return i;
    }


Measured memory_bytes: 2144
N = int(input())
As = list(map(int, input().split()))

count = 10 ** 9
for i in range(N):
  tmp = As[i]
  tmp_count = 0
  while tmp % 2 == 0:
    tmp = tmp // 2
    tmp_count += 1
  count = min(count, tmp_count)
    
print(count)
    



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  char s='A', k;
  int h, w, c=0;
  cin >> h >> w;
  string a[h][w];
  rep(i,0,h){
    rep(j,0,w) cin >> a[i][j];
  }
  
  rep(i,0,h){
    rep(j,0,w){
      if(a[i][j]=="snuke"){
        k=s+j;
        cout << k << i+1 << endl;
        c++;
        break;
      }
    }
    if(c==1) break;
  }
  
  
  return 0;
}


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

std::string get_kth_substring(std::string s, int k);
std::set<std::string> extract_substrings_less_than_k(std::string s, int k);

int main()
{
    std::string s;
    int K;

    std::cin >> s >> K;
    std::cout << get_kth_substring(s, K) << std::endl;

    return 0;
}

std::string get_kth_substring(std::string s, int k)
{
    auto substrs = extract_substrings_less_than_k(s, k);
    std::string kth_substr;

    for (auto substr : substrs)
    {
        kth_substr = substr;

        static int count = 0;
        if (++count == k)
        {
            break;
        }
    }

    return kth_substr;
}

std::set<std::string> extract_substrings_less_than_k(std::string s, int k)
{
    std::set<std::string> substrs;
    int len = s.length();

    for (int i = 0; i < len; i++)
    {
        std::string substr;
        for (int j = 0; j < k; j++)
        {
            if (i + j == len)
            {
                break;
            }

            substr += s[i + j];
            substrs.emplace(substr);
        }
    }

    return substrs;
}

Measured memory_bytes: 1664
#include <stdio.h>
#define MAX 100

int count = 0;

void print_array(int *A, int N) {
  int i;
  for(i = 0; i < N - 1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);
}

void bubbleSort(int *A, int N) {
  int i = 0, j, v, frag = 1;
  while(frag) {
    frag = 0;
    for(j = N - 1; j >= i + 1; j--) {
      if(A[j] < A[j-1]) {
	v = A[j];
	A[j] = A[j-1];
	A[j-1] = v;
	frag = 1;
	count++;
      }
    }
    i++;
  }
}

int main() {
  int n, i, a[MAX];
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  bubbleSort(a, n);
  print_array(a, n);
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 1976
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    h = list(map(int, input().split()))
    if k>=n:
        print(0)
    else:
        h.sort()
        res = 0
        for i in h[:n-k]:
            res += i
        print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 80724
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
  using namespace std;
  vector<int> inp(3);
  for(auto& i: inp) {
    cin >> i;
  }
  sort(inp.begin(), inp.end());

  int N = inp[2] - inp[1];
  int M = inp[1] - inp[0];
  //a > b > cとしたとき
  // N = a - b
  // M = b - c
  //一回の操作で、
  //1.を行うと、 Nが1へる
  //2.を行うと、 Mが2へる
  //よって操作の回数は、 N + (M + 1) / 2 回
  //ただし、M % 2 > 0のとき、最後に1.をもう一度行う必要がある
  //従って、回数は以下の通りになる
  cout << N + (M + 1) / 2 + M % 2 << endl;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110, M = 1010, INF = 0x3f3f3f3f;

int n, m;
int g[N][N];
struct Edge
{
	int a, b, c;
}e[M];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			if (i == j) g[i][j] = 0;
			else g[i][j] = INF;
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b, c;
		cin >> a >> b >> c;
		e[i] = {a, b, c};
		g[a][b] = g[b][a] = c;
	}
	
	for (int k = 1; k <= n; k ++ )
		for (int i = 1; i <= n; i ++ )
			for (int j = 1; j <= n; j ++ )
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
				
	int res = 0;
	for (int i = 0; i < m; i ++ )
	{
		int a = e[i].a, b = e[i].b, c = e[i].c;
		if (c != g[a][b]) res ++ ;
	}
		
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

using namespace std;

inline int gi()
{
    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 * 10 + c - '0';
        c = getchar();
    }
    return f * x;
}

struct Node
{
	int id, sum;
	string s;
} q[103];
int n, p;

inline bool cmp(Node x, Node y)
{
	if (x.s != y.s) return x.s < y.s;
	else return x.sum > y.sum;
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; i++)
	{
		cin >> q[i].s;
		q[i].sum = gi();
		q[i].id = i;
	}
	sort(q + 1, q + 1 + n, cmp);
	for (int i = 1; i <= n; i++)
	{
		printf("%d\n", q[i].id);
	} 
	return 0;
}

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
ans=[0]*n
for i in range(m):
  a,b=list(map(int, input().split()))
  a,b=a-1,b-1
  ans[a],ans[b]=ans[a]+1,ans[b]+1
for i in range(n):
  print(ans[i])


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

int main()
{
    int a , b , c ;
    cin >> a >> b >> c ;
    cout << a <<" "<< b <<" "<< 3*c-a-b <<" "<< endl ;
    cout << 4*c-2*a-b <<" "<< c <<" "<< 2*a+b-2*c <<" "<< endl ;
    cout << a+b-c <<" "<< 2*c-b <<" "<< 2*c-a <<" "<< endl ;
    return 0 ;
}

Measured memory_bytes: 256