#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 = rap + n * m; while (rap < nm) { RD(t); *rap++ = t; } // b[n] = 1000000000 + 9; int *ap = a; do { int *bp = b; do { *bp++ += *ap++; } while (bp - b < n); // for (int j = 0; j < n; ++j) printf("%d ", b[j]); // printf("\n"); int *left = b; int *right = b; int sm = 0; do { if ((sm += *right++) == TARGET) { printf("YES"); exit(0); } else if (sm > TARGET) { do { sm -= *left++; } while (sm > TARGET); if (sm == TARGET) { printf("YES"); exit(0); } } } while (right < bp); } while (ap < rap); printf("NO"); exit(0); return 0; // }