#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++) {
for (x = 0; x < W;) {
if (hori_len[y][x] >= T) {
for (len = 0; len < hori_len[y][x]; len++) {
if (vert_len[y][x + len] < S) {
break;
}
}
if (len >= T) {
count += len - T + 1;
}
x += len + 1;
} else if (hori_len[y][x] >= 0) {
x += hori_len[y][x] + 1;
} else {
x -= hori_len[y][x];
}
}
}
answer(count);
}
void resolve_vert(S, T)
int S; // ウィジェットの縦サイズ
int T; // ウィジェットの横サイズ
{
int count, len;
int x, xx, y;
count = 0;
xx = W - T;
for (x = 0; x <= xx; x++) {
for (y = 0; y < H;) {
if (vert_len[y][x] >= S) {
for (len = 0; len < vert_len[y][x]; len++) {
if (hori_len[y + len][x] < T) {
break;
}
}
if (len >= S) {
count += len - S + 1;
}
y += len + 1;
} else if (vert_len[y][x] >= 0) {
y += vert_len[y][x] + 1;
} 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+OBlQoKdm9pZCByZXNvbHZlX2hvcmkoUywgVCkKCWludCBTOyAvLyDjgqbjgqPjgrjjgqfjg4Pjg4jjga7nuKbjgrXjgqTjgroKCWludCBUOyAvLyDjgqbjgqPjgrjjgqfjg4Pjg4jjga7mqKrjgrXjgqTjgroKewoJaW50IGNvdW50LCBsZW47CglpbnQgeCwgeSwgeXk7CgkKCWNvdW50ID0gMDsKCXl5ID0gSCAtIFM7Cglmb3IgKHkgPSAwOyB5IDw9IHl5OyB5KyspIHsKCQlmb3IgKHggPSAwOyB4IDwgVzspIHsKCQkJaWYgKGhvcmlfbGVuW3ldW3hdID49IFQpIHsKCQkJCWZvciAobGVuID0gMDsgbGVuIDwgaG9yaV9sZW5beV1beF07IGxlbisrKSB7CgkJCQkJaWYgKHZlcnRfbGVuW3ldW3gg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