malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 9;   vector<pair<int, int> > barr[N];   int n, q, arr[N], a, b;   long long t[N], ans[N];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> arr[i];     scanf( %d , &q);     int kok = sqrt(n);     for (int i = 1; i <= q; i++) {       scanf( %d %d , &a, &b);       if (b > kok) {         for (int j = a; j <= n; j += b) ans[i] += arr[j];       } else         barr[b].push_back(make_pair(a, i));     }     for (int i = 1; i <= kok; i++) {       if (barr[i].size()) {         for (int j = n; j >= 1; j--) t[j] = arr[j] + t[(i + j) * (i + j <= n)];         for (int j = 0; j < barr[i].size(); j++)           ans[barr[i][j].second] = t[barr[i][j].first];       }     }     for (int i = 1; i <= q; i++) printf( %lld n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int maxN = 5e5 + 5;   int m, k, n, s;   vector<int> a;   int c[maxN], h[maxN];   int main(int argc, char *argv[]) {     cin >> m >> k >> n >> s;     a.resize(m + 1);     for (int i = 1; i <= m; ++i) cin >> a[i];     int total = 0;     for (int i = 0; i < s; ++i) {       int x;       cin >> x;       c[x]++;       if (c[x] == 1) total++;     }     int cur_s = 0;     vector<int> ans;     bool found = false;     for (int l = 1, r = 1; l + k - 1 <= m; ++l) {       while ((cur_s < total && r <= m) || r - l + 1 <= k) {         h[a[r]]++;         if (h[a[r]] == c[a[r]]) cur_s++;         r++;       }       if (cur_s == total && (l - 1) / k + (m - r + 1) / k + 1 >= n) {         found = true;         int to_remove = r - l - k;         for (int i = l; to_remove > 0 && i < r; ++i) {           if (h[a[i]] > c[a[i]]) {             to_remove--;             ans.emplace_back(i);             h[a[i]]--;           }         }         break;       }       if (h[a[l]] == c[a[l]]) cur_s--;       h[a[l]]--;     }     if (found == false)       cout << -1 << endl;     else {       cout << ans.size() << endl;       for (int i = 0; i < ans.size(); ++i) {         if (i > 0) cout <<    ;         cout << ans[i];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char nl =   n ;   const long long mod = 1e9 + 7;   long long bigmod(long long a, long long b) {     if (b == 0) return 1;     long long ans = bigmod(a, b / 2);     ans = (ans * ans) % mod;     if (b & 1) ans *= a;     return ans % mod;   }   void solve() {     long long n;     cin >> n;     cout << (bigmod(4, pow(2, n) - 2) * 6) % mod << nl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }   }
#include  bits/stdc++.h    #define int long long    using namespace std ;   const int M=998244353,mxM=5e4  ;   int d[21][mxM+1],n,m,p,iv[21],f1[21],f2[21];   signed main(){    cin >> n >> m  ;    for(int i=0;i<n;i++)     for(int j=0;j<m;j++)      cin >> d[i][j]  ;    iv[1]=1 ;    for(int i=2;i<n+1;i++)     iv[i]=M-M/i*iv[M%i]%M ;    f1[0]=f2[0]=1 ;    for(int i=1;i<n+1;i++){     f1[i]=f1[i-1]*i%M  ;     f2[i]=f2[i-1]*iv[i]%M ;    }    p=m*f1[n]%M ;    for(int j=0;j<m;j++){     vector<int>a ;     for(int i=0;i<n;i++)      a.push_back(d[i][j]) ;     sort(a.begin(),a.end()) ;     int c=1 ;     for(int i=0;i<n;i++){      if(a[i]-i-1<=0){       c=0 ;break ;      }      (c*=(a[i]-i-1))%=M  ;     }     p=(p-c+M)%M  ;    }    cout << (p*f2[n])%M<<   n  ;   }
#include <bits/stdc++.h>   using namespace std;   inline bool read(int &x) {     char ch;     bool flag = false;     for (ch = getchar(); !isdigit(ch); ch = getchar())       if (ch ==  - ) flag = true;     for (x = 0; isdigit(ch); x = x * 10 + ch -  0 , ch = getchar())       ;     x = flag ? -x : x;     if (ch ==   n ) return 0;     return 1;   }   inline void write(int x) {     static const int maxlen = 100;     static char s[maxlen];     if (x < 0) {       putchar( - );       x = -x;     }     if (!x) {       putchar( 0 );       return;     }     int len = 0;     for (; x; x /= 10) s[len++] = x % 10 +  0 ;     for (int i = len - 1; i >= 0; --i) putchar(s[i]);   }   const int MAXN = 2500;   int n, lim;   int g[MAXN][MAXN];   char s[MAXN];   int f[MAXN][MAXN];   bool go_l[MAXN][MAXN], go_r[MAXN][MAXN];   bool go_up[MAXN][MAXN], go_down[MAXN][MAXN];   int add_l[MAXN][MAXN];   int add_h[MAXN][MAXN];   int sum_l[MAXN][MAXN];   int sum_h[MAXN][MAXN];   int main() {     read(n);     read(lim);     for (int i = 1; i <= n; i++) {       scanf( %s , s);       for (int j = 1; j <= n; j++)         if (s[j - 1] ==  B )           g[i][j] = 1;         else           g[i][j] = 0;     }     for (int i = 1; i <= n; i++) {       go_l[i][0] = 1;       for (int j = 1; j <= n; j++)         if ((go_l[i][j - 1]) && (g[i][j] == 0))           go_l[i][j] = 1;         else           go_l[i][j] = 0;       go_r[i][n + 1] = 1;       for (int j = n; j >= 1; j--)         if ((go_r[i][j + 1]) && (g[i][j] == 0))           go_r[i][j] = 1;         else           go_r[i][j] = 0;       for (int j = 1; j <= n - lim + 1; j++)         if (go_l[i][j - 1] && go_r[i][j + lim] && (!go_r[i][1]))           add_h[i][j] = 1;         else           add_h[i][j] = 0;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) sum_h[i][j] = sum_h[i - 1][j] + add_h[i][j];     for (int j = 1; j <= n; j++) {       go_up[0][j] = 1;       for (int i = 1; i <= n; i++)         if ((go_up[i - 1][j]) && (g[i][j] == 0))           go_up[i][j] = 1;         else           go_up[i][j] = 0;       go_down[n + 1][j] = 1;       for (int i = n; i >= 1; i--)         if ((go_down[i + 1][j]) && (g[i][j] == 0))           go_down[i][j] = 1;         else           go_down[i][j] = 0;       for (int i = 1; i <= n - lim + 1; i++)         if (go_up[i - 1][j] && go_down[i + lim][j] && (!go_down[1][j]))           add_l[i][j] = 1;         else           add_l[i][j] = 0;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) sum_l[i][j] = sum_l[i][j - 1] + add_l[i][j];     int tot = 0;     for (int i = 1; i <= n; i++)       if (go_r[i][1]) tot++;     for (int i = 1; i <= n; i++)       if (go_down[1][i]) tot++;     int ans = 0;     for (int i = 1; i <= n - lim + 1; i++)       for (int j = 1; j <= n - lim + 1; j++)         ans = max(ans, (sum_l[i][j + lim - 1] - sum_l[i][j - 1]) +                            (sum_h[i + lim - 1][j] - sum_h[i - 1][j]));     cout << ans + tot << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   long long int n, k, mx, sum, a[N];   int main() {     cin >> n >> k;     sum++;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i) {         if (a[i] != a[i - 1]) {           sum++;           mx = max(mx, sum);         } else {           sum = 1;         }       }     }     mx = max(sum, mx);     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   void solve() {     int n, k;     cin >> n >> k;     string A[n];     map<string, int> m;     for (int i = (0); i < (n); i++) {       cin >> A[i];       m[A[i]]++;     }     long long ans = 0;     sort(A, A + n);     set<string> st;     for (int i = (0); i < (n - 2); i++) {       for (int j = (i + 1); j < (n - 1); j++) {         string s(k,  . );         for (int z = (0); z < (k); z++) {           if (A[i][z] == A[j][z]) {             s[z] = A[i][z];           } else {             int tmp = A[i][z] + A[j][z];             if (tmp == 152) {               s[z] =  T ;             } else if (tmp == 153) {               s[z] =  S ;             } else {               s[z] =  E ;             }           }         }         string tmp = A[i] + A[j] + s;         if (s.compare(A[i]) >= 0 && s.compare(A[j]) >= 0 &&             st.find(tmp) == st.end()) {           ans += m[s];           if (s.compare(A[i]) == 0) {             ans--;           }           if (s.compare(A[j]) == 0) {             ans--;           }           st.insert(tmp);         }       }     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int tt = 1;     while (tt--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   int n, k, f, c, ans;   int main() {     cin >> n >> k;     for (int i = 2; i <= n; i++) {       f = 0;       for (int j = 2; j <= i / 2; j++) f += (i % j == 0);       if (f == 0) a.push_back(i);     }     for (int i = 2; i < a.size(); i++)       for (int j = 1; j < i && a[j - 1] + a[j] + 1 <= a[i]; j++)         if (a[j - 1] + a[j] + 1 == a[i]) ans++;     if (ans >= k)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, f[200009];   int judge(int len) {     if (len == 2) return 0;     if (len == 3) return k == (n - 1) ? 1 : 0;     if ((long long)(k - 2) * ((len - 1) / 2 - 1) < n - len - k + 2) return 0;     return 1;   }   int main() {     scanf( %d%d , &n, &k);     int l = 2, r = n - k + 2, len = 0;     while (l <= r) {       int mid = (l + r) / 2;       if (judge(mid))         r = mid - 1, len = mid;       else         l = mid + 1;     }     printf( %d n , len - 1);     for (int i = 1; i < len; i++) printf( %d %d n , i, i + 1);     int lf = k - 2, ilf = n - len - k + 2, t = len + 1;     for (int i = 1; i <= lf; i++) {       printf( %d %d n , (len + 1) / 2, t);       f[i] = t, t++;     }     int x = 1;     while (ilf > 0) {       printf( %d %d n , f[x], t);       f[x] = t;       t++;       x = x % lf + 1;       ilf--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const long long N = 100001;   long long mod = 1000000007;   long long min(long long a, long long b) {     if (a < b)       return a;     else       return b;   }   long long max(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long power(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long p, long long q) {     if (p % q == 0)       return q;     else {       return gcd(q, p % q);     }   }   long long mul(long long a, long long b) {     return ((a % mod) * (b % mod)) % mod;   }   long long sub(long long a, long long b) {     return (((a - b) % mod) + mod) % mod;   }   vector<long long> kmp(string s) {     long long n = s.size();     vector<long long> ans(n);     long long len = 0;     for (long long i = 1; i < n; i++) {       while (len > 0 && s[len] != s[i]) len = ans[len - 1];       len += (s[i] == s[len]);       ans[i] = len;     }     return ans;   }   void solve() {     string s;     cin >> s;     vector<long long> ans = kmp(s);     if (ans.back() == 0) {       cout <<  Just a legend  <<   n ;       return;     }     for (long long i = 1; i < s.size() - 1; i++) {       if (ans[i] == ans.back()) {         cout << s.substr(0, ans[i]);         cout <<   n ;         return;       }     }     if (ans[ans.back() - 1] == 0)       cout <<  Just a legend ;     else       cout << s.substr(0, ans[ans.back() - 1]);   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     for (long long i = 0; i < t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     int curr_len = 0;     int l = 0, r = a.size() - 1;     while (l <= r) {       if (a[l] - 1 < int(1e6) - a[r]) {         curr_len = a[l] - 1;         ++l;       } else {         curr_len = int(1e6) - a[r];         --r;       }     }     cout << curr_len;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 400;   struct hh {     double x, y;   } a[MAX];   double jisuan(hh a, hh b, hh c) {     double x1, y1, x2, y2;     x1 = b.x - a.x;     y1 = b.y - a.y;     x2 = c.x - a.x;     y2 = c.y - a.y;     return (x1 * y2 - x2 * y1) / 2;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].x >> a[i].y;     }     double area, l, r;     area = 0;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         l = r = 0;         for (int k = 0; k < n; k++) {           double w = jisuan(a[i], a[j], a[k]);           if (w > 0 && w > l)             l = w;           else if (w < 0 && -w > r)             r = -w;         }         if (l + r > area && l > 0 && r > 0) area = l + r;       }     }     printf( %.6f n , area);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     cout << (n * 6 - 1) * k << endl;     for (int i = 0; i < n; i++)       cout << (i * 6 + 1) * k <<     << (i * 6 + 2) * k <<     << (i * 6 + 3) * k            <<     << (i * 6 + 5) * k << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Node {    public:     vector<int> kids;     int pos[26];     int size;     int depth;     Node() {       this->size = 0;       memset(pos, 0, sizeof(pos));     }     void push(int kid, int next) {       this->kids.push_back(kid);       pos[next] = this->kids.size();     }   } N[300005];   int n, x, y;   char c;   int maxdepth;   int reduce[300005];   void init(int id) {     N[id].size = 1;     int l = N[id].kids.size();     for (int i = 0; i < l; i++) {       N[N[id].kids[i]].depth = N[id].depth + 1;       init(N[id].kids[i]);       maxdepth = max(maxdepth, N[N[id].kids[i]].depth);       N[id].size += N[N[id].kids[i]].size;     }   }   int dfsS(vector<int> &kids) {     if (kids.size() <= 1) return 0;     int ret = kids.size() - 1;     int l = kids.size();     int pos;     vector<int> tmp;     for (int i = 0; i < 26; i++) {       for (int j = 0; j < l; j++) {         pos = N[kids[j]].pos[i];         if (pos) {           tmp.push_back(N[kids[j]].kids[pos - 1]);         }       }       if (tmp.size() > 1) ret += dfsS(tmp);       tmp.clear();     }     return ret;   }   void dfsD(int id) {     int l = N[id].kids.size();     int ret = l ? 1 : 0;     ret += dfsS(N[id].kids);     reduce[N[id].depth + 1] += ret;     for (int i = 0; i < l; i++) {       dfsD(N[id].kids[i]);     }   }   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> x >> y >> c;       N[x].push(y, c -  a );     }     N[1].depth = 0;     init(1);     dfsD(1);     int mm = 0;     int ans = 0;     for (int i = 1; i <= maxdepth; i++) {       if (reduce[i] > mm) {         ans = i;         mm = reduce[i];       }     }     cout << N[1].size - mm << endl;     cout << ans;     return 0;   };
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int C = 26;   void add(int &x, int y) {     x += y;     while (x >= MOD) x -= MOD;     while (x < 0) x += MOD;   }   int fix(int x) {     while (x >= MOD) x -= MOD;     while (x < 0) x += MOD;     return x;   }   int pw(int a, int b) {     int ret = 1;     while (b) {       if (b & 1) ret = 1ll * ret * a % MOD;       b >>= 1;       a = 1ll * a * a % MOD;     }     return ret;   }   bitset<3> bs(int x) { return bitset<3>(x); }   const int MAXN = 1e5 + 10;   vector<int> vec[MAXN];   int mark[MAXN], tt;   int single(int x) { return (x & (x - 1)) == 0; }   void solve() {     ++tt;     int a[3];     vector<int> sec;     for (int i = 0; i < 3; i++) {       cin >> a[i];       for (int x : vec[a[i]]) {         if (mark[x] ^ tt) sec.push_back(x);         mark[x] = tt;       }     }     int cnt[8] = {};     for (int x : sec) {       int mask = 0;       for (int i = 0; i < 3; i++)         if (a[i] % x == 0) mask ^= 1 << i;       ++cnt[mask];     }     int ans = 0;     for (int i = 0; i < (1 << 3); i++) {       for (int j = i; j < (1 << 3); j++) {         for (int k = j; k < (1 << 3); k++) {           if ((i | j | k) != (1 << 3) - 1) continue;           if ((i == j && single(i)) || (j == k && single(j))) continue;           int cnt_single = single(i) + single(j) + single(k);           int memo_ans = ans;           if (cnt_single == 3) {             ans += cnt[i] * cnt[j] * cnt[k];           } else if (cnt_single == 2) {             ans += cnt[i] * cnt[j] * cnt[k];           } else if (cnt_single == 1) {             if (single(i)) {               if (j == k) {                 ans += cnt[i] * (cnt[j] + 1) * cnt[j] / 2;               } else {                 ans += cnt[i] * cnt[j] * cnt[k];               }             }             if (single(j)) {               if (i == k) {                 ans += cnt[j] * (cnt[i] + 1) * cnt[i] / 2;               } else {                 ans += cnt[i] * cnt[j] * cnt[k];               }             }             if (single(k)) {               if (i == j) {                 ans += cnt[k] * (cnt[i] + 1) * cnt[i] / 2;               } else {                 ans += cnt[i] * cnt[j] * cnt[k];               }             }           } else if (i == j && j == k) {             ans += (cnt[i] + 2) * (cnt[i] + 1) * cnt[i] / 6;           } else if (i == j) {             ans += cnt[k] * (cnt[i] + 1) * cnt[i] / 2;           } else if (j == k) {             ans += cnt[i] * (cnt[j] + 1) * cnt[j] / 2;           } else {             ans += cnt[i] * cnt[j] * cnt[k];           }           if (ans != memo_ans && 0) {             cerr << bs(i) <<     << bs(j) <<     << bs(k) <<   n ;             cerr <<  ans:   << memo_ans <<   n ;             cerr <<  now ans:   << ans <<   n n ;           }         }       }     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (int i = 1; i < MAXN; i++)       for (int j = i; j < MAXN; j += i) vec[j].push_back(i);     int te = 1;     cin >> te;     for (int w = 1; w <= te; w++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:64000000 )   const int MAXN = 1000002;   int n, l, t;   int a[MAXN << 1];   inline void init() {     scanf( %d%d%d , &n, &l, &t);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     sort(a, a + n);   }   int main() {     init();     t <<= 1;     double res = 0.0;     int cycles = t / l;     t %= l;     res += (double)cycles * (double)n * (double)(n - 1) * 0.5;     for (int i = 0; i < n; ++i) a[i + n] = a[i] + l;     for (int i = 0; i < n; ++i) {       int ind = i + n;       int l = 1, r = n - 1;       int cur = 0;       while (l <= r) {         int mid = (l + r) >> 1;         if (a[ind] - a[ind - mid] <= t) {           cur = mid;           l = mid + 1;         } else {           r = mid - 1;         }       }       res += (double)cur * 0.25;       cur = 0;       l = 1, r = n - 1;       while (l <= r) {         int mid = (l + r) >> 1;         if (a[i + mid] - a[i] <= t) {           cur = mid;           l = mid + 1;         } else {           r = mid - 1;         }       }       res += (double)cur * 0.25;     }     res /= 2.0;     printf( %.15lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, a, b, c, n, t, f, d;     string s, v;     map<char, int> ma, sa;     vector<int> vv;     map<char, int>::iterator it, ki;     cin >> s;     f = 0;     c = 0;     for (j = 0; j < s.size(); j++) {       if ((s[j] >=  A  && s[j] <=  Z )) {         c++;       }     }     if (c == s.size()) {       for (j = 0; j < s.size(); j++) {         cout << char(s[j] + 32);       }       cout << endl;     } else if (s[0] >=  a  && s[0] <=  z  && c == s.size() - 1) {       cout << char(s[0] - 32);       for (j = 1; j < s.size(); j++) {         cout << char(s[j] + 32);       }       cout << endl;     } else {       cout << s << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int alpha[26] = {0}, dig[105] = {0};   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long int lcm(long long int a, long long int b) {     return ((a * b) / gcd(a, b));   }   bool isPrime(int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   void getArr(int a[], int n) {     for (int i = 0; i < n; i++) cin >> a[i];   }   void putArr(int a[], int n) {     for (int i = 0; i < n; i++) cout << a[i] <<    ;     cout <<   n ;   }   void initAlpha(string s) {     int n = s.size();     for (int i = 0; i < n; i++) alpha[s[i] -  a ]++;   }   void initDigit(int a[], int n) {     for (int i = 0; i < n; i++) dig[a[i]]++;   }   bool isPalindrome(string input) {     if (input == string(input.rbegin(), input.rend())) return true;     return false;   }   int numLen(int n) {     int len = 0;     while (n != 0) {       n /= 10;       len++;     }     return len;   }   void robot() {     string s;     char n[50];     cin >> s;     int l = s.size(), k = 0;     bool flag = false;     for (int i = l - 1; i >= 0; i--) {       if (s[i] ==  0  && !flag)         continue;       else {         n[k++] = s[i];         flag = true;       }     }     n[k] =   0 ;     if (isPalindrome(n))       cout <<  YES n ;     else       cout <<  NO n ;   }   int main() { robot(); }
#include <bits/stdc++.h>   using namespace std;   int n, u, v, N;   vector<char> ans(1e5 + 5);   vector<int> sub(1e5 + 5);   vector<set<int> > adj(1e5 + 5);   void dfs(int u, int par) {     sub[u] = 1;     for (int v : adj[u]) {       if (v != par) {         dfs(v, u);         sub[u] += sub[v];       }     }   }   int centroid(int u, int par) {     for (int v : adj[u]) {       if (v != par && sub[v] > n / 2) {         return centroid(v, u);       }     }     return u;   }   void build(int u, int prev, int level) {     dfs(u, -1);     n = sub[u];     int cur = centroid(u, -1);     ans[cur] = char(level + 65);     for (int v : adj[cur]) {       adj[v].erase(cur);       build(v, cur, level + 1);     }   }   int main(void) {     ios ::sync_with_stdio(0);     cin.tie(0);     cin >> n;     N = n;     for (int i = 1; i <= n - 1; ++i) {       cin >> u >> v;       adj[u].insert(v);       adj[v].insert(u);     }     build(1, -1, 0);     for (int i = 1; i <= N; ++i) {       cout << ans[i] <<    ;     }     cout <<   n ;     return 0;   }