malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct pairvar {     int a;     int b;   };   bool isPrime(long long x) {     if (x == 1) {       return false;     }     long long a = (long long)x;     for (int i = 2; i <= (long long)sqrt((double)a); i++) {       if (a % i == 0) {         return false;       }     }     return true;   }   int gcd(int a, int b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   long long factorial(long long x) {     long long sum = 1;     for (long long i = 1; i <= x; i++) {       sum *= i;     }     return sum;   }   int toint(string s) {     int x = 0;     int k = (int)pow(10, (double)s.length() - 1);     for (int i = 0; i < (int)s.length(); i++) {       x += (s[i] -  0 ) * k;       k /= 10;     }     return x;   }   string tostr(int x) {     if (x == 0) {       return  0 ;     }     string s =   ;     bool f = x < 0;     x = abs(x);     while (x != 0) {       s += (x % 10) +  0 ;       x /= 10;     }     string t =   ;     if (f) {       t =  - ;     }     for (int i = s.length() - 1; i >= 0; i--) {       t += s[i];     }     return t;   }   int lcm(int a, int b) { return (a * b) / gcd(a, b); }   string tobin(int a) {     string s;     while (a != 0) {       s +=  0  + (a % 2);       a /= 2;     }     string r =   ;     for (int i = s.length() - 1; i >= 0; i--) {       r += s[i];     }     return r;   }   bool cmp(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first == b.first) {       return a.second < b.second;     }     return a.first < b.first;   }   int cnt[2000005];   int main() {     int n;     cin >> n;     set<int> w;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       w.insert(x);       cnt[x] = i;     }     int mn = 1000000000;     int ans = 0;     for (int i = 0; i < 200005; i++) {       if (cnt[i] < mn && cnt[i] && w.find(i) != w.end()) {         mn = cnt[i];         ans = i;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int f[100010];   int main() {     int x;     cin >> n;     for (int i = 0; i <= n - 1; i++) {       cin >> x;       f[x]++;     }     for (int i = 100000; i >= 0; i--) {       if (f[i] & 1) {         printf( Conan n );         return 0;       }     }     printf( Agasa n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x60000000;   const int MINF = -1000000000;   const int mod = 1000000007;   const int cons = 100001;   const double pi = 3.141592653589793;   const int sqrtMax = 317;   const int blocks = cons / 3;   const int MOD = 100000;   long long dp[1000001];   int ans[5001];   int main() {     int m;     scanf( %d , &m);     for (int n = 1; n <= 50; n++) {       int cnt = 0;       int sum = 0;       memset(dp, 0, sizeof(dp));       for (int i = 0; i <= n; i++) {         for (int j = 0; j <= n; j++) {           for (int k = 0; k <= n; k++) {             for (int p = 0; p <= n; p++) {               if (i + j + k + p == n) {                 sum = i * 1 + j * 5 + k * 10 + p * 50;                 dp[sum]++;                 if (dp[sum] > 1) {                 } else if (dp[sum] == 1)                   cnt++;               }             }           }         }       }       ans[n] = cnt;     }     if (m > 50) {       printf( %lld n , (long long)ans[50] + 49LL * (m - 50));     } else {       printf( %d n , ans[m]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, t;     cin >> n >> t;     string str;     cin >> str;     long long ptr = 0;     while (str[ptr] !=  . ) ptr++;     long long tmp = ptr;     ptr++;     while (ptr < n and str[ptr] <  5 ) ptr++;     if (ptr == n) {       cout << str <<   n ;       return 0;     }     while (t) {       if (str[ptr] <  5 ) {         break;       }       if (str[ptr] >=  5 ) {         str[ptr] =   0 ;         if (str[ptr - 1] !=  . ) {           str[ptr - 1] = str[ptr - 1] + 1;           t--;           ptr--;         } else {           str[ptr - 1] =   0 ;           if (str[ptr - 2] ==  9 ) {             ptr = ptr - 2;             while (ptr >= 0 and str[ptr] ==  9 ) str[ptr--] =  0 ;             if (ptr == -1) {               cout <<  1  << str.substr(0, tmp) <<   n ;               return 0;             }             str[ptr] = str[ptr] + 1;             cout << str.substr(0, tmp) <<   n ;             return 0;           }           str[ptr - 2] += 1;           cout << str.substr(0, tmp) <<   n ;           return 0;         }       }     }     long long len = 0;     while (str[len] !=   0 ) len++;     cout << str.substr(0, len) <<   n ;   }
#include <bits/stdc++.h>   template <class T>   inline T gcd(T a, T b) {     a = abs(a);     b = abs(b);     if (!b) return a;     return __gcd(b, a % b);   }   template <class T>   inline T lcm(T a, T b) {     a = abs(a);     b = abs(b);     return (a / __gcd(a, b)) * b;   }   template <class T>   inline T ncr(T n, T r) {     return n * (n - 1) / r;   }   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n, a;     cin >> n >> a;     double total = ((n - 2) * 180) / float(n);     double temp = total;     double mi = float(180) / n;     double ans = 10000000000;     int loc = -1;     for (int i = 1; i <= n - 2; i++) {       if (abs(temp - a) < ans) {         ans = abs(temp - a);         loc = i;       }       temp -= mi;     }     cout << 1 <<     << loc + 1 <<     << loc + 2;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #include<algorithm>   #include<map>   #include<fstream>   #define ll long long   #define ld long double   #define pb push_back   #define fi first   #define se second   #define endl   n    #define For(i,n) for(long long i=0; i<n; i++)   #define FOR(i,f,l) for(long long i=f; i<l; i++)   #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   #define mod 1000000007      void solve(){     ll n;     cin>>n;     vector<ll> v(n),ans;     For(i,n){       cin>>v[i];     }     if(n==1){       cout<<0<<endl;     }     else{       ans.pb(0);       for(ll i=1; i<n; i++){           if((v[i]&v[i-1])==v[i-1]){               ans.pb(0);           }           else{               ll temp = v[i]^v[i-1];               temp = temp&v[i-1];             //  cout<<i<<endl;              // cout<<temp<<   <<1<<endl;               ans.pb(temp);               v[i] = v[i]+temp;             //  cout<<v[i]<<   <<2<<endl;           }       }       for(ll i=0; i<n; i++){           cout<<ans[i]<<   ;       }       cout<<endl;     }      }         int main(){      fastio      ll t;      cin>>t;      while(t--){        solve();      }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       double a, b, c, d, k;       cin >> a >> b >> c >> d >> k;       if (ceil(a / c) + ceil(b / d) > k) {         cout << -1 << endl;       } else {         cout << ceil(a / c) <<     << ceil(b / d) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9 + 34;   const int N = (int)1e6 + 34;   int p[N], sz[N];   int fnd(int v) { return (p[v] == v ? v : fnd(p[v])); }   void uniq(int v1, int v2) {     v1 = fnd(v1);     v2 = fnd(v2);     if (v1 == v2) return;     p[v1] = v2;     sz[v2] += sz[v1];   }   int a[N];   void solve() {     int n;     cin >> n;     map<int, vector<int>> mp;     for (int i = 0; i < n; i++) {       cin >> a[i];       p[i] = i;       sz[i] = 1;       mp[a[i]].push_back(i);     }     int tot = 0, lst = -1;     int ansL = 1;     int ansK = mp.rbegin()->first;     map<int, int> num;     for (auto it = mp.begin(); it != mp.end(); it++) {       auto v = it->second;       for (int ps : v) {         tot++;         num[1]++;         lst = 1;         if (ps > 0 && a[ps] >= a[ps - 1]) {           int v1 = fnd(ps);           int v2 = fnd(ps - 1);           if (v1 != v2) {             tot--;             num[sz[v1]]--;             num[sz[v2]]--;             uniq(v1, v2);             lst = sz[fnd(ps)];             num[lst]++;           }         }         if (ps + 1 < n && a[ps] >= a[ps + 1]) {           int v1 = fnd(ps);           int v2 = fnd(ps + 1);           if (v1 != v2) {             tot--;             num[sz[v1]]--;             num[sz[v2]]--;             uniq(v1, v2);             lst = sz[fnd(ps)];             num[lst]++;           }         }       }       if (tot == num[lst]) {         int curK = it->first;         int curL = num[lst];         if (curL > ansL || (curL == ansL && curK < ansK)) {           ansL = curL;           ansK = curK;         }       }     }     cout << ansK + 1 <<   n ;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int *a = new int[n];     int max = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       max += a[i];     }     for (int del = 2; del < n; del++) {       int vLeft = n / del;       if (n % del == 0 && vLeft > 2) {         for (int j = 0; j < n; j++) {           int done = 0;           int start = j;           int sum = 0;           while (done < vLeft) {             if (start >= n) start -= n;             sum += a[start];             start += del;             done++;           }           if (sum > max) max = sum;         }       }     }     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace fastIO1 {   inline char read() {     static const int IN_LEN = 1000000;     static char buf[IN_LEN], *s, *t;     return (s == t               ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin),             (s == t ? -1 : *s++) : *s++);   }   template <class T>   inline void read(T &x) {     static bool iosig;     static char c;     for (iosig = false, c = read(); !isdigit(c); c = read()) {       if (c ==  - ) iosig = true;       if (c == -1) return;     }     for (x = 0; isdigit(c); c = read()) x = ((x + (x << 2)) << 1) + (c ^  0 );     if (iosig) x = -x;   }   inline char readc(char &c) {     for (c = read(); !isalpha(c) && !isdigit(c); c = read())       if (c == -1) return 0;   }   const int OUT_LEN = 10000000;   char obuf[OUT_LEN], *ooh = obuf;   inline void print(char c) {     if (ooh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), ooh = obuf;     *ooh++ = c;   }   template <class T>   inline void print(T x) {     static int buf[30], cnt;     if (x == 0)       print( 0 );     else {       if (x < 0) print( - ), x = -x;       for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;       while (cnt) print((char)buf[cnt--]);     }   }   inline void flush() { fwrite(obuf, 1, ooh - obuf, stdout); }   }  // namespace fastIO1   namespace fastIO2 {   template <class T>   inline void read(T &x) {     static bool iosig;     static char c;     for (iosig = false, c = getchar(); !isdigit(c); c = getchar()) {       if (c ==  - ) iosig = true;       if (c == -1) return;     }     for (x = 0; isdigit(c); c = getchar()) x = ((x + (x << 2)) << 1) + (c ^  0 );     if (iosig) x = -x;   }   }  // namespace fastIO2   using namespace fastIO1;   long long n, ans, f[2][(135)][2];   long long calc(int x, int lena, int lenb, long long sum) {     memset(f, 0, sizeof(f)), f[1][0][0] = 1;     int now = 0, pre = 1;     for (int i = 0; (1ll << i) <= sum; i++, now ^= 1, pre ^= 1) {       for (int j = 0; j <= x; j++) f[now][j][0] = f[now][j][1] = 0;       for (int j = 0; j < 2; j++)         if (i < lena || !j)           for (int k = 0; k < 2; k++)             if (i < lenb || !k)               for (int l = 0; l < 2; l++) {                 int S = j + k + l;                 if (((sum >> i) & 1) ^ (S & 1)) continue;                 for (int m = 0; m + j + k <= x; m++)                   f[now][m + j + k][S >> 1] += f[pre][m][l];               }     }     return f[pre][x][0];   }   int main() {     read(n);     for (int i = 0; i <= 60; i++)       for (int j = 0; j <= 60; j++) {         long long mul = (1ll << i + 1) + (1ll << j + 1) - 3;         if (n < mul) break;         long long ret = n % mul - (1ll << j) + 1;         if (ret < 0) continue;         for (int k = (ret & 1); k <= i + j; k += 2)           ans += calc(k, i - 1, j - 1, (ret + k) >> 1);       }     cout << ans;   }
#include<bits/stdc++.h>   using namespace std;      #define sz(s) (int)s.size()   #define f first   #define s second   #define pb push_back   #define all(s) s.begin(), s.end()      #define vi vector<int>   #define vvi vector<vi>      #define ll long long   #define vll vector<ll>      #define ii pair<int, int>   #define vii vector<ii>   #define vvii vector<vii>      const int INF = 1e9 + 7;   const int mod = 1e9 + 7;   const int N = 1e6 + 7;   const int T = 1 << 20;   #define ld long double      int n;      int suma[T + T];   int maxi[T + T];      void set_val(int poz, int val){       poz += T;       suma[poz] = val;       maxi[poz] = max(val, 0);       poz /= 2;          while(poz > 0){           suma[poz] = suma[poz + poz] + suma[poz + poz + 1];           maxi[poz] = max(maxi[poz + poz + 1], suma[poz + poz + 1] + maxi[poz + poz]);           poz /= 2;       }   }      int max_suf(int poz){       poz += T;       int ret = 1;       int temp_suma = 1;          while(poz > 0){           if(poz % 2 == 1){               ret = max(ret, maxi[poz - 1] + temp_suma);               temp_suma += suma[poz - 1];           }           poz /= 2;       }          return ret;   }      vector<int> policz(vector<int> tab){       for(auto & u : tab)           assert(u >= 0 and u <= n);          for(int i = 0; i < T + T; i++)           suma[i] = maxi[i] = 0;          for(int i = T; i < T + n; i++)           suma[i] = maxi[i] = 1;       for(int i = T - 1; i > 0; i--)           suma[i] = maxi[i] = suma[i + i] + suma[i + i + 1];          vector<vector<int> > values(n + 1);          for(int i = 0; i < n; i++)           values[tab[i]].pb(i);          vector<int> ret(n);          for(int i = 0; i <= n; i++){           for(auto & poz : values[i])               ret[poz] = max_suf(poz);           for(auto & poz : values[i])               set_val(poz, -1);       }       return ret;   }      void solve(){       cin >> n;          vector<int> tab(n);       for(int i = 0; i < n; i++)           cin >> tab[i];          // for(auto & u : tab)       //     cout << u <<    ;       // cout << endl;          vector<int> ans(n);          for(int faza = 0; faza < 2; faza++){           // cout <<  Tab:  ;           // for(auto & u : tab)               // cout << u <<    ;           // cout << endl;           auto a = policz(tab);           reverse(all(tab));           auto b = policz(tab);           reverse(all(b));           reverse(all(tab));              // cout <<  a :  ;           // for(auto & u : a)           //     cout << u <<    ;           // cout << endl;           // cout <<  b :  ;           // for(auto & u : b)           //     cout << u <<    ;           // cout << endl;                      for(int i = 0; i < n; i++)               ans[i] = max(ans[i], (a[i] + b[i] - 1 - faza) / 2);                  for(auto & u : tab)               u = -u + n;           }          for(int i = 0; i < n; i++)           cout << ans[i] <<    ;       cout <<   n ;   }      signed main(){       ios::sync_with_stdio(0);       cin.tie(0);          int test = 1;       // cin >> test;          for(int i = 0; i < test; i++)           solve();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10, mod = 998244353;   int mu[maxn], n, m, l[51], r[51], prime[maxn], cnt;   bool is_composite[maxn];   int dp[maxn], pre[maxn];   int cal(int d) {     int M = m / d;     for (int i = 1; i <= M; i++) dp[i] = 0;     dp[0] = 1;     for (int i = 1; i <= n; i++) {       int L = (l[i] + d - 1) / d, R = r[i] / d;       if (L > R) return 0;       pre[0] = dp[0];       for (int j = 1; j <= M; j++) pre[j] = (pre[j - 1] + dp[j]) % mod;       for (int j = 0; j <= M; j++) {         dp[j] = (((j - L >= 0) ? pre[j - L] : 0) -                  ((j - R - 1 >= 0) ? pre[j - R - 1] : 0)) %                 mod;       }     }     pre[0] = dp[0];     for (int j = 0; j <= M; j++) pre[j] = (pre[j - 1] + dp[j]) % mod;     return pre[M];   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) scanf( %d%d , &l[i], &r[i]);     mu[1] = 1;     for (int i = 2; i <= m; i++) {       if (!is_composite[i]) {         prime[++cnt] = i;         mu[i] = mod - 1;       }       for (int j = 1; j <= cnt && i * prime[j] <= m; j++) {         is_composite[i * prime[j]] = true;         if (i % prime[j])           mu[i * prime[j]] = (mod - mu[i]) % mod;         else           break;       }     }     int ans = 0;     for (int d = 1; d <= m; d++) {       ans = (ans + 1LL * cal(d) * mu[d]) % mod;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 100000;   typedef struct P {     int x, y;     P() {}     P(int x, int y) : x(x), y(y) {}   } P;   bool operator<(const P &a, const P &b) {     if (a.x != b.x) return a.x < b.x;     return a.y > b.y;   }   P operator-(const P &a, const P &b) { return P(a.x - b.x, a.y - b.y); }   long long operator^(const P &a, const P &b) {     return (long long)a.x * b.y - (long long)a.y * b.x;   }   int side(const P &a, const P &b, const P &c) {     long long ret = (b - a) ^ (c - a);     return ret < 0 ? -1 : ret > 0 ? +1 : 0;   }   void makehull(int &n, P p[MAXN + 2]) {     sort(p, p + n);     int nh = 0;     for (int i = (0); i < (n); ++i) {       while (nh >= 2 && side(p[nh - 2], p[nh - 1], p[i]) >= 0) --nh;       p[nh++] = p[i];     }     n = nh;   }   int n[2];   P s;   P p[2][MAXN + 2];   void run() {     for (int i = (0); i < (2); ++i) scanf( %d , &n[i]);     scanf( %d%d , &s.x, &s.y);     for (int i = (0); i < (2); ++i)       for (int j = (0); j < (n[i]); ++j) scanf( %d%d , &p[i][j].x, &p[i][j].y);     for (int i = (0); i < (2); ++i) {       int hx = p[i][0].x;       for (int j = (1); j < (n[i]); ++j)         if (p[i][j].x > hx) hx = p[i][j].x;       p[i][n[i]].x = hx, p[i][n[i]].y = 0, ++n[i];     }     for (int i = (0); i < (2); ++i) {       int hy = p[i][0].y;       for (int j = (1); j < (n[i]); ++j)         if (p[i][j].y > hy) hy = p[i][j].y;       p[i][n[i]].x = 0, p[i][n[i]].y = hy, ++n[i];     }     for (int i = (0); i < (2); ++i) makehull(n[i], p[i]);     int j = 0;     for (int i = (0); i < (n[0]); ++i) {       while (j + 2 < n[1] && p[1][j + 1] < p[0][i]) ++j;       if (side(p[1][j], p[0][i], p[1][j + 1]) <= 0) {         printf( Max n );         return;       }     }     printf( Min n );   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   char s[2000005];   int sign[2000005], o[2000005], n, m, L;   int main() {     scanf( %s , s), n = strlen(s), m = 0;     for (int i = 0; i < n; i++) {       int x = s[n - 1 - i] - 48;       if (x) {         if (m == 1) o[L++] = i - 1;         m += m < 2;       } else if (m == 1)         sign[L] = 1, o[L++] = i + m - 2, m = 0;       else if (m == 2)         m--;     }     if (m) sign[L] = 1, o[L++] = n + m - 2;     printf( %d n , L);     for (int i = 0; i < L; i++) printf( %c2^%d n , sign[i] ?  +  :  - , o[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 5;   int n, q, num, b0[N], b[N], c[2][N], ans[N];   struct data {     int p, s, b;   } a[N];   struct qry {     int x, y, id;   } Q[N];   bool cmp(qry a, qry b) { return a.x < b.x; }   bool cmp1(data a, data b) { return a.p < b.p; }   bool cmp2(data a, data b) { return a.s < b.s; }   void mdf(int *c, int o, int x) {     while (o <= num) c[o] += x, o += (o & -o);   }   int qry(int *c, int o) {     int s = 0;     while (o) s += c[o], o -= (o & -o);     return s;   }   int calc(int x, int y) {     int res = 0;     res += qry(c[0], upper_bound(b + 1, b + num + 1, x + y) - b - 1);     res += qry(c[1], upper_bound(b + 1, b + num + 1, x - y) - b - 1);     return res - qry(c[0], num);   }   int main() {     scanf( %d%d , &n, &q);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i].p);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i].s);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i].b);     for (int i = (1); i <= (n); ++i)       b0[i] = a[i].p + a[i].b, b0[i + n] = a[i].p - a[i].b;     sort(b0 + 1, b0 + n * 2 + 1);     b[++num] = b0[1];     for (int i = (2); i <= (n << 1); ++i)       if (b0[i] != b0[i - 1]) b[++num] = b0[i];     for (int i = (1); i <= (q); ++i) scanf( %d , &Q[i].x);     for (int i = (1); i <= (q); ++i) scanf( %d , &Q[i].y);     for (int i = (1); i <= (q); ++i) Q[i].id = i;     sort(Q + 1, Q + q + 1, cmp);     sort(a + 1, a + n + 1, cmp1);     int j = 1;     for (int i = (1); i <= (q); ++i) {       while (j <= n && a[j].p <= Q[i].x) {         int x = lower_bound(b + 1, b + num + 1, a[j].p + a[j].b) - b;         int y = lower_bound(b + 1, b + num + 1, a[j].p - a[j].b) - b;         mdf(c[0], x, 1), mdf(c[1], y, 1), ++j;       }       ans[Q[i].id] += calc(Q[i].x, Q[i].y);     }     memset(c, 0, sizeof(c));     sort(a + 1, a + n + 1, cmp2);     j = 1;     for (int i = (1); i <= (q); ++i) {       while (j <= n && a[j].s < Q[i].x) {         int x = lower_bound(b + 1, b + num + 1, a[j].p + a[j].b) - b;         int y = lower_bound(b + 1, b + num + 1, a[j].p - a[j].b) - b;         mdf(c[0], x, 1), mdf(c[1], y, 1), ++j;       }       ans[Q[i].id] -= calc(Q[i].x, Q[i].y);     }     for (int i = (1); i <= (q); ++i) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   const int maxm = 3e5 + 10;   vector<pair<int, int> > g[maxn];   stack<int> S;   struct edge {     int x, y;   } e[maxm];   int n, m, cnt, dfn;   int d[maxn], low[maxn], fa[maxn], pre[maxn];   void tarjan(int now, int f) {     d[now] = low[now] = ++dfn;     S.push(now);     for (int i = 0; i < g[now].size(); i++) {       int son = g[now][i].first, id = g[now][i].second;       if (id == f) continue;       if (!d[son]) {         fa[son] = now;         tarjan(son, id);         low[now] = min(low[now], low[son]);       } else         low[now] = min(low[now], d[son]);     }     if (low[now] > d[fa[now]]) {       cnt++;       while (!S.empty()) {         int x = S.top();         pre[x] = cnt;         S.pop();         if (x == now) break;       }     }   }   int pos, far;   void dfs(int now, int f, int dep) {     if (dep > far) {       far = dep;       pos = now;     }     for (int i = 0; i < g[now].size(); i++) {       int son = g[now][i].first;       if (son == f) continue;       dfs(son, now, dep + 1);     }   }   void init() {     dfn = cnt = 0;     while (!S.empty()) S.pop();     memset(d, 0, sizeof d);     memset(low, 0, sizeof low);     for (int i = 1; i <= n; i++) g[i].clear();   }   void input() {     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       g[x].push_back({y, i});       g[y].push_back({x, i});       e[i] = (edge){x, y};     }   }   int main() {     while (cin >> n >> m) {       if (n == 0 && m == 0) break;       init();       input();       tarjan(1, 0);       for (int i = 1; i <= n; i++) g[i].clear();       for (int i = 1; i <= m; i++) {         int u = e[i].x, v = e[i].y;         if (pre[u] != pre[v]) {           u = pre[u];           v = pre[v];           g[u].push_back({v, 0});           g[v].push_back({u, 0});         }       }       far = pos = 0;       dfs(1, 0, 0);       int s = pos;       far = pos = 0;       dfs(s, 0, 0);       cout << far << endl;     }     return 0;   }