func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace io {   const int SIZE = (1 << 21) + 1;   char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,                                          qu[55];   int f, qr;   inline void flush() {     fwrite(obuf, 1, oS - obuf, stdout);     oS = obuf;   }   inline void putc(char x) {     *oS++ = x;     if (oS == oT) flush();   }   template <class I>   inline void read(I &x) {     for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                                 (iS == iT ? EOF : *iS++))                               : *iS++);          c <  0  || c >  9 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       if (c ==  - ) f = -1;     for (x = 0; c <=  9  && c >=  0 ;          c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),                          (iS == iT ? EOF : *iS++))                        : *iS++))       x = x * 10 + (c & 15);     x *= f;   }   template <class I>   inline void print(I &x) {     if (!x) putc( 0 );     if (x < 0) putc( - ), x = -x;     while (x) qu[++qr] = x % 10 +  0 , x /= 10;     while (qr) putc(qu[qr--]);   }   struct Flusher_ {     ~Flusher_() { flush(); }   } io_flusher_;   }  // namespace io   using io ::print;   using io ::putc;   using io ::read;   struct node {     int nxt;     long long cnt;   } s[100005];   int a[15][100005];   int main() {     int i, j, k;     int n, m;     read(n), read(m);     for (i = 1; i <= m; i++)       for (j = 1; j <= n; j++) read(a[i][j]);     for (i = 1; i < n; i++) {       s[a[1][i]].nxt = a[1][i + 1];       s[a[1][i]].cnt = 1;     }     for (int i = (int)2; i <= (int)m; i++)       for (int j = (int)1; j <= (int)n - 1; j++)         if (s[a[i][j]].nxt == a[i][j + 1]) s[a[i][j]].cnt++;     long long sum = 1, ans = 0;     for (int i = (int)1; i <= (int)n - 1; i++) {       if (s[a[1][i]].cnt != m)         ans += sum * (sum + 1) / 2, sum = 1;       else         sum++;     }     if (sum > 0) ans += sum * (sum + 1) / 2;     cout << ans << endl;     return 0;   }   