buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
<?php
$inputs = str_split(file_get_contents("php://stdin"));
echo array_reduce($inputs, function($prev, $cur) {
if ($cur === "B") {
return strlen($prev) == 0 ? $prev : substr($prev, 0, -1);
} else if ($cur === "0" || $cur === "1"){
return $prev.$cur;
}
}, "");
| <?php
$inputs = str_split(file_get_contents("php://stdin"));
echo array_reduce($inputs, function($prev, $cur) {
if ($cur === "B") {
return strlen($prev) == 0 ? $prev : substr($prev, 0, -1);
} else {
return $prev.$cur;
}
}, ""); | [["-", 8, 9, 0, 57, 75, 76, 8, 57, 0, 121], ["-", 0, 57, 75, 76, 8, 57, 15, 23, 0, 24], ["-", 15, 23, 0, 16, 31, 16, 31, 606, 0, 607], ["-", 15, 23, 0, 16, 31, 16, 31, 606, 0, 141], ["-", 8, 57, 15, 23, 0, 16, 31, 16, 17, 565], ["-", 15, 23, 0, 16, 31, 16, 12, 609, 0, 62], ["-", 15, 23, 0, 16, 31, 16, 12, 609, 0, 610],... | 6 | 95 |
// B.
#include <iostream>
#include <sstream>
using namespace std;
int main(int argc, char *argv[]) {
string s, ans;
cin >> s;
for (char c : s) {
if (c == 'B') {
if (!ans.empty()) {
ans = ans.substr(1);
}
} else {
ans += c;
}
}
cout << ans << endl;
return 0;
}
| // B.
#include <iostream>
#include <sstream>
using namespace std;
int main(int argc, char *argv[]) {
string s, ans;
cin >> s;
for (char c : s) {
if (c == 'B') {
if (!ans.empty()) {
ans = ans.substr(0, ans.length() - 1);
}
} else {
ans += c;
}
}
cout << ans << endl;
r... | [["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 17, 131], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 119, 120], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 11, 12, 2, 3, 4... | 1 | 87 |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<char> cc;
string s;
cin >> s;
int sl = s.size();
for (int i = 0; i < sl; i++) {
if (s[i] == '0') {
cc.push_back('0');
} else if (s[i] == '1') {
cc.push_back('1');
} else {
if (s.empty()) {
} else {
... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<char> cc;
string s;
cin >> s;
int sl = s.size();
for (int i = 0; i < sl; i++) {
if (s[i] == '0') {
cc.push_back('0');
} else if (s[i] == '1') {
cc.push_back('1');
} else {
if (cc.size() != 0)
cc.pop_back()... | [["-", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 75, 76, 0, 9, 0, 57, 64, 9, 0... | 1 | 149 |
#include <iostream>
using namespace std;
int main() {
string input, answer = {};
cin >> input;
for (int i = 0; i < input.size(); i++) {
switch (input[i]) {
case '0':
answer += input[i];
break;
case '1':
answer += input[i];
break;
case 'B':
answer.pop_back();
}
... |
#include <iostream>
using namespace std;
int main() {
string input, answer = {};
cin >> input;
for (int i = 0; i < input.size(); i++) {
switch (input[i]) {
case '0':
answer += input[i];
break;
case '1':
answer += input[i];
break;
case 'B':
if (answer.size())
... | [["+", 0, 99, 8, 9, 0, 100, 0, 57, 0, 121], ["+", 8, 9, 0, 100, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["... | 1 | 101 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
string ans;
cin >> s;
for (int i = 0; i < (int)s.length(); i++) {
if (s[i] == '0') {
ans += '0';
} else if (s[i] == '1') {
ans += '1';
} else {
if (!ans.empty())
ans.erase(i - 1);
}
}
cout << ans... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
string ans;
cin >> s;
for (int i = 0; i < (int)s.length(); i++) {
if (s[i] == '0') {
ans += '0';
} else if (s[i] == '1') {
ans += '1';
} else {
if (!ans.empty()) {
ans.erase(ans.end() - 1);
}
}... | [["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45], ["-", 64, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 17, 131], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 119, 120], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25], ["+", 75, 76, 0, 9, 0... | 1 | 114 |
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
while (s.find("B") != string::npos) {
if (!s.empty()) {
if (s.find("B") == 0) {
s.erase(0, 1);
} else {
s.erase(s.find("B") - 1, s.find("B") + 1);
}
}
}
c... | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
while (s.find("B") != string::npos) {
if (!s.empty()) {
if (s.find_first_of("B") == 0) {
s.erase(0, 1);
} else {
s.erase(s.find_first_of("B") - 1, 2);
}
}
}... | [["-", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["-", 3, 4, 0, 16, 31, 2, 63, 118, 119, 120], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 119, 120], ["-", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22], ["-", 3, 4, 0, 16, 31, 2, 63, 118, 17, 131], ["-", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24]... | 1 | 112 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
char y[10];
cin >> x;
int s = 0;
for (int i = 0; i < x.size(); i++) {
if (x[i] == '0' || x[i] == '1') {
y[s] = x[i];
s++;
} else {
for (int j = s - 1; j >= 0; j--)
if (y[j] == '0' || y[j] == '1')
... | #include <bits/stdc++.h>
using namespace std;
int main() {
string x;
char y[10];
cin >> x;
int s = 0;
for (int i = 0; i < x.size(); i++) {
if (x[i] == '0' || x[i] == '1') {
y[s] = x[i];
s++;
} else {
for (int j = s - 1; j >= 0; j--)
if (y[j] == '0' || y[j] == '1') {
... | [["+", 0, 9, 0, 7, 8, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 7, 8, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 57, 64, 9, 0, 93, 0, 35], ["+", 8, 57, 64, 9, 0, 1, 0, 16, 31, 22], ["+", 8, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 64, 9, 0, 1, 0, 16, 12, 5... | 1 | 183 |
from collections import deque
s = str(input())
b = deque()
for i in range(len(s)):
if s[0] == "B":
pass
elif s[i] == "0":
b.append("0")
elif s[i] == "1":
b.append("1")
elif s[i] == "B":
if len(b) == 0:
pass
else:
b.pop()
print("".join(ma... | from collections import deque
s = str(input())
b = deque()
for i in range(len(s)):
if s[i] == "0":
b.append("0")
elif s[i] == "1":
b.append("1")
elif s[i] == "B":
if len(b) == 0:
pass
else:
b.pop()
print("".join(map(str, b)))
| [["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 612], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6], ["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 1... | 5 | 116 |
#include <stdio.h>
int main(int argc, char *argv[]) {
char S[32], Ans[32] = {0};
int i, n = 0;
fgets(S, 32, stdin);
for (i = 0; S[i] != '\n'; i++) {
if (S[i] == 'B') {
if (n > 0) {
n--;
}
} else {
Ans[n++] = S[i];
}
}
printf("%s\n", Ans);
return 0;
} | #include <stdio.h>
int main(int argc, char *argv[]) {
char S[32], Ans[32] = {0};
int i, n = 0;
fgets(S, 32, stdin);
for (i = 0; S[i] != '\n'; i++) {
if (S[i] == 'B') {
if (n > 0) {
n--;
}
} else {
Ans[n++] = S[i];
}
}
Ans[n] = '\0';
printf("%s\n", Ans);
return 0;
} | [["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 0, 70], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 0, 73], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 44], ["+", 0, 30, 0, 14, 8, 9, 0... | 0 | 118 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define fol(i, n) for (int i = 0; i < n; i++)
int main() {
string N, M;
cin >> N;
fol(i, N.size()) {
if (N[i] == '0')
M += '0... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define fol(i, n) for (int i = 0; i < n; i++)
int main() {
string N, M;
cin >> N;
fol(i, N.size()) {
if (N[i] == '0')
M += '0'... | [["+", 75, 76, 0, 57, 75, 76, 0, 57, 0, 121], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25],... | 1 | 104 |
// ABC043B
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <string>
using namespace std;
int main() {
string s;
list<char> st;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '0' || s[i] == '1') {
st.push_back(s[i]);
} else if (s[i] == 'B') {
... | // ABC043B
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <string>
using namespace std;
int main() {
string s;
list<char> li;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '0' || s[i] == '1') {
li.push_back(s[i]);
} else if (s[i] == 'B') {
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 15, 339, 51, 91, 28, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 28, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 30, ... | 1 | 158 |
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
string s;
cin >> s;
vector<char> v;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'B') {
v.pop_back();
} else {
v.push_back(s[i]);
}
}
for (int i = 0; i < v.size(); i++) {
cout << v[i];
}
cout <<... | #include <iostream>
#include <vector>
using namespace std;
int main(void) {
string s;
cin >> s;
vector<char> v;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'B') {
if (v.size())
v.pop_back();
} else {
v.push_back(s[i]);
}
}
for (int i = 0; i < v.size(); i++) {
cout ... | [["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+... | 1 | 111 |
#include <algorithm>
#include <iostream>
#include <stack>
using namespace std;
int main() {
string s;
stack<char> ans;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'B') {
if (!ans.empty()) {
ans.pop();
}
} else
ans.push(s[i]);
}
while (!ans.empty()) {
c... | #include <algorithm>
#include <iostream>
#include <list>
#include <stack>
using namespace std;
int main() {
string s;
list<char> ans;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'B') {
if (!ans.empty()) {
ans.pop_back();
}
} else
ans.push_back(s[i]);
}
whi... | [["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["-", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["-", 75, 76, 0, 1, 0, 2, 63, 118, 119, 120],... | 1 | 119 |
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
char buf[20];
char res[20];
int main(void) {
scanf("%s", buf);
int n = 0;
for (int i = 0; buf[i]; ++i) {
if (buf[i] == 'B') {
if (n > 0) {
--n;
}
} else {
res[n++] = buf[i]++;
}
}... |
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
char buf[20];
char res[20];
int main(void) {
scanf("%s", buf);
int n = 0;
for (int i = 0; buf[i]; ++i) {
if (buf[i] == 'B') {
if (n > 0) {
--n;
}
res[n] = 0;
} else {
res[n++] = b... | [["+", 64, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 111 |
#include <iostream>
#include <math.h>
#include <unordered_map>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() {
string S;
cin >> S;
string codes;
for (int i = 0; i < S.length(); i++) {
if (S[i] == 'B') {
codes.pop_back();
} else {
codes.push_back(S[i]);
... | #include <iostream>
#include <math.h>
#include <unordered_map>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() {
string S;
cin >> S;
string codes;
for (int i = 0; i < S.length(); i++) {
if (S[i] == 'B') {
if (codes.length() != 0) {
codes.pop_back();
}... | [["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25]... | 1 | 100 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define PI acos(-1.0)
#define FOR(I, A, B) ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define PI acos(-1.0)
#define FOR(I, A, B) ... | [["+", 0, 9, 0, 57, 75, 76, 0, 57, 0, 121], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["+", 75, 76, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 2... | 1 | 160 |
#include <cstdlib>
#include <iostream>
#include <string>
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::string s;
std::cin >> s;
std::string answer = s;
for (decltype(s)::size_type i = 0, j = 0; i < s.length(); i++) {
if (s[i] != 'B') {
answer[j++] = s[i];
} else if (j ... | #include <cstdlib>
#include <iostream>
#include <string>
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::string s;
std::cin >> s;
std::string answer = s;
decltype(s)::size_type j = 0;
for (decltype(j) i = 0; i < s.length(); i++) {
if (s[i] != 'B') {
answer[j++] = s[i];
... | [["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 24], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 30, 0, 14, 8, 9, 0, 7,... | 1 | 137 |
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long int
#define ALL(x) x.begin(), x.end()
using namespace std;
ll ans = 0, sum = 0... | #include <bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long int
#define ALL(x) x.begin(), x.end()
using namespace std;
ll ans = 0, sum = 0, ... | [["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0... | 1 | 278 |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
std::vector<int> v;
string s;
cin >> s;
for (int i = 0; i < (int)s.length(); i++) {
if (s[i] == '0')
v.push_back(0);
else if (s[i] == '1')
v.push_back(1);
else
v.pop_back();
... | #include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
std::vector<int> v;
string s;
cin >> s;
for (int i = 0; i < (int)s.length(); i++) {
if (s[i] == '0')
v.push_back(0);
else if (s[i] == '1')
v.push_back(1);
else if (v.size() > 0)
... | [["+", 75, 76, 0, 57, 75, 76, 0, 57, 0, 121], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0,... | 1 | 140 |
#include <bits/stdc++.h>
using namespace std;
#define lli long long
#define FOR(i, a, b) for (lli i = (a); i < (b); i++)
#define REP(i, n) for (lli i = 0; i < (n); i++)
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define INF LONG_MAX / 3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(), (a).en... | #include <bits/stdc++.h>
using namespace std;
#define lli long long
#define FOR(i, a, b) for (lli i = (a); i < (b); i++)
#define REP(i, n) for (lli i = 0; i < (n); i++)
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define INF LONG_MAX / 3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(), (a).en... | [["-", 15, 339, 51, 91, 28, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 119, 120], ["-", 64, 57, 64, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 57, 64, 1, 0, 2, 63, 118, 119, 120], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 17, 131], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 1... | 1 | 160 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
string c;
cin >> c;
for (int i = 0; i < c.size(); i++) {
if (c[i] == '1') {
s += "1";
} else if (c[i] == '0') {
s += "0";
} else if (c[i] == 'B') {
s.erase(s.end() - 1);
}
}
cout << s << endl;
retur... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
string c;
cin >> c;
for (int i = 0; i < c.size(); i++) {
if (c[i] == '1') {
s += "1";
} else if (c[i] == '0') {
s += "0";
} else if (c[i] == 'B') {
if (!s.empty())
s.erase(s.end() - 1);
}
}
cou... | [["+", 75, 76, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 64, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 25... | 1 | 117 |
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
... | #include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
... | [["+", 0, 57, 15, 339, 51, 16, 31, 91, 17, 111], ["+", 51, 16, 31, 91, 28, 2, 63, 118, 28, 22], ["+", 51, 16, 31, 91, 28, 2, 63, 118, 17, 131], ["+", 51, 16, 31, 91, 28, 2, 63, 118, 119, 120], ["+", 51, 16, 31, 91, 28, 2, 3, 4, 0, 24], ["+", 51, 16, 31, 91, 28, 2, 3, 4, 0, 25], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 9... | 1 | 314 |
package main
import (
"fmt"
)
func main() {
var input string
fmt.Scan(&input)
inputRune := []rune(input)
var outputRune []rune
for ip := range inputRune {
switch inputRune[ip] {
case 'B':
outputRune = outputRune[:len(outputRune)-1]
default:
outputRune = append(outputRune, inputRune[ip])
}
}
fmt.... | package main
import (
"fmt"
)
func main() {
var input string
fmt.Scan(&input)
inputRune := []rune(input)
var outputRune []rune
for ip := range inputRune {
switch inputRune[ip] {
case 'B':
l := len(outputRune)
if l > 0 {
outputRune = outputRune[:l-1]
}
default:
outputRune = append(outputRun... | [["+", 0, 459, 0, 456, 0, 431, 31, 432, 0, 22], ["+", 8, 196, 0, 459, 0, 456, 0, 431, 0, 466], ["+", 0, 456, 0, 431, 12, 432, 0, 2, 63, 22], ["+", 0, 431, 12, 432, 0, 2, 3, 4, 0, 24], ["+", 0, 431, 12, 432, 0, 2, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 459, 0, 456, 0, 165], ["+", 8, 196, 0, 459, 0, 456, 0, 57, 0, 121], ["... | 7 | 101 |
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#de... | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#de... | [["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 64, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 91, 28, 2, 3, 4, 0, 25], ["+", 0... | 1 | 372 |
<?php
$S = trim(fgets(STDIN));
$text = '';
for ($i = 0; $i < strlen($S); $i++) {
$key = $S[$i];
switch($key) {
case '0':
$text .= '0';
break;
case '1':
$text .= '1';
break;
case 'B':
if (!empty($text)) {
$text = substr(0, -1, $text);
}
... | <?php
$S = trim(fgets(STDIN));
$text = '';
for ($i = 0; $i < strlen($S); $i++) {
$key = $S[$i];
switch($key) {
case '0':
$text .= '0';
break;
case '1':
$text .= '1';
break;
case 'B':
if (strlen($text) > 0) {
$text = substr($text, 0, -1);
... | [["-", 0, 100, 0, 57, 15, 23, 0, 616, 0, 111], ["-", 0, 57, 15, 23, 0, 616, 0, 613, 63, 141], ["+", 0, 57, 15, 23, 0, 16, 31, 613, 63, 141], ["+", 0, 100, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 0, 100, 0, 57, 15, 23, 0, 16, 12, 612], ["+", 12, 613, 3, 3, 0, 28, 0, 606, 0, 607], ["+", 12, 613, 3, 3, 0, 28, 0, 606, 0, 141]... | 6 | 124 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
vector<char> dst;
cin >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'B') {
dst.pop_back();
} else {
dst.push_back(s[i]);
}
}
for (auto it = dst.begin(); it != dst.end(); ++it) {
cout << *it;
}
co... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
vector<char> dst;
cin >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'B') {
if (dst.size() > 0) {
dst.pop_back();
}
} else {
dst.push_back(s[i]);
}
}
for (auto it = dst.begin(); it != dst.en... | [["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25]... | 1 | 113 |
s=input()
sum=""
for i in s:
if i=="0" or i=="1":
sum+=i
elif len(sum) != 0:
sum=sum.rstrip(sum[len(sum)-1])
print(sum) | s=input()
sum=""
for i in s:
if i=="0" or i=="1":
sum+=i
elif len(sum) != 0:
sum=sum[0:len(sum)-1]
print(sum) | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 662, 12, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 612], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 2... | 5 | 58 |
#include <stdio.h>
int main(void) {
char s[15] = {'\0'};
char d[15] = {'\0'};
int len = 0;
int i;
int j = 0;
scanf("%s", s);
while (s[len]) {
len++;
}
for (i = 0; i < len; i++) {
if (s[i] == '0' || s[i] == '1') {
d[j] = s[i];
j++;
} else if (s[i] == 'B') {
if (j > 0) {
... | #include <stdio.h>
int main(void) {
char s[15] = {'\0'};
char d[15] = {'\0'};
int len = 0;
int i;
int j = 0;
scanf("%s", s);
while (s[len]) {
len++;
}
for (i = 0; i < len; i++) {
if (s[i] == '0' || s[i] == '1') {
d[j] = s[i];
j++;
} else if (s[i] == 'B') {
if (j > 0) {
... | [["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 0, 70], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 0, 73], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 44], ["+", 0, 30, 0, 14, 8, 9, 0... | 0 | 154 |
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'B') {
s = s.substr(0, max(0, i - 1)) + s.substr(i + 1);
i -= 2;
}
}
cout << s << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
string s;
int main() {
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'B') {
s = s.substr(0, max(0, i - 1)) + s.substr(i + 1);
i -= 2;
}
i = max(i, -1);
}
cout << s << '\n';
return 0;
}
| [["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]... | 1 | 94 |
package main
import (
"fmt"
)
func main() {
var s string
fmt.Scan(&s)
var ans string
for _, char := range s {
if char == '0' {
ans += string('0')
} else if char == '1' {
ans += string('1')
} else if char == 'B' {
tmp := []rune(ans)
ans = string(tmp[:(len(tmp) - 1)])
}
}
fmt.Println(ans)
... | package main
import (
"fmt"
)
func main() {
var s string
fmt.Scan(&s)
var ans string
for _, char := range s {
if char == '0' {
ans += string('0')
} else if char == '1' {
ans += string('1')
} else if char == 'B' && len(ans) > 0 {
tmp := []rune(ans)
ans = string(tmp[:(len(tmp) - 1)])
}
}
f... | [["+", 0, 57, 75, 57, 75, 57, 15, 16, 17, 98], ["+", 75, 57, 15, 16, 12, 16, 31, 2, 63, 22], ["+", 15, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 16, 12, 16, 31, 2, 3, 4, 0, 22], ["+", 15, 16, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 17, 47], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 12, 433]] | 7 | 113 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<char> ans;
for (int unsigned i = 0; i < s.size(); i++) {
if (s[i] == 'B') {
ans.pop_back();
continue;
}
ans.emplace_back(s[i]);
}
for (int unsigned i = 0; i < ans.size(); i++) {
cout << ans[i]... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<char> ans;
for (int unsigned i = 0; i < s.size(); i++) {
if (s[i] == 'B') {
if (ans.size())
ans.pop_back();
continue;
}
ans.emplace_back(s[i]);
}
for (int unsigned i = 0; i < ans.size(); i... | [["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+... | 1 | 112 |
#include <cmath>
#include <iostream>
int N, total, avg, arr[100];
void solve() {
std::cin >> N;
avg = 0;
total = 0;
for (int i = 0; i < N; ++i)
std::cin >> arr[i];
for (int i = 0; i < N; ++i)
avg += arr[i];
avg = round((double)avg / (double)N);
std::cout << avg << std::endl;
for (int i = 0; i ... | #include <cmath>
#include <iostream>
int N, total, avg, arr[100];
void solve() {
std::cin >> N;
avg = 0;
total = 0;
for (int i = 0; i < N; ++i)
std::cin >> arr[i];
for (int i = 0; i < N; ++i)
avg += arr[i];
avg = round((double)avg / (double)N);
for (int i = 0; i < N; ++i) {
total += pow((arr... | [["-", 0, 1, 0, 16, 31, 16, 31, 343, 345, 348], ["-", 0, 1, 0, 16, 31, 16, 31, 343, 0, 349], ["-", 0, 1, 0, 16, 31, 16, 31, 343, 141, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["-", 8, ... | 1 | 160 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
REP(i, n) cin >> a[i];
int sum = accumulate(a.begin(), a.end(), 0);
int ave = sum / a.size();
int dist = 0;
REP(i... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
REP(i, n) cin >> a[i];
int sum = accumulate(a.begin(), a.end(), 0);
int num = a.size();
int ave = sum / num;
int ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 85], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 85], ["+", 8, 9, 0, ... | 1 | 216 |
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, result = 8888888;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = arr[0]; i < arr[n - 1] + 1; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (arr[j] - i) * (arr[j] - i);
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, result = 1e32;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
sort(arr, arr + n);
for (int i = arr[0]; i <= arr[n - 1]; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (arr[j] - i) * (arr[j] - ... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0... | 1 | 138 |
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, result = 8888888;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = arr[0]; i < arr[n - 1] + 1; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (arr[j] - i) * (arr[j] - i);
... | #include <iostream>
#include <string>
using namespace std;
int main() {
int n, result = 8888888;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = -100; i < 101; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += (arr[j] - i) * (arr[j] - i);
}
if ... | [["-", 0, 7, 10, 43, 49, 50, 51, 69, 28, 22], ["-", 10, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["-", 10, 43, 49, 50, 51, 69, 341, 342, 0, 13], ["-", 10, 43, 49, 50, 51, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 7, 15, 16, 12, 16, 31, 69, 28, 22], ["-", 15, 16, 12, 16, 31, 69, 341, 342, 0,... | 1 | 138 |
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
template <class T> inline void chmin(T &a, T b) {
if (a > b)
a = b;
}
template <class T> inline void chmax... | // #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
template <class T> inline void chmin(T &a, T b) {
... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 16, 31, 2, 63, 40], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 25]] | 1 | 195 |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N = 0;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
double ave = 0;
int Ave = 0;
for (int i = 0; i < N; i++) {
ave += A.at(i);
}
ave = ave / N + 0.5;
Ave = ave;
int sum = 0;
... | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N = 0;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
double ave = 0;
int Ave = 0;
for (int i = 0; i < N; i++) {
ave += A.at(i);
}
ave = ave / N;
if (ave > 0)
ave += 0.5;
else... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9... | 1 | 156 |
N = int(input())
A = list(map(int, input().split()))
ans = float('inf')
for i, a in enumerate(A):
cost = 0
for j, aj in enumerate(A):
cost += (aj - a)**2
ans = min(ans, cost)
print(ans) | N = int(input())
A = list(map(int, input().split()))
ans = float('inf')
for target in range(-100, 101):
cost = 0
for j, a in enumerate(A):
cost += (target - a)**2
ans = min(ans, cost)
print(ans) | [["-", 36, 36, 0, 656, 0, 7, 31, 684, 0, 22], ["-", 36, 36, 0, 656, 0, 7, 31, 684, 0, 21], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 17, 33], ["+",... | 5 | 77 |
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); \
i += 1 - 2 * ((begin) > ... | #include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); \
i += 1 - 2 * ((begin) > ... | [["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 3, 4, 0, 16, 12, 74, 39, 77, 39, 40], ["+", 12, 2, 3,... | 1 | 131 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
int MIN = MOD;
int ans;
for (int i = -100; i <= 100; i++) {
int sum = 0;
rep(... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
int ans = MOD;
for (int i = -100; i <= 100; i++) {
int sum = 0;
rep(j, n) { sum... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 8, 9, 0, 57, 15, 339... | 1 | 134 |
#include <stdio.h>
void main() {
int N;
scanf("%d", &N);
int data[N], sum, res;
sum = res = 0;
for (int i = 0; i < N; i++) {
scanf("%d", &data[i]);
sum += data[i];
}
sum = sum / N;
for (int i = 0; i < N; i++) {
res += (sum - data[i]) * (sum - data[i]);
}
printf("%d", res);
} | #include <math.h>
#include <stdio.h>
void main() {
int N;
scanf("%d", &N);
int data[N], res, ave;
double sum;
sum = res = 0;
for (int i = 0; i < N; i++) {
scanf("%d", &data[i]);
sum += data[i];
}
ave = (int)round(sum / N);
for (int i = 0; i < N; i++) {
res += (ave - data[i]) * (ave - dat... | [["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14... | 0 | 124 |
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline... | # coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline... | [["-", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["-", 0, 14, 8, 196, 0, 7, 12, 634, 0, 70], ["+", 0, 14, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196... | 5 | 1,139 |
package main
import (
"bufio"
"container/heap"
"fmt"
"math"
"os"
"strconv"
)
const (
initialBufSize = 10000
maxBufSize = 1000000
mod = 1e9 + 7
)
var (
sc *bufio.Scanner = func() *bufio.Scanner {
sc := bufio.NewScanner(os.Stdin)
buf := make([]byte, initialBufSize)
sc.Buffer(buf, maxBufS... | package main
import (
"bufio"
"container/heap"
"fmt"
"math"
"os"
"strconv"
)
const (
initialBufSize = 10000
maxBufSize = 1000000
mod = 1e9 + 7
)
var (
sc *bufio.Scanner = func() *bufio.Scanner {
sc := bufio.NewScanner(os.Stdin)
buf := make([]byte, initialBufSize)
sc.Buffer(buf, maxBufS... | [["-", 0, 435, 8, 196, 0, 431, 31, 432, 0, 22], ["+", 0, 435, 8, 196, 0, 431, 31, 432, 0, 22], ["-", 8, 196, 0, 431, 12, 432, 0, 2, 63, 22], ["-", 0, 431, 12, 432, 0, 2, 3, 4, 0, 24], ["-", 12, 432, 0, 2, 3, 4, 0, 464, 0, 22], ["-", 12, 432, 0, 2, 3, 4, 0, 464, 0, 389], ["-", 0, 431, 12, 432, 0, 2, 3, 4, 0, 25], ["+", ... | 7 | 2,116 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
double sum = 0.0;
for (int i = 0; i < N; i++) {
cin >> A.at(i);
sum += A.at(i);
}
double ave = sum / N;
int i_ave = (ave + 0.5);
int ans = 0;
for (int i = 0; i < N; i++) {
ans += pow(i_ave - A.... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
double sum = 0.0;
for (int i = 0; i < N; i++) {
cin >> A.at(i);
sum += A.at(i);
}
double ave = sum / N;
int i_ave;
if (ave >= 0) {
i_ave = (ave + 0.5);
} else {
i_ave = (ave - 0.5);
}
... | [["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 14, 8,... | 1 | 126 |
if __name__ == '__main__':
n = int(input())
lst = list(map(int, input().split()))
ans = 50*101
for i in range(-100,101):
mn = 0
for c in lst:
mn += (i-c)*(i-c)
ans = min(ans,mn)
print(ans)
| if __name__ == '__main__':
n = int(input())
lst = list(map(int, input().split()))
ans = (50*101)*(50*101)
for i in range(-100,101):
mn = 0
for c in lst:
mn += (i-c)*(i-c)
ans = min(ans,mn)
print(ans)
| [["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 24], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 31, 612], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 48], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 0, 1, 0, 662, 12, 657, 12, 23,... | 5 | 81 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
in... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
in... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 8, 9, 0, 43, 0, 153, 0, 154], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49,... | 1 | 190 |
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
for (int(i) = (int)(initial); (i) < (int)(n); ++(i))... | #include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
for (int(i) = (int)(initial); (i) < (int)(n); ++(i))... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 17, 72], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["-", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["-", 12, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["-", 12, ... | 1 | 796 |
#include <bits/stdc++.h>
using namespace std;
#define f(i, a, b) for (int(i) = int(a); i <= int(b); i++)
#define ff(i, a, b) for (int(i) = int(a); i < int(b); i++)
#define F(i, a, b) for (int(i) = int(a); i >= int(b); i--)
#define foreach(i, x) \
for (typeof((c... | #include <bits/stdc++.h>
using namespace std;
#define f(i, a, b) for (int(i) = int(a); i <= int(b); i++)
#define ff(i, a, b) for (int(i) = int(a); i < int(b); i++)
#define F(i, a, b) for (int(i) = int(a); i >= int(b); i--)
#define foreach(i, x) \
for (typeof((c... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 39, 40], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 0, 11, 12, 16, 31... | 1 | 251 |
#include <cmath>
#include <iostream>
#include <vector>
int main() {
int n;
std::cin >> n;
std::vector<int> a;
for (int i = 0; i < n; i++) {
int an;
std::cin >> an;
a.push_back(an);
}
long int ans = 99 * 99 + 1;
for (int i = -100; i < 101; i++) {
long int sum = 0;
for (int j = 0; j < n... | #include <climits>
#include <cmath>
#include <iostream>
#include <vector>
int main() {
int n;
std::cin >> n;
std::vector<int> a;
for (int i = 0; i < n; i++) {
int an;
std::cin >> an;
a.push_back(an);
}
long int ans = LONG_MAX;
for (int i = -100; i < 101; i++) {
long int sum = 0;
for (... | [["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 31, 13], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13],... | 1 | 152 |
#include <bits/stdc++.h>
using namespace std;
#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class U> bool chmin(T &a, const U ... | #include <bits/stdc++.h>
using namespace std;
#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class U> bool chmin(T &a, const U ... | [["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["-", 8, 9, 0, 14, 49, 53, 54, 55, 0, 21], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0,... | 1 | 450 |
N = int(input())
A = list(map(int,input().split()))
R = []
for i in range(min(A), max(A)):
cost = 0
for j in range(len(A)):
cost += (i - A[j])**2
R.append(cost)
print(min(R))
| N = int(input())
A = list(map(int,input().split()))
R = []
for i in range(min(A), max(A)):
cost = 0
for j in range(len(A)):
cost += (i - A[j])**2
R.append(cost)
if R == []:
print(0)
else:
print(min(R))
| [["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 60], ["+", 0, 656, 0, 57, 15, 666, 0, 634, 0, 70], ["+", 0, 656, 0, 57, 15, 666, 0, 634, 0, 73], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 2... | 5 | 84 |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int inf = (int)1e9 + 7;
const i... | #include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int inf = (int)1e9 + 7;
const i... | [["+", 0, 338, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0,... | 1 | 273 |
def main():
n = int(input())
al = list(map(int, input().split()))
maxval = max(abs(max(al)), abs(min(al)))
cost = [0] * maxval
if len(list(set(al))) == 1 :
print("0")
else :
for i in range(maxval) :
#cost[i] = 0
for j in range(n) :
cost[i] ... | def main():
n = int(input())
al = list(map(int, input().split()))
maxval = max(abs(max(al)), abs(min(al)))
cost = []
if len(list(set(al))) == 1 :
print("0")
else :
k = -1
for i in range(-100,100) :
k += 1
cost.append(0)
for j in range(n... | [["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 28, 612]... | 5 | 134 |
#include <bits/stdc++.h>
using namespace std;
int n, a[100];
int main() {
cin >> n;
int maxn = -998244353, minn = 998244353;
for (int i = 0; i < n; i++) {
cin >> a[i];
maxn = max(maxn, a[i]);
minn = min(minn, a[i]);
}
cout << maxn << " " << minn << endl;
long long g1 = 998244353, g2;
int i;
... | #include <bits/stdc++.h>
using namespace std;
int n, a[100];
int main() {
cin >> n;
int maxn = -998244353, minn = 998244353;
for (int i = 0; i < n; i++) {
cin >> a[i];
maxn = max(maxn, a[i]);
minn = min(minn, a[i]);
}
long long g1 = 998244353, g2;
int i;
for (i = minn; i <= maxn; i++) {
g2... | [["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-",... | 1 | 171 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 14, 8,... | 1 | 15,505 |
#include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()... | #include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 49, 50, 51, 2, 63, 343, 345, 344, 141, 78], ["+", 51, 2, 63, 343, 345, 344, 3, 347, 0, 18], ["+", 63, 343, 345, 344, 3, 347, 0, 77, 39, 78], ["+", 51, 2, 63, 343, 345, 344, 3, 347, 0, 47], ["+", 0, 43, 49, 50, 51, 2, 63, 343, 0, 349], ["+", 0, 43, 49, 50, 51, 2, 63, 343... | 1 | 606 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#de... | /*
ID: anonymo14
TASK: wormhole
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB pus... | [["+", 0, 134, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 30, 0, 134, 39, 344, 3, 347, 0, 47], ["+", 36, 36, 36, 36, 0, 30, 0, 134, 49, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 134, 0, 35], ["+", 36, 36, 36, 36, 0, 30, 0, 134, 0, 157], ["+", 36, 36, 0, 30, 0, 134, 39, 344, 141, 78], ["+", 0, 30, 0, 134, 39, 344, 3, 347, 0, ... | 1 | 203 |
// ConsoleApplication1.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string... | // ConsoleApplication1.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string... | [["+", 36, 36, 36, 36, 0, 30, 0, 112, 141, 22], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 24], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 22], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 25], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 0, 148], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ... | 1 | 1,101 |
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
#pragma warning(disable : 4996)
int main() {
int N;
int ret;
ret = scanf("%d", &N);
vector<int> v(N);
for (int i = 0; i < N; i++) {
... | #include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
#pragma warning(disable : 4996)
int main() {
int N;
int ret;
ret = scanf("%d", &N);
vector<int> v(N);
for (int i = 0; i < N; i++) {
... | [["-", 0, 43, 49, 50, 51, 16, 12, 74, 0, 24], ["-", 49, 50, 51, 16, 12, 74, 39, 77, 39, 40], ["-", 0, 43, 49, 50, 51, 16, 12, 74, 0, 25], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, ... | 1 | 189 |
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
//#define _DBG
int main() {
uint32_t N;
int ret;
#ifdef _DBG
ret = scanf_s("%d", &N);
#else
ret = scanf("%d", &N);
#endif
vector<int> v(N);
for (size_t i = 0; i < N; i++) {
#ifdef _DB... | #include <algorithm>
#include <climits>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
//#define _DBG
int main() {
int N;
int ret;
#ifdef _DBG
ret = scanf_s("%d", &N);
#else
ret = scanf("%d", &N);
#endif
vector<int> v(N);
for (int i = 0; i < N; i++) {
... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+",... | 1 | 227 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
int ans = INT_MAX;
for (int diff = 1; diff <= 100; diff++) {
int cur = 0;
for (int i = 0; i < n; i++) {
cur += (abs(a[i]) - diff) * (abs(a[i]) - diff);
}
ans = ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
int ans = INT_MAX;
for (int diff = -100; diff <= 100; diff++) {
int cur = 0;
for (int i = 0; i < n; i++) {
cur += (a[i] - diff) * (a[i] - diff);
}
ans = min(ans... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 23, 0, 16, 31, 2, 63, 22], ["-", 31, 23, 0, 16, 31, 2, 3, 4, 0, 25], ["-", 12, 16, 12, 23, 0, 16, 31, 2, 63, 22], ["-", 12, 23, 0, 16, 31, 2, 3, 4, 0, 24], ["-", 12, 23, 0,... | 1 | 121 |
N=int(input())
a=list(map(int,input().split()))
ave=sum(a)/N
res=ave%1
if ave>=0 and res>=0.5:
ave=int(ave)+1
elif ave<0 and res<=0.5:
ave=int(ave)-1
else:
ave=int(ave)
ans=0
for i in a:
ans+=(i-ave)**2
print(ans)
| N=int(input())
a=list(map(int,input().split()))
ave=sum(a)/N
if ave>=0 and ave%1>=0.5:
ave=int(ave)+1
elif ave<0 and -ave%1>=0.5:
ave=int(ave)-1
else:
ave=int(ave)
ans=0
for i in a:
ans+=(i-ave)**2
print(ans)
| [["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 0, 656, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 31, ... | 5 | 101 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert
#define mp make_pair
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
#define sz(x) (int)(x).size()
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert
#define mp make_pair
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
#define sz(x) (int)(x).size()
... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 8, 9, 0, 43, 49, 50, 51, 66, 17, 48], ["-", 0, 43, 49, 50, 51, 66, 28, 2, 63, 22], ["-", 49, 50, 51, 66, 28, 2, 3, 4, 0, 24], ["-", 51, 66, 28, 2, 3, 4, 0, 2, 63, 22], ["-", 28, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["-", 28, 2, 3, 4, 0,... | 1 | 295 |
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free So... | // C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free So... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 16,... | 1 | 488 |
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
int a[N];
for (int i = 0; i < N; i++) {
scanf("%d", &a[i]);
}
int temp, min;
for (int i = -100; i <= 100; i++) {
int sum = 0;
for (int j = 0; j < N; j++) {
sum += (a[j] - i) * (a[j] - i);
}
if (i == -100) {
min = su... | int main() {
int N;
scanf("%d", &N);
int a[N];
for (int i = 0; i < N; i++) {
scanf("%d", &a[i]);
}
int temp, min;
for (int i = -100; i <= 100; i++) {
int sum = 0;
for (int j = 0; j < N; j++) {
sum += (a[j] - i) * (a[j] - i);
}
if (i == -100) {
min = sum;
temp = sum;... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]] | 0 | 162 |
def keisan(N,A):
KAI = 0
A.sort
min = A[0]
max = A[N-1]
i = min
while i <= max:
kari = 0
j = 0
while j < N:
kari += (A[j]-i)**2
j += 1
if kari <= KAI or i == min:
KAI = kari
... | def keisan(N,A):
KAI = 0
A.sort
min = -100
max = 101
i = min
while i <= max:
kari = 0
j = 0
while j < N:
kari += (A[j]-i)**2
j += 1
if kari <= KAI or i == min:
KAI = kari
... | [["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 206, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 73], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 28, 612], ["-", 0, 1, 0, 662, 12, 206, 206, 657, 31,... | 5 | 116 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int N;
cin >> N;
vector<int> a(N);
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> a[i];
sum += a[i];
}
int avg = sum / N;
if (sum % N) {
avg++;
}
int cost = 0;
for (int i = 0; i < N; i++) {
int dist = abs(a[i] - avg);... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int N;
cin >> N;
vector<int> a(N);
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> a[i];
sum += a[i];
}
double avg = (double)sum / N;
avg = round(avg);
int cost = 0;
for (int i = 0; i < N; i++) {
int dist = abs(a[i] - avg);
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 24], ["+", 49, 50, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8,... | 1 | 152 |
#include <math.h>
#include <stdio.h>
int main(void) {
int i;
double n;
double ave = 0;
scanf("%lf", &n);
int a[(int)n];
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
ave += a[i];
}
ave /= n;
if (ave - ceil(ave) >= 0.5) {
ave = floor(ave);
} else {
ave = ceil(ave);
}
int ans = 0;... | #include <math.h>
#include <stdio.h>
int main(void) {
int i;
double n;
double ave = 0;
scanf("%lf", &n);
int a[(int)n];
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
ave += (double)a[i];
}
ave /= n;
if (ceil(ave) - ave >= 0.5) {
ave = floor(ave);
} else {
ave = ceil(ave);
}
int ... | [["+", 8, 9, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 74, 39, 77, 39, 40], ["+", 8, 9, 0, 1, 0, 11, 12, 74, 0, 25], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22]] | 0 | 157 |
#include <cmath>
#include <iostream>
#include <limits.h>
#include <vector>
using namespace std;
int main(void) {
int n;
cin >> n;
vector<int> arr;
int x;
int media = 0;
while (n--) {
cin >> x;
arr.push_back(x);
media += x;
}
media /= arr.size();
int minimo = INT_MAX;
for (int j = -200; j... | #include <iostream>
#include <vector>
using namespace std;
int main(void) {
int n;
cin >> n;
vector<int> arr;
int x;
int media = 0;
while (n--) {
cin >> x;
arr.push_back(x);
media += x;
}
media /= arr.size();
int minimo = 10000000;
for (int j = -100; j <= 100; j++) {
int casox = 0;
... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14... | 1 | 150 |
// abc043_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include... | // abc043_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include... | [["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 383 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
int n;
cin >> n;
vector<int> va(n);
for (int i = 0; i < n; ++i) {
cin >> va[i];
}
int ans = 20000;
for (int i = -100; i <= 100; ++i) {
int cost = 0;
for (int j = 0; j < va.size(); ++j) {
cost += po... | #include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
int n;
cin >> n;
vector<int> va(n);
for (int i = 0; i < n; ++i) {
cin >> va[i];
}
int ans = -1;
for (int i = -100; i <= 100; ++i) {
int cost = 0;
for (int j = 0; j < va.size(); ++j) {
cost += pow(v... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 57, 15, 339, 51, 16, 31... | 1 | 140 |
#入力
N = int(input())
lst = input().split()
#整数値化
for i in range(len(lst)):
lst[i] = int(lst[i])
#ソート
lst.sort()
#コスト計算関数
def get_cost(x, y):
return (x - y) ** 2
costs = []
#コスト計算
for i in range(lst[0], lst[-1]): #入力値の最小値から最大値まで
cost = 0
for j in lst:
cost = cost + get_cost(j, i)
costs.append(c... | #入力
N = int(input())
lst = input().split()
#整数値化
for i in range(len(lst)):
lst[i] = int(lst[i])
#ソート
lst.sort()
#コスト計算関数
def get_cost(x, y):
return (x - y) ** 2
costs = []
#コスト計算
for i in range(lst[0], lst[-1]): #入力値の最小値から最大値まで
cost = 0
for j in lst:
cost = cost + get_cost(j, i)
costs.append(c... | [["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 79], ["+", 0, 656, 0, 57, 15, 666, 0, 634, 0, 70], ["+", 0, 656, 0, 57, 15, 666, 0, 634, 0, 73], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]... | 5 | 126 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
int n, a[102] = {}, b = 0, c = 0;
cin >> n;
for (int i = 0; i < n; i++)
... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
int n, a[102] = {}, b = 0, c = 0;
cin >> n;
for (int i = 0; i < n; i++)
... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 2, 3, 4, 0... | 1 | 144 |
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define all(v) v.begin(), v.end()... | #include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define all(v) v.begin(), v.end()... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 2... | 1 | 513 |
/*
author: Salam_35
Created at :
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define sc(n) scanf("%d", &n)
#define Max 100005
#define scan(n) scanf("%lld", &n)
#define pi acos(-1.0)
#define _fastio ... | /*
author: Salam_35
Created at :
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define sc(n) scanf("%d", &n)
#define Max 100005
#define scan(n) scanf("%lld", &n)
#define pi acos(-1.0)
#define _fastio ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 16, 31, 74, 39, 77, 39, 40], ["+", 12, 2, 3, 4, 0, 16, ... | 1 | 292 |
from decimal import *
n = int(input())
x = list(map(int, input().split()))
num = Decimal(str(sum(x)/n)).quantize(Decimal('0'), rounding=ROUND_DOWN)
num = int(num)
print(num)
cost=0
for i in range(n):
cost += (x[i]-num)*(x[i]-num)
print(cost) | from decimal import Decimal, ROUND_HALF_UP
n = int(input())
x = list(map(int, input().split()))
num = Decimal(str(sum(x)/n)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
num = int(num)
cost=0
for i in range(n):
cost += (x[i]-num)*(x[i]-num)
print(cost) | [["-", 36, 36, 0, 656, 0, 686, 0, 690, 0, 48], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 21], ["-", 0, 662, 12, 652, 3, 4, 0, 653, 51, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 653, 51, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], [... | 5 | 101 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, sum = 0, cost = 1 << 60;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum = sum + arr[i];
}
for (int i = -100; i <= 100; i++) {
long long cc = 0;
for (int j = 0; j < n; j++) {
cc = cc + (arr[j... | #include <bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
long long n;
lli cost = INT64_MAX;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = -100; i <= 100; i++) {
lli cc = 0;
for (int j = 0; j < n; j++) {
cc = cc + (arr[j] - i) * (... | [["+", 36, 36, 36, 36, 0, 30, 0, 360, 0, 233], ["+", 36, 36, 36, 36, 0, 30, 0, 360, 141, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 360, 0, 32], ["+", 36, 36, 0, 30, 0, 360, 39, 77, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 360, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", ... | 1 | 143 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; }
int main() {
int n;
cin >> n;
ll ans = 1e18;
ll sum = 0;
ll count = 0;
int a[n];
rep(i, n) cin >> a[i];
rep(i, n) sum += a[i];
sum =... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// ll gcd(int a, int b){ return b? gcd(b,a%b) : a ; }
int main() {
int n;
cin >> n;
ll ans = 1e18;
ll sum = 0;
ll count = 0;
int a[n];
rep(i, n) cin >> a[i];
rep(i, n) sum += a[i];
sum =... | [["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 184 |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sfl(i, a, n) for (int i = a; i < n; i++)
#define ufl(i, a, n) for (int i = n - 1; i >= a; i--)
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;
ll power(ll a, ll b) {
ll res = 1;
for (int i = 0; i <... | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sfl(i, a, n) for (int i = a; i < n; i++)
#define ufl(i, a, n) for (int i = n - 1; i >= a; i--)
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;
ll power(ll a, ll b) {
ll res = 1;
for (int i = 0; i <... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 11, 12, 2, 3, 4,... | 1 | 226 |
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int N;
int a[100];
int i, cnt;
char str[512];
char *p;
int rd = 0, ru = 0, minus = 0;
int rdchk = 0, ruchk = 0, minux = 0;
fgets(str, 512, stdin);
N = atoi(str);
fgets(str, 512, stdin);
p = str;
for (i = 0, cnt = 0; i < 512; i++) {
i... | #include <stdio.h>
#include <stdlib.h>
#define absmin(a, b) (((a) > 0) &&
int main(void) {
int N;
int a[100];
int i, cnt;
char str[512];
char *p;
int rd = 0, ru = 0, minus = 0;
int rdchk = 0, ruchk = 0, minux = 0;
fgets(str, 512, stdin);
N = atoi(str);
fgets(str, 512, stdin);
p = str;
for (i ... | [["+", 36, 36, 36, 36, 0, 30, 0, 112, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 141, 22], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 24], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 22], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 21], ["+", 36, 36, 0, 30, 0, 112, 54, 158, 0, 25], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 5... | 0 | 332 |
N = int(input())
A = list(map(int,input().split()))
S = 100000000
for i in range(-100,101):
T = 0
for j in range(N):
T += (A[j] - i)**2
print("i",i,"T",T)
if S > T:
S = T
print(S) | N = int(input())
A = list(map(int,input().split()))
S = 100000000
for i in range(-100,101):
T = 0
for j in range(N):
T += (A[j] - i)**2
if S > T:
S = T
print(S) | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, ... | 5 | 88 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long lon... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long lon... | [["-", 8, 123, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 8, 123, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 49, 50, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 49, 50, 51, 16, 12, 74, 39, 77, 39, 40], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 123, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, ... | 1 | 465 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> as(n);
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> as[i];
sum += as[i];
}
cout << sum << ... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> as(n);
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> as[i];
sum += as[i];
}
double avg = do... | [["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35]] | 1 | 161 |
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int a[110];
int n, sum = 0, ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
double n1 = 1.0 * sum / n;
int av = (int)(n1 + 0.5);
for (int i = 1; i <= n; i++) {
ans += (a[i] - av) * (a[i] - ... | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int a[106];
int n, sum = 0, ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
double n1 = 1.0 * sum / n;
int av;
if (n1 >= 0)
av = (int)(n1 + 0.5);
else
av = (int)(n1 - 0.5);
for (int... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57... | 1 | 128 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); ... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); ... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 3, 4, 0, 16, 31, 69, 341, 342, 0, 22], ["-", 3, 4, 0, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 12, 2, 3, 4, 0, 16, 12, 69, 28, 22], ["-", 3, 4, 0, 16, 12, 69, 341... | 1 | 323 |
n=int(input())
a=list(map(int,input().split()))
b=sum(a)/n
c=(b*2+1)//2
s=0
for i in a:
s+=(i-s)**2
print(s)
| n=int(input())
a=list(map(int,input().split()))
b=sum(a)/n
c=(b*2+1)//2
s=0
for i in a:
s+=(i-c)**2
s=int(s)
print(s)
| [["-", 0, 677, 12, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 677, 12, 657, 31, 23, 0, 657, 12, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["... | 5 | 65 |
<?php
fscanf(STDIN,'%d', $d);
$a = explode(' ',trim(fgets(STDIN)));
$same = $a[0];
$same_flg = true;
foreach ($a as $value) {
// var_dump($same, $value);
if ($same !== $value){
$same_flg = false;
}
}
//var_dump($same);
if ($same_flg){
echo '0'.PHP_EOL;
exit;
}
$max = 0;
foreach ($a as $val... | <?php
fscanf(STDIN,'%d', $d);
$a = explode(' ',trim(fgets(STDIN)));
$same = $a[0];
$same_flg = true;
foreach ($a as $value) {
// var_dump($same, $value);
if ($same !== $value){
$same_flg = false;
}
}
if ($same_flg){
echo '0'.PHP_EOL;
exit;
}
$max = 0;
foreach ($a as $value){
if ($value... | [["+", 0, 493, 0, 1, 0, 11, 31, 606, 0, 607], ["+", 0, 493, 0, 1, 0, 11, 31, 606, 0, 141], ["+", 36, 36, 0, 493, 0, 1, 0, 11, 0, 32], ["+", 0, 493, 0, 1, 0, 11, 12, 227, 0, 70], ["+", 0, 493, 0, 1, 0, 11, 12, 227, 0, 73], ["+", 36, 36, 36, 36, 0, 493, 0, 1, 0, 35], ["-", 36, 36, 0, 493, 0, 7, 0, 11, 12, 612], ["+", 0, ... | 6 | 213 |
<?php
fscanf(STDIN,'%d', $d);
$a = explode(' ',trim(fgets(STDIN)));
$same = $a[0];
$same_flg = true;
foreach ($a as $value) {
// var_dump($same, $value);
if ($same !== $value){
$same_flg = false;
}
}
if ($same_flg){
echo '0'.PHP_EOL;
exit;
}
$max = 0;
foreach ($a as $value){
if ($value... | <?php
fscanf(STDIN,'%d', $d);
$a = explode(' ',trim(fgets(STDIN)));
$same = $a[0];
$same_flg = true;
foreach ($a as $value) {
// var_dump($same, $value);
if ($same !== $value){
$same_flg = false;
}
}
if ($same_flg){
echo '0'.PHP_EOL;
exit;
}
$max = 0;
foreach ($a as $value){
if ($value... | [["-", 36, 36, 36, 36, 0, 493, 0, 7, 0, 88], ["-", 36, 36, 36, 36, 0, 493, 0, 7, 0, 24], ["-", 0, 493, 0, 7, 0, 11, 31, 606, 0, 141], ["+", 0, 493, 0, 1, 0, 11, 31, 606, 0, 141], ["-", 36, 36, 0, 493, 0, 7, 0, 11, 12, 612], ["-", 36, 36, 36, 36, 0, 493, 0, 7, 0, 35], ["-", 0, 493, 0, 7, 0, 16, 31, 606, 0, 607], ["-", 0... | 6 | 203 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#inclu... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#inclu... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 7, 15, 16, ... | 1 | 365 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INPUT() freopen("input.txt", "r", stdin)
#define OUTPUT() freopen("output.txt", "w", stdout)
#define F first
#define S second
// Templatefunctions
template <typename T> T gcd(T x, T y) {
if (y == 0)
return x;
else
return gcd(y, x % ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INPUT() freopen("input.txt", "r", stdin)
#define OUTPUT() freopen("output.txt", "w", stdout)
#define F first
#define S second
// Templatefunctions
template <typename T> T gcd(T x, T y) {
if (y == 0)
return x;
else
return gcd(y, x % ... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0... | 1 | 501 |
import itertools
import math
n=int(input())
a=list(map(int,input().split()))
ave=round(sum(a)/n)
#print(ave)
count=0
for i in range(n):
count+=(a[i]-ave)**2
print(count)
print(round(-1.6))
| import itertools
import math
n=int(input())
a=list(map(int,input().split()))
ave=round(sum(a)/n)
#print(ave)
count=0
for i in range(n):
count+=(a[i]-ave)**2
print(count)
| [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 3, 4, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 3, 4, 0, 652, 3, 4, 0, 664, 28, 531], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["-", 0, 656, 0, 1... | 5 | 76 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll N, m = 1e9;
cin >> N;
ll a[N];
for (ll i = 0; i < N; i++)
cin >> a[i];
for (ll i = a[0]; i <= a[N - 1]; i++) {
ll x = 0;
for (ll j = 0; j < N; j++) {
ll y = (i - a[j]) * (i - a[j]);
x += y;
}
... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll N, m = 1e9;
cin >> N;
ll a[N];
for (ll i = 0; i < N; i++)
cin >> a[i];
sort(a, a + N);
for (ll i = a[0]; i <= a[N - 1]; i++) {
ll x = 0;
for (ll j = 0; j < N; j++) {
ll y = (i - a[j]) * (i - a[j]);
... | [["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0... | 1 | 138 |
#include <bits/stdc++.h>
#define sqr(x) (x) * (x)
#define int long long
using namespace std;
signed main() {
#ifdef _DEBUG
freopen("_in", "r", stdin);
freopen("_out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int n, s = 0;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin ... | #include <bits/stdc++.h>
#define sqr(x) (x) * (x)
#define int long long
using namespace std;
signed main() {
#ifdef _DEBUG
freopen("_in", "r", stdin);
freopen("_out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int n, s = 0;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin ... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 8, 9, 0, 57... | 1 | 163 |
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>
typedef long long ll;
using namespace std;
#define debug(x) c... | #include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>
typedef long long ll;
using namespace std;
#define debug(x) c... | [["-", 0, 11, 31, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 57, 75, 76, 0, 57, 64, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8,... | 1 | 163 |
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s, ans;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '0' || s[i] == '1') {
ans.push_back(s[i]);
} else if (s[i] == 'B') {
ans.pop_b... | #include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s, ans;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '0' || s[i] == '1') {
ans.push_back(s[i]);
} else if (s[i] == 'B' && ans.length() > ... | [["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 51, 16, 12, 16, 31, 2, 63, 118, 28, 22], ["+", 51, 16, 12, 16, 31, 2, 63, 118, 17, 131], ["+", 51, 16, 12, 16, 31, 2, 63, 118, 119, 120], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, ... | 1 | 117 |
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s, ans = "";
cin >> s;
for (auto c : s) {
if (c == 'B')
if (!ans.empty())
ans.pop_back();
else
ans.push_back(c);
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
string ans;
for (auto c : s) {
if (c == 'B') {
if (ans.size())
ans.pop_back();
} else
ans.push_back(c);
}
cout << ans << endl;
return 0;
}
| [["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 8, 9, 0, 43, 49, 50, 51, 5, 0, 62], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 338, 8, 9, 0, 57,... | 1 | 77 |
#include <stdio.h>
#include <string.h>
char s[11];
int main() {
scanf("%s", s);
int len = strlen(s);
char ans[11];
for (int i = 0; i < 11; i++) {
ans[i] = '\0';
}
int j = 0;
for (int i = 0; i < len; i++) {
if (s[i] == 'B') {
if (j) {
j--;
}
} else {
ans[j] = s[i];
... | #include <stdio.h>
#include <string.h>
char s[11];
int main() {
scanf("%s", s);
int len = strlen(s);
char ans[11];
for (int i = 0; i < 11; i++) {
ans[i] = '\0';
}
int j = 0;
for (int i = 0; i < len; i++) {
if (s[i] == 'B') {
if (j) {
j--;
ans[j] = '\0';
}
} else ... | [["+", 64, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 64, 9, 0, 1, 0, 11, 12, 103, 0, 104], ["+", 64, 9, 0, 1, 0, 11, 12, 103, 0, 44], ["+", 64, 9,... | 1 | 136 |
s = list(map(str, input()))
display = []
for action in s:
if action == '0':
display.append('0')
elif action == '1':
display.append('1')
elif action == 'B':
display.pop()
print(''.join(display)) | s = list(map(str, input()))
display = []
for action in s:
if action == '0':
display.append('0')
elif action == '1':
display.append('1')
elif action == 'B':
if len(display) > 0:
display.pop()
print(''.join(display)) | [["+", 0, 57, 75, 665, 64, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 75, 665, 64, 196, 0, 57, 15, 666, 667, 47], ["+", 75, 665, 64, 196, 0, 57, 15, 666, 0,... | 5 | 74 |
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define sz 12
char s[sz + 3], st[sz + 3];
int main() {
int i, j, k;
scanf("%s", s);
k = 0;
for (i = 0; s[i]; i++) {
if (s[i] == '0') {
st[k] = '0';
} else if (s[i] == '1') {
st[k] == '1... | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define sz 12
char s[sz + 2], st[sz + 3];
int main() {
// char str[10] = { }, ans[10] = { };
int i, j, k;
k = 0;
scanf("%s", &s);
for (i = 0; s[i]; i++) {
if (s[i] == '0')
st[k] = '0';
else if (s[i] == '1')
... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["-", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+",... | 1 | 194 |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#includ... | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#includ... | [["+", 0, 57, 75, 76, 0, 9, 0, 57, 0, 121], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25... | 1 | 163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.