#include using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define DEBUG #define int long long #define INF 1e18 template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template ostream& operator << (ostream &s, pair P) { return s << '<' << P.first << ", " << P.second << '>'; } template ostream& operator << (ostream &s, vector P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template ostream& operator << (ostream &s, vector > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template ostream& operator << (ostream &s, set P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template ostream& operator << (ostream &s, map P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } templatevoid show(vectorv){for (int i = 0; i < v.size(); i++){cerr<>n>>k; k--; vectora(n); REP(i,n) cin>>a[i]; int index1=0; if(k-1>=0){ for (size_t i = k-1; i>=0; i--) { if(a[i]==0){ index1=i+1; break; } if(a[i]==1){ index1=i; break; } } } int index2=n-1; if(k+1=0){ for (size_t i = k-1; i >=index1; i--) { cnt1+=a[i]; // cerr<