akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,temp,count=0;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
	    cin>>temp;
	    a.push_back(temp);
	}
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++){
	    for(int j=i+1;j<a.size();j++){
	        for(int k=j+1;k<a.size();k++){
	            
	            if(a[i]!=a[j]&& a[j]!=a[k]){
	                
	            if(a[i]+a[k]>a[j] && a[i]+a[j]>a[k] && a[j]+a[k]>a[i]){
	                
	                
	                count++;
	            }
	        }
	    }
	}
	}
	cout<<count;
	return 0;
}


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

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

int main() {
    ll a,b,c;
    cin >> a >> b;
    if (b-a > 2500) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 10000;
    for(ll i = a; i <= b; i++) {
        for(ll j = i+1; j <= b; j++) {
            c = i*j%2019;
            ans = min(ans,c);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
tax8, tax10 = map(int,input().split())
import math

tax10_list = []
list = []
count = 0

for i in range(10):
    tax10_list.append(math.floor(tax10*10+i))

for x in range(10):
    if math.floor(tax10_list[x] * 0.08) == tax8:
        print(tax10_list[x])

        break
    else:
        count += 1

if count == 10:
    print("-1")
else:
    None

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

bool isEvenString(string s) {
    if (s.length() % 2 != 0) return false;
    // cerr << "IES: " << s.length() << endl;
    for (int i = 0; i < s.length()/2; i++)
    {
      // cerr << s[i] << " " << s[s.length() / 2 + i] << endl;
        if (s[i] != s[s.length()/2 + i]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s; cin >> s;
    s.pop_back();
    if(s.length() % 2 != 0)s.pop_back();
    for(int i = s.length();i > 0;i-=2){
      // cerr << s.substr(0, i) << endl;
      if(isEvenString(s.substr(0, i))){
        cout << i << endl;
        return 0;
      }
    }    
    return 0;
}


Measured memory_bytes: 256
l = input().split()
N = int(l[0])
M = int(l[1])

C = [[] for i in range(N)]

for i in range(M):
    l = input().split()
    a = int(l[0]) - 1
    b = int(l[1]) - 1
    C[a].append(b)
    C[b].append(a)

# print(N, M, C)

def visit(cur, visited, ans, depth):
    depth += 1
    # print('depth={}, cur={}, visited={}, ans={}, C[cur]={}'.format(
    #     depth, cur, visited, ans, C[cur]))
    visited.append(cur)
    if len(visited) == N:
        # print('goal')
        return ans + 1
    for n in C[cur]:
        # print('n={}'.format(n))
        if n not in visited:
            v = [x for x in visited]
            ans = visit(n, v, ans, depth)
    return ans

ans = 0
for n in C[0]:
    visited = [0]
    ans += visit(n, visited, 0, 0)

print(ans)


Measured memory_bytes: 43996
#define $ scanf("%d",
a[100],l,r,p,n;main(c){for(;c*=l=$&r)*r;printf("%d\n",c)){for(;c=l;)$--l+a);for($&n);l<r&&!++c|a[p=l+r>>1]-n;)a[p]<n?r=p:(l=p+1);}}

Measured memory_bytes: 0
S = input()
tmp = 0
ans = 0
index = 0
while index != len(S):
    if S[index] == "A" or S[index] == "T"  or S[index] == "G" or S[index] == "C":
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp
        tmp = 0
    index += 1
if tmp > ans:
    ans = tmp
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  int n,k,d;
  vector<bool> iroha_likes(10, true);
  cin >> n >> k;
  
  for(int i=0; i < k; i++){
    cin >> d;
    iroha_likes[d] = false;
  }
  
  string s;
  int digit;
  int answer=88888;
  for(int i = n; i <= 88888; i++){
    s = to_string(i);
    for(int j = 0; j<s.size(); j++){
    digit = s[j] - '0';
      if(!iroha_likes[digit]){
        break;
      }
      if(j == s.size()-1){
        answer = i;
        break;
      }
    }
    if (answer < 88888) break; 
  }
  
  cout << answer;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    while(n >= 10){
        n %= 10;
    }
    if(n == 3)cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define N 200010 
#define ll long long
using namespace std;
int n,a[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	a[0]=-1;
	for(int i=1;i<=n;i++)		
		if(a[i]-a[i-1]>1){
			cout<<-1<<endl;
			
			return 0;
		}
	ll ans=0;
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1]+1) ans++;
		else ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX=1e5+5;
const ll INF=1e9;
char re[20];
ll shi[11]={1},wei;
ll get_wei()
{
    printf("? %lld\n",INF);
    fflush(stdout);
    scanf("%s",re);
    fflush(stdout);
    if(re[0]=='Y')
    {
        for(ll i=1;i<=10;i++)
        {
            printf("? %lld\n",2LL*shi[i-1]);
            fflush(stdout);
            scanf("%s",re);
            if(re[0]=='Y')
                return i;
            fflush(stdout);
        }
    }
    else
    {
        for(ll i=1;i<=10;i++)
        {
            printf("? %lld\n",shi[i-1]);
            fflush(stdout);
            scanf("%s",re);
            if(re[0]=='N')
                return i-1;
            fflush(stdout);
        }
    }
}
ll get_an(ll wei)
{
    ll l=shi[wei-1],r=shi[wei]-1;
    ll an=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        printf("? %lld\n",10LL*mid);
        fflush(stdout);
        scanf("%s",re);
        if(re[0]=='Y')
        {
            an=mid;
            r=mid-1;
        }
        else
            l=mid+1;
        fflush(stdout);
    }
    return an;
}
int main()
{
    for(ll i=1;i<=10;i++)
        shi[i]=10LL*shi[i-1];
    wei=get_wei();
    printf("! %lld\n",get_an(wei));
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 596
n = int(input())
w = list(map(str,[input() for i in range(n)]))

shi = []
t = w[0][-1]
shi.append(w[0])
#print(t)
for i in range(1,n):
	if shi.count(w[i]) == 1:
		print("No")
		exit()
	else:
		if t == w[i][0]:
			t = w[i][-1]
			shi.append(w[i])
		else:
			print("No")
			exit()
print("Yes")

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

using namespace std;

typedef long long ll;

const int MXN = 1e6 + 10;

char s[MXN];
int a[MXN], c[MXN], la, lc;
int sum[MXN];
ll csum[MXN];


int main ()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	sum[0] = 0;
	la = lc = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'D')
			a[++la] = i;
		else if (s[i] == 'C')
			c[++lc] = i;
		if (s[i] == 'M')
			sum[i + 1] = sum[i] + 1;
		else
			sum[i + 1] = sum[i];
	}
	csum[0] = 0;
	for (int i = 1; i <= lc; i++)
	{
		csum[i] = csum[i - 1] + 1ll * sum[c[i]];
	}
	int q;
	scanf("%d", &q);
	while (q--)
	{
		int d;
		scanf("%d", &d);
		ll ans = 0;
		for (int k = 1, i = 1, j = 1; k <= la; k++)
		{
			while (i <= lc && c[i] <= a[k])
			{
				i++;
			}
			// i == n + 1 => every number <= a[k]
			while (j <= lc && c[j] < a[k] + d)
			{
				j++;
			}
			j--;
			// j == 0 => every number >= a[k] + d
			if (j >= i)
			{
				ans = ans + csum[j] - csum[i - 1] - 1ll * (j - i + 1) * sum[a[k]];
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define ppb           pop_back()
#define ppb           pop_back()
#define B(c)          (c).begin()
#define E(c)          (c).end()
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(2e18)
#define err           cerr << "move" << '\n';
#define endl          '\n'
#define pow(x, n)     (int)(pow(x, n))
#define mp            make_pair
#define tp            template
#define ty            typename

typedef vector<int>                           vi;
typedef pair<int,int>                         pii;
typedef vector<pii>                           vpi;
typedef priority_queue<pii, vector<pii>, greater<pii> > pq;

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

tp<ty T1, ty T2, ty T3> struct query{
    T1 ss; T2 x; T3 y;
};
tp<ty T1, ty T2, ty T3> bool operator<(query<T1, T2, T3> &o1, query<T1, T2, T3> &o2){
    return o1.x < o2.x;
}
tp<ty T1, ty T2, ty T3> istream& operator>>(istream& in, query<T1, T2, T3> &q){
    in >> q.ss >> q.x >> q.y; return in;
}
tp<ty T1, ty T2, ty T3> ostream& operator<<(ostream& out, query<T1, T2, T3> &q){
    out << q.ss << " " << q.x << " " << q.y; return out;
}


void solve(){  
    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 n;
    cin >> n; n--;
    cout << a[n] << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(15);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    //cin >> t;
    
    while(t--){
        solve();
    }

    double time_taken = double(clock() - start) / double(CLOCKS_PER_SEC); 
    //cerr << time_taken;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

vector<long> pp;

void preparePrime( long maxp )
{
    long i;
    vector<long> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        long k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void decompositPrime( ll a, vector<pair<ll,ll> >& vv )
{
    preparePrime( (long)sqrt((double)a) );

    long i;
    for(i=0; i<(long)pp.size(); i++) {
        long count = 0;
        while(a % pp[i] == 0 ) {
            a /= pp[i];
            count ++;
        }
        if(count>0) vv.push_back( make_pair( pp[i], count ) );
        if (a==1) break;
    }
    if(a>1) {
        vv.push_back( make_pair( a, 1 ) );
    }

    return;
}

ll n, s, a;
ll ans;

void dfs( long i, const long siz, const pair<ll,ll>* vv, ll curr)
{
    if(i==siz) {
        if(curr>0) {
            //printf("%lld ", curr);
            ll curr1=curr+1;
            ll ans0=0;
            ll tmp=n;
            while(tmp>0) {
                ans0 += tmp%curr1;
                tmp /= curr1;
            }
            if(ans0==s) {
                ans=MIN(ans,curr1);
            }
        }
        return;
    }

    long k;
    ll tmp=1;
    for(k=0; k<=vv[i].second; k++) {
        if(k>0) tmp*= vv[i].first;
        dfs(i+1, siz, vv, curr*tmp);
    }
    return;
}

int main(int argc, char* argv[])
{
    scanf("%lld%lld", &n, &s);
    if(n<s) {
        printf("-1\n"); return 0;
    }
    else if(n==s) {
        printf("%lld\n", n+1); return 0;
    }

    a=n-s;

    vector<pair<ll,ll> > vv;
    decompositPrime( a, vv );

    long siz=(long)vv.size();

    ans=LINF;
    dfs(0, siz, &(vv[0]), 1);

    if(ans==LINF) ans=-1;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3072
N, K = map(int,input().split())
Q = [0 for i in range(N)]
for i in range(N):
    Q[i] = list(map(int,input().split()))
Q.sort()
cnt = 0
j = 0
while cnt < K:
    cnt += Q[j][1]
    j += 1
print(Q[j-1][0])

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

#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const int MX= 1000005;
const ll mod=10000000007;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
 
const int MOD = 1000000007;
using mint = Fp<MOD>;

int main(){
  int n,k;cin>>n>>k;
  mint cnt=0;
  Rep(i,k,n+2){
    mint in=i;
    mint nm=n;
    mint now=0;
    now+=in*(nm+nm-in+1)/2;
    now-=in*(in-1)/2;
    now=now+1;
    cnt+=now;
  }
  
  cout<<cnt<<endl;
}
    

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

int main(){
  string s;
  int K,count=0;
  cin>>s>>K;
  int N = s.size();  
  vector<string> S;

  for(int i=0;i<N;i++){
    for(int j=0;j<N-i;j++){
      if(j+1>K)
        break;
      string t = s.substr(i,j+1);
      auto result = std::find(S.begin(), S.end(), t);
      if(result==S.end())
        S.push_back(t);         
    }
  }
  sort(S.begin(), S.end());
  cout<<S.at(K-1)<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll read()
{
	ll neg=1LL,x=0LL;char ch;
	while((ch=getchar())<'0'||ch>'9') if(ch=='-') neg=-1LL;
	x=ch-'0';
	while((ch=getchar())>='0'&&ch<='9') x=x*10LL+(ch-'0');
	return x*neg;
}
ll a,b,ans;
int main()
{
	a=read(),b=read();
	if(a==b)
	{
		ans=a;
	}
	else if(a%2==0&&b%2==0)
	{
		if((b-a)%4==0)
		{
			ans=0LL^b;
		}
		else
		{
			ans=1LL^b;
		}
	}
	else if(a%2&&b%2)
	{
		if((b-a)%4==0)
		{
			ans=a^0LL;
		}
		else
		{
			ans=a^1LL;
		}
	}
	else if(a%2==0&&b%2)
	{
		if((b-a+1)%4==0)
		{
			ans=0LL;	
		}
		else
		{
			ans=1LL;
		}
	}
	else if(a%2&&b%2==0)
	{
		if((b-a-1)%4==0)
		{
			//printf("YES");
			ans=a^0LL^b;
		}
		else 
		{
			ans=a^1LL^b;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
S = str(input())

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)

Measured memory_bytes: 8932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  ll i,j;
  ll n,a,b;
  cin>>n>>a>>b;
  ll z=b-a;
  if(z%2==0){
    cout<<z/2<<endl;
  }
  else{
    ll m=(a+b-1)/2;
    m=min(m,n-(a+b-1)/2);
    cout<<m<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int main()
{
	int N, D;
	cin >> N >> D;
	int ret = 0;
	while (N > 0) {
		ret++;
		N -= 2 * D + 1;
	}
	printf("%d\n", ret);
	return 0;
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//   cout<<std::setprecision(12)<<
mapll mrk;
int main()
{
    ll i,j,k,l,m,n,x,y,a,b,c;

    cin >> x >> y >> a >> b >> c;

    vector<pll>v;
    ll ans = 0;

    for(i=0;i<a;i++)
    {
        cin>>l;
        v.pb({l,1});
    }
    for(i=0;i<b;i++)
    {
        cin >> l;
        v.pb({l,2});
    }
    for(i=0;i<c;i++)
    {
        cin >> l;
        v.pb({l,3});
    }

     sort(all(v));
     reverse(all(v));

    ll p,q,r;
    p = x , q = y,r=0;
//for(auto x : v)
//    cout<<x.F<<" "<<x.S<<endl;
    for(i=0;;i++)
    {
        if(p==0 && q==0)
        {
            j = i;
          //  cout << j <<endl;
            break;
        }

        if(v[i].S == 1 && p)
        {
            ans += v[i].F;
            p--;
            mrk[i] = 1;
        }
        else if(v[i].S == 2 && q)
        {
            ans += v[i].F;
            q--;
            mrk[i] = 1;
        }
        else if(v[i].S == 3)
        {
            ans += v[i].F;
            r++;
        }
    }

    for(i=j-1;i>=0;i--)
    {
        if(r==0)break;
        if(v[i].S == 3)
        {
            ans -= v[i].F;
            r--;
        }
        else if(mrk[i]){
        ans -= v[i].F;
        r--;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 18152
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	int n;
	cin >> n;
	unordered_map<string, int> mp;
	string  s;
	for(int i = 0; i < n; i++) {
		cin >> s;
		mp[s]++;
	}
	cout << mp.size() << endl;

}

Measured memory_bytes: 17684
n = int(input())
l = []
for i in range(n):
    a = input()
    l.append(a)
abc = 'abcdefghijklmnopqrstuvwxyz'
x = [50] * 26
ans = []
for i in range(26):
    for j in l:
        x[i] = min(x[i], j.count(abc[i]))
for i in range(26):
    if(x[i] != 0):
        ans.append(abc[i]*x[i])
for i in range(len(ans)):
    print(ans[i],end="")


Measured memory_bytes: 3064
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,c = map(int,ipt().split())
    stt = [tuple(map(int,ipt().split())) for _ in range(n)]

    rw = [0]*(n+1)
    rh = [0]*(n+1)
    lw = [0]*(n+1)
    lh = [0]*(n+1)
    nr = 0
    for i,si in enumerate(stt):
        nr += si[1]
        rw[i+1] = nr-si[0]*2 if rw[i]<nr-si[0]*2 else rw[i]
        rh[i+1] = nr-si[0] if rh[i]<nr-si[0] else rh[i]
    nl = 0
    for i,si in enumerate(stt[::-1]):
        nl += si[1]
        lw[i+1] = nl-(c-si[0])*2 if lw[i]<nl-(c-si[0])*2 else lw[i]
        lh[i+1] = nl-(c-si[0]) if lh[i]<nl-(c-si[0]) else lh[i]

    ma = 0
    for i in range(n):
        if ma < rw[i]+lh[n-i]:
            ma = rw[i]+lh[n-i]
        if ma < lw[i]+rh[n-i]:
            ma = lw[i]+rh[n-i]
    print(ma)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 93144
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n ;
    cin >> n ;
    
    bool flag = false ;
    while(n >= 0){
        if(n % 7 == 0){
            flag = true ;
        }

        n -= 4 ;

    }

    if(flag == true ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}

import GHC.TypeLits
import Data.Int
import Data.Proxy
import qualified Data.Map.Lazy as Map
import Control.Monad
import Control.Monad.State
import Data.List

import Data.Maybe
import qualified Data.ByteString.Char8 as BS

import qualified Data.Vector.Unboxed as VU


getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


{-- Mod Int --}
data Mint (m :: Nat) = Mint {getMintValue :: Integer} deriving (Eq, Show)

getMintMod :: forall p. KnownNat p => Mint p -> Integer
getMintMod = natVal

makeMint :: forall p. KnownNat p => Integer -> Mint p
makeMint a = let r = Mint $ fromInteger $ a `mod` (getMintMod r) in r

instance KnownNat p => Num (Mint p) where
  (Mint a) + (Mint b) = makeMint $ a + b
  (Mint a) - (Mint b) = makeMint $ a - b
  (Mint a) * (Mint b) = makeMint $ a * b
  negate (Mint a) = makeMint $ negate a
  abs = id
  signum (Mint a) = if a == 0 then 0 else 1
  fromInteger = makeMint

invMint :: forall p. KnownNat p => Mint p -> Mint p
invMint m = let p = getMintMod m in m ^ (p - 2)

powerMint :: forall p. KnownNat p => Integer -> Integer -> Mint p
powerMint n p
  | p >= 0 = (fromInteger n :: Mint p) ^ p
  | otherwise = invMint $ powerMint n (-p)


type M = Mint 1000000007




main :: IO ()
main = do
  n <- readLn :: IO Int
  c <- VU.fromList . sort <$> getInts

  let a = (powerMint 2 (fromIntegral $ 2 * n - 2) :: M)

  let ans = (* a) $ sum [(fromIntegral $ i+1) * (fromIntegral $ c VU.! (fromIntegral $ n-i))| i <- [1..n]]
  
  print $ getMintValue ans

  return ()


Measured memory_bytes: 65916
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct node
{
    int val,si,tot,fa,ch[2];
}t[N];
int tot,root;
void update(int x)
{
    if(x==0) return;
    t[x].si=t[t[x].ch[0]].si+t[t[x].ch[1]].si+t[x].tot;
}
void Rotate(int x)
{
    int y=t[x].fa,z=t[y].fa,k=t[y].ch[1]==x;
    t[y].ch[k]=t[x].ch[k^1];
    t[t[x].ch[k^1]].fa=y;
    t[x].ch[k^1]=y;
    t[y].fa=x;
    t[x].fa=z;
    t[z].ch[t[z].ch[1]==y]=x;
    update(y);update(x);update(z);
}
void splay(int x,int s)
{
    while(t[x].fa!=s)
    {
        int y=t[x].fa,z=t[y].fa;
        if(z!=s) (t[y].ch[1]==x)^(t[z].ch[1]==y)?Rotate(x):Rotate(y);
        Rotate(x);
    }
    if(s==0) root=x;
}
void Insert(int x)
{
    int u=root,fa=0;
    while(u&&t[u].val!=x)
        fa=u,u=t[u].ch[x>t[u].val];
    if(u) t[u].tot++;
    else
    {
        u=++tot;
        t[u].val=x;
        t[u].si=t[u].tot=1;
        t[u].fa=fa;
        if(fa) t[fa].ch[x>t[fa].val]=u;
        t[u].ch[0]=t[u].ch[1]=0;
    }
    splay(u,0);
}
void Find(int x)
{
    int u=root;
    if(!u) return;
    while(t[u].val!=x&&t[u].ch[x>t[u].val])
        u=t[u].ch[x>t[u].val];
    splay(u,0);
}
int Next(int x,int f)
{
    Find(x);
    int u=root;
    if(t[u].val<x&&!f||t[u].val>x&&f) return u;
    u=t[u].ch[f];
    while(t[u].ch[f^1]) u=t[u].ch[f^1];
    return u;
}
void Delete(int x)
{
    int pre=Next(x,0),bk=Next(x,1);
    splay(pre,0);splay(bk,pre);
    int u=t[bk].ch[0];
    if(!u) return;
    if(t[u].tot>1) t[u].tot--,splay(u,0);
    else
        t[bk].ch[0]=0,update(bk);
}
int main()
{
    Insert(-1);Insert(1e9+1);
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int x;scanf("%d",&x);
        int u=Next(x,0);
        if(t[u].val==-1) Insert(x);
        else
        {
            Delete(t[u].val);
            Insert(x);
        }
    }
    update(root);
    printf("%d\n",t[root].si-2);
}


Measured memory_bytes: 2560
// AtCoder Beginner Contest 124 - Problem D: Handstand (https://atcoder.jp/contests/abc124/tasks/abc124_d)
#include <bits/stdc++.h>

using namespace std;

int solve(int N, int K, const string& S)
{
    int ans = 0, L = 0;
    vector<int> xs, bs;

    while (L < N)
    {
        int R = L + 1;

        while (R < N and S[L] == S[R])
            ++R;

        xs.push_back(R - L);
        bs.push_back(S[L] == '0' ? 1 : 0);

        L = R;
    }

    L = 0;
    N = xs.size();

    int sum = xs[0], flips = bs[0], R = L + 1;

    while (L < N)
    {
        while (R < N and (flips < K or (flips == K and bs[R] == 0)))
        {
            sum += xs[R];
            flips += bs[R];
            R++;
        }

        ans = max(ans, sum);

        sum -= xs[L];
        flips -= bs[L];
        ++L;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    string S;
    cin >> N >> K >> S;

    auto ans = solve(N, K, S);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1372
#include <iostream>
#include <algorithm>
#include <set>
#define int long long
using namespace std;

int dp[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,w,a,b,i,j,ans=0;
	cin>>n>>w;
	for(i=1;i<=n*1000+1;i++)
	{
		dp[i]=1e18;
	}
	for(i=0;i<n;i++)
	{
		cin>>a>>b;
		for(j=n*1000;j-b>=0;j--)
		{
			dp[j]=min(dp[j], dp[j-b]+a);
			if(dp[j]<=w)
			{
				ans=max(ans, j);
			}
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>

using namespace std;

double r;
int main(){
	cin >> r;

	printf("%f05 %f05\n", (r*r*M_PI), (r * 2 * M_PI));

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
char s[N]; 
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int res=n;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i+1])
			res=min(res,max(i,n-i));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=(int)n; i++)
#define FF(i,n) for (int i=0; i<(int)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < int , int >
#define re(x) (int)x.size()
#define y1 u228
#define vi vector <int>
using namespace std;
typedef long long ll;
const int N = 1e5+228;
const int big = 2e9;
const int md = 1e9 + 7;
int n,m,ans;
void go(int x){
    if (m/x>=n) ans=max(ans,x);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    cin>>n>>m;
    for (int i=1; i<=trunc(sqrt(m)); i++){
        if (m%i==0) {go(i); go(m/i);}
    }
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string s;
    cin >> s;
    
    if (s[0] == s[2])
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
        

    return 0;
}

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

DP = [0]*(N+1)

for x in range(1,round(N**0.5)):
    for y in range(1,round(N**0.5)):
        for z in range(1,round(N**0.5)):
            hoge = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

            if hoge <= N:
                DP[hoge] += 1
            else:
                break

for i in range(1,N+1):
    print(DP[i])


Measured memory_bytes: 70172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 101010;
int n, m;
int par[N], dis[N];
pii find(int x) {
	if(x == par[x])
		return {x, 0};
	pii res = find(par[x]);
	par[x] = res.fi; dis[x] = dis[x] + res.se;
	return {par[x], dis[x]};
}
int main() {
	scanf("%d%d", &n, &m);
	rep(i, 0, n) par[i] = i;
	bool ans = 1;
	rep(i, 0, m) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		u--, v--;
		pii a = find(u), b = find(v);
	//	dd(u), dd(v), de(w);
	//	dd(a.fi), de(a.se);
	//	dd(b.fi), de(b.se);
		if(a.fi == b.fi) {
			ans &= a.se + w == b.se;
		} else {
			if(b.fi == v) {
				par[b.fi] = a.fi;
				dis[b.fi] = a.se + w;
			} else {
				par[a.fi] = b.fi;
				dis[a.fi] = b.se - a.se - w;
			}
		}
	}
	int mn = 0, mx = 0;
	rep(i, 0, n) {
		mn = min(find(i).se, mn);
		mx = max(find(i).se, mx);
	}
	ans &= mx - mn <= 1000000000;
	puts(ans ? "Yes" : "No");
	return 0;
}



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

int N, M, l, r;
vector<int> L;
vector<int> R;

int main() {
  cin >> N >> M;
  rep(i, M) {
    cin >> l >> r;
    L.push_back(l);
    R.push_back(r);
  }
  cout << max(0, 1 + *min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end())) << endl;
  return 0;
}



Measured memory_bytes: 1276
import heapq
f=lambda:map(int,input().split());n=int(input());g=[[]for _ in range(n+1)];z=[-1]*n;d=[1e9]*n+[0];q=[-1]*(n+1);r='';Q=[];heapq.heappush(Q,(0,-2,n))
for _ in range(n-1):a,b=f();a-=1;b-=1;g[a]+=[(1,a,b)];g[b]+=[(1,b,a)]
for _ in range(int(input())):a,b=f();a-=1;g[n]+=[(b,n,a)];z[a]=b
while Q:
	e=heapq.heappop(Q)
	if q[e[2]]!=-1:continue
	q[e[2]]=e[1]
	for f in g[e[2]]:
		if d[f[2]]>e[0]+f[0]:d[f[2]]=e[0]+f[0];heapq.heappush(Q,(e[0]+f[0],f[1],f[2]))
for _ in g:
	if any(e[1]!=n and abs(d[e[1]]-d[e[2]])!=1 for e in _):r='No'
if any(z[i]>=0 and z[i]!=d[i] for i in range(n)):r='No'
print(r or "Yes\n"+"\n".join(map(str,d[:n])))

Measured memory_bytes: 70856
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <tuple>

using namespace std;

using PII = pair<int, int>;
using TUP = tuple<int, int, char>;

void show(vector<int> v) {
	for (auto x: v) {
		cout << x << " ";
	}
	cout << endl;
}


vector<int> get_minmax(vector<int> v) {
	if (v.empty()) {
		return {};
	} else if (v.size() == 1) {
		return v;
	}

	sort(v.begin(), v.end());
	return {v.front(), v.back()};
}


set<double> get_changing_times(vector<TUP> points, int which) {
	char d_plus, d_minus;
	if (which == 0) {
		// x;
		d_plus = 'R';
		d_minus = 'L';
	} else {
		// y;
		d_plus = 'U';
		d_minus = 'D';
	}

	int x, y;
	char d;

	vector<int> v_plus, v_minus, v_zero;
	for (auto t: points) {
		tie(x, y, d) = t;

		int tmp = which == 0 ? x : y;

		if (d == d_plus) {
			v_plus.emplace_back(tmp);
		} else if (d == d_minus) {
			v_minus.emplace_back(tmp);
		} else {
			v_zero.emplace_back(tmp);
		}
	}

	v_plus = get_minmax(v_plus);
	v_minus = get_minmax(v_minus);
	v_zero = get_minmax(v_zero);

	// cout << "v_plus : "; show(v_plus);
	// cout << "v_minus: "; show(v_minus);
	// cout << "v_zero : "; show(v_zero);

	set<double> s = {0};

	for (auto p1: v_plus) {
		for (auto p2: v_minus) {
			if (p1 <= p2) {
				s.insert(0.5 * (p2 - p1));
			}
		}
	}
	for (auto p1: v_zero) {
		for (auto p2: v_plus) {
			if (p2 <= p1) {
				s.insert(p1 - p2);
			}
		}
	}
	for (auto p1: v_zero) {
		for (auto p2: v_minus) {
			if (p1 <= p2) {
				s.insert(p2 - p1);
			}
		}
	}

	return s;
}

double calc(double t, vector<TUP> &points) {
	int x, y;
	char d;

	double x_max = -1e20;
	double x_min = 1e20;
	double y_max = -1e20;
	double y_min = 1e20;

	for (auto p: points) {
		tie(x, y, d) = p;

		double now_x = x;
		double now_y = y;

		switch (d) {
			case 'R': now_x += t; break;
			case 'L': now_x -= t; break;
			case 'U': now_y += t; break;
			case 'D': now_y -= t; break;
			default: break;
		}

		x_max = max(x_max, now_x);
		x_min = min(x_min, now_x);
		y_max = max(y_max, now_y);
		y_min = min(y_min, now_y);
	}

	double ret = (x_max - x_min) * (y_max - y_min);
	return ret;
}


int main() {
	int n, x, y;
	char d;
	cin >> n;

	vector<int> a(n, 0);
	vector<TUP> points;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> d;
		points.emplace_back(make_tuple(x, y, d));
	}


	auto s1 = get_changing_times(points, 0);
	auto s2 = get_changing_times(points, 1);
	s1.insert(s2.begin(), s2.end());

	double ans = 1e18;
	for (double t: s1) {
		auto tmp = calc(t, points);
		ans = min(ans, tmp);
	}

	printf("%.12f\n", ans);
	return 0;
};


Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if((a < b) && (b < c)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

string s, t;
int q;
int ssum[100005], tsum[100005];
void solve() {
    cin >> s >> t;

    int n = sz(s), m = sz(t);
    rep(i, n) {
        if (s[i] == 'A') ssum[i + 1] = ssum[i] + 1;
        else ssum[i + 1] = ssum[i] + 2;
    }

    rep(i, m) {
        if (t[i] == 'A') tsum[i + 1] = tsum[i] + 1;
        else tsum[i + 1] = tsum[i] + 2;
    }

    cin >> q;
    rep(i, q) {
        int a, b, c, d; cin >> a >> b >> c >> d;

        if ((ssum[b] - ssum[a - 1]) % 3 == (tsum[d] - tsum[c - 1]) % 3) cout << "YES" << endn;
        else cout << "NO" << endn;
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  int cnt = 0,ans = 0;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'R') cnt++;
    else cnt = 0;
    ans = max(ans,cnt);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    if (n % k == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define   sz(x)  (int)x.size()
#define   ff first
#define   ss second
#define   pii  pair<int,int> 
#define   pb  push_back
#define   eb  emplace_back
using namespace std;

void solve(){
	int  n,k;
	cin >> n >> k ; 
	int ans=k;
	for (int i=1;i<n;i++) ans *= (k-1);
	cout << ans << endl; 
}

signed main()
{
	int  n=1; // cin >> n;
	while (n--) 
	solve();
    return 0;
}
/*
4 
10 30 40 20

*/

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

const ll INF = (ll)1e18;

struct edge {
  ll to, cost;

  edge(ll t, ll c) {
    to = t;
    cost = c;
  }
};

struct graph {
  ll V;
  vector<vector<edge>> G;
  vector<ll> d;

  graph(ll n) { init(n); }

  void init(ll n) {
    V = n;
    G.resize(V);
    d.resize(V);
  }

  void add_edge(ll s, ll t, ll cost) { G[s].push_back(edge(t, cost)); }

  void Dijkstra(ll s) {
    for (int i = 0; i < V; i++) {
      d[i] = INF;
    }
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));

    while (!que.empty()) {
      P p = que.top();
      que.pop();
      ll v = p.second;

      if (d[v] < p.first) {
        continue;
      }

      for (auto e : G[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
  }
};

int N, M;
graph G = graph(N);

void solve() {
  G.Dijkstra(0);
  vector<int> res(N, 1);
  for (int i = 0; i < N; i++) {
    if (G.d[i] % 2 == 0) {
      res[i] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << res[i] << "\n";
  }
}

int main() {
  cin >> N;
  G.init(N);
  M = N - 1;
  for (int i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    G.add_edge(a - 1, b - 1, c);
    G.add_edge(b - 1, a - 1, c);
  }
  solve();
  return 0;
}


Measured memory_bytes: 9088
def main():
  N =  int(input())
  ans = ""
  moji = "abcdefghijklmnopqrstuvwxyz"
  while N > 0:
    N -= 1
    ans += moji[N%26]
    N //= 26
  print(ans[::-1])
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    for(int CASE = 1; ; ++CASE) {
        int W;
        cin >> W;
        if(!W) break;

        int N;
        cin >> N;
        vector<pair<int, int> > v;
        for(int i = 0; i < N; ++i) {
            int val, w;
            char comma;
            cin >> val >> comma >> w;
            v.push_back(make_pair(val, w));
        }

        vector<vector<int> > dp(2, vector<int>(W+1, 0));
        int vn = 0;
        int mv = 0;
        for(int i = 0; i < N; ++i) {
            vector<int> &vec = dp[vn];
            vector<int> &prev = dp[1-vn];

            for(int w = 0; w <= W; ++w) {
                int pw = w - v[i].second;
                vec[w] = prev[w];
                if(pw >= 0) {
                    vec[w] = max(vec[w], prev[pw] + v[i].first);
                    mv = max(mv, vec[w]);
                }
            }
            vn = 1-vn;
        }

        cout << "Case " << CASE << ":" << endl;
        for(int w = 0; w <= W; ++w) {
            if(dp[1-vn][w] == mv) {
                cout << mv << endl;
                cout << w << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
counter = 0

for i in range(n):
    a = list(map(int,input().split()))
    sum_ab = c
    for j in range(m):
        sum_ab += a[j] * b[j]
    if sum_ab > 0:
        counter += 1

print(counter)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D, X):
    p = set([i**2 for i in range(1, int(math.sqrt(16000)))])
    ans = 0
    for i, j in combinations(range(N), 2):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        if d in p:
            ans += 1
    return ans


def main():
    N, D = read_int_n()
    X = [read_int_n() for _ in range(N)]
    print(slv(N, D, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


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

 const int nmmax=50;
 char A[nmmax][nmmax],B[nmmax][nmmax];


for(int y=0;y<N;++y){
 for(int x=0;x<N;++x){
 cin >> A[y][x];
 }
 }

 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 cin >> B[y][x];
 }
 }

 bool exist=false;

 for(int ly=0;ly<N;++ly){
 for(int lx=0;lx<N;++lx){
 if(ly+M-1>=N or lx+M-1>=N) continue;

 bool match=true;
 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
 if(match) exist=true;
 }
 }

 if(exist)
 cout << "Yes" << endl;
 else
 cout << "No" << endl;

 return 0;
 }
//   return 0;


Measured memory_bytes: 256
/*
 ********************************************************************************
 *  Author: ThoseBygones
 *  Version: V1.0
 *  Date: 2018-06-29
 *  Subject: ACM-ICPC
 *  Language: C/C++11
 *  OJ: AOJ
 *  Algorithm:
 ********************************************************************************
 *  Algo-Description:
 ********************************************************************************
 */

//#include <bits/stdc++.h>  //For CodeForces only

//#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
template<class T> inline T sqr(T x)
{
    return x * x;
}
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<LD, LD> PDD;
#define MP make_pair
#define PB push_back
#define sz(x) ((int)(x).size())
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define FOR(i,n) for(int i=0;i<(n);++i)
#define forIt(mp,it) for(__typeof(mp.begin()) it = mp.begin();it!=mp.end();it++)
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const LL LINF = INF * 1ll * INF;
const double PI = acos(-1.0);

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lowbit(u) (u&(-u))
#define MAXN 500005

struct Node
{
    int l,r;
    int val;
    void init()
    {
        l=r=-1;
        val=-1;
    }
} nd[MAXN];

int cnt;
int root;

void addNode(int val)
{
    nd[++cnt].init();
    int cur=root;
    while(~nd[cur].val)
    {
        if(val<nd[cur].val)
        {
            if(~nd[cur].l)
                cur=nd[cur].l;
            else
            {
                nd[cur].l=cnt;
                break;
            }
        }
        else
        {
            if(~nd[cur].r)
                cur=nd[cur].r;
            else
            {
                nd[cur].r=cnt;
                break;
            }

        }
    }
    nd[cnt].val=val;
}

void preOrder(int u)
{
    printf(" %d",nd[u].val);
    if(~nd[u].l)
        preOrder(nd[u].l);
    if(~nd[u].r)
        preOrder(nd[u].r);
}

void inOrder(int u)
{
    if(~nd[u].l)
        inOrder(nd[u].l);
    printf(" %d",nd[u].val);
    if(~nd[u].r)
        inOrder(nd[u].r);
}

int main()
{
    int n;
    scanf("%d",&n);
    root=1;
    for(int i=0; i<n; i++)
    {
        char op[10];
        scanf("%s",op);
        if(op[0]=='i')
        {
            int x;
            scanf("%d",&x);
            addNode(x);
        }
        else
        {
            inOrder(root);
            puts("");
            preOrder(root);
            puts("");
        }
    }
    return 0;
}



Measured memory_bytes: 8968