akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  std::vector<long long> sum(N + 1);
  std::vector<long long> pref(N + 1), suf(N + 1);
  for (int i: range(0, N)) {
    sum[i + 1] = sum[i] + A[i];
    pref[i + 1] = pref[i] + std::max(A[i], 0);
    suf[i + 1] = suf[i] + std::max(A[N - i - 1], 0);
  }
  long long ans = 0;
  for (int i: range(0, N - K + 1)) {
    chmax(ans, pref[i] + suf[N - (i + K)] + std::max((sum[i + K] - sum[i]), 0ll));
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2944
#include <cstdio>
#include <bitset>

#define R register
#define maxn 5010
int a[maxn], b[maxn], ans, K;
std::bitset<maxn> f[20];
void solve(R int o, R int l, R int r)
{
	if (l > r) return ;
//	printf("%d %d %d\n", o, l, r);
	if (l == r)
	{
		R bool flag = 1;
		for (R int i = K - b[l]; flag && i < K; ++i)
		{
//			printf("%d\n", i);
			if (f[o][i]) flag = 0;
		}
		ans += flag;
		return ;
	}
	R int mid = l + r >> 1;
	f[o + 1] = f[o];
	for (R int i = l; i <= mid; ++i)
		f[o + 1] |= f[o + 1] << b[i];
	solve(o + 1, mid + 1, r);

	f[o + 1] = f[o];
	for (R int i = mid + 1; i <= r; ++i)
		f[o + 1] |= f[o + 1] << b[i];
	solve(o + 1, l, mid);
}
int main()
{
	R int n, m = 0; scanf("%d%d", &n, &K);
	for (R int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		a[i] < K ? b[++m] = a[i] : 0;
	}
	f[1][0] = 1; solve(1, 1, m);
	printf("%d\n", ans);
	return 0;
}
/*
5 5
1 1 1 1 1
*/

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

using namespace std;

string str;

void receiveInput(){
  cin >> str;
}

bool solve(){
  for(int i = 0; i < str.length(); i++){
    if(str[i] == 'C'){
      for(int j = i + 1; j < str.length(); j++){
        if(str[j] == 'F'){
          return true;
        }
      }
    }
  }
  return false;
}

int main(){
  receiveInput();
  if(solve()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void) {
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int t;
	cin >> t;
	cout << a[t - 1] << endl;
	return 0;
}

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

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

	unsigned long long int res = 0;
	int m;
	long long int d,c;
	long long int len = 0;
	vector <int> v;

	cin >> m;

	for(int i=0;i<m;i++)
	{
		cin >> d >> c;
		int now = d;
		while(c>0)
		{
			if(c%2==1)
			{
				v.push_back(now);
			}
			res += (c/2);
			now+=now;
			if(now>=10)
			{
				res += c/2;
				now = (now/10) + (now%10);
			}
			c/=2;
		}
	}

	if(v.size()>=2)
	{
		int now = v[0];
		for(int i=1;i<v.size();i++)
		{
			now += v[i];
			res++;
			if(now>=10)
			{
				res += 1;
				now = (now/10) + (now%10);
			}
		}
	}

	cout << res << '\n';

	return 0;
}

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

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    vector<int> vect;

    for(int i = 0 ; i < N ; i++)
    {
    	int n;
    	cin >> n;
    	vect.push_back(n);
    }

    int res = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	for(int j = i+1 ; j < N ; j++)
    	{
    		for(int k = j+1 ; k < N ; k++)
    		{
    			if(vect[i] != vect[j] && vect[i] != vect[k] && vect[j] != vect[k])
    			{
    				vector<int> ttt;

    				ttt.push_back(vect[i]);
    				ttt.push_back(vect[j]);
    				ttt.push_back(vect[k]);

    				sort(ttt.begin(), ttt.end());

    				if(ttt[0] + ttt[1] > ttt[2])res++;
    			}
    		}
    	}
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	string s; cin >> s;
	cout << (s == "RRR" ? 3 : s == "RRS" || s == "SRR" ? 2 : s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR" ? 1 : 0) << '\n';
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

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


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
string a[11];
signed main() {
    cin >> H >> W;
    rep(i, H) { cin >> a[i]; }
    vpint ps;
    rep(i, H)rep(j, W) { if (a[i][j] == '#') { ps.push_back({i, j}); }}
    for (int i = 1; i < ps.size(); i++) {
        if (ps[i].first == ps[i - 1].first) {
            if (ps[i].second != ps[i - 1].second + 1) {
                cout << "Impossible" << endl;
                return 0;
            }
        } else {
            if (ps[i].second != ps[i - 1].second) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
}


Measured memory_bytes: 256
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
count=0
for i in range(n,2*n):
	count+=N[i]
res=x=0
for i in range(3*n-2,-1,-2):
	if x==n:
		break
	res+=N[i]
	x+=1
print max(res,count)

Measured memory_bytes: 72016
import Data.List (foldl')

parse1 :: IO Int
parse1 = getLine >>= return . read

parse2 :: IO [Double]
parse2 = getLine >>= return . fmap read . words

parse3 :: IO [Double]
parse3 = getLine >>= return . fmap read . words

type T = Double
type A = Double
type H = Double

calc :: T -> [H] -> [Double]
calc t hs = map calc' hs
  where calc' h = t - 0.006 * h

indexed :: [a] -> [(Int, a)]
indexed as = go 1 as
  where go i (x:xs) = (i, x) : go (i + 1) xs
        go _ _ = []

choose :: T -> A -> [H] -> Int
choose t a hs = 
  let ts = indexed $ calc t hs
  in fst $ foldr1 choose' ts
  where choose' :: (Int, Double) -> (Int, Double) -> (Int, Double)
        choose' (n, d) (n', d') = if abs(a - d) < abs(a - d')
                                  then (n, d)
                                  else (n', d')

main = do
  n <- parse1
  [t, a] <- parse2
  hs <- parse3
  print $ choose t a hs


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
vector<ll>z_algorithm(string s){
  ll n = s.size();
  vector<ll>ret(n,0);
  ret[0] = n;
  ll p = 1,len = 0;
  while(p < n){
    while(p+len < n && s[len] == s[p+len])len++;
    ret[p] = len;
    if(len == 0){p++; continue;}
    ll k = 1;
    while(p+k < n && k+ret[k] < len)ret[p+k] = ret[k], k++;
    p += k, len -= k;
  }
  return ret;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  string s,t;cin>>s>>t;
  auto p=s,q=t;
  ll n=t.size();
  while(p.size()<=q.size())p+=s;
  while(p.size()>=q.size())q+=t;
  auto v=z_algorithm(q+q+q+p+p+p);
  //debug(v,v.size());
  //cout<<q+q+q+p+p+p<<endl;
  rep(i,3*q.size(),v.size()){
    //cout<<v[i]<<endl;
    if(v[i]>=2*p.size()){
      judge=false;
    }
    chmax(res,v[i]/n);
  }
  //debug(v,v.size());
  ans(!judge,-1,res);
  return 0;
}

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

int main(){
    int n, h;
    cin >> n >> h;
    int A[n], B[n];
    for(int i = 0; i < n; i++){
        cin >> A[i] >> B[i];
    }
    sort(A, A + n, greater<int>());
    sort(B, B + n, greater<int>());
    
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(B[i] > A[0]){
            h -= B[i];
            cnt++;
        }
        if(h <= 0){
            cout << cnt << endl;
            return 0;
        }
    }
    cnt += (h + A[0] - 1) / A[0];
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 1; i + 1 < n; i++) {
    int b[] = {a[i - 1], a[i], a[i + 1]};
    sort(b, b + 3);
    if (b[1] == a[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#define LL long long

using namespace std;

int main()
{
	
	int n,m;
	cin>>n>>m;
	priority_queue <int> q;
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		q.push(x); 
	}
	for(int i=1;i<=m;i++){
		x=q.top() ;
		q.pop() ;
		q.push(x/2);
		if(q.top() ==0) break; 
	}
	LL sum=0;
	while(!q.empty() ){
		sum+=q.top() ;
		q.pop() ;
	}
	cout<<sum<<endl;
	return 0;
 } 

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

int main(){
    string S;
    cin >> S;
    string sub;
    int min = 999;
    for (int i = 0; i < S.length() - 2; i++){
        sub = S.substr(i, 3);
        int num = atoi(sub.c_str());
        if (abs(num - 753) < min){
            min = abs(num - 753);
        } 
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >t(n,0),x(n,0),y(n,0);
  for(int i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
  int startx=0,starty=0;
  int pos=1;
  int dist;
  int times;
  for(int i=0;i<n;i++){
    //  cout<<startx<<' '<<starty<<'\n';
        if(i!=0)times=t[i]-t[i-1];
        else times=t[i];
		dist = abs(x[i]-startx)+abs(y[i]-starty);
    	if(dist<=times && times%2==dist%2){startx=x[i];starty=y[i];continue;}
    	else {pos=0;break;}
  }
  if(pos==0)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 4512
/*
输入 N 个数字 A1, A2, . . . , AN，
输入 K。 如果对于所有包含 Ai，
且和大于等于 K 的集合，
去掉 Ai 后和还大于等于 K，
那么 Ai 就是可有可无 的。 
问有多少个元素是可有可无的。
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n, k, a[maxn], dp[maxn][maxn];
bool check(int x) {
	memset(dp, 0, sizeof dp);
	if(x == 1) {
		dp[2][0] = 1; dp[2][a[2]] = 1;
		for (int i = 3; i <= n; ++i) 
			for (int j = 0; j <= k; ++j) {
				dp[i][j] = dp[i - 1][j];
				if(j >= a[i]) dp[i][j] |= dp[i - 1][j - a[i]]; 
			}
	}
	else {
		dp[1][0] = dp[1][a[1]] = 1;
		for (int i = 2; i <= n; ++i) {
			if(x == i) {
				for (int j = 0; j <= k; ++j) dp[i][j] = dp[i - 1][j]; continue;
			}
			for (int j = 0; j <= k; ++j) {
				dp[i][j] = dp[i - 1][j];
				if(j >= a[i]) dp[i][j] |= dp[i - 1][j - a[i]];
			}
		}
	}
	for (int i = k - a[x]; i < k; ++i) if(dp[n][i]) return 1;
	return 0; 
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]); a[i] = min(a[i], k);
	}
	if(n == 1) {
		if(a[1] >= k) puts("0");
		else puts("1"); return 0;
	}
	sort(a + 1, a + n + 1);
	int l = 0, r = n + 1, ans = 0;
	while(l + 1 < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 98176
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

typedef vector<vector<bool> > Matrix;
typedef vector<bool> vec;


Matrix make_matrix(int n) {
  vec a(n, false);
  Matrix b(n, a);
  return b;
}

vec make_vec(int n) {
  vector<bool> v(n, false);
  return v;
}

Matrix multiply(Matrix a, Matrix b, int n) {
  Matrix c = b;
  bool t = false;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      for(int c = 0, r = 0; c < n; c++, r++) {
	t = t||(a[i][c]&&b[r][j]);
      }
      c[i][j] = t;
      t = false;
    }
  }
  return c;
}

vec multiply_vec(Matrix a, vec b, int n) {
  vec c = b;
  bool t = false;
  for(int i = 0; i < n; i++) {
    for(int c = 0, r = 0; c < n; c++, r++) {
      t = t||(a[i][c]&&b[r]);
    }
    c[i] = t;
    t = false;
  }
  return c;
}

Matrix m_power(Matrix a, int n, int m) {
  if(m == 1) return a;
  else if(m%2 != 0) return multiply(m_power(a, n, m-1), a, n);
  else {
    Matrix b = m_power(a, n, m/2);
    return multiply(b, b, n);
  }
}

int main() {
  int N, M, Z;
  while(true) {
    cin >> N >> M >> Z;
    if(!(N||M||Z)) break;
    int s, d;
    vector<pair<int, int> > edges(2*M);
    for(int i = 0; i < M; i++) {
      cin >> s >> d;
      edges[2*i] = make_pair(s, d);
      edges[2*i+1] = make_pair(d, s);
    }
    Matrix mat = make_matrix(2*M);
    vec v_0 = make_vec(2*M);
    for(int i = 0; i < 2*M; i++) {
      if(edges[i].first == 1) v_0[i] = true;
      for(int j = 0; j < 2*M; j++) {
	if(edges[j].first == edges[i].second && edges[j].second != edges[i].first)
	  mat[j][i] = true;
      }
    }
    vec v_f;
    if(Z > 1) v_f = multiply_vec(m_power(mat, 2*M, Z-1), v_0, 2*M);
    else v_f = v_0;
    bool result = false;
    for(int i = 0; i < 2*M; i++) {
      if(edges[i].second == N && v_f[i] == true) {
	result = true;
	break;
      }
    }
    if(result) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

				 
	
    
    
  

Measured memory_bytes: 3724
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long int N, A, B;
    cin >> N >> A >> B;
    cout << max(0LL, B * (N - 1) + A - (B + (N - 1) * A) + 1) << endl;


    return 0;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    vector<int> a(n+1);
    rep(i, 1, n+1) {
        cin>>a[i];
    }
    dump(a);

    vi ans(n+1);

    int cnt = 0;
    rrep(i, 1, n+1){
        int c = 0;
        for(int j=2*i; j<=n; j+=i){
            c += ans[j];
        }
        dump(i, c);
        ans[i] = (c+a[i])%2;
        if (ans[i]) cnt++;
    }
    dump(ans);
    cout << cnt << endl;
    rep(i, 1, n+1){
        if (ans[i]){
            cout << i << endl;
        }
    }

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if (S == "SUN"){
    cout << 7 << endl;
  }
  else if (S == "MON"){
    cout << 6 << endl;
  }
  else if (S == "TUE"){
    cout << 5 << endl;
  }
  else if (S == "WED"){
    cout << 4 << endl;
  }
  else if (S == "THU"){
    cout << 3 << endl;
  }
  else if (S == "FRI"){
    cout << 2 << endl;
  }
  else if (S == "SAT"){
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    n, k = map(int, readline().split())
    d = {int(i) for i in readline().split()}
    dq = deque()
    dq.append(0)
    cnd = []
    while len(dq)>0:
        v = dq.popleft()
        for i in range(10):
            if i in d:
                continue
            cnd.append(v*10+i)
            dq.append(v*10+i)
        if n <= dq[-1]:
            break

    ans = 0
    for i in cnd:
        if n <= i:
            print(i)
            break
if __name__ == '__main__':
    main()


Measured memory_bytes: 39792
#include <stdio.h>
using namespace std;

int main() {
  int a, b, c, tmp;
  scanf("%d %d %d", &a, &b, &c);
  tmp = a;
  a = b;
  b = tmp;
  tmp = a;
  a = c;
  c = tmp;
  printf("%d %d %d", a, b, c);
  return 0;
}

Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    cur = 0
    cnt = 0
    for _ in range(N):
        x, y = map(int, readline().split())
        if x == y:
            cur += 1
        else:
            cur = 0
        cnt = max(cnt, cur)

    if cnt >= 3:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61860
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int n = vals[0];
		int m = vals[1];


		//var to = new var[];
		//object[] to = new object[n + 1];
		var to = new List<List<int>>();

		for (int i = 0; i < n + 1; i++) {
			to.Add(new List<int>());
		}
		for (int i = 1; i < m+1; i++) {
			vals = parseAry(Console.ReadLine().Split(cs));
			to[vals[0]].Add(vals[1]);
		}

		int flg = 0;
			foreach (int a in to[1]) {
				foreach (int b in to[a]) {
					if (b == n) { flg = 1; break; }
				}
				
			}
			string re = "IMPOSSIBLE";
			if (flg == 1) { re="POSSIBLE";}

			Console.WriteLine(re);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 36296
function Main(input) {
  lines = input.split("\n")
  n = lines[0] * 1
  a = lines[1].split(' ').map(Number)
  ans = 0
  min = Math.abs(a[a.length-1])
  flgs = 0
  for (i=0; i<a.length;i++) {
    if (a[i] < 0) flgs++
    min = Math.min(Math.abs(a[i]), min)
    ans += a[i] >= 0 ? a[i] : a[i] * -1 
  }
  if (flgs % 2 == 0) {
    console.log(ans);  
  } else {
    console.log(ans-min*2);    
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;cin >> s;
    s[5]=' ';
    s[13]=' ';
    cout << s <<endl;
}

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



int main(){
    ll n; cin >> n;
    vl a(n);
    vl sum(n);
    ll s = 0;
    map<ll,ll> mp;
    rep(i,n){
        cin >> a[i];
        sum[i] = s + a[i];
        s = sum[i];
        mp[sum[i]]++;
    }
    s = 0;
    ll ans = 0;
    rep(i,n){
        ans += mp[s];
        mp[sum[i]]--;
        s = sum[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  a = 0
  ans = (A*a)//B - A*math.floor(a/B)
else:
  ans = (A*a)//B - A*math.floor(a/B)

if ans < (A*N)//B - A*math.floor(N/B):
  re = (A*N)//B - A*math.floor(N/B)
else:
  re = ans
print(re)



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

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

    int n, i, h, m;
    double hour, minute, answer;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d:%d", &h, &m);
        minute = m * 6;
        hour = h * 30 + minute / 12;
        answer = fabs(minute - hour);
        
        if (answer > 180) {
            answer = 360 - answer;
        }
        
        if (answer < 30) {
            printf("alert\n");
        } else if (answer < 90) {
            printf("warning\n");
        } else {
            printf("safe\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int a,b;
    cin >>a>>b;
    cout <<((a-1)+(a<=b));

    return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  bool mm1 = false;
  bool mm2 = false;
  if (S[0] == '0' && 1 <= S[1] - '0' && S[1] - '0' <= 9)
    mm1 = true;
  else if (S[0] == '1' && 0 <= S[1] - '0' && S[1] - '0' <= 2)
    mm1 = true;
  if (S[2] == '0' && 1 <= S[3] - '0' && S[3] - '0' <= 9)
    mm2 = true;
  else if (S[2] == '1' && 0 <= S[3] - '0' && S[3] - '0' <= 2)
    mm2 = true;
  if (mm1 && mm2)
    cout << "AMBIGUOUS" << endl;
  else if (mm1)
    cout << "MMYY" << endl;
  else if (mm2)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
// A - Dividing a String
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int n = s.size();
	vector<vector<int> > dp(n, vector<int>(2));
	dp[0][0] = 1;
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1);
		if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
		if (i - 2 >= 0)
			dp[i][1] = max(dp[i][1], dp[i - 2][0] + 1);
	}

	cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;

	return 0;
}


Measured memory_bytes: 11396
import java.util.Scanner;

public class Main {
    static final int COLORS = 3;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        long c = 1;
        int[] h = new int[COLORS];
        for(int i=0; i<COLORS; i++) {
            h[i] = -1;
        }
        for(int i=0; i<n; i++) {
            int temp = 0;
            boolean added = false;
            for(int j=0; j<COLORS; j++) {
                if(h[j] == a[i]-1) {
                    temp++;
                    if(!added) {
                        added = true;
                        h[j] = a[i];
                    }
                }
            }
            c *= temp;
            if(temp == 0) {
                break;
            }
            if(c%1000000007 > 1) {
                c = c % 1000000007;
            }
        }

        System.out.println(c % 1000000007);
    }
}


Measured memory_bytes: 52400
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
LL Q,H,S,D,N;
int b[4]={8,4,2,1};
int main(){
    LL a[4];
    for (int i=0; i<4; i++) {
        scanf("%lld",&a[i]);
    }
    cin>>N;
    LL m=a[3];
    int j=3;
    for (int i=2; i>=0; i--) {
        if (a[i]*(LL)b[i]<=m) {
            m=a[i]*(LL)b[i];
            j=i;
        }
    }
    LL u=a[2]*2;
    int h=2;
    for (int i=1; i>=0; i--) {
        if (a[i]*(LL)b[i]<=u) {
            u=a[i]*(LL)b[i];
            h=i;
        }
    }
    LL cost;
    if (j!=h) {
        cost=(N/2)*a[3]+(N%2)*a[h]*(LL)(b[h]/2);
    }
    else {
        cost=N*a[h]*(LL)(b[h]/2);
    }
    cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 256
numbers = list(map(int, input().split()))
n = numbers[0]

v = []

for i in range(n):
    numbers = list(map(int, input().split()))
    a = numbers[0]
    
    w = []
    
    for j in range(a):
        z = list(map(int, input().split()))
        w.append(z)
        
    v.append(w)
    
rezultat = 0

max_steps = 2 ** n

for i in range(max_steps):
    w = [-1] * n
    
    for j in range(n):
        if i >> j & 1:
            w[j] = 1
        else:
            w[j] = 0
    
    ok = 1
    
    for j in range(n):
        if ok == 0:
            break
        for a, b in v[j]:
            if w[j] == 1:
                a = a - 1
                if w[a] != b:
                    ok = 0
                    break
                
    if ok:
        rezultat = rezultat if rezultat > sum(w) else sum(w)
        
print(rezultat)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n-i+1 << "\n";
    return 0;
}


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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 2019;
const int MAXN = 1e6 + 26;

int cnt[mod];
int pw[MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    pw[0] = 1;
    int n = s.size();
    for (int i = 1; i < MAXN; ++i)
    {
        pw[i] = (pw[i - 1] * 10) % mod;
    }
    int ans = 0;
    int cur = 0;
    int ind = 0;
    cnt[0]++;
    for (auto el : s)
    {
        ++ind;
        cur *= 10;
        cur += (el - '0');
        cur %= mod;
        ans += cnt[(cur * pw[n - ind]) % mod];
        ++cnt[(cur * pw[n - ind]) % mod];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11608
import sys

eps = float(pow(10,-7))

while (True):
    L = map(float, sys.stdin.readline().split())
    if L:
        (a, b, c, d, e, f) = L
        x = (e * c - b * f) / (a * e - b * d)
        y = (a * f - d * c) / (a * e - b * d)

        if (abs(x) < eps):
            x = 0.0
        if (abs(y) < eps):
            y = 0.0

        print "{0:.3f} {1:.3f}".format(x, y)

    else:
        break

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

int main(){
  int N;
  cin >> N;
  int A[N-1];
  for(int i=0; i<N-1; i++){
    cin >> A[i];
  }
  int count[N];
  for(int i=0; i<N; i++){
    count[i] = 0;
  }
  for(int i=0; i<N-1; i++){
    count[A[i]-1]++;
  }
  for(int i=0; i<N; i++){
    cout << count[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  string c;
  cin>>a>>c>>b;
  char d=c[b-1];
  rep(i,a){
   if(c[i]!=d)
     c.replace(i,1,"*");
  }
  out(c);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N,0);
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        a--;
        A[a]=1;
    }

    vector<ll> dp(N+1,0);
    dp[0]=1;
    for(int i=0; i<N; i++){
        if(A[i]==0){
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(A[i+1]==0 && i+1<N){
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    cout << dp[N] << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());
	long long sad = 0;
	for (auto&& ai : a) sad += abs(ai - a[0]);
	long long minsad = sad;
	for (int i = 1; i < n; i++)
	{
		sad += (a[i] - a[i-1])*(2*i - n);
		minsad = min(minsad, sad);
	}
	cout << minsad << endl;
	return 0;
}


Measured memory_bytes: 1792
if __name__=="__main__":
    h = int(input())
    
    cnt = 0
    cnt_div = 0
    while h > 1:
        h = int(h/2)
        cnt += 2**cnt_div
        cnt_div += 1
        #print("cnt_div, h, cnt= {}, {}, {}".format(cnt_div, h, cnt))

    print(cnt + 2**cnt_div)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, a, ca = 1, c = 0;
  cin >> n;
  REP(i, n) {
    cin >> a;
    if (a != ca) {
      c++;
      continue;
    }
    ca++;
  }
  if (c == n) c = -1;
  cout << c << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    set<string> X;
    REP(i,N){
        string s;
        cin >> s;
        X.insert(s);
    }

    cout << X.size() << endl;
    return 0;
}


Measured memory_bytes: 19256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        String[] s = S.split("");
        String[] t = T.split("");
        String ans = "Yes";
        //Map<String, String> map = new HashMap<>();
        List<String> list = new ArrayList<>();
        for(int i=0; i<s.length; i++) {
            if(s[i].equals(t[i])) {
                continue;
            }else {
                if(list.contains(t[i]) || list.contains(s[i])) {
                    ans = "No";
                    break;
                }else {
                    S = S.replaceAll(t[i], "#");
                    S = S.replaceAll(s[i], t[i]);
                    S = S.replaceAll("#", s[i]);
                    s = S.split("");
                    list.add(t[i]);
                }
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 184580
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e5 + 5;

int i,n,triangle[50];

void solve(){
    cin>>n;
    if(n==1){
        cout<<0;
        return;
    }
    map<int,int> freq;
    while (n % 2 == 0)  
    {  
        freq[2]++;
        n = n/2;  
    } 
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
            freq[i]++;
            n = n/i;  
        }  
    }
    if (n > 2)  
        freq[n]++;
    for(i=1;i<=48;++i){
        triangle[i]=i*(i+1)/2;
    }
    int ans=0;
    for(auto j:freq){
        for(i=1;i<=48;++i){
            if(j.s<triangle[i]){
                ans+=i-1;
                break;
            }
        }
    }
    cout<<ans;
}

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


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

int foo(char t){
	int a = 0;//cout<<t<<endl;
	switch(t){
		case 'm': a = 1000;break;
		case 'c': a = 100; break;
		case 'x': a = 10;  break;
		case 'i': a = 1;   break;
	}
	return a;
}


int main(){
	int n, si, si2, temp, sum;
	string str, str2;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>str>>str2;
		si = str.size(); si2 = str2.size();
		sum = 0;//	cout<<"A"<<endl;
		for(int j = 0, temp =1; j < si; j++){
			if('0' <=str[j] && str[j] <= '9') temp = str[j] - '0';
			else {sum += temp *foo(str[j]); /*cout<<temp<<" "<<foo(str[j])<<endl*/;temp = 1;}
		}
		//cout<<"B "<<sum<<endl;
		for(int j = 0, temp =1; j < si2; j++){
			if('0' <= str2[j] && str2[j] <= '9') temp = str2[j] - '0';
			else {sum += temp *foo(str2[j]); temp = 1;}
		}
		//cout<<"D "<<sum<<endl;
		for(int j = 3; j >= 0; j--){
			temp = pow(10, j);
			if((sum/temp)%10){
				if((sum/temp)%10 >= 2)cout<<(sum/temp)%10;
				switch(j){
					case 3: cout<<"m"; break;
					case 2: cout<<"c"; break;
					case 1: cout<<"x"; break;
					case 0: cout<<"i"; break;
				}
			}
		}
		cout<<endl;
		//cout<<" C "<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {
	int num;
	double w, h;
	while(scanf("%d,%lf,%lf", &num, &w, &h) != EOF) {
		if(w / (h * h) >= 25.0)		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

const ll N = 2e6 + 1;
//vector<ll> adj[N];
//bool visited[N];

ll modfac[N];
ll modfacinv[N];
ll invsi[N];

void simake(){
	invsi[0]=1;
	invsi[1]=1;

	modfac[0]=1;
	modfac[1]=1;

	modfacinv[0]=1;
	modfacinv[1]=1;

	for(ll i=2;i<N;i++)
	{
		invsi[i] = mul(invsi[mod%i], (mod-(mod/i)));
		modfac[i] = mul(i, modfac[i-1]);
		modfacinv[i] = mul(invsi[i], modfacinv[i-1]);
	}
}

ll nCrm(ll n,ll r){
	if(n==r||r==0) return 1;
	if(n<r) return 0;
	return mul(mul(modfac[n], modfacinv[r]), modfacinv[n-r]);
}

int main() {
	simake();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll k;
	cin>>k;
	string s;
	cin>>s;
	ll n = s.size();
	ll ans=0;
	for(int i=n;i<=n+k;i++){
		ans = add(ans, mul(nCrm(n+k, i), power(25, n+k-i, mod)));
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 51180
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    char s;
    cin >> s;
    for (char moji = 'a'; moji <= 'z'; ++moji) {
        if(s == moji) cout << "a" << endl;
    }
    for (char moji = 'A'; moji <= 'Z'; ++moji) {
        if(s == moji) cout << "A" << endl;
    }
    
}

Measured memory_bytes: 3604