Create a new link on your bookmark bar with the following URL:
javascript:for(var data="",inputs=document.querySelectorAll(".input pre"),i=0;i<inputs.length;i++){var s=inputs[i].innerHTML;s=s.replace(/<br>/g,"\n"),s=s.replace(/\n*$/,"\n\n");var div=document.createElement("div");div.innerHTML=s,s=div.textContent,data+=s}var a=document.createElement("a");a.setAttribute("href","data:text/plain,"+encodeURIComponent(data)),a.setAttribute("download","tests.txt"),document.body.appendChild(a),a.click();
which is a minified version of this:
var data = "";
var inputs = document.querySelectorAll(".input pre");
for (var i = 0; i < inputs.length; i++) {
var s = inputs[i].innerHTML;
// fix spacing
s = s.replace(/<br>/g, "\n");
s = s.replace(/\n*$/, "\n\n");
// decode html entities
var div = document.createElement("div");
div.innerHTML = s;
s = div.textContent;
data += s;
}
var a = document.createElement("a");
a.setAttribute("href", "data:text/plain," + encodeURIComponent(data));
a.setAttribute("download", "tests.txt");
document.body.appendChild(a);
a.click();
Clicking this bookmark will download a file with all the sample tests from currently opened problem statement.
You can run your solution with all the sample inputs like this:
int main() {
#ifndef ONLINE_JUDGE
freopen("tests.txt", "r", stdin);
#endif
int n;
while (cin >> n) {
// solve
}
return 0;
}
Cheers!