#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #include #include #include // clang-format off #define RD(v) int v=0;{int _c,sign=0;for(;;){if(*rp=='-'){sign=1;rp++;}else{_c=*rp++-48;if(_c>=0)v=v*10+_c;else break;}}if(sign)v=-v;} // // clang-format on int a[1000 * 1000]; int b[1001]; #define TARGET 777 int main() { char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll); RD(n) RD(m); int *rap = a; int nm = n * m; for (int i = 0; i < nm; ++i) { RD(t); *rap++ = t; } // b[n] = 1000000000 + 9; int *ap = a; while (ap < rap) { int *bp = b; while (bp - b < n) *bp++ += *ap++; // for (int j = 0; j < n; ++j) printf("%d ", b[j]); // printf("\n"); int *left = b; int sm = 0; for (int *right = b; right < bp; ++right) { sm += *right; if (sm == TARGET) { printf("YES"); exit(0); } else if (sm > TARGET) { do { sm -= *left; left++; } while (sm > TARGET); if (sm == TARGET) { printf("YES"); exit(0); } } } } printf("NO"); exit(0); return 0; // }