#include <stdio.h>
void answer(int count) {
}
#define Y_SIZE (300)
#define X_SIZE (300)
int H; // ホーム画面縦の区画数
int W; // ホーム画面横の区画数
int array[Y_SIZE][X_SIZE]; // ホーム画面の配置
int vert_len[Y_SIZE][X_SIZE]; // 縦方向の区画の長さ
int hori_len[Y_SIZE][X_SIZE]; // 横方向の区画の長さ
void resolve_hori(S, T)
int S; // ウィジェットの縦サイズ
int T; // ウィジェットの横サイズ
{
int count, len;
int x, y, yy;
count = 0;
yy = H - S;
for (y = 0; y <= yy; y++) {
len = 0;
for (x = 0; x < W;) {
if ((!len && hori_len[y][x] >= T) || (len && hori_len[y][x] > 0)) {
if (vert_len[y][x] >= S) {
if (++len >= T) {
count++;
}
} else {
len = 0;
}
x++;
} else {
len = 0;
if (hori_len[y][x] > 0) {
x += hori_len[y][x];
} else {
x -= hori_len[y][x];
}
}
}
}
answer(count);
}
void resolve_vert(S, T)
int S; // ウィジェットの縦サイズ
int T; // ウィジェットの横サイズ
{
int count, len;
int x, y, xx;
count = 0;
xx = W - T;
for (x = 0; x <= xx; x++) {
len = 0;
for (y = 0; y < H;) {
if ((!len && vert_len[y][x] >= S) || (len && vert_len[y][x] > 0)) {
if (hori_len[y][x] >= T) {
if (++len >= S) {
count++;
}
} else {
len = 0;
}
y++;
} else {
len = 0;
if (vert_len[y][x] > 0) {
y += vert_len[y][x];
} else {
y -= vert_len[y][x];
}
}
}
}
answer(count);
}
void resolve(S, T)
int S; // ウィジェットの縦サイズ
int T; // ウィジェットの横サイズ
{
if (S < T) {
resolve_hori(S, T);
} else {
resolve_vert(S, T);
}
}
int main(void) {
char str[305];
int N, s, t;
int x, y, i;
int len;
for (y = 0; y < H; y++) {
for (x = 0; x < W; x++) {
array[y][x] = (int)(str[x] - '0');
}
}
for (x = 0; x < W; x++) {
len = 0;
for (y = H - 1; y >= 0; y--) {
if (array[y][x]) {
if (len > 0) {
len = 0;
}
len--;
} else {
if (len < 0) {
len = 0;
}
len++;
}
vert_len[y][x] = len;
}
}
for (y = 0; y < H; y++) {
len = 0;
for (x = W - 1; x >= 0; x--) {
if (array[y][x]) {
if (len > 0) {
len = 0;
}
len--;
} else {
if (len < 0) {
len = 0;
}
len++;
}
hori_len[y][x] = len;
}
}
for (i = 0; i < N; i++) {
resolve(s, t);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGFuc3dlcihpbnQgY291bnQpIHsKCXByaW50ZigiJWRcbiIsIGNvdW50KTsKfQoKI2RlZmluZSBZX1NJWkUgKDMwMCkKI2RlZmluZSBYX1NJWkUgKDMwMCkKCmludCBIOyAvLyDjg5vjg7zjg6DnlLvpnaLnuKbjga7ljLrnlLvmlbAKaW50IFc7IC8vIOODm+ODvOODoOeUu+mdouaoquOBruWMuueUu+aVsAppbnQgYXJyYXlbWV9TSVpFXVtYX1NJWkVdOyAvLyDjg5vjg7zjg6DnlLvpnaLjga7phY3nva4KaW50IHZlcnRfbGVuW1lfU0laRV1bWF9TSVpFXTsgLy8g57im5pa55ZCR44Gu5Yy655S744Gu6ZW344GVCmludCBob3JpX2xlbltZX1NJWkVdW1hfU0laRV07IC8vIOaoquaWueWQkeOBruWMuueUu+OBrumVt+OBlQoKdm9pZCByZXNvbHZlX2hvcmkoUywgVCkKCWludCBTOyAvLyDjgqbjgqPjgrjjgqfjg4Pjg4jjga7nuKbjgrXjgqTjgroKCWludCBUOyAvLyDjgqbjgqPjgrjjgqfjg4Pjg4jjga7mqKrjgrXjgqTjgroKewoJaW50IGNvdW50LCBsZW47CglpbnQgeCwgeSwgeXk7CgkKCWNvdW50ID0gMDsKCXl5ID0gSCAtIFM7Cglmb3IgKHkgPSAwOyB5IDw9IHl5OyB5KyspIHsKCQlsZW4gPSAwOwoJCWZvciAoeCA9IDA7IHggPCBXOykgewoJCQlpZiAoKCFsZW4gJiYgaG9yaV9sZW5beV1beF0gPj0gVCkgfHwgKGxlbiAmJiBob3JpX2xlblt5XVt4XSA+IDApKSB7CgkJCQlpZiAodmVydF9s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