foo.cpp:1:1: error: 'include' does not name a type
include <bits/stdc++.h>
^~~~~~~
foo.cpp: In function 'int read()':
foo.cpp:7:29: error: 'getchar' was not declared in this scope
int x=0,f=1;char ch=getchar();
^
foo.cpp: In function 'int main()':
foo.cpp:15:22: error: 'scanf' was not declared in this scope
while (scanf("%d", &n) == 1) {
^
foo.cpp:27:40: error: 'max' was not declared in this scope
ans = max(ans, (s[top] - pos[i]) * h[i]);
^
foo.cpp:30:19: error: 'printf' was not declared in this scope
printf("%d\n", ans);
^
foo.cpp:32:11: error: 'printf' was not declared in this scope
printf("0");
^