signedmain() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int t; cin >> t; for (int k = 1; k <= t; k ++) { int n; cin >> n >> s + 1; l[0] = -0x3f3f3f3f, r[n + 1] = 0x3f3f3f3f; for (int i = 1; i <= n; i ++) { if (s[i] == '1') l[i] = i; else l[i] = l[i - 1]; } for (int i = n; i >= 1; i --) { if (s[i] == '1') r[i] = i; else r[i] = r[i + 1]; } LL ans = 0; for (int i = 1; i <= n; i ++) { ans += min(i - l[i], r[i] - i); } cout << "Case #" << k << ": " << ans << endl; } }