[ { "id": "s539273394", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint kekka[2];\nint prime_or_not[1001];\nint prime_list[1001];\nint prime_num[1001];\nint prime_counter = 0;\nvoid sosuubunnpu() {\n for (int i = 1; i <= 1000; ++i) {\n prime_or_not[i] = 0;\n }\n for (int i = 2; i <= 1000; ++i) {\n for (int j = 2; j <= 1000 / i; ++j) {\n if (prime_or_not[i] == 0) {\n prime_or_not[i * j] = 1;\n }\n }\n }\n for (int i = 2; i <= 1000; ++i) {\n if (prime_or_not[i] == 0) {\n prime_list[prime_counter] = i;\n prime_counter += 1;\n }\n }\n}\nvoid innsuubunnkai(int N, int n) {\n int time = 0;\n while (1) {\n if (N % n == 0) {\n N = N / n;\n time++;\n } else {\n break;\n }\n }\n kekka[0] = time;\n kekka[1] = N;\n}\n\nint main() {\n sosuubunnpu();\n int N;\n cin >> N;\n int innsuu[11];\n int A[N + 1][11];\n for (int i = 0; i <= 1000; ++i) {\n prime_num[i] = 0;\n }\n unsigned long long result = 1;\n for (int current_num = 2; current_num <= N; ++current_num) {\n kekka[1] = current_num;\n for (int i = 0; i < prime_counter; ++i) {\n innsuubunnkai(kekka[1], prime_list[i]);\n prime_num[i] += kekka[0];\n }\n }\n for (int current_num = 2; current_num <= N; ++current_num) {\n for (int i = 0; i < 11; ++i) {\n innsuu[i] += A[current_num][i];\n }\n }\n for (int i = 0; i < prime_counter; ++i) {\n result = (result * (prime_num[i] + 1)) % 1000000007;\n }\n cout << result << endl;\n\n return 0;\n}", "test_IO": [ { "input": "3\n", "output": "4\n" } ] }, { "id": "s837925207", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long int\nusing namespace std;\nint h[6], w[6];\n\nint main() {\n int x, ans = 0;\n\n cin >> x;\n\n ans = x + x * x + x * x * x;\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "14\n" } ] }, { "id": "s275739084", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int A, B;\n cin >> A >> B;\n int C = A + B;\n if (A % 3 != 0 && B % 3 != 0 && C % 3 != 0) {\n cout << \"Impossible\" << endl;\n } else {\n cout << \"Possible\" << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "4 5\n", "output": "Possible\n" } ] }, { "id": "s110965154", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nvoid sort(vector& a_rvecIntValue);\n\nint main(void) {\n int iNum = 0;\n cin >> iNum;\n vector vecIntValue;\n while (iNum) {\n int iIntValue = 0;\n cin >> iIntValue;\n vecIntValue.push_back(iIntValue);\n iNum--;\n }\n\n sort(vecIntValue);\n\n return 0;\n}\n\nvoid sort(vector& a_rvecIntValue) {\n for (unsigned int i = 0; i < a_rvecIntValue.size(); i++) {\n if (i != 0) {\n int iIntValue = a_rvecIntValue.at(i);\n int j = i - 1;\n while ((j >= 0) && (a_rvecIntValue.at(j) > iIntValue)) {\n a_rvecIntValue.at(j + 1) = a_rvecIntValue.at(j);\n j--;\n }\n a_rvecIntValue.at(j + 1) = iIntValue;\n }\n\n for (unsigned int k = 0; k < a_rvecIntValue.size(); k++) {\n cout << a_rvecIntValue.at(k);\n if (k != a_rvecIntValue.size() - 1) {\n cout << \" \";\n }\n }\n cout << endl;\n }\n}", "test_IO": [ { "input": "6\n5 2 4 6 1 3\n", "output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n" } ] }, { "id": "s480704678", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing lint = long long int;\nlong long int INF = 1001001001001001LL;\nint inf = 1000000007;\nlong long int MOD = 1000000007LL;\ndouble PI = 3.1415926535897932;\n\ntemplate \ninline void chmin(T1 &a, const T2 &b) {\n if (a > b) a = b;\n}\ntemplate \ninline void chmax(T1 &a, const T2 &b) {\n if (a < b) a = b;\n}\n\n#define ALL(a) a.begin(), a.end()\n#define RALL(a) a.rbegin(), a.rend()\n\nint main() {\n int n;\n cin >> n;\n vector a(n);\n vector acc(n + 1, 0);\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n acc[i + 1] = acc[i] + a[i];\n acc[i + 1] %= MOD;\n }\n\n lint ans = 0;\n for (int i = 0; i < n; i++) {\n ans += a[i] % MOD * (MOD + acc[n] - acc[i + 1]) % MOD;\n ans %= MOD;\n }\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "3\n1 2 3\n", "output": "11\n" } ] }, { "id": "s275513165", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nstring str;\n\nint main() {\n cin >> str;\n if (str[2] == str[3] && str[4] == str[5])\n cout << \"Yes\\n\";\n else\n cout << \"No\\n\";\n}", "test_IO": [ { "input": "sippuu\n", "output": "Yes\n" } ] }, { "id": "s263967574", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n int x;\n cin >> x;\n if (x >= 1200)\n cout << \"ARC\" << endl;\n else\n cout << \"ABC\" << endl;\n return 0;\n}", "test_IO": [ { "input": "1000\n", "output": "ABC\n" } ] }, { "id": "s744854383", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))\n#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))\n#define INF (int)2e9\n#define MOD (1000 * 1000 * 1000 + 7)\n#define Ceil(x, n) (((((x)) + ((n)-1)) / n))\n#define CeilN(x, n) (((((x)) + ((n)-1)) / n) * n)\n#define FloorN(x, n) ((x) - (x) % (n))\n#define IsOdd(x) (((x) & 0x01UL) == 0x01UL)\n#define IsEven(x) (!IsOdd((x)))\n#define ArrayLength(x) (sizeof(x) / sizeof(x[0]))\n#define MAX_QWORD ((QWORD)0xFFFFFFFFFFFFFFFF)\n#define M_PI 3.14159265358979323846\ntypedef long long ll;\ntypedef unsigned long long int QWORD;\ntypedef pair P;\n\nint main() {\n int N;\n cin >> N;\n vector a(N);\n REP(i, N) cin >> a[i];\n\n int idx = 1;\n int ans = 0;\n REP(i, N) {\n if (a[i] == idx) {\n idx++;\n } else {\n ans++;\n }\n }\n\n if (idx == 1) {\n cout << -1 << endl;\n } else {\n cout << ans << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "3\n2 1 2\n", "output": "1\n" } ] }, { "id": "s035123609", "dataset": "codenet", "language": "C++", "code": "#include \n\ntypedef long long ll;\n\nint mat[3000][3000];\n\nll dp[3000][3000][4];\nll dpl[3000];\n\nint main(int argc, char **argv) {\n int rr, cc, k;\n\n std::cin >> rr >> cc >> k;\n for (int i = 1; i <= k; i++) {\n int r, c, v;\n std::cin >> r >> c >> v;\n mat[r - 1][c - 1] = v;\n }\n dp[0][0][1] = mat[0][0];\n for (int y = 0; y < rr; y++) {\n for (int x = 0; x < cc; x++) {\n for (int c = 0; c < 4; c++) {\n int v = mat[y][x];\n ll q;\n if (c == 0 || v == 0) {\n q = (x == 0) ? dpl[x] : std::max(dpl[x], dp[y][x - 1][c]);\n } else {\n q = (x == 0) ? dpl[x] + v\n : std::max(dpl[x] + v,\n std::max(dp[y][x - 1][c],\n dp[y][x - 1][c - 1] + v));\n }\n dp[y][x][c] = q;\n }\n }\n for (int x = 0; x < cc; x++) {\n dpl[x] = std::max(std::max(dp[y][x][0], dp[y][x][1]),\n std::max(dp[y][x][2], dp[y][x][3]));\n }\n }\n std::cout << dpl[cc - 1] << std::endl;\n return 0;\n}", "test_IO": [ { "input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n", "output": "8\n" } ] }, { "id": "s907227314", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n string s;\n cin >> s;\n int a, z;\n for (int i = 0; i < s.size(); i++) {\n if (s[i] == 'A') {\n a = i;\n break;\n }\n }\n for (int i = s.size() - 1; i >= 0; i--) {\n if (s[i] == 'Z') {\n z = i;\n break;\n }\n }\n cout << z - a + 1 << endl;\n return 0;\n}", "test_IO": [ { "input": "QWERTYASDFZXCV\n", "output": "5\n" } ] }, { "id": "s531853923", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n int a, b, c, d;\n cin >> a >> b >> c >> d;\n if (a * b % 2 == 1 && (c + d) % 2 == 1) {\n cout << \"No\" << endl;\n } else {\n cout << \"Yes\" << endl;\n }\n}", "test_IO": [ { "input": "3 5 1 4\n", "output": "No\n" } ] }, { "id": "s992338735", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint N, S;\n\nint main() {\n while (cin >> N && N > 0) {\n int M, m, addup, i;\n M = -1;\n m = 1001;\n addup = 0;\n for (i = 0; i < N; i++) {\n cin >> S;\n addup += S;\n if (S > M) M = S;\n if (S < m) m = S;\n }\n cout << (addup - M - m) / (N - 2) << endl;\n }\n}", "test_IO": [ { "input": "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n", "output": "342\n7\n300\n326\n" } ] }, { "id": "s129191754", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define REP(i, n) for (int i = 0; i < n; i++)\n#define all(x) (x).begin(), (x).end()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n\ntypedef long long ll;\nusing namespace std;\n\nint main(void) {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int n;\n cin >> n;\n vector a(n);\n REP(i, n) cin >> a[i];\n sort(all(a));\n REP(i, n - 1) {\n if (a[i] == a[i + 1]) {\n cout << \"NO\" << '\\n';\n return 0;\n }\n }\n cout << \"YES\" << '\\n';\n\n return 0;\n}", "test_IO": [ { "input": "5\n2 6 1 4 5\n", "output": "YES\n" } ] }, { "id": "s028542090", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\n\nunsigned long a[100100];\n\nint main(void) {\n int k;\n unsigned long min, max;\n scanf(\"%d\", &k);\n\n for (int i = 0; i < k; i++) scanf(\"%ld\", &a[i]);\n\n max = 3, min = 2;\n\n if (a[k - 1] != 2) {\n cout << -1 << endl;\n return 0;\n }\n\n for (int i = k - 2; i >= 0; i--) {\n if (a[i] > max) {\n cout << -1 << endl;\n return 0;\n } else {\n max = ((max / a[i]) + 1) * a[i] - 1;\n if (min % a[i] != 0) {\n min = ((min / a[i]) + 1) * a[i];\n }\n }\n\n if (max <= min) {\n cout << -1 << endl;\n return 0;\n }\n }\n\n printf(\"%ld %ld\\n\", min, max);\n\n return 0;\n}", "test_IO": [ { "input": "4\n3 4 3 2\n", "output": "6 8\n" } ] }, { "id": "s240156356", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n string str1, str2;\n cin >> str1 >> str2;\n\n sort(str1.begin(), str1.end());\n sort(str2.rbegin(), str2.rend());\n\n int loop = str1.length() > str2.length() ? str2.length() : str1.length();\n bool flag = false;\n\n for (int i = 0; loop > i; i++) {\n char ch1 = str1[i];\n char ch2 = str2[i];\n\n if (ch1 == ch2) {\n if (loop == i + 1 && str1.length() < str2.length()) {\n flag = true;\n break;\n } else {\n continue;\n }\n } else {\n if (ch2 > ch1) {\n flag = true;\n break;\n } else {\n break;\n }\n }\n }\n\n if (flag) {\n cout << \"Yes\" << endl;\n } else {\n cout << \"No\" << endl;\n }\n}", "test_IO": [ { "input": "yx\naxy\n", "output": "Yes\n" } ] }, { "id": "s074619936", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \nusing namespace std;\n\nint main() {\n string str;\n string tmp;\n int sum;\n\n while (1) {\n cin >> str;\n if (str == \"0\") break;\n sum = 0;\n for (int i = 0; i < str.size(); i++) {\n tmp = str[i];\n int num = atoi(tmp.c_str());\n sum += num;\n }\n\n cout << sum << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "123\n55\n1000\n0\n", "output": "6\n10\n1\n" } ] }, { "id": "s343280137", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define INF 1 << 29\n#define LL long long int\n\nLL const MOD = 1000000007;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n LL n, c;\n cin >> n >> c;\n\n vector x(n + 1, 0), v(n + 1, 0);\n\n for (int i = 1; i < n + 1; i++) {\n cin >> x[i] >> v[i];\n }\n\n vector lefttotal(n + 1, 0), maxlefttotal(n + 1, 0);\n for (int i = 1; i < n + 1; i++) {\n lefttotal[i] = lefttotal[i - 1] + v[i];\n }\n\n for (int i = 1; i < n + 1; i++) {\n maxlefttotal[i] = max(maxlefttotal[i - 1], lefttotal[i] - x[i]);\n }\n\n vector righttotal(n + 1, 0), maxrighttotal(n + 1, 0);\n for (int i = 1; i < n + 1; i++) {\n righttotal[i] = righttotal[i - 1] + v[n - i + 1];\n }\n\n for (int i = 1; i < n + 1; i++) {\n maxrighttotal[i] =\n max(maxrighttotal[i - 1], righttotal[i] - (c - x[n + 1 - i]));\n }\n\n LL ans = 0;\n\n for (int i = 1; i < n + 1; i++) {\n ans = max(ans, lefttotal[i] - x[i]);\n ans = max(ans, lefttotal[i] - 2 * x[i] + maxrighttotal[n - i]);\n ans = max(ans, righttotal[i] - (c - x[n + 1 - i]));\n ans = max(ans,\n righttotal[i] - 2 * (c - x[n + 1 - i]) + maxlefttotal[n - i]);\n }\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "3 20\n2 80\n9 120\n16 1\n", "output": "191\n" } ] }, { "id": "s324508229", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define PB push_back\n#define MP make_pair\n#define REP(i, n) for (int i = 0; i < (n); i++)\nint main() {\n int n, ii, a, b;\n cin >> n;\n long long cnt[10][10];\n REP(i, 100) cnt[i % 10][i / 10] = 0;\n for (int i = 1; i <= n; i++) {\n b = i % 10;\n a = i;\n while (a >= 10) {\n a /= 10;\n }\n cnt[a][b]++;\n }\n long long ans = 0;\n for (int i = 1; i <= 9; i++) {\n for (int j = 1; j <= 9; j++) {\n ans += cnt[i][j] * cnt[j][i];\n }\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "25\n", "output": "17\n" } ] }, { "id": "s240627521", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n#define fi first\n#define se second\n#define mp make_pair\n#define rep(i, n) for (int i = 0; i < n; ++i)\n#define rrep(i, n) for (int i = n; i >= 0; --i)\nconst int inf = 1e9 + 7;\nconst ll mod = 1e9 + 7;\nconst ll mod1 = 998244353;\nconst ll big = 1e18;\nconst double PI = 2 * asin(1);\n\nint main() {\n int N;\n cin >> N;\n vector A(N);\n for (int i = 0; i < N; ++i) cin >> A[i];\n sort(A.begin(), A.end(), greater());\n int index;\n ll max = inf;\n for (int i = 1; i < N; ++i) {\n if (max > abs(A[0] - 2 * A[i])) {\n max = abs(A[0] - 2 * A[i]);\n index = i;\n }\n }\n cout << A[0] << \" \" << A[index] << endl;\n}", "test_IO": [ { "input": "5\n6 9 4 2 11\n", "output": "11 6\n" } ] }, { "id": "s345215315", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n#define ld long double\n#define EPS 0.0000000001\n#define INF 1e9\n#define LINF (ll) INF* INF\n#define MOD 1000000007\n#define rep(i, n) for (int i = 0; i < (n); i++)\n#define loop(i, a, n) for (int i = a; i < (n); i++)\n#define all(in) in.begin(), in.end()\n#define shosu(x) fixed << setprecision(x)\n\n#define int ll\n\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef vector vp;\n\nint gcd(int a, int b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\nint lcm(int a, int b) { return a / gcd(a, b) * b; }\n\nint ans = INF;\nint h = 19, w = 15;\nint dx[] = {0, 1, 0, -1, 1, 1, -1, -1};\nint dy[] = {1, 0, -1, 0, 1, -1, 1, -1};\nvs s(19);\n\nvoid dfs(int x, int y, int cnt) {\n if (cnt > 20) return;\n\n if (x == h - 1) {\n ans = min(ans, cnt);\n return;\n }\n rep(i, 8) {\n int nx = x + dx[i];\n int ny = y + dy[i];\n if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;\n if (s[nx][ny] != 'X') continue;\n bool c = true;\n while (c && s[nx][ny] == 'X') {\n s[nx][ny] = '.';\n nx += dx[i];\n ny += dy[i];\n if (nx < 0 || nx >= h || ny < 0 || ny >= w) {\n if (nx >= h) ans = min(ans, cnt + 1);\n c = false;\n }\n }\n if (c) dfs(nx, ny, cnt + 1);\n while (nx != x || ny != y) {\n nx -= dx[i];\n ny -= dy[i];\n s[nx][ny] = 'X';\n }\n s[x][y] = '.';\n }\n}\n\nsigned main(void) {\n rep(i, h) cin >> s[i];\n int sx, sy;\n rep(i, h) rep(j, w) if (s[i][j] == 'O') {\n sx = i, sy = j;\n s[i][j] = '.';\n }\n dfs(sx, sy, 0);\n if (ans == INF)\n cout << -1 << endl;\n else\n cout << ans << endl;\n}", "test_IO": [ { "input": "...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n......O........\n......X........\n", "output": "1\n" } ] }, { "id": "s189738089", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#define rep(i, k, n) for (int i = k; i < n; ++i)\nusing namespace std;\n\ntemplate \ninline void chmin(T &a, T b) {\n if (a > b) a = b;\n return;\n}\nconst int INF = 1 << 30;\n\nint main() {\n vector dp(101000, INF);\n dp.at(0) = 0;\n\n int N, K;\n cin >> N >> K;\n vector h(N);\n rep(i, 0, N) cin >> h[i];\n\n rep(i, 0, N) {\n rep(j, 1, K + 1) { chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j])); }\n }\n\n cout << dp[N - 1] << endl;\n return 0;\n}", "test_IO": [ { "input": "5 3\n10 30 40 50 20\n", "output": "30\n" } ] }, { "id": "s807902500", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n string s, t;\n cin >> s >> t;\n s += s;\n puts(s.find(t) + 1 ? \"Yes\" : \"No\");\n}", "test_IO": [ { "input": "kyoto\ntokyo\n", "output": "Yes\n" } ] }, { "id": "s085712108", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define MOD 7007\nstruct QUEUE {\n int a, b, c, tot;\n} Push;\nint F[6][3] = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1},\n {2, 0, 0}, {0, 2, 0}, {0, 0, 2}};\nvector Hash[MOD];\nbool HASH(int n) {\n for (int i = 0; i < Hash[n % MOD].size(); i++)\n if (n == Hash[n % MOD][i]) return false;\n Hash[n % MOD].push_back(n);\n return true;\n}\nint main() {\n Push.tot = 0;\n queue que;\n scanf(\"%d%d%d\", &Push.a, &Push.b, &Push.c);\n que.push(Push);\n while (!que.empty()) {\n QUEUE Fro = que.front();\n if (Fro.a == Fro.b && Fro.b == Fro.c) {\n printf(\"%d\\n\", Fro.tot);\n return 0;\n }\n for (int i = 0; i < 6; i++) {\n Push = Fro;\n Push.tot++;\n Push.a += F[i][0];\n Push.b += F[i][1];\n Push.c += F[i][2];\n int n = Push.a * 10000 + Push.b * 100 + Push.c;\n if (!HASH(n)) continue;\n que.push(Push);\n }\n que.pop();\n }\n return 0;\n}", "test_IO": [ { "input": "2 5 4\n", "output": "2\n" } ] }, { "id": "s780006912", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int n;\n int array[100];\n cin >> n;\n for (int i = 0; i < n; i++) {\n cin >> array[i];\n }\n\n int sum = 0;\n for (int i = 0; i < n - 1; i++) {\n for (int j = i + 1; j < n; j++) {\n sum += array[i] * array[j];\n }\n }\n\n cout << sum << endl;\n return (0);\n}", "test_IO": [ { "input": "3\n3 1 2\n", "output": "11\n" } ] }, { "id": "s475106338", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main(void) {\n int i, t, n;\n for (i = 0; i < 4; i++) {\n cin >> t >> n;\n if (t == 1) {\n cout << 6000 * n << endl;\n } else if (t == 2) {\n cout << 4000 * n << endl;\n } else if (t == 3) {\n cout << 3000 * n << endl;\n } else if (t == 4) {\n cout << 2000 * n << endl;\n }\n }\n}", "test_IO": [ { "input": "3 10\n1 4\n4 1\n2 5\n", "output": "30000\n24000\n2000\n20000\n" } ] }, { "id": "s422352362", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nlong long a[200005];\nlong long pre[200005];\nlong long last[200005];\nint main() {\n int n;\n scanf(\"%d\", &n);\n for (int i = 1; i <= n; i++) {\n scanf(\"%lld\", &a[i]);\n }\n long long sumpre = 0, sumlast = 0;\n for (int i = 1; i < n; i++) {\n sumpre = sumpre + a[i];\n pre[i] = sumpre;\n }\n for (int i = n; i > 1; i--) {\n sumlast = sumlast + a[i];\n last[i] = sumlast;\n }\n long long d = (1ll << 60);\n for (int i = 1; i < n; i++) {\n d = min(d, abs(pre[i] - last[i + 1]));\n }\n printf(\"%lld\\n\", d);\n}", "test_IO": [ { "input": "6\n1 2 3 4 5 6\n", "output": "1\n" } ] }, { "id": "s976558978", "dataset": "codenet", "language": "C++", "code": "#ifdef _WIN32\n#pragma warning(disable : 4996)\n#endif\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\nusing namespace std;\n\nFILE* _fin = stdin;\nFILE* _fout = stdout;\n#define PI 3.141592653589793238462643383279502884197169399375105820974\n#define ten5p1 100001\n#define ten6p1 1000001\n#define ten8p1 100000001\n#define ten9p1 1000000001\n#define uint unsigned int\n#define ll long long\n#define ull unsigned long long\n#define rep(var, n) for (int var = 0; var < n; ++var)\n#define repi(n) rep(i, n)\n#define repj(n) rep(j, n)\n#define repi1(n) for (int i = 1; i < n; ++i)\n#define repj1(n) for (int j = 1; j < n; ++j)\n#define _min(a, b) (a) < (b) ? (a) : (b)\n#define _max(a, b) (a) > (b) ? (a) : (b)\n#define zeroi(data, n) memset(data, 0, sizeof(int) * n);\n#define zeroll(data, n) memset(data, 0, sizeof(long long) * n);\n#define one(data, n) \\\n { \\\n for (int _ONEI = 0; _ONEI < n; ++_ONEI) data[_ONEI] = 1; \\\n }\nchar readc() {\n char var;\n fscanf(_fin, \"%c\", &var);\n return var;\n}\nint readi() {\n int var;\n fscanf(_fin, \"%d\", &var);\n return var;\n}\nll readll() {\n ll var;\n fscanf(_fin, \"%lld\", &var);\n return var;\n}\nvoid repread(int* data, int n) { repi(n) data[i] = readi(); }\nvoid repread(ll* data, int n) { repi(n) data[i] = readll(); }\nint reads(char* str, int maxsize) {\n for (;;) {\n if (fgets(str, maxsize, _fin) == NULL) break;\n if (str[0] != '\\n' && str[0] != '\\r') break;\n }\n int slen = strlen(str);\n if (slen == 0) return 0;\n if (str[slen - 1] == '\\n' || str[slen - 1] == '\\r') str[--slen] = 0;\n return slen;\n}\n\n#define writec(var) fprintf(_fout, \"%c\", var)\n#define writecsp(var) fprintf(_fout, \"%c \", var)\n#define writecln(var) fprintf(_fout, \"%c\\n\", var)\n#define writei(var) fprintf(_fout, \"%d\", var)\n#define writeisp(var) fprintf(_fout, \"%d \", var)\n#define writellsp(var) fprintf(_fout, \"%lld \", var)\n#define writeiln(var) fprintf(_fout, \"%d\\n\", var)\n#define writellln(var) fprintf(_fout, \"%lld\\n\", var)\n#define writeulln(var) fprintf(_fout, \"%llu\\n\", var)\n#define writefln(var) fprintf(_fout, \"%f\\n\", var)\n#define writes(str) fprintf(_fout, \"%s\", str)\n#define writesp() fprintf(_fout, \" \")\n#define writeln() fprintf(_fout, \"\\n\")\n#define iseven(x) ((x & 1) == 0 ? 1 : 0)\n#define RUN_LOCAL(testfilename) \\\n { \\\n _fin = fopen(testfilename, \"r\"); \\\n if (_fin == NULL) _fin = stdin; \\\n }\n#define swap(type, a, b) \\\n { \\\n type t = a; \\\n a = b; \\\n b = t; \\\n }\n#define swapxor(a, b) \\\n { \\\n a ^= b; \\\n b ^= a; \\\n a ^= b; \\\n }\n#define sort(data, n) std::sort(data, data + n)\n#define mod(a, b) b == 0 ? 0 : a == 0 ? 0 : (a > 0 ? a % b : b + a % b)\nll gcd(ll a, ll b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\n\nvoid reversei(int* data, int n) {\n int k = n >> 1;\n repi(k) {\n int tmp = data[i];\n data[i] = data[n - i - 1];\n data[n - i - 1] = tmp;\n }\n}\nint bsearch(int val, int* data, int n) {\n if (data[0] > val) return -1;\n if (data[n - 1] < val) return n;\n int l = 0;\n int r = n - 1;\n for (; l < r;) {\n int mid = (l + r + 1) >> 1;\n if (data[mid] <= val)\n l = mid;\n else\n r = mid - 1;\n }\n if (data[r] != val) ++r;\n return r;\n}\n\n#define _Vec(type, name) \\\n struct name { \\\n type* data; \\\n int size; \\\n int n; \\\n }; \\\n void init(name* t, int size) { \\\n t->data = (type*)malloc(sizeof(type) * size); \\\n t->size = size; \\\n t->n = 0; \\\n } \\\n void resize(name* t) { \\\n int ns = t->size * 1.2f; \\\n t->data = (type*)realloc(t->data, sizeof(type) * ns); \\\n t->size = ns; \\\n } \\\n void add(name* t, type val) { \\\n if (t->n >= t->size) resize(t); \\\n int k = t->n; \\\n t->data[k] = val; \\\n t->n = k + 1; \\\n } \\\n void free(name* t) { free(t->data); }\n_Vec(int, Veci) _Vec(long long, Vecll) _Vec(char*, Vecs)\n#define _ispal(type, name) \\\n int name(type* a, type* b, int n) { \\\n repi(n) { \\\n if (a[i] != b[n - i - 1]) { \\\n return 0; \\\n } \\\n } \\\n return 1; \\\n }\n _ispal(int, ispali) _ispal(char, ispalc)\n\n#define _Pair(type, name) \\\n struct name { \\\n type x, y; \\\n }; \\\n int cmp_##name(const void* _a, const void* _b) { \\\n name* a = (name*)_a; \\\n name* b = (name*)_b; \\\n if (a->x == b->x) { \\\n if (a->y < b->y) \\\n return -1; \\\n else \\\n return 1; \\\n } \\\n if (a->x < b->x) \\\n return -1; \\\n else \\\n return 1; \\\n } \\\n void sort_##name(name* d, int n) { \\\n qsort(d, n, sizeof(name), cmp_##name); \\\n }\n _Pair(int, Pairi)\n\n int cmp_Str(const void* _a, const void* _b) {\n char* a = *((char**)_a);\n char* b = *((char**)_b);\n return strcmp(a, b);\n}\nvoid sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }\n\nll expmod(ll x, ll n, ll m) {\n ll ans = 1;\n for (; n;) {\n if (n & 1) ans = (ans * x) % m;\n x = (x * x) % m;\n n >>= 1;\n }\n return ans;\n}\n\nll combmod(ll n, ll k, ll m) {\n ll ret = 1;\n ll div = 1;\n for (ll i = 0; i < k; ++i) {\n ret = (ret * (n - i) % m) % m;\n div = (div * (i + 1)) % m;\n }\n div = expmod(div, m - 2, m) % m;\n return (ret * div) % m;\n}\n\nint main() {\n RUN_LOCAL(\"dataabc155A.txt\");\n int a = readi();\n int b = readi();\n if (a < b) {\n repi(b) writei(a);\n writeln();\n } else {\n repi(a) writei(b);\n writeln();\n }\n\n return 0;\n}", "test_IO": [ { "input": "4 3\n", "output": "3333\n" } ] }, { "id": "s527973537", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n string N;\n cin >> N;\n int S = 0;\n for (int i = 0; i < N.size(); i++) {\n S += N[i] - '0';\n }\n if (stoi(N) % S == 0)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n return 0;\n}", "test_IO": [ { "input": "12\n", "output": "Yes\n" } ] }, { "id": "s623008479", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n int n, k;\n cin >> n >> k;\n vector l(n);\n for (int i = 0; i < n; i++) {\n cin >> l[i];\n }\n\n sort(l.begin(), l.end());\n\n int ans = 0;\n for (int i = 0; i < k; i++) {\n ans += l[n - 1 - i];\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "5 3\n1 2 3 4 5\n", "output": "12\n" } ] }, { "id": "s221616550", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nbool isPalindrome(string s) {\n for (int i = 0; i < s.length() / 2; i++) {\n if (s[i] == s[s.length() - 1 - i])\n continue;\n else\n return false;\n }\n return true;\n}\n\nint main() {\n string s;\n cin >> s;\n if (isPalindrome(s) && isPalindrome(s.substr(0, s.length() / 2))) {\n cout << \"Yes\" << endl;\n } else {\n cout << \"No\" << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "akasaka\n", "output": "Yes\n" } ] }, { "id": "s661916956", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint main() {\n int a, b, c;\n cin >> a >> b >> c;\n if (a > b) {\n swap(a, b);\n }\n if (b > c) {\n swap(b, c);\n }\n if (a > b) {\n swap(a, b);\n }\n cout << a << \" \" << b << \" \" << c << endl;\n}", "test_IO": [ { "input": "3 8 1\n", "output": "1 3 8\n" } ] }, { "id": "s300263829", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int a, b;\n cin >> a >> b;\n cout << a * b << endl;\n return 0;\n}", "test_IO": [ { "input": "2 5\n", "output": "10\n" } ] }, { "id": "s343804973", "dataset": "codenet", "language": "C++", "code": "#include \n#define int long long\nint n, m, mod, C[310][310], pre[310][310], f[310][310];\nusing namespace std;\nsigned main() {\n scanf(\"%lld%lld%lld\", &n, &m, &mod);\n C[0][0] = 1;\n for (int i = 1; i <= n; i++) {\n C[i][0] = C[i][i] = 1;\n for (int j = 1; j < i; j++)\n C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;\n }\n for (int i = 0; i <= m; i++) f[1][i] = 1, pre[1][i] = m - i + 1;\n for (int i = 2; i <= n + 1; i++) {\n for (int j = 0; j <= m; j++)\n for (int k = 1; k < i; k++)\n (f[i][j] +=\n f[i - k][j] * pre[k][j + 1] % mod * C[i - 2][k - 1]) %= mod;\n for (int j = m; j >= 0; j--)\n pre[i][j] = (pre[i][j + 1] + f[i][j]) % mod;\n }\n printf(\"%lld\\n\", f[n + 1][0]);\n}", "test_IO": [ { "input": "2 2 100\n", "output": "5\n" } ] }, { "id": "s208784214", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint N, A;\nint main() {\n cin >> N >> A;\n cout << (N % 500 <= A ? \"Yes\" : \"No\") << endl;\n return 0;\n}", "test_IO": [ { "input": "2018\n218\n", "output": "Yes\n" } ] }, { "id": "s620821061", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\nusing ll = long long;\n\ntemplate \nstruct BitMatching {\n vector G[2 * V];\n int match[2 * V];\n bool used[2 * V];\n\n void init() {\n for (int i = 0; i < 2 * V; i++) {\n G[i].clear();\n }\n }\n\n void add(int a, int b) {\n G[a].push_back(b + V);\n G[b + V].push_back(a);\n }\n\n bool dfs(int v) {\n used[v] = true;\n for (int i = 0; i < G[v].size(); i++) {\n int u = G[v][i], w = match[u];\n if (w < 0 || (!used[w] && dfs(w))) {\n match[v] = u;\n match[u] = v;\n return true;\n }\n }\n return false;\n }\n\n int exec() {\n int res = 0;\n memset(match, -1, sizeof(match));\n for (int v = 0; v < V; v++) {\n if (match[v] < 0) {\n memset(used, 0, sizeof(used));\n if (dfs(v)) {\n res++;\n }\n }\n }\n return res;\n }\n};\n\nconst int MN = 520;\nBitMatching bm;\nll gcd(ll a, ll b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\nint main() {\n while (true) {\n int n, m;\n cin >> n >> m;\n if (!n) break;\n bm.init();\n int a[n], b[m];\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n }\n for (int i = 0; i < m; i++) {\n cin >> b[i];\n }\n\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n if (gcd(a[i], b[j]) != 1) {\n bm.add(i, j);\n }\n }\n }\n cout << bm.exec() << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "4 3\n2 6 6 15\n2 3 5\n2 3\n4 9\n8 16 32\n4 2\n4 9 11 13\n5 7\n5 5\n2 3 5 1001 1001\n7 11 13 30 30\n10 10\n2 3 5 7 9 11 13 15 17 29\n4 6 10 14 18 22 26 30 34 38\n20 20\n195 144 903 63 137 513 44 626 75 473\n876 421 568 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421\n373 984 564 54 823 477 565 866 879 638\n100 100\n195 144 903 63 137 513 44 626 75 473\n876 421 568 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421\n373 984 564 54 823 477 565 866 879 638\n117 755 835 683 52 369 302 424 513 870\n75 874 299 228 140 361 30 342 750 819\n761 123 804 325 952 405 578 517 49 457\n932 941 988 767 624 41 912 702 241 426\n351 92 300 648 318 216 785 347 556 535\n166 318 434 746 419 386 928 996 680 975\n231 390 916 220 933 319 37 846 797 54\n272 924 145 348 350 239 563 135 362 119\n446 305 213 879 51 631 43 755 405 499\n509 412 887 203 408 821 298 443 445 96\n274 715 796 417 839 147 654 402 280 17\n298 725 98 287 382 923 694 201 679 99\n699 188 288 364 389 694 185 464 138 406\n558 188 897 354 603 737 277 35 139 556\n826 213 59 922 499 217 846 193 416 525\n69 115 489 355 256 654 49 439 118 961\n0 0\n", "output": "3\n1\n0\n4\n9\n18\n85\n" } ] }, { "id": "s853750785", "dataset": "codenet", "language": "C++", "code": "#define _USE_MATH_DEFINES\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)\n#define EPS (1e-7)\n#define INF (1e9)\n#define PI (acos(-1))\n#define rep(i, n) for (int i = 0; i < n; i++)\n#define show(s) cout << s << endl\n#define chmin(x, y) x = min(x, y)\n#define chmax(x, y) x = max(x, y)\n#define LINF (1000000000000000000ll)\n#define MOD (1e9 + 7)\n#define rep1(i, n) for (int i = 1; i <= n; i++)\ntypedef pair P;\nll gcd(ll a, ll b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\nll lcd(ll a, ll b) {\n if (b == 0) return a;\n return (a / gcd(a, b)) * b;\n}\nvector divnum(ll num) {\n int dig;\n vector p;\n while (num) {\n dig = num % 10;\n p.push_back(dig);\n num /= 10;\n }\n return p;\n}\nint digiter(ll num) {\n int dig;\n vector p;\n while (num) {\n dig = num % 10;\n p.push_back(dig);\n num /= 10;\n }\n return p.size();\n}\nvector convertstring(string s) {\n vector d;\n ll n = s.size();\n rep(i, n) { d.push_back(s[i] - '0'); }\n return d;\n}\nmap prime_factor(ll n) {\n map ret;\n for (ll i = 2; i * i <= n; i++) {\n while (n % i == 0) {\n ret[i]++;\n n /= i;\n }\n }\n if (n != 1) ret[n] = 1;\n return ret;\n}\nvector divisor(ll n) {\n vector res;\n for (ll i = 1; i * i <= n; i++) {\n if (n % i != 0) continue;\n res.push_back(i);\n if (i * i != n) res.push_back(n / i);\n }\n return res;\n}\n\nll myPow(ll x, ll n, ll m) {\n if (n == 0) return 1;\n if (n % 2 == 0)\n return myPow(x * x % m, n / 2, m);\n else\n return x * myPow(x, n - 1, m) % m;\n}\nstd::vector Eratosthenes(const int N) {\n std::vector is_prime(N + 1);\n for (int i = 0; i <= N; i++) {\n is_prime[i] = true;\n }\n std::vector P;\n for (int i = 2; i <= N; i++) {\n if (is_prime[i]) {\n for (int j = 2 * i; j <= N; j += i) {\n is_prime[j] = false;\n }\n P.emplace_back(i);\n }\n }\n return P;\n}\nconst ll mod = MOD;\nstruct mint {\n ll x;\n mint(ll x = 0) : x((x % mod + mod) % mod) {}\n mint operator-() const { return mint(-x); }\n mint& operator+=(const mint a) {\n if ((x += a.x) >= mod) x -= mod;\n return *this;\n }\n mint& operator-=(const mint a) {\n if ((x += mod - a.x) >= mod) x -= mod;\n return *this;\n }\n mint& operator*=(const mint a) {\n (x *= a.x) %= mod;\n return *this;\n }\n mint operator+(const mint a) const { return mint(*this) += a; }\n mint operator-(const mint a) const { return mint(*this) -= a; }\n mint operator*(const mint a) const { return mint(*this) *= a; }\n mint pow(ll t) const {\n if (!t) return 1;\n mint a = pow(t >> 1);\n a *= a;\n if (t & 1) a *= *this;\n return a;\n }\n\n mint inv() const { return pow(mod - 2); }\n mint& operator/=(const mint a) { return *this *= a.inv(); }\n mint operator/(const mint a) const { return mint(*this) /= a; }\n};\nistream& operator>>(istream& is, const mint& a) { return is >> a.x; }\nostream& operator<<(ostream& os, const mint& a) { return os << a.x; }\nstruct combination {\n vector fact, ifact;\n combination(ll n) : fact(n + 1), ifact(n + 1) {\n assert(n < mod);\n fact[0] = 1;\n for (ll i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;\n ifact[n] = fact[n].inv();\n for (ll i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;\n }\n mint operator()(ll n, ll k) {\n if (k < 0 || k > n) return 0;\n return fact[n] * ifact[k] * ifact[n - k];\n }\n} comb(1000005);\nmint f(ll n, ll k) {\n if (n < 0) return 0;\n\n mint res = comb(n, k);\n res *= comb.fact[k];\n return res;\n}\n\nint N, M;\nint H[100005];\nvector G[100005];\nint main() {\n cin >> N >> M;\n rep(i, N) cin >> H[i];\n rep(i, M) {\n int u, v;\n cin >> u >> v;\n u--;\n v--;\n G[u].push_back(v);\n G[v].push_back(u);\n }\n ll ans = 0;\n rep(u, N) {\n bool flag = true;\n for (int v : G[u]) {\n if (H[u] <= H[v]) flag = false;\n }\n if (flag) ans++;\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n", "output": "2\n" } ] }, { "id": "s495709932", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#define rep(i, n) for (int i = 0; i < (n); i++)\nusing namespace std;\n\nint main(void) {\n ios::sync_with_stdio(false);\n int N;\n cin >> N;\n vector A(N);\n rep(i, N) cin >> A[i];\n\n int64_t answer = 0;\n for (int i = 0; i < N - 1; ++i) {\n for (int j = i + 1; j < N; ++j) {\n int64_t diff = abs(A[i] - A[j]);\n answer = max(answer, diff);\n }\n }\n cout << answer << endl;\n return 0;\n}", "test_IO": [ { "input": "4\n1 4 6 3\n", "output": "5\n" } ] }, { "id": "s387994967", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n int A, B;\n cin >> A >> B;\n if (A < 13 && A >= 6) {\n cout << B / 2 << endl;\n }\n if (A < 6) {\n cout << 0 << endl;\n }\n if (A >= 13) {\n cout << B << endl;\n }\n}", "test_IO": [ { "input": "30 100\n", "output": "100\n" } ] }, { "id": "s107204188", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(void) {\n int minA = pow(10, 9) + 1;\n int num = 0;\n\n int n, t, f = 0;\n cin >> n >> t;\n vector A(n);\n\n for (int i = 0; i < n; i++) {\n cin >> A[i];\n }\n\n for (int i = 0; i < n; i++) {\n if (minA > A[i]) {\n minA = A[i];\n } else {\n if (f == A[i] - minA)\n num++;\n else if (f < A[i] - minA) {\n num = 1;\n f = A[i] - minA;\n }\n }\n }\n\n cout << num << endl;\n}", "test_IO": [ { "input": "3 2\n100 50 200\n", "output": "1\n" } ] }, { "id": "s367896206", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nclass Cube {\n public:\n int f[6];\n Cube() {}\n void roll_z() { roll(1, 2, 4, 3); }\n void roll_y() { roll(0, 2, 5, 3); }\n void roll_x() { roll(0, 1, 5, 4); }\n void roll(int i, int j, int k, int l) {\n int t = f[i];\n f[i] = f[j];\n f[j] = f[k];\n f[k] = f[l];\n f[l] = t;\n }\n};\n\nbool eq(Cube c1, Cube c2) {\n for (int i = 0; i < 6; i++)\n if (c1.f[i] != c2.f[i]) return false;\n return true;\n}\n\nbool equal(Cube c1, Cube c2) {\n for (int i = 0; i < 6; i++) {\n for (int j = 0; j < 4; j++) {\n if (eq(c1, c2)) return true;\n c1.roll_z();\n }\n if (i % 2 == 0)\n c1.roll_y();\n else\n c1.roll_x();\n }\n return false;\n}\n\nint main() {\n Cube c1, c2;\n\n for (int i = 0; i < 6; i++) cin >> c1.f[i];\n for (int i = 0; i < 6; i++) cin >> c2.f[i];\n\n if (equal(c1, c2))\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n\n return 0;\n}", "test_IO": [ { "input": "1 2 3 4 5 6\n6 2 4 3 5 1\n", "output": "Yes\n" } ] }, { "id": "s064900223", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint main() {\n int i, n, ans;\n cin >> n;\n vector p(n);\n for (i = 0; i < n; i++) {\n cin >> p[i];\n }\n ans = 0;\n for (i = 0; i < n - 1; i++) {\n if (p[i] == i + 1) {\n p[i + 1] = p[i];\n ans += 1;\n }\n }\n if (p[n - 1] == n) {\n ans += 1;\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "5\n1 4 3 5 2\n", "output": "2\n" } ] }, { "id": "s788730767", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \nusing namespace std;\ntypedef long long ll;\n\nint n, a[50], p, b = 0, c = 0;\n\nll nPr(ll n, ll r) {\n ll res = 1;\n for (int i = 0; i < r; i++) {\n res *= (n - i);\n }\n\n return res;\n}\n\nll nCr(ll n, ll r) {\n double res = 1;\n for (int i = 0; i < r; i++) {\n res *= (n - i);\n res /= (i + 1);\n }\n return (ll)res;\n}\n\nint main() {\n cin >> n >> p;\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n if (a[i] % 2 == 0) {\n b++;\n } else {\n c++;\n }\n }\n\n ll bsum = 0, csum = 0;\n bsum = (ll)pow(2, b);\n\n if (p == 0) {\n for (int i = 0; i <= c; i++) {\n if (i % 2 == 0) {\n csum += nCr(c, i);\n }\n }\n } else {\n for (int i = 0; i <= c; i++) {\n if (i % 2 == 1) {\n csum += nCr(c, i);\n }\n }\n }\n\n ll ans = bsum * csum;\n cout << ans << endl;\n}", "test_IO": [ { "input": "2 0\n1 3\n", "output": "2\n" } ] }, { "id": "s814403222", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef pair P;\nP v[22];\nvector d[33];\nint main(void) {\n int n;\n while (cin >> n && n) {\n int m;\n for (int i = 0; i < 33; i++) d[i].clear();\n for (int i = 0; i < n; i++) {\n v[i].first = 0;\n cin >> v[i].second >> m;\n for (int j = 0; j < m; j++) {\n int a;\n cin >> a;\n v[i].first += n - (int)d[a].size();\n for (int k = 0; k < (int)d[a].size(); k++) {\n v[d[a][k]].first--;\n }\n d[a].push_back(i);\n }\n }\n sort(v, v + n);\n cout << v[0].first << \" \" << v[0].second << endl;\n }\n}", "test_IO": [ { "input": "4\nakzakr 2 1 8\nfnmyi 5 2 3 4 6 9\ntsnukk 5 2 3 4 7 9\nyskwcnt 6 3 4 7 8 9 10\n4\nakzakr 1 2\nfnmyi 3 10 11 12\ntsnukk 2 1 8\nyskwcnt 2 1 8\n5\nknmmdk 2 13 19\nakmhmr 4 13 15 19 22\nmksyk 6 3 7 12 13 15 19\nskrkyk 3 1 4 8\ntmemm 3 1 17 24\n5\nknmmdk 5 5 6 16 18 26\nakmhmr 9 3 4 7 11 14 15 17 18 20\nmksyk 5 6 13 25 27 28\nskrkyk 4 3 16 23 24\ntmemm 3 6 12 20\n14\nhrkamm 6 4 6 8 10 20 22\nmkhsi 6 1 10 12 15 22 27\nhbkgnh 2 4 9\nchyksrg 8 3 4 12 15 16 20 25 28\nmktkkc 6 0 1 8 15 17 20\ntknsj 6 6 8 18 19 25 26\nyyitktk 3 3 12 18\nykhhgwr 5 3 9 10 11 24\namftm 7 2 6 8 12 13 14 17\nmmftm 4 6 12 16 18\nrtkakzk 3 14 15 21\nazsmur 7 1 2 4 12 15 18 20\niormns 2 4 20\nktrotns 6 7 12 14 17 20 25\n14\nhrkamm 2 4 21\nmkhsi 6 2 3 8 11 18 20\nhbkgnh 4 4 16 28 29\nchyksrg 5 0 3 9 17 22\nmktkkc 2 7 18\ntknsj 3 3 9 23\nyyitktk 3 10 13 25\nykhhgwr 2 18 26\namftm 3 13 18 22\nmmftm 4 1 20 24 27\nrtkakzk 2 1 10\nazsmur 5 2 5 10 14 17\niormns 3 9 15 16\nktrotns 5 7 12 16 17 20\n0\n", "output": "7 akzakr\n4 akzakr\n6 knmmdk\n12 tmemm\n19 iormns\n24 mktkkc\n" } ] }, { "id": "s798522572", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n int N, T;\n cin >> N >> T;\n int A[N];\n vector B(N);\n for (int i = 0; i < N; i++) cin >> A[i];\n int m = A[0];\n B[1] = A[1] - m;\n m = min(m, A[1]);\n for (int i = 2; i < N; i++) {\n B[i] = A[i] - m;\n m = min(m, A[i]);\n }\n cout << count(B.begin(), B.end(), *max_element(B.begin(), B.end())) << endl;\n}", "test_IO": [ { "input": "3 2\n100 50 200\n", "output": "1\n" } ] }, { "id": "s166776347", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\n#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)\n#define pb push_back\n#define INF (ll)1e18\n\nll mod = 1e9 + 7;\n\nint main() {\n ll N, K;\n cin >> N >> K;\n ll A[N];\n REP(i, N) cin >> A[i];\n\n ll ans1 = 0;\n REP(i, N) {\n REP(j, N) {\n if (i >= j) continue;\n if (A[i] > A[j]) ans1++;\n ans1 %= mod;\n }\n }\n\n ll count[2005] = {0};\n REP(i, N) { count[A[i] - 1]++; }\n\n ll ans2 = 0;\n ll remain = N;\n REP(i, 2005) {\n remain -= count[i];\n ans2 += count[i] * remain;\n }\n\n ll ans = 0;\n ll tmp = K * (K - 1);\n tmp /= 2;\n tmp %= mod;\n tmp *= ans2;\n tmp %= mod;\n ans += ans1 * K;\n ans %= mod;\n ans += tmp;\n ans %= mod;\n\n cout << ans << endl;\n}", "test_IO": [ { "input": "2 2\n2 1\n", "output": "3\n" } ] }, { "id": "s628937234", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nint main() {\n using namespace std;\n string s, t;\n cin >> s;\n t = s[0];\n t += to_string(s.size() - 2);\n t += s[s.size() - 1];\n cout << t << endl;\n}", "test_IO": [ { "input": "internationalization\n", "output": "i18n\n" } ] }, { "id": "s794872785", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool solve() {\n int maxsize = 0;\n int maxcnt = 0;\n int ans_num;\n int ans_num2;\n vector str_v;\n\n string in;\n while (cin >> in) {\n str_v.push_back(in);\n if (maxsize < in.size()) {\n maxsize = in.size();\n ans_num = str_v.size() - 1;\n }\n }\n for (int i = 0; i < str_v.size(); i++) {\n int cnt = 0;\n for (int j = 0; j < str_v.size(); j++) {\n if (str_v[i] == str_v[j]) cnt++;\n }\n if (maxcnt < cnt) {\n maxcnt = cnt;\n ans_num2 = i;\n }\n }\n\n cout << str_v[ans_num2] << \" \" << str_v[ans_num] << endl;\n\n return true;\n}\n\nint main() {\n cout.setf(ios::fixed);\n cout.precision(10);\n solve();\n\n return 0;\n}", "test_IO": [ { "input": "Thank you for your mail and your lectures\n", "output": "your lectures\n" } ] }, { "id": "s208096306", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing ll = long long int;\n\nint gcd(int a, int b) {\n if (a < b) swap(a, b);\n int r;\n while ((r = a % b) > 0) {\n a = b;\n b = r;\n }\n return b;\n}\n\nint main() {\n int n;\n cin >> n;\n\n int ans;\n cin >> ans;\n\n for (int i = 1; i < n; ++i) {\n int a;\n cin >> a;\n ans = gcd(ans, a);\n }\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "4\n2 10 8 40\n", "output": "2\n" } ] }, { "id": "s353737529", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n\nint dy[4] = {-1, 0, +1, 0};\nint dx[4] = {0, +1, 0, -1};\n\nconst long long INF = 1LL << 60;\nconst ll MOD = 1e9 + 7;\n\nbool greaterSecond(const pair& f, const pair& s) {\n return f.second > s.second;\n}\n\nint gcd(int a, int b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\n\nint main(void) {\n int n;\n\n cin >> n;\n\n string s = \"\";\n\n if (n == 0) {\n cout << '0' << endl;\n return 0;\n }\n\n int i = 1;\n while (n != 0) {\n if (n % 2 == 0) {\n s += '0';\n } else {\n s += '1';\n }\n\n n -= abs(n % 2);\n\n n /= -2;\n }\n\n reverse(s.begin(), s.end());\n\n cout << s << endl;\n}", "test_IO": [ { "input": "-9\n", "output": "1011\n" } ] }, { "id": "s929864256", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nusing Pll = pair;\n\nconst ll INF = 1LL << 60;\nconst ll MOD = 1000000007;\n\nint main() {\n ll a, b;\n cin >> a >> b;\n cout << max(a + b, max(a - b, a * b)) << endl;\n\n return 0;\n}", "test_IO": [ { "input": "-13 3\n", "output": "-10\n" } ] }, { "id": "s338629964", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define MOD2 1000000007\n#define MOD 998244353\n#define INF ((1 << 30) - 1)\n#define LINF (1LL << 60)\n#define EPS (1e-10)\ntypedef long long Int;\ntypedef pair P;\n\nInt fact[1100000];\nInt revfact[1100000];\nInt rev[1100000];\n\nvoid init() {\n Int m = MOD;\n fact[0] = 1;\n revfact[0] = 1;\n rev[0] = 0;\n rev[1] = 1;\n for (int i = 1; i < 1100000; i++) {\n fact[i] = fact[i - 1] * i % m;\n if (i > 1) rev[i] = MOD / i * (MOD - rev[MOD % i]) % MOD;\n revfact[i] = revfact[i - 1] * rev[i] % MOD;\n }\n}\n\nInt comb[1100][1100];\n\nInt nCk(Int n, Int k) {\n if (n < k) return 0;\n if (comb[n][k] != 0) return comb[n][k];\n Int &res = comb[n][k];\n return res = fact[n] * revfact[n - k] % MOD * revfact[k] % MOD;\n}\n\nInt mod_pow(Int x, Int a, Int m = MOD) {\n if (a == 0) return 1;\n Int res = mod_pow(x, a / 2, m);\n res = res * res % m;\n if (a % 2) res *= x;\n return res % m;\n}\n\nInt inv(Int x, Int m = MOD) { return mod_pow(x, m - 2, m); }\n\nInt aall, ball;\nInt n, ans;\nInt a[440], b[440];\nInt dp[440][440][2][2];\n\nint main() {\n init();\n cin >> n;\n for (int i = 0; i < n; i++) {\n cin >> a[i] >> b[i];\n aall += a[i];\n ball += b[i];\n }\n\n dp[0][0][0][0] = 1;\n for (int i = 1; i <= n; i++) {\n int id = i % 2;\n for (int asum = aall; asum >= 0; asum--) {\n for (int cnt = 0; cnt <= ball; cnt++) {\n for (int p = 0; p < 2; p++) {\n if (asum - a[i - 1] < 0) continue;\n Int pw = 1;\n for (int use = 0; use < b[i - 1]; use++) {\n if (cnt - use >= 0) {\n Int tmp = nCk(cnt, use) % MOD * pw % MOD;\n dp[asum][cnt][p][0] +=\n dp[asum - a[i - 1]][cnt - use][p ^ 1][0] * tmp %\n MOD;\n dp[asum][cnt][p][1] +=\n dp[asum - a[i - 1]][cnt - use][p ^ 1][1] * tmp %\n MOD;\n } else\n break;\n pw = pw * a[i - 1] % MOD;\n }\n if (cnt - b[i - 1] + 1 >= 0)\n dp[asum][cnt][p][1] +=\n dp[asum - a[i - 1]][cnt - b[i - 1] + 1][p ^ 1][0] *\n nCk(cnt, b[i - 1] - 1) % MOD * pw % MOD;\n dp[asum][cnt][p][0] %= MOD;\n dp[asum][cnt][p][1] %= MOD;\n }\n }\n }\n }\n\n for (int asum = 0; asum <= aall; asum++) {\n Int rev_asum_pow = 1;\n for (int cnt = 0; cnt <= ball; cnt++) {\n rev_asum_pow = rev_asum_pow * rev[asum] % MOD;\n for (int p = 0; p < 2; p++) {\n Int x = dp[asum][cnt][p][1] * rev_asum_pow % MOD * (cnt + 1) %\n MOD * aall % MOD * rev[asum] % MOD;\n if (p == 1)\n ans += x;\n else\n ans -= x;\n ans %= MOD;\n }\n }\n }\n if (ans < 0) ans += MOD;\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "2\n1 1\n1 1\n", "output": "3\n" } ] }, { "id": "s684825280", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\n\nconst int SIZE = (1e5 * 2) + 13;\n\nvector a;\nvector cnt(SIZE);\n\nint main() {\n int n, k;\n cin >> n >> k;\n for (int i = 0; i < n; ++i) {\n int x;\n cin >> x;\n cnt[x]++;\n }\n for (int i = 0; i < cnt.size(); ++i) {\n if (cnt[i] > 0) a.push_back(cnt[i]);\n }\n int ans = 0;\n sort(a.begin(), a.end());\n int m = a.size() - k;\n for (int i = 0; i < m; ++i) {\n ans += a[i];\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "5 2\n1 1 2 2 5\n", "output": "1\n" } ] }, { "id": "s397891977", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int r;\n cin >> r;\n\n cout << (r * r) << endl;\n}", "test_IO": [ { "input": "2\n", "output": "4\n" } ] }, { "id": "s950360470", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\nconst ll MOD = 1e9 + 7;\n\nll pow(ll a, ll n) {\n ll res = 1;\n while (n > 0) {\n if (n & 1) res *= a;\n a *= a;\n n >>= 1;\n }\n return res;\n}\n\nll mod_pow(ll a, ll n, ll mod) {\n ll res = 1;\n while (n > 0) {\n if (n & 1) res = res * a % mod;\n a = a * a % mod;\n n >>= 1;\n }\n return res;\n}\n\nll mod_inv(ll a, ll mod) { return mod_pow(a, mod - 2, mod); }\n\nll mod_nCk(int n, int k, int mod) {\n if (n == 0 || k == 0) return 1;\n ll p = 1, q = 1;\n for (int i = n - k + 1; i <= n; i++) p = (p * i) % MOD;\n for (int i = 2; i <= k; i++) q = (q * i) % MOD;\n q = mod_inv(q, MOD);\n return (p * q) % MOD;\n}\n\nint main() {\n int n, k;\n cin >> n >> k;\n cout << mod_nCk(k, n, MOD) << endl;\n}", "test_IO": [ { "input": "3 5\n", "output": "10\n" } ] }, { "id": "s970719454", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define reps(i, f, n) for (int i = f; i < int(n); i++)\n#define rep(i, n) reps(i, 0, n)\n\nint here[100001];\nint dp1[100001];\nint dp2[100001];\n\nint main() {\n while (1) {\n int n, m;\n cin >> n >> m;\n if (n == 0) break;\n\n rep(i, 100001) here[i] = dp1[i] = dp2[i] = 0;\n\n bool dpflg = false;\n\n rep(i, m) {\n int a;\n cin >> a;\n if (a == 0) dpflg = true;\n\n here[a] = 1;\n }\n\n int maxi1 = 0;\n int maxi2 = 0;\n\n reps(i, 1, n + 1) {\n if (here[i] == 1) dp1[i] = dp1[i - 1] + 1;\n maxi1 = max(dp1[i], maxi1);\n }\n\n reps(i, 1, n + 1) {\n if (here[i] == 1)\n dp2[i] = dp2[i - 1] + 1;\n else\n dp2[i] = dp1[i - 1] + 1;\n maxi2 = max(dp2[i], maxi2);\n }\n\n if (!dpflg) {\n printf(\"%d\\n\", maxi1);\n } else {\n printf(\"%d\\n\", maxi2);\n }\n }\n}", "test_IO": [ { "input": "7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0\n", "output": "2\n4\n" } ] }, { "id": "s448220316", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\ninline int read() {\n int k = 0, f = 1;\n char ch = getchar();\n while (ch < '0' || ch > '9') {\n if (ch == '-') f = -1;\n ch = getchar();\n }\n while (ch >= '0' && ch <= '9') {\n k = k * 10 + ch - '0';\n ch = getchar();\n }\n return k * f;\n}\n\ninline void write(int x) {\n if (x < 0) x = -x, putchar('-');\n if (x > 9) write(x / 10);\n putchar(x % 10 + '0');\n}\n\ninline void writeln(int x) {\n write(x);\n puts(\"\");\n}\n\nint n, m, l, r, vi, fa[100005], v[200005];\n\ninline int get(int x) {\n if (x == fa[x]) return x;\n int f = get(fa[x]);\n v[x] += v[fa[x]];\n return fa[x] = f;\n}\n\nint main() {\n n = read();\n m = read();\n for (int i = 1; i <= n; i++) fa[i] = i;\n for (int i = 1; i <= m; i++) {\n l = read();\n r = read();\n vi = read();\n int li = get(l), ri = get(r);\n if (li != ri) {\n v[ri] = vi - v[r] + v[l];\n fa[ri] = li;\n } else {\n if (v[r] - v[l] != vi) {\n cout << \"No\\n\";\n return 0;\n }\n }\n }\n cout << \"Yes\\n\";\n return 0;\n}", "test_IO": [ { "input": "3 3\n1 2 1\n2 3 1\n1 3 2\n", "output": "Yes\n" } ] }, { "id": "s151802561", "dataset": "codenet", "language": "C++", "code": "#include \n\nint main() {\n int A[100], n, i, j, t, sw = 0, mini;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) scanf(\"%d\", &A[i]);\n\n for (i = 0; i < n; i++) {\n mini = i;\n for (j = i; j < n; j++) {\n if (A[j] < A[mini]) mini = j;\n }\n t = A[i];\n A[i] = A[mini];\n A[mini] = t;\n if (i != mini) sw++;\n }\n\n for (i = 0; i < n; i++) {\n if (i) printf(\" \");\n printf(\"%d\", A[i]);\n }\n printf(\"\\n\");\n printf(\"%d\\n\", sw);\n\n return 0;\n}", "test_IO": [ { "input": "6\n5 6 4 2 1 3\n", "output": "1 2 3 4 5 6\n4\n" } ] }, { "id": "s680076196", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nint main() {\n int a, b, c, d;\n cin >> a >> b >> c >> d;\n cout << (a - c) * (b - d) << endl;\n}", "test_IO": [ { "input": "3 2\n2 1\n", "output": "1\n" } ] }, { "id": "s257064825", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define int long long int\nint32_t main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n string str;\n cin >> str;\n int sum = 0;\n for (char x : str) {\n sum += (x - 48);\n }\n if (sum % 9 == 0) {\n cout << \"Yes\" << endl;\n } else\n cout << \"No\" << endl;\n}", "test_IO": [ { "input": "123456789\n", "output": "Yes\n" } ] }, { "id": "s097779718", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nlong long Euclid(long long x, long long y) {\n long long tmp;\n\n if (x < y) {\n tmp = x;\n x = y;\n y = tmp;\n }\n\n if (!(x % y)) return y;\n return Euclid(y, x % y);\n}\n\nint main() {\n long long A, B;\n cin >> A >> B;\n\n cout << (A * B) / Euclid(A, B) << endl;\n}", "test_IO": [ { "input": "2 3\n", "output": "6\n" } ] }, { "id": "s716198307", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(void) {\n int n, a[100];\n double avg = 0, s, ans;\n cin >> n;\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n avg += a[i];\n }\n avg /= n;\n s = abs(a[0] - avg);\n ans = 0;\n for (int i = 1; i < n; i++) {\n if (s > abs(a[i] - avg)) {\n s = abs(a[i] - avg);\n ans = i;\n }\n }\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "3\n1 2 3\n", "output": "1\n" } ] }, { "id": "s569774535", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing ll = long long;\n\nint main() {\n int n;\n cin >> n;\n vector a(n);\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n }\n\n int ans = 0;\n bool ok = true;\n while (ok) {\n for (int i = 0; i < n; i++) {\n if (a[i] % 2 == 1) {\n cout << ans << endl;\n return 0;\n } else {\n a[i] /= 2;\n }\n }\n ans++;\n }\n\n cout << ans << endl;\n}", "test_IO": [ { "input": "3\n8 12 40\n", "output": "2\n" } ] }, { "id": "s285212630", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define int long long\ntypedef pair P;\n#define rep(i, n) for (int i = 0; i < (n); i++)\n#define all(c) (c).begin(), (c).end()\n#define uniq(c) c.erase(unique(all(c)), (c).end())\n#define _1 first\n#define _2 second\n#define pb push_back\n#define INF 1145141919\n#define MOD 1000000007\n#define MAX_L 22\nint N;\nvector

G[100000];\nint U[MAX_L][100000], R[100000];\nlong long L[100000];\n\nvoid dfs(int x, int p, int r, long long l) {\n U[0][x] = p;\n R[x] = r;\n L[x] = l;\n for (P pp : G[x]) {\n int t = pp._1;\n if (t == p) continue;\n dfs(t, x, r + 1, l + pp._2);\n }\n}\n\nint lca(int a, int b) {\n if (R[a] > R[b]) swap(a, b);\n for (int k = 0; k < MAX_L; k++) {\n if ((R[a] - R[b]) >> k & 1) b = U[k][b];\n }\n if (a == b) return a;\n for (int k = MAX_L - 1; k >= 0; k--) {\n if (U[k][a] != U[k][b]) {\n a = U[k][a];\n b = U[k][b];\n }\n }\n return U[0][a];\n}\nlong long dist(int x, int y) {\n int g = lca(x, y);\n return L[x] + L[y] - 2LL * L[g];\n}\n\nsigned main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cin >> N;\n rep(i, N - 1) {\n int a, b, c;\n cin >> a >> b >> c;\n a--, b--;\n G[a].pb(P(b, c));\n G[b].pb(P(a, c));\n }\n rep(i, MAX_L) rep(j, N) U[i][j] = -1;\n dfs(0, -1, 0, 0);\n for (int i = 0; i < MAX_L - 1; i++) {\n for (int v = 0; v < N; v++) {\n if (U[i][v] == -1) U[i + 1][v] = -1;\n U[i + 1][v] = U[i][U[i][v]];\n }\n }\n int Q, K;\n cin >> Q >> K;\n K--;\n rep(i, Q) {\n int x, y;\n cin >> x >> y;\n x--, y--;\n cout << dist(x, K) + dist(K, y) << \"\\n\";\n }\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n", "output": "3\n2\n4\n" } ] }, { "id": "s501882481", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i, N) for (int i = 0; i < (int)N; i++)\n#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)\n#define ALL(x) (x).begin(), (x).end()\n#define MOD 1000000007\n#define MAX (1 << 29)\n#define DEBUG(...) debug(__LINE__, \":\" __VA_ARGS__)\n\nusing Pi = pair;\nusing ll = long long;\nconst int INF = 1 << 28;\n\nstring to_string(string s) { return s; }\n\ntemplate \nstring to_string(pair p) {\n return \"{\" + to_string(p.first) + \",\" + to_string(p.second) + \"}\";\n}\n\ntemplate \nstring to_string(vector v) {\n string ret = \"{\";\n for (int i = 0; i < v.size() - 1; ++i) {\n ret += to_string(v[i]) + \",\";\n }\n if (v.size() > 0) {\n ret += to_string(v.back());\n }\n ret += \"}\";\n return ret;\n}\n\nvoid debug() { cerr << endl; }\n\ntemplate \nvoid debug(Head head, Tail... tail) {\n cerr << to_string(head) << \" \";\n debug(tail...);\n}\n\nvoid print() { cout << endl; }\n\ntemplate \nvoid print(Head head, Tail... tail) {\n cout << to_string(head);\n print(tail...);\n}\n\nvoid get() {}\n\ntemplate \nvoid get(Head& head, Tail&... tail) {\n cin >> head;\n get(tail...);\n}\n\ntemplate \nvoid getv(vector& vec) {\n for (int i = 0; i < vec.size(); ++i) cin >> vec[i];\n}\n\nint main() {\n string S;\n cin >> S;\n if (S == \"Sunny\") {\n print(\"Cloudy\");\n } else if (S == \"Cloudy\") {\n print(\"Rainy\");\n } else {\n print(\"Sunny\");\n }\n return 0;\n}", "test_IO": [ { "input": "Sunny\n", "output": "Cloudy\n" } ] }, { "id": "s531812249", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define PI 3.14159265358979\ntypedef long long ll;\n#define rep(i, n) for (int i = 0; i < n; i++)\n#include \n\nint main(void) {\n int n, m;\n\n cin >> n >> m;\n\n int ans = 0;\n\n ans += n * (n - 1) / 2;\n\n ans += m * (m - 1) / 2;\n\n cout << ans << endl;\n}", "test_IO": [ { "input": "2 1\n", "output": "1\n" } ] }, { "id": "s968402497", "dataset": "codenet", "language": "C++", "code": "#pragma GCC optimize(2)\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mod 1000000007\n#define mod9 998244353\n#define ld long double\n#define ull unsigned long long\n#define db double\n#define ll long long\nconst db eps = 1e-7;\n\nconst int INF = 0x3f3f3f3f;\nconst ll inf = 0x3f3f3f3f3f3f3f3f;\n#define rep(i, be, en) for (ll i = be; i <= en; i++)\n#define per(i, be, en) for (int i = en; i >= be; i--)\nusing namespace std;\nconst int N = 1e5 + 7;\n\nint tc, n, m, fl = 0;\n\nint main() {\n scanf(\"%d%d%d\", &tc, &n, &m);\n if (n > m) swap(n, m);\n for (int i = 1; i <= m; i++) {\n if (i * tc >= n && i * tc <= m) {\n printf(\"OK\\n\");\n fl = 1;\n break;\n }\n }\n if (fl == 0) puts(\"NG\");\n return 0;\n}", "test_IO": [ { "input": "7\n500 600\n", "output": "OK\n" } ] }, { "id": "s452437940", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \nusing namespace std;\nint main() {\n long long int a, b, x;\n scanf(\"%lld%lld%lld\", &a, &b, &x);\n long long int s = (b / x - a / x);\n if (a % x == 0) s++;\n printf(\"%lld\\n\", s);\n return 0;\n}", "test_IO": [ { "input": "4 8 2\n", "output": "3\n" } ] }, { "id": "s571373151", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nint main() {\n int n, m;\n std::cin >> n >> m;\n\n std::vector foods(m);\n\n for (int i = 0; i < n; i++) {\n int k;\n std::cin >> k;\n\n for (int j = 0; j < k; j++) {\n int temp;\n std::cin >> temp;\n temp--;\n\n foods[temp]++;\n }\n }\n\n int ans = 0;\n for (auto elem : foods) {\n if (elem == n) {\n ans++;\n }\n }\n\n std::cout << ans << std::endl;\n}", "test_IO": [ { "input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n", "output": "1\n" } ] }, { "id": "s698205968", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\n\nint main() {\n int m, f, r;\n while (cin >> m >> f >> r && (m != -1 || f != -1 || r != -1)) {\n if (m == -1 || f == -1)\n cout << \"F\";\n else if (m + f >= 80)\n cout << \"A\";\n else if (m + f >= 65)\n cout << \"B\";\n else if (m + f >= 50 || r >= 50)\n cout << \"C\";\n else if (m + f >= 30)\n cout << \"D\";\n else\n cout << \"F\";\n cout << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n", "output": "A\nC\nF\n" } ] }, { "id": "s672953945", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define int long long\n#define REP(i, s, e) for ((i) = (s); (i) < (e); (i)++)\n#define RREP(i, s, e) for ((i) = ((s)-1); (i) >= (e); (i)--)\n#define FOR(i, n) for ((i) = (0); (i) < (n); (i)++)\n#define RFOR(i, n) for ((i) = ((n)-1); (i) >= (0); (i)--)\n#define MOD 1000000007\n\nsigned main() {\n vector v;\n int N, L;\n\n cin >> N >> L;\n for (int i = 0; i < N; i++) {\n string s;\n cin >> s;\n v.push_back(s);\n }\n\n sort(v.begin(), v.end());\n\n for (int i = 0; i < v.size(); i++) {\n cout << v[i];\n }\n cout << endl;\n}", "test_IO": [ { "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n" } ] }, { "id": "s941927127", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(void) {\n string W;\n cin >> W;\n\n sort(W.begin(), W.end());\n\n for (string::iterator itr = W.begin(); itr != W.end(); itr += 2) {\n if (*itr != *(itr + 1)) {\n cout << \"No\" << endl;\n return 0;\n }\n }\n cout << \"Yes\" << endl;\n\n return 0;\n}", "test_IO": [ { "input": "abaccaba\n", "output": "Yes\n" } ] }, { "id": "s050708710", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n int r, g, b, n;\n cin >> r >> g >> b >> n;\n int ans = 0;\n for (int i = 0; i <= n / r; ++i) {\n for (int j = 0; j <= n / g; ++j) {\n int num = n - r * i - g * j;\n if (num >= 0 && num % b == 0) {\n ++ans;\n }\n }\n }\n\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "1 2 3 4\n", "output": "4\n" } ] }, { "id": "s173139590", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n int ac_count = 0;\n int wa_count = 0;\n int tle_count = 0;\n int re_count = 0;\n for (int i = 0; i < n; ++i) {\n string s;\n cin >> s;\n if (s == \"AC\") {\n ac_count += 1;\n } else if (s == \"WA\") {\n wa_count += 1;\n } else if (s == \"TLE\") {\n tle_count += 1;\n } else if (s == \"RE\") {\n re_count += 1;\n }\n }\n cout << \"AC x \" << ac_count << endl;\n cout << \"WA x \" << wa_count << endl;\n cout << \"TLE x \" << tle_count << endl;\n cout << \"RE x \" << re_count << endl;\n}", "test_IO": [ { "input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n", "output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n" } ] }, { "id": "s123678341", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair PII;\ntypedef pair PLL;\n#define fs first\n#define sc second\n#define INF 1000000000\n#define MOD 1000000007\n#define EPS 0.00000001\n\nint main() {\n int X, Y, Z, K;\n cin >> X >> Y >> Z >> K;\n vector A(X);\n vector B(Y);\n vector C(Z);\n for (ll &a : A) cin >> a;\n for (ll &b : B) cin >> b;\n for (ll &c : C) cin >> c;\n\n sort(A.begin(), A.end(), greater());\n sort(B.begin(), B.end(), greater());\n sort(C.begin(), C.end(), greater());\n\n vector AB;\n for (int i = 0; i < X; i++) {\n for (int j = 0; j < Y; j++) {\n AB.push_back(A[i] + B[j]);\n }\n }\n\n sort(AB.begin(), AB.end(), greater());\n vector ABC;\n for (int i = 0; i < min(K, (int)AB.size()); i++) {\n for (int j = 0; j < Z; j++) {\n ABC.push_back(AB[i] + C[j]);\n }\n }\n\n sort(ABC.begin(), ABC.end(), greater());\n for (int i = 0; i < K; i++) {\n cout << ABC[i] << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "2 2 2 8\n4 6\n1 5\n3 8\n", "output": "19\n17\n15\n14\n13\n12\n10\n8\n" } ] }, { "id": "s984540390", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\nll ans, mx, sum, mn = 1e8, cnt = 1;\n\nint main() {\n ll h;\n cin >> h;\n while (h != 1) {\n if (h % 2 != 0) h--;\n h /= 2;\n cnt *= 2;\n ans += cnt;\n }\n cout << ans + 1 << endl;\n}", "test_IO": [ { "input": "2\n", "output": "3\n" } ] }, { "id": "s844285682", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n int a, b;\n\n cin >> a;\n\n cout << a / (60 * 60) << \":\" << a % (60 * 60) / 60 << \":\"\n << a % (60 * 60) % 60 << endl;\n\n return 0;\n}", "test_IO": [ { "input": "46979\n", "output": "13:2:59\n" } ] }, { "id": "s391929974", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int n;\n int sq[10000], fr[5000];\n vector com;\n int tmp;\n\n while (1) {\n cin >> n;\n if (!n) break;\n\n for (int i = 1; i < n; i++) sq[i] = (i * i) % n;\n com.clear();\n\n for (int i = 1; i < n; i++) {\n bool f = true;\n for (int j = 0; j < com.size(); j++) {\n if (com[j] == sq[i]) {\n f = false;\n break;\n }\n }\n if (f) com.push_back(sq[i]);\n }\n\n for (int i = 0; i <= (n - 1) / 2; i++) fr[i] = 0;\n\n for (int i = 0; i < com.size(); i++) {\n for (int j = 0; j < com.size(); j++) {\n if (i != j) {\n tmp = com[i] - com[j];\n if (tmp < 0) tmp += n;\n if (tmp > (n - 1) / 2) tmp = n - tmp;\n fr[tmp]++;\n }\n }\n }\n\n for (int i = 1; i <= (n - 1) / 2; i++) cout << fr[i] << endl;\n }\n}", "test_IO": [ { "input": "11\n15\n0\n", "output": "4\n4\n4\n4\n4\n2\n2\n4\n2\n4\n4\n2\n" } ] }, { "id": "s209567491", "dataset": "codenet", "language": "C++", "code": "#define _CRT_SECURE_NO_WARNINGS\n#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\nint main(int argc, char *args[]) {\n int N, D, X;\n int num_of_chocolate;\n int counter;\n int days;\n int A[101];\n cin >> N >> D >> X;\n for (int i = 0; i < N; i++) {\n cin >> A[i];\n }\n num_of_chocolate = 0;\n for (int i = 0; i < N; i++) {\n days = 0;\n counter = 0;\n for (int j = 0;; j++) {\n days = j * A[i] + 1;\n if (days <= D) {\n counter++;\n } else {\n break;\n }\n }\n num_of_chocolate = num_of_chocolate + counter;\n }\n num_of_chocolate = num_of_chocolate + X;\n\n cout << num_of_chocolate << endl;\n}", "test_IO": [ { "input": "3\n7 1\n2\n5\n10\n", "output": "8\n" } ] }, { "id": "s466967233", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define REPD(i, a, b) for (int i = (a); i < (b); ++i)\n#define REP(i, n) REPD(i, 0, n)\ntypedef long long ll;\n#define fin(ans) cout << (ans) << '\\n'\n\nint main() {\n ll N, K;\n ll A[200100];\n ll B[200100] = {-1};\n int now = 1;\n ll cnt = 0;\n cin >> N >> K;\n REP(i, N) { cin >> A[i + 1]; }\n REP(i, 200100) { B[i] = -1; }\n\n ll j;\n B[1] = 0;\n for (j = 1; j <= K; j++) {\n now = A[now];\n if (B[now] == -1) {\n B[now] = j;\n } else {\n cnt = j;\n\n break;\n }\n }\n if (j < K) {\n ll tmp;\n tmp = (K - B[now]) % (cnt - B[now]);\n\n for (ll j = 0; j < tmp; j++) {\n now = A[now];\n }\n }\n fin(now);\n return 0;\n}", "test_IO": [ { "input": "4 5\n3 2 4 1\n", "output": "4\n" } ] }, { "id": "s575600334", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nvoid binPrint(int x, int bits) {\n for (int i = bits - 1; i >= 0; i--) {\n cout << (x & (1 << i) ? 1 : 0);\n }\n cout << endl;\n}\nint main(void) {\n unsigned a, b;\n cin >> a >> b;\n\n binPrint(a & b, 32);\n binPrint(a | b, 32);\n binPrint(a ^ b, 32);\n\n return 0;\n}", "test_IO": [ { "input": "8 10\n", "output": "00000000000000000000000000001000\n00000000000000000000000000001010\n00000000000000000000000000000010\n" } ] }, { "id": "s469969316", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\n#define rep(i, n) for (int i = 0; i < int(n); i++)\n\nstring input, ss;\nint a[3], it, cnt;\n\nint Not(int x) { return 2 - x; }\n\nint And(int x, int y) {\n if (x * y == 0) return 0;\n if (x == 2 && y == 2) return 2;\n return 1;\n}\n\nint Or(int x, int y) {\n if (x == 2 || y == 2) return 2;\n if (x == 1 || y == 1) return 1;\n return 0;\n}\n\nint parse() {\n char c = ss[it++];\n if ('0' <= c && c <= '2') return c - '0';\n if (c == '-') return Not(parse());\n\n int x = parse();\n c = ss[it++];\n int y = parse();\n ++it;\n return c == '*' ? And(x, y) : Or(x, y);\n}\n\nint main() {\n while (cin >> input && input != \".\") {\n rep(i, 3) a[i] = i;\n cnt = 0;\n rep(i, 3) rep(j, 3) rep(k, 3) {\n a[0] = i;\n a[1] = j;\n a[2] = k;\n ss = input;\n for (char& c : ss) {\n if (c == 'P') c = a[0] + '0';\n if (c == 'Q') c = a[1] + '0';\n if (c == 'R') c = a[2] + '0';\n }\n it = 0;\n if (parse() == 2) cnt++;\n }\n cout << cnt << endl;\n }\n}", "test_IO": [ { "input": "(P*Q)\n(--R+(P*Q))\n(P*-P)\n2\n1\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.\n", "output": "3\n11\n0\n27\n0\n7\n" } ] }, { "id": "s812763520", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int n, ans = 0;\n string a, b, c;\n cin >> n;\n cin >> a >> b >> c;\n\n for (int i = 0; i < n; i++) {\n if (a[i] == b[i] && b[i] == c[i]) {\n } else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {\n ans++;\n } else {\n ans += 2;\n }\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "4\nwest\neast\nwait\n", "output": "3\n" } ] }, { "id": "s144923291", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define intmax INT_MAX\n#define lmax LONG_MAX\n#define uintmax UINT_MAX\n#define ulmax ULONG_MAX\n#define llmax LLONG_MAX\n#define ll long long\n#define rep(i, a, N) for ((i) = (a); (i) < (N); (i)++)\n#define rrp(i, N, a) for ((i) = (N)-1; (i) >= (a); (i)--)\n#define llfor ll i, j\n#define sc(a) cin >> a\n#define pr(a) cout << a << endl\n#define pY puts(\"YES\")\n#define pN puts(\"NO\")\n#define py puts(\"Yes\")\n#define pn puts(\"No\")\n#define pnn printf(\"\\n\")\n#define all(a) a.begin(), a.end()\n#define push(a, b) (a).push_back(b)\n#define llvec vector>\n#define charvec vector>\n#define size(a, b) (a, vector(b))\n#define llpvec vector>\ndouble pi = acos(-1);\nll cei(ll x, ll y) {\n ll ans = x / y;\n if (x % y != 0) ans++;\n return ans;\n}\nll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }\nll lcm(ll x, ll y) { return x / gcd(x, y) * y; }\nll llpow(ll x, ll n) {\n ll i, ans = 1;\n rep(i, 0, n) ans *= x;\n return ans;\n}\nll fact(ll x) {\n ll i, ans = 1;\n rep(i, 0, x) ans *= (x - i);\n return ans;\n}\nll ncr(ll n, ll r) { return fact(n) / fact(r) / fact(n - r); }\nll npr(ll n, ll r) { return fact(n) / fact(n - r); }\nbool prime(ll a) {\n if (a <= 1) return false;\n ll i;\n for (i = 2; i * i <= a; i++) {\n if (a % i == 0) return false;\n }\n return true;\n}\nll fib(ll x) {\n ll i, fibo[x + 10];\n fibo[0] = 1;\n fibo[1] = 1;\n fibo[2] = 1;\n rep(i, 3, x + 1) fibo[i] = fibo[i - 1] + fibo[i - 2];\n return fibo[x];\n}\nll dig(ll n) {\n ll d = 0, i = 0;\n while (n / 10 > 0) {\n i++;\n d++;\n }\n return d;\n}\nllfor;\nll ans = 0;\nint main() {\n ll h, w;\n cin >> h >> w;\n char t[10], s[10] = \"snuke\";\n rep(i, 0, h) {\n rep(j, 0, w) {\n sc(t);\n if (!strcmp(s, t)) {\n char c = 'A' + j;\n cout << c << i + 1 << endl;\n return 0;\n }\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snuke snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n", "output": "H6\n" } ] }, { "id": "s360529905", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing std::sort;\nint main(void) {\n int *a, *b, i, N;\n int frontHalf, backHalf;\n scanf(\"%d\", &N);\n a = new int[N];\n b = new int[N];\n for (i = 0; i < N; i++) {\n scanf(\"%d\", a + i);\n b[i] = a[i];\n }\n sort(b, b + N);\n frontHalf = b[N / 2 - 1];\n backHalf = b[N / 2];\n delete[] b;\n for (i = 0; i < N; i++) {\n if (a[i] < backHalf)\n printf(\"%d\\n\", backHalf);\n else\n printf(\"%d\\n\", frontHalf);\n }\n delete[] a;\n return 0;\n}", "test_IO": [ { "input": "4\n2 4 4 3\n", "output": "4\n3\n3\n4\n" } ] }, { "id": "s438448326", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int A, B, C, D, E, F;\n cin >> A >> B >> C >> D >> E >> F;\n\n int m1 = 0, m2 = 0;\n float maxD = 0.f;\n for (size_t i = 0; 100 * A * i <= F; i++) {\n int mA = 100 * A * i;\n for (size_t j = 0; mA + 100 * B * j <= F; j++) {\n int mB = 100 * B * j;\n for (size_t k = 0; mA + mB + C * k <= F; k++) {\n int mC = C * k;\n for (size_t l = 0; mA + mB + mC + D * l <= F; l++) {\n int mD = D * l;\n if ((mA + mB) * E / 100 < mD + mC) {\n break;\n }\n float d = (float)(mD + mC) / (float)(mA + mB + mC + mD);\n if (d > maxD) {\n m1 = mA + mB + mC + mD;\n m2 = mC + mD;\n maxD = d;\n }\n }\n }\n }\n }\n if (m1 == 0) {\n m1 = 100 * A;\n }\n cout << m1 << \" \" << m2 << endl;\n return 0;\n}", "test_IO": [ { "input": "1 2 10 20 15 200\n", "output": "110 10\n" } ] }, { "id": "s593850729", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n int A, B, C, X;\n cin >> A >> B >> C >> X;\n\n int cnt = 0;\n for (int a = 0; a <= A; a++) {\n for (int b = 0; b <= B; b++) {\n for (int c = 0; c <= C; c++) {\n int total = 500 * a + 100 * b + 50 * c;\n if (total == X) cnt++;\n }\n }\n }\n cout << cnt << endl;\n}", "test_IO": [ { "input": "2\n2\n2\n100\n", "output": "2\n" } ] }, { "id": "s330459995", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int W, H, x, y, r;\n cin >> W >> H >> x >> y >> r;\n if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {\n cout << \"No\" << endl;\n } else if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= W) {\n cout << \"Yes\" << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "5 4 2 2 1\n", "output": "Yes\n" } ] }, { "id": "s384319383", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#define REP(i, n) for (int i = 0; i < (n); ++i)\n#define ALL(v) (v).begin, (v).end()\n#define INF 1e9\n#define MOD 1e9 + 7\ntypedef long long llong;\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n vector cnt(26, 1);\n vector s(n);\n REP(i, n) {\n cin >> s[i];\n cnt[s[i] - 'a']++;\n }\n\n llong ans = cnt[0];\n for (int i = 1; i < 26; ++i) {\n ans *= cnt[i];\n ans %= (int)MOD;\n }\n\n cout << ans - 1 << endl;\n return 0;\n}", "test_IO": [ { "input": "4\nabcd\n", "output": "15\n" } ] }, { "id": "s789380051", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\ntypedef long long LL;\n\nusing namespace std;\n\n#define MOD 1000000007\n\nLL mod_pow(LL x, LL n) {\n LL ans = 1;\n while (n > 0) {\n if ((n & 1) == 1) {\n ans = ans * x % MOD;\n }\n x = x * x % MOD;\n n >>= 1;\n }\n return ans;\n}\n\nLL comb_s(LL n, LL r) {\n LL tmp_n = 1;\n LL tmp_d = 1;\n LL ans;\n for (int i = 1; i <= r; i++) {\n tmp_n = (tmp_n * (n + 1 - i)) % MOD;\n tmp_d = (tmp_d * i) % MOD;\n ans = tmp_n * mod_pow(tmp_d, MOD - 2);\n }\n\n return ans;\n}\n\nint main() {\n LL n;\n LL n_tmp;\n LL a;\n LL b;\n LL ans = 1;\n\n cin >> n >> a >> b;\n ans = mod_pow(2, n);\n ans--;\n LL tmp_nd;\n tmp_nd = comb_s(n, a);\n ans = (ans - tmp_nd) % MOD;\n while (ans < 0) {\n ans += MOD;\n }\n\n tmp_nd = comb_s(n, b);\n ans = (ans - tmp_nd) % MOD;\n\n while (ans < 0) {\n ans += MOD;\n }\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "4 1 3\n", "output": "7\n" } ] }, { "id": "s772335512", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nvector G[100000];\nbool used[100000];\nint grundy[100000];\n\nvoid dfs(int v) {\n used[v] = true;\n grundy[v] = 0;\n for (int i = 0; i < G[v].size(); i++) {\n if (!used[G[v][i]]) {\n dfs(G[v][i]);\n grundy[v] ^= (grundy[G[v][i]] + 1);\n }\n }\n}\n\nint main() {\n int N;\n cin >> N;\n for (int i = 0; i < N - 1; i++) {\n int x, y;\n cin >> x >> y;\n x--;\n y--;\n G[x].push_back(y);\n G[y].push_back(x);\n }\n dfs(0);\n if (grundy[0] != 0) {\n cout << \"Alice\" << endl;\n } else {\n cout << \"Bob\" << endl;\n }\n}", "test_IO": [ { "input": "5\n1 2\n2 3\n2 4\n4 5\n", "output": "Alice\n" } ] }, { "id": "s659042676", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nint main() {\n int a, b;\n cin >> a >> b;\n cout << 6 - a - b << endl;\n}", "test_IO": [ { "input": "3\n1\n", "output": "2\n" } ] }, { "id": "s612033342", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\nusing vi = vector;\nusing vi2 = vector;\n\nint pow2(int a) {\n int ret = 1;\n for (int i = 0; i < a; i++) ret *= 2;\n return ret;\n}\n\nint count(vi2 hw, int a, int b) {\n int sum = 0;\n for (int i = 0; i < hw.size(); i++) {\n for (int j = 0; j < hw[0].size(); j++) {\n if (a >> i & 1 && b >> j & 1 && hw[i][j] == 1) sum++;\n }\n }\n return sum;\n}\n\nint main() {\n int h, w, k;\n cin >> h >> w >> k;\n vi2 hw(h, vi(w, 0));\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n char c;\n cin >> c;\n if (c == '#') hw[i][j] = 1;\n }\n }\n int sum = 0;\n for (int i = 0; i < pow2(h); i++) {\n for (int j = 0; j < pow2(w); j++) {\n if (count(hw, i, j) == k) sum++;\n }\n }\n cout << sum << endl;\n}", "test_IO": [ { "input": "2 3 2\n..#\n###\n", "output": "5\n" } ] }, { "id": "s023282516", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nstring divide[4] = {\"dream\", \"dreamer\", \"erase\", \"eraser\"};\n\nint main() {\n string S;\n cin >> S;\n\n reverse(S.begin(), S.end());\n for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());\n\n bool can = true;\n for (int i = 0; i < S.size();) {\n bool can2 = false;\n for (int j = 0; j < 4; ++j) {\n string d = divide[j];\n if (S.substr(i, d.size()) == d) {\n can2 = true;\n i += d.size();\n }\n }\n if (!can2) {\n can = false;\n break;\n }\n }\n\n if (can)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n}", "test_IO": [ { "input": "erasedream\n", "output": "YES\n" } ] }, { "id": "s778828888", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nint main() {\n int n, m, x;\n int a[105] = {};\n scanf(\"%d %d %d\", &n, &m, &x);\n\n for (int i = 0; i < m; ++i) {\n int temp;\n scanf(\"%d\", &temp);\n a[temp] = 1;\n }\n\n int ansl = 0, ansr = 0, i;\n for (i = x; i <= n; ++i) {\n ansr += a[i];\n }\n for (i = x; i >= 0; --i) {\n ansl += a[i];\n }\n\n printf(\"%d\\n\", std::min(ansl, ansr));\n return 0;\n}", "test_IO": [ { "input": "5 3 3\n1 2 4\n", "output": "1\n" } ] }, { "id": "s956589471", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\n\nint main() {\n int a, b, c, d, e, k;\n cin >> a >> b >> c >> d >> e >> k;\n\n cout << (e - a <= k ? \"Yay!\" : \":(\") << endl;\n\n return 0;\n}", "test_IO": [ { "input": "1\n2\n4\n8\n9\n15\n", "output": "Yay!\n" } ] }, { "id": "s559238064", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int inf = 0x3f3f3f3f;\nconst int mod = (1 ? 1e9 + 7 : 998244353);\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll a, b, c, d, e, f, g, T;\n string z;\n cin >> z;\n a = z.size();\n for (int i = 0; i < a - 1; i++) {\n if (z[i] == z[i + 1]) {\n cout << \"Bad\" << endl;\n return 0;\n }\n }\n cout << \"Good\" << endl;\n}", "test_IO": [ { "input": "3776\n", "output": "Bad\n" } ] }, { "id": "s003531724", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i, a, b) for (int i = a; i <= b; i++)\n#define dep(i, a, b) for (int i = a; i >= b; i--)\n#define Rep(i, a) for (int i = 0; i < a; i++)\n#define pb(a) push_back(a)\n#define mp(a, b) make_pair(a, b)\n#define ab(x) ((x) < 0 ? -(x) : (x))\nusing namespace std;\ntypedef long long LL;\ntypedef map::iterator mit;\ntypedef set::iterator sit;\ntypedef pair pii;\n#define x first\n#define y second\nconst int N = 1e5 + 10;\n\nstruct edge {\n int to, pre, c;\n} e[N << 1];\nint u[N], l = 0;\nvoid ins(int a, int b, int c) { e[++l] = (edge){b, u[a], c}, u[a] = l; }\n#define v e[i].to\n#define ec e[i].c\n#define reg(i, a) for (int i = u[a]; i; i = e[i].pre)\n\nint n, m;\nbool vis[N], ok;\nLL cnt[3];\nint d[N];\nint T;\nvoid dfs(int x, int l) {\n vis[x] = true;\n cnt[l]++;\n d[x] = l;\n reg(i, x) {\n T++;\n if (!vis[v])\n dfs(v, (l + ec) % 3);\n else if ((l + ec) % 3 != d[v])\n ok = false;\n }\n}\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n rep(i, 1, m) {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n ins(a, b, 1), ins(b, a, 2);\n }\n LL ans = 0;\n rep(i, 1, n) if (!vis[i]) {\n T = 0;\n rep(j, 0, 2) cnt[j] = 0;\n ok = true;\n dfs(i, 0);\n LL s = cnt[0] + cnt[1] + cnt[2];\n if (!ok)\n ans += s * s;\n else {\n if (cnt[0] && cnt[1] && cnt[2])\n ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];\n else\n ans += T / 2;\n }\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "3 2\n1 2\n2 3\n", "output": "3\n" } ] }, { "id": "s550008428", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n int s, x, d = 2;\n cin >> s;\n set a;\n a.insert(s);\n\n while (1) {\n if (s % 2 == 0) {\n x = s / 2;\n if (a.find(x) != a.end()) {\n cout << d << endl;\n return 0;\n }\n a.insert(x);\n } else {\n x = 3 * s + 1;\n if (a.find(x) != a.end()) {\n cout << d << endl;\n return 0;\n }\n a.insert(x);\n }\n s = x;\n d++;\n }\n\n cout << d << endl;\n\n return 0;\n}", "test_IO": [ { "input": "8\n", "output": "5\n" } ] }, { "id": "s798006876", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\nconst int MAX_N = 1e3;\nint data[MAX_N];\nint main() {\n int m, nmi, nma;\n while (cin >> m >> nmi >> nma && nmi != 0) {\n for (int i = 0; i < m; i++) cin >> data[i];\n int ma = 0;\n int ans = 0;\n for (int i = nmi - 1; i < nma; i++) {\n if (ma <= data[i] - data[i + 1]) {\n ans = i + 1;\n ma = data[i] - data[i + 1];\n }\n }\n cout << ans << endl;\n }\n}", "test_IO": [ { "input": "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n4000\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0\n", "output": "3\n4\n2\n2\n3\n2\n" } ] }, { "id": "s615050061", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing u64 = unsigned long long;\n\nconst u64 B = 13131;\nconst int N = 500000 + 7;\n\nint n;\nchar s[N];\nu64 f[N];\nint g[N];\nstd::map map;\nu64 cnt;\n\nu64 pow(u64 a, u64 k) {\n if (k < 0) k += (1llu << 63) - 1;\n u64 t = 1;\n for (; k; a = a * a, k >>= 1)\n if (k & 1) t = t * a;\n return t;\n}\n\nint main() {\n scanf(\"%d%s\", &n, s + 1);\n for (int i = 1; i <= n; ++i)\n if (s[i] == '+' || s[i] == '-')\n f[i] = f[i - 1] + (s[i] == '+' ? 1 : -1) * pow(B, g[i] = g[i - 1]);\n else\n f[i] = f[i - 1], g[i] = g[i - 1] + (s[i] == '<' ? -1 : 1);\n for (int i = n; i; --i)\n ++map[f[i]], cnt += map[f[n] * pow(B, g[i - 1]) + f[i - 1]];\n printf(\"%lld\\n\", cnt);\n\n return 0;\n}", "test_IO": [ { "input": "5\n+>+<-\n", "output": "3\n" } ] }, { "id": "s438435664", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\nll gcd(ll x, ll y) {\n ll tmp = 0;\n if (x < y) {\n tmp = x;\n x = y;\n y = tmp;\n }\n while (y > 0) {\n ll r = x % y;\n x = y;\n y = r;\n }\n return x;\n}\n\nll lcm(ll x, ll y) { return x / gcd(x, y) * y; }\n\nll kaijo(ll k) {\n ll sum = 1;\n for (ll i = 1; i <= k; ++i) {\n sum *= i;\n sum %= 1000000000 + 7;\n }\n return sum;\n}\n\nll lmax(ll s, ll t) {\n if (s > t) {\n return s;\n } else {\n return t;\n }\n}\n\nll lmin(ll s, ll t) {\n if (s < t) {\n return s;\n } else {\n return t;\n }\n}\n\nint main() {\n int n, k;\n cin >> n >> k;\n ll sum = 0;\n for (int b = 1; b <= n; b++) {\n int cnt = (n + 1) / b;\n int md = (n + 1) % b;\n sum += cnt * max((b - k), 0) + max((md - k), 0);\n if (k == 0) sum--;\n }\n cout << sum << endl;\n return 0;\n}", "test_IO": [ { "input": "5 2\n", "output": "7\n" } ] }, { "id": "s634121896", "dataset": "codenet", "language": "C++", "code": "#pragma GCC optimize(\"fast-math\")\n#pragma GCC optimize(\"unroll-loops\")\n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define DEBUG\n#define fi first\n#define se second\n#define pqueue priority_queue\n#define pb(x) push_back(x)\n\n#define all(x) x.begin(), x.end()\n#define int long long\n#define mk(a, b) make_pair(a, b)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector > vvi;\ntypedef vector vull;\ntypedef vector vll;\n\ntypedef pair pii;\ntypedef vector > vpii;\ntypedef pair pll;\ntypedef vector vb;\ntypedef vector vs;\ntypedef vector > vvll;\ntypedef vector vc;\n\nconst ll INF = 1e9 + 228;\nconst ll INFLL = 1e18;\nconst ll MOD = 1e9 + 7;\n\nconst ld eps = 1e-6;\nconst ld eps2 = 1e-9;\nconst ll MOD2 = 998244353;\nconst ll dosz = 5e5;\nconst ll SZ = (1 << 18);\nconst ld PI = atan2l(0, -1);\n\nvoid fast_io() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n}\n\nvoid solve() {\n int n;\n cin >> n;\n vi nums(n);\n int last = 0;\n for (int i = 0; i < n; i++) {\n cin >> nums[i];\n }\n vi dp(n + 1, 0);\n dp[0] = 1;\n map kek;\n map prev;\n for (int i = 1; i <= n; i++) {\n dp[i] = dp[i - 1] + (prev[nums[i - 1]] != i - 1 ? kek[nums[i - 1]] : 0);\n dp[i] %= MOD;\n kek[nums[i - 1]] = dp[i];\n prev[nums[i - 1]] = i;\n }\n cout << dp[n] << endl;\n}\n\nsigned main() {\n fast_io();\n srand(time(NULL));\n cout << fixed << setprecision(12);\n int q = 1;\n\n while (q--) solve();\n}", "test_IO": [ { "input": "5\n1\n2\n1\n2\n2\n", "output": "3\n" } ] }, { "id": "s800506321", "dataset": "codenet", "language": "C++", "code": "#include \nint main(void) {\n int n, k, x, y, z;\n scanf(\"%d\", &n);\n scanf(\"%d\", &k);\n x = n / k;\n y = n % k;\n if (y != 0) {\n z = x + 1 - x;\n } else {\n z = x - x;\n }\n printf(\"%d\\n\", z);\n\n return 0;\n}", "test_IO": [ { "input": "7 3\n", "output": "1\n" } ] }, { "id": "s447383972", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define For(i, x, y) for (ll i = x; i <= y; ++i)\n#define FOr(i, x, y) for (ll i = x; i >= y; --i)\nusing namespace std;\ninline ll read() {\n ll x = 0, f = 1;\n char ch = getchar();\n while (ch < '0' || ch > '9') {\n if (ch == '-') f = -1;\n ch = getchar();\n }\n while (ch >= '0' && ch <= '9') {\n x = x * 10 + ch - '0';\n ch = getchar();\n }\n return x * f;\n}\ninline void write(ll x) {\n if (x < 0) putchar('-'), x = -x;\n if (x >= 10) write(x / 10);\n putchar(x % 10 + '0');\n}\ninline void writeln(ll x) {\n write(x);\n puts(\"\");\n}\n\nconst ll N = 200010;\nll a[N], q[N], n, tot;\nint main() {\n n = read();\n For(i, 1, n) a[i] = read();\n sort(a + 1, a + n + 1);\n For(i, 1, n) if (a[i] == a[i + 1]) q[++tot] = a[i], i++;\n writeln(q[tot] * q[tot - 1]);\n}", "test_IO": [ { "input": "6\n3 1 2 4 2 1\n", "output": "2\n" } ] }, { "id": "s495283729", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nint main(void) {\n char s[1000];\n scanf(\"%s\", s);\n int i, flag = 0;\n for (i = 0; i < strlen(s); i++) {\n if (i % 2 == 0) {\n switch (s[i]) {\n case 'R':\n break;\n case 'U':\n break;\n case 'D':\n break;\n default:\n flag = 1;\n break;\n }\n } else {\n switch (s[i]) {\n case 'L':\n break;\n case 'U':\n break;\n case 'D':\n break;\n default:\n flag = 1;\n break;\n }\n }\n }\n if (flag == 0) {\n puts(\"Yes\");\n } else {\n puts(\"No\");\n }\n}", "test_IO": [ { "input": "RUDLUDR\n", "output": "Yes\n" } ] }, { "id": "s973217665", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define REP(i, n) for (int i = 0; i < n; ++i)\n#define FOR(i, a, b) for (int i = a; i <= b; ++i)\n#define FORR(i, a, b) for (int i = a; i >= b; --i)\n#define pi M_PI\n\ntypedef long long ll;\ntypedef vector VI;\ntypedef vector VL;\ntypedef vector VVI;\ntypedef pair P;\ntypedef pair PL;\n\nint main() {\n int n;\n cin >> n;\n while (n--) {\n int p, q;\n cin >> p >> q;\n int l = sqrt(p * p + q * q);\n bool isprime = 1;\n REP(i, l) REP(j, l) {\n int x = i * i + j * j;\n if (x <= 1 || x >= p * p + q * q) continue;\n if ((i * p + j * q) % x == 0 && (i * q - j * p) % x == 0)\n isprime = 0;\n }\n cout << (isprime ? \"P\" : \"C\") << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "8\n10 0\n0 2\n-3 0\n4 2\n0 -13\n-4 1\n-2 -1\n3 -1\n", "output": "C\nC\nP\nC\nC\nP\nP\nC\n" } ] }, { "id": "s990022717", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define INF 1000000000\nusing namespace std;\nbool debug = false;\n\nint main() {\n int n, k, x, y;\n cin >> n >> k >> x >> y;\n int sum = 0;\n for (int i = 1; i <= n; i++) {\n if (i > k)\n sum += y;\n else\n sum += x;\n }\n cout << sum << endl;\n\n return 0;\n}", "test_IO": [ { "input": "5\n3\n10000\n9000\n", "output": "48000\n" } ] }, { "id": "s194793609", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nint main() {\n int n;\n std::cin >> n;\n\n std::vector a(n);\n for (int i = 0; i < n; i++) {\n std::cin >> a[i];\n }\n\n std::vector abs_a = a;\n\n for (int i = 0; i < n; i++) {\n if (abs_a[i] < 0) {\n abs_a[i] = -abs_a[i];\n }\n }\n\n long long ans = 0;\n long long min = abs_a[0];\n for (auto e : abs_a) {\n ans += e;\n if (min > e) {\n min = e;\n }\n }\n int num_negative = 0;\n for (auto e : a) {\n if (e < 0) {\n num_negative++;\n }\n }\n\n if (num_negative % 2) {\n ans -= min * 2;\n }\n\n std::cout << ans << std::endl;\n}", "test_IO": [ { "input": "3\n-10 5 -4\n", "output": "19\n" } ] }, { "id": "s049366196", "dataset": "codenet", "language": "C++", "code": "#define _GLIBCXX_DEBUG\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n#define ALL(v) (v).begin(), (v).end()\nconst int inf = 1e9;\nconst int mod = 1e9 + 7;\n\nbool is_prime(ll x) {\n for (ll i = 2; i * i <= x; i++)\n if (x % i == 0) return false;\n return true;\n}\n\nint main() {\n int N;\n cin >> N;\n\n ll ans = 1;\n for (int i = 2; i <= N; i++) {\n if (is_prime((ll)i)) {\n int NN = N;\n int cnt = 0;\n while (NN) {\n cnt += NN / i;\n NN /= i;\n }\n ans *= cnt + 1;\n ans %= mod;\n }\n }\n\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "3\n", "output": "4\n" } ] }, { "id": "s575944217", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\n#define MAX_V 100001\n#define MOD 1000000007\ntypedef vector > Graph;\n\nint main() {\n int n;\n cin >> n;\n vector ans(n);\n for (int i = 0; i < n - 1; i++) {\n int a;\n cin >> a;\n a--;\n ans[a]++;\n }\n for (int i = 0; i < n; i++) cout << ans[i] << endl;\n}", "test_IO": [ { "input": "5\n1 1 2 2\n", "output": "2\n2\n0\n0\n0\n" } ] }, { "id": "s107598592", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int N;\n cin >> N;\n vector X(N);\n vector Y(N);\n for (int i = 0; i < N; i++) {\n cin >> X[i];\n Y[i] = X[i];\n }\n\n sort(Y.begin(), Y.end());\n\n int y = Y[N / 2];\n for (int i = 0; i < N; i++) {\n if (X[i] < Y[N / 2]) {\n cout << Y[N / 2];\n } else {\n cout << Y[N / 2 - 1];\n }\n cout << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "4\n2 4 4 3\n", "output": "4\n3\n3\n4\n" } ] }, { "id": "s014089689", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int n;\n cin >> n;\n string s;\n cin >> s;\n int cnt = 0;\n for (int i = 0; i < n; i++) {\n cnt++;\n int j = i + 1;\n for (; j < n; j++) {\n if (s[i] != s[j]) {\n break;\n }\n }\n i = j - 1;\n }\n cout << cnt << endl;\n}", "test_IO": [ { "input": "10\naabbbbaaca\n", "output": "5\n" } ] }, { "id": "s700281300", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define REP(i, k, n) for (int i = k; i < n; i++)\n#define rep(i, n) for (int i = 0; i < n; i++)\n\nusing namespace std;\ntypedef long long ll;\n\nint main() {\n int n;\n cin >> n;\n\n rep(i, n) {\n string s;\n cin >> s;\n\n set st;\n st.insert(s);\n\n REP(j, 1, s.size()) {\n stringstream ss;\n rep(k, j) { ss << s[k]; }\n string res = ss.str();\n\n stringstream ss2;\n REP(k, j, s.size()) { ss2 << s[k]; }\n\n string res2 = ss2.str();\n\n string t = res;\n reverse(res.begin(), res.end());\n string t2 = res2;\n reverse(res2.begin(), res2.end());\n\n st.insert(t + t2);\n st.insert(t2 + t);\n\n st.insert(t + res2);\n st.insert(res2 + t);\n\n st.insert(res + t2);\n st.insert(t2 + res);\n\n st.insert(res + res2);\n st.insert(res2 + res);\n }\n\n cout << st.size() << endl;\n }\n\n return 0;\n}", "test_IO": [ { "input": "4\naa\nabba\nabcd\nabcde\n", "output": "1\n6\n12\n18\n" } ] }, { "id": "s934757053", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nint main() {\n int A, B;\n int ans = 0;\n int out = 1;\n cin >> A >> B;\n\n while (out < B) {\n out--;\n out += A;\n ans++;\n }\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "4 10\n", "output": "3\n" } ] }, { "id": "s218395502", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int a, b, c;\n\n cin >> a >> b >> c;\n\n if ((100 * a + 10 * b + c) % 4 == 0) {\n cout << \"YES\" << endl;\n } else {\n cout << \"NO\" << endl;\n }\n}", "test_IO": [ { "input": "4 3 2\n", "output": "YES\n" } ] }, { "id": "s395011148", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nlong long N, A[1 << 18];\nlong long dp[1 << 18][2][20];\n\nint main() {\n cin >> N;\n for (int i = 1; i <= N; i++) cin >> A[i];\n for (int i = 0; i <= N; i++) {\n for (int j = 0; j < 20; j++) {\n dp[i][0][j] = -(1LL << 60);\n dp[i][1][j] = -(1LL << 60);\n }\n }\n dp[0][0][10] = 0;\n for (int i = 1; i <= N; i++) {\n for (int j = 6; j <= 14; j++) {\n if (dp[i - 1][0][j] != (1LL << 60)) {\n dp[i][1][j + 1] = max(dp[i][1][j + 1], dp[i - 1][0][j] + A[i]);\n dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][0][j]);\n }\n if (dp[i - 1][1][j] != (1LL << 60)) {\n dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][1][j]);\n }\n }\n }\n\n long long V = 10LL + (N / 2) - (N - (N / 2));\n long long T1 = dp[N][0][V];\n long long T2 = dp[N][1][V];\n cout << max(T1, T2) << endl;\n return 0;\n}", "test_IO": [ { "input": "6\n1 2 3 4 5 6\n", "output": "12\n" } ] }, { "id": "s350755479", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 1e5 + 5;\n\nstruct Node {\n int x, y, id;\n} node[maxn];\n\nstruct Edge {\n int u, v, val;\n bool operator<(const Edge &rhs) const { return val < rhs.val; }\n} e[maxn << 1];\n\nint par[maxn];\nint n;\n\nbool cmp1(const Node &a, const Node &b) { return a.x < b.x; }\n\nbool cmp2(const Node &a, const Node &b) { return a.y < b.y; }\n\nvoid init() {\n for (int i = 0; i <= n; i++) par[i] = i;\n}\n\nint findpar(int x) { return par[x] = (par[x] == x ? x : findpar(par[x])); }\n\nvoid unite(int x, int y) {\n x = findpar(x), y = findpar(y);\n if (x == y) return;\n par[x] = y;\n}\n\nint main(int argc, char const *argv[]) {\n cin >> n;\n\n init();\n\n for (int i = 1; i <= n; i++) {\n scanf(\"%d%d\", &node[i].x, &node[i].y);\n node[i].id = i;\n }\n\n sort(node + 1, node + n + 1, cmp1);\n\n int cnt = 0;\n for (int i = 2; i <= n; i++)\n e[cnt++] =\n (Edge){node[i - 1].id, node[i].id, node[i].x - node[i - 1].x};\n\n sort(node + 1, node + n + 1, cmp2);\n for (int i = 2; i <= n; i++)\n e[cnt++] =\n (Edge){node[i - 1].id, node[i].id, node[i].y - node[i - 1].y};\n\n sort(e, e + cnt);\n\n long long ans = 0;\n for (int i = 0; i < cnt; i++) {\n int u = e[i].u, v = e[i].v, val = e[i].val;\n if (findpar(u) == findpar(v)) continue;\n unite(u, v);\n ans += val;\n }\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "3\n1 5\n3 9\n7 8\n", "output": "3\n" } ] }, { "id": "s579031873", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair P;\n\nvector > table;\nvector

roads;\nvector

qs;\n\nint main() {\n ll N, X;\n cin >> N >> X;\n\n ll ans = 0;\n ll min = 1000000000;\n for (int i = 0; i < N; i++) {\n ll tmp;\n cin >> tmp;\n X -= tmp;\n ans++;\n if (tmp < min) min = tmp;\n }\n\n ans += X / min;\n\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "3 1000\n120\n100\n140\n", "output": "9\n" } ] }, { "id": "s793402552", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n\nint main() {\n int a, b;\n cin >> a >> b;\n string bstr = to_string(b);\n int num = a * pow(10, bstr.length()) + b;\n\n int i;\n for (i = 1; i <= 100100; i++) {\n if (i * i == num) break;\n }\n\n if (i > 100100)\n cout << \"No\" << endl;\n else\n cout << \"Yes\" << endl;\n}", "test_IO": [ { "input": "1 21\n", "output": "Yes\n" } ] }, { "id": "s121463387", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \nusing namespace std;\n\nint main(void) {\n int n, x;\n string s;\n cin >> n;\n\n for (int i = 1; i <= n; i++) {\n x = i;\n s = std::to_string(x);\n if (x % 3 == 0 || x % 10 == 3) {\n cout << \" \" << i;\n continue;\n } else {\n int k = s.size();\n while (k > 0) {\n k = k - 1;\n int j = pow(10, k);\n if ((x / j) % 10 == 3) {\n cout << \" \" << i;\n break;\n }\n }\n }\n }\n cout << endl;\n\n return 0;\n}", "test_IO": [ { "input": "30\n", "output": " 3 6 9 12 13 15 18 21 23 24 27 30\n" } ] }, { "id": "s654970460", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int n, a[101], i;\n cin >> n;\n for (i = 0; i < n; i++) cin >> a[i];\n cout << a[n - 1];\n for (i = 1; i < n; i++) cout << \" \" << a[n - i - 1];\n cout << endl;\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n", "output": "5 4 3 2 1\n" } ] }, { "id": "s582643375", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int mod = 1e9 + 7;\nconst int NMAX = 1000010;\n\nll fac[NMAX], finv[NMAX], inv[NMAX];\n\nvoid init() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < NMAX; i++) {\n fac[i] = fac[i - 1] * i % mod;\n inv[i] = mod - inv[mod % i] * (mod / i) % mod;\n finv[i] = finv[i - 1] * inv[i] % mod;\n }\n}\n\nll C(int n, int k) {\n if (n < k) return 0;\n if (n < 0 || k < 0) return 0;\n return fac[n] * (finv[k] * finv[n - k] % mod) % mod;\n}\n\nint main() {\n init();\n int X, Y;\n cin >> X >> Y;\n if ((X + Y) % 3 != 0) {\n cout << 0 << endl;\n return 0;\n }\n int n = (X + Y) / 3 + 1;\n int k = 2 * (n - 1) - Y + 1;\n cout << C(n - 1, k - 1) << endl;\n return 0;\n}", "test_IO": [ { "input": "3 3\n", "output": "2\n" } ] }, { "id": "s938564096", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nconst long long int MOD = 1e9 + 7;\n\nint main() {\n int r;\n cin >> r;\n cout << r * r << endl;\n}", "test_IO": [ { "input": "2\n", "output": "4\n" } ] }, { "id": "s459892612", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int a, b, c;\n cin >> a >> b >> c;\n\n if (a + b >= c) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "50 100 120\n", "output": "Yes\n" } ] }, { "id": "s353226283", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nint n, k, t;\nstd::vector vec;\nint ans = 1000000001;\nint main() {\n std::cin >> n >> k;\n for (int i = 0; i < n; i++) {\n std::cin >> t;\n vec.push_back(t);\n }\n std::sort(vec.begin(), vec.end());\n for (int i = 0; i + k - 1 < n; i++) {\n int diff = vec[i + k - 1] - vec[i];\n if (diff < ans) {\n ans = diff;\n }\n }\n std::cout << ans << std::endl;\n}", "test_IO": [ { "input": "5 3\n10\n15\n11\n14\n12\n", "output": "2\n" } ] }, { "id": "s247537353", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\ntemplate \ninline bool chmin(T& a, T b) {\n if (a > b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \ninline bool chmax(T& a, T b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\n\nconst int INF = (1 << 30) - 1;\nconst ll INFLL = (1LL << 61) - 1;\nconst int MOD = 1000000007;\n#define ALL(a) (a).begin(), (a).end()\n#define rALL(a) (a).rbegin(), (a).rend()\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n\nint main() {\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n ll A, B, C, K;\n cin >> A >> B >> C >> K;\n if (A + B >= K) {\n cout << min(A, K) << endl;\n } else {\n cout << A - (K - (A + B)) << endl;\n }\n}", "test_IO": [ { "input": "2 1 1 3\n", "output": "2\n" } ] }, { "id": "s323607209", "dataset": "codenet", "language": "C++", "code": "#include \nint main() {\n int n, k;\n long long int l = 0, r = 0;\n scanf(\"%d%d\", &n, &k);\n if (k % 2 == 0) {\n for (int i = 1; i <= n; i++)\n if (i % k == k / 2)\n l++;\n else if (i % k == 0)\n r++;\n printf(\"%lld\\n\", l * l * l + r * r * r);\n } else {\n for (int i = 1; i <= n; i++)\n if (i % k == 0) r++;\n printf(\"%lld\\n\", r * r * r);\n }\n}", "test_IO": [ { "input": "3 2\n", "output": "9\n" } ] }, { "id": "s628121241", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \nusing namespace std;\n\nint gcd(int a, int b) {\n if (a == 0) return b;\n return gcd(b % a, a);\n}\n\nint main() {\n int R;\n cin >> R;\n if (R < 1200)\n cout << \"ABC\" << endl;\n else if (R >= 2800)\n cout << \"AGC\" << endl;\n else\n cout << \"ARC\" << endl;\n}", "test_IO": [ { "input": "1199\n", "output": "ABC\n" } ] }, { "id": "s013321508", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int N, M;\n cin >> N >> M;\n\n vector L(100000);\n int l;\n for (int i = 0; i < N; i++) {\n scanf(\"%d\", &l);\n L[i] = l;\n }\n\n sort(L.begin(), L.end());\n\n vector::iterator itr;\n\n for (int i = 0; i < M; i++) {\n int max_L = L.back();\n if (max_L == 0) {\n break;\n }\n\n max_L /= 2;\n itr = lower_bound(L.begin(), L.end(), max_L);\n L.insert(itr, max_L);\n L.pop_back();\n }\n\n long long ans = accumulate(L.begin(), L.end(), 0LL);\n\n cout << ans << '\\n';\n}", "test_IO": [ { "input": "3 3\n2 13 8\n", "output": "9\n" } ] }, { "id": "s571001771", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair PP;\nll key[1005] = {0};\nll cost[1005] = {0};\nll dp[(1 << 12) + 5][1005] = {0};\nconst ll INF = 123456789012;\nint main() {\n ll n, m;\n cin >> n >> m;\n for (int i = 0; i < (1 << 12) + 5; i++) {\n for (int j = 0; j < 1005; j++) {\n dp[i][j] = INF;\n }\n }\n dp[0][0] = 0;\n for (int i = 1; i <= m; i++) {\n ll b;\n cin >> cost[i] >> b;\n for (int j = 0; j < b; j++) {\n ll c;\n cin >> c;\n key[i] += (1 << (c - 1));\n }\n }\n for (ll i = 0; i < (1 << n); i++) {\n for (int j = 0; j < m; j++) {\n dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);\n dp[i | key[j + 1]][j + 1] =\n min(dp[i | key[j + 1]][j + 1], dp[i][j] + cost[j + 1]);\n }\n }\n if (dp[(1 << n) - 1][m] == INF)\n cout << -1 << endl;\n else\n cout << dp[(1 << n) - 1][m] << endl;\n}", "test_IO": [ { "input": "2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n", "output": "25\n" } ] }, { "id": "s557795702", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#define INF 0x3f3f3f3f\nusing namespace std;\ntypedef long long LL;\nconst int MAXN = 2 * 1e5 + 10;\nint a[MAXN], n, L[MAXN / 2], R[MAXN / 2];\nLL merge(int left, int mid, int right) {\n int i, j, k;\n LL cnt = 0;\n int n1 = mid - left;\n int n2 = right - mid;\n for (i = 0; i < n1; ++i) L[i] = a[left + i];\n for (i = 0; i < n2; ++i) R[i] = a[mid + i];\n L[n1] = R[n2] = INF;\n i = j = 0;\n for (k = left; k < right; ++k) {\n if (L[i] <= R[j])\n a[k] = L[i++];\n else {\n a[k] = R[j++];\n cnt += n1 - i;\n }\n }\n return cnt;\n}\nLL mergesort(int left, int right) {\n int mid;\n LL v1, v2, v3;\n if (left + 1 < right) {\n mid = (left + right) / 2;\n v1 = mergesort(left, mid);\n v2 = mergesort(mid, right);\n v3 = merge(left, mid, right);\n return v1 + v2 + v3;\n }\n return 0;\n}\nint main() {\n ios::sync_with_stdio(false);\n cin >> n;\n for (int i = 0; i < n; ++i) cin >> a[i];\n LL ans = mergesort(0, n);\n cout << ans << '\\n';\n return 0;\n}", "test_IO": [ { "input": "5\n3 5 2 1 4\n", "output": "6\n" } ] }, { "id": "s098326932", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\ntemplate \ninline bool chmax(T& a, T b) {\n if (a < b) {\n a = b;\n return 1;\n }\n return 0;\n}\ntemplate \ninline bool chmin(T& a, T b) {\n if (a > b) {\n a = b;\n return 1;\n }\n return 0;\n}\nconst ll INF = 1e18 + 1;\n\nll f(ll N) {\n vector a(20, 0);\n ll d = 0;\n while (N > 0) {\n a[d] = N % 10;\n N /= 10;\n d++;\n }\n double m = 1e18;\n ll res = N;\n for (int i = 0; i <= d; i++) {\n ll bunsi = 0;\n ll bunbo = 9 * i;\n for (int j = d - 1; j >= 0; j--) {\n bunsi *= 10;\n if (j < i)\n bunsi += 9;\n else\n bunsi += a[j];\n\n if (j >= i) bunbo += a[j];\n }\n\n double frac = (double)bunsi / (double)bunbo;\n if (frac < m) {\n m = frac;\n res = bunsi;\n }\n }\n return res;\n}\n\nint main() {\n ll K;\n cin >> K;\n ll N = f(1);\n for (ll i = 0; i < K; i++) {\n cout << N << endl;\n N = f(N + 1);\n }\n}", "test_IO": [ { "input": "10\n", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n" } ] }, { "id": "s669128523", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nstatic const int N = 100;\nstatic const int WHITE = 0;\nstatic const int GRAY = 1;\nstatic const int BLACK = 2;\n\nint M[N][N], n;\nint color[N], d[N], f[N], tt;\n\nvoid dfs_visit(int u) {\n int v;\n color[u] = GRAY;\n d[u] = ++tt;\n for (v = 0; v < n; v++) {\n if (M[u][v] == 0) continue;\n if (color[v] == WHITE) {\n dfs_visit(v);\n }\n }\n color[u] = BLACK;\n f[u] = ++tt;\n}\n\nvoid dfs() {\n int u;\n for (int i = 0; i < n; i++) {\n color[i] = WHITE;\n }\n tt = 0;\n\n for (u = 0; u < n; u++) {\n if (color[u] == WHITE) dfs_visit(u);\n }\n\n for (int i = 0; i < n; i++)\n cout << i + 1 << \" \" << d[i] << \" \" << f[i] << endl;\n}\n\nint main() {\n int k, u, v;\n cin >> n;\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) M[i][j] = 0;\n }\n for (int i = 0; i < n; i++) {\n cin >> u >> k;\n u--;\n for (int j = 0; j < k; j++) {\n cin >> v;\n v--;\n M[u][v] = 1;\n }\n }\n\n dfs();\n\n return 0;\n}", "test_IO": [ { "input": "4\n1 1 2\n2 1 4\n3 0\n4 1 3\n", "output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n" } ] }, { "id": "s314711832", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#define MIN(a, b) ((a < b) ? a : b)\n#define INF 1000000001\n#define N 100000\n\nusing namespace std;\n\nstruct edge {\n int source;\n int target;\n int weight;\n};\n\nvector edges;\n\nint distances[N];\nint prev_distances[N] = {0};\n\nint main() {\n int V, E, r;\n\n cin >> V >> E >> r;\n\n for (int i = 0; i < E; i++) {\n int source, target, distance;\n cin >> source >> target >> distance;\n edge new_edge = {source, target, distance};\n edges.push_back(new_edge);\n }\n\n for (int i = 0; i < N; i++) {\n distances[i] = INF;\n }\n\n distances[r] = 0;\n\n for (int i = 1; i < V; i++) {\n for (int j = 0; j < V; j++) {\n prev_distances[j] = distances[j];\n }\n\n for (vector::iterator edgeptr = edges.begin();\n edgeptr != edges.end(); edgeptr++) {\n distances[edgeptr->target] =\n MIN(distances[edgeptr->source] + edgeptr->weight,\n distances[edgeptr->target]);\n }\n\n bool same = true;\n for (int j = 0; j < V; j++) {\n if (distances[j] != prev_distances[j]) {\n same = false;\n break;\n }\n }\n\n if (same) break;\n }\n\n for (int i = 0; i < V; i++) {\n if (distances[i] == INF) {\n cout << \"INF\" << endl;\n } else {\n cout << distances[i] << endl;\n }\n }\n}", "test_IO": [ { "input": "4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n", "output": "0\n1\n3\n4\n" } ] }, { "id": "s501065052", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\n\nint main(void) {\n int N;\n cin >> N;\n int mem[N + 1];\n for (int i = 1; i <= N; ++i) {\n int P;\n cin >> P;\n mem[P] = i;\n }\n\n int maxcnt = 1;\n int cnt = 1;\n for (int i = 1; i < N; ++i) {\n if (mem[i] < mem[i + 1]) {\n cnt++;\n } else {\n maxcnt = max(maxcnt, cnt);\n cnt = 1;\n }\n if (i == N - 1) {\n maxcnt = max(maxcnt, cnt);\n }\n }\n\n cout << N - maxcnt << endl;\n return 0;\n}", "test_IO": [ { "input": "4\n1\n3\n2\n4\n", "output": "2\n" } ] }, { "id": "s299205600", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int a;\n int b;\n cin >> a;\n cin >> b;\n int result;\n if (a > b) {\n result = 2 * a - 1;\n } else if (a == b) {\n result = 2 * a;\n } else {\n result = 2 * b - 1;\n }\n cout << result << endl;\n\n return 0;\n}", "test_IO": [ { "input": "5 3\n", "output": "9\n" } ] }, { "id": "s983388294", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma warning(disable : 4996)\n\ntypedef long long ll;\n#define MIN(a, b) ((a) > (b) ? (b) : (a))\n#define MAX(a, b) ((a) < (b) ? (b) : (a))\n#define LINF 9223300000000000000\n#define INF 2140000000\nconst long long MOD = 1000000007;\n\nusing namespace std;\n\nint main(int argc, char* argv[]) {\n int n;\n scanf(\"%d\", &n);\n\n vector a(n);\n int i;\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n int curr = 0;\n for (i = 0; i < n; i++) {\n if (a[i] == curr + 1) curr++;\n }\n if (curr > 0) {\n printf(\"%d\\n\", n - curr);\n } else {\n printf(\"-1\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "3\n2 1 2\n", "output": "1\n" } ] }, { "id": "s074799395", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n char B, OUT;\n cin >> B;\n if (B == 'A')\n OUT = 'T';\n else if (B == 'T')\n OUT = 'A';\n else if (B == 'C')\n OUT = 'G';\n else\n OUT = 'C';\n cout << OUT << endl;\n}", "test_IO": [ { "input": "A\n", "output": "T\n" } ] }, { "id": "s134430594", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define int long long\n\nstruct Ban {\n int l;\n int r;\n int val;\n\n Ban() {}\n\n Ban(int l_, int r_, int val_) {\n l = l_;\n r = r_;\n val = val_;\n }\n};\n\nnamespace Sp {\nconst int LIM = 20;\nconst int N = 2e5 + 7;\n\nint mn[LIM][N];\nint pw[N];\n\nvoid init(vector a) {\n int n = (int)a.size();\n for (int i = 0; i < n; i++) {\n mn[0][i] = a[i];\n }\n for (int i = 0; i + 1 < LIM; i++) {\n for (int j = 0; j + (1 << (i + 1)) <= n; j++) {\n mn[i + 1][j] = max(mn[i][j], mn[i][j + (1 << i)]);\n }\n }\n pw[1] = 0;\n for (int i = 2; i < N; i++) {\n pw[i] = pw[i / 2] + 1;\n }\n}\n\nint get(int l, int r) {\n r++;\n int p = pw[r - l];\n return min(mn[p][l], mn[p][r - (1 << p)]);\n}\n} // namespace Sp\n\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n\n int n;\n cin >> n;\n vector a(n);\n for (auto &t : a) {\n cin >> t;\n }\n vector dl(n);\n for (int i = 0; i < n; i++) {\n if (a[i] > i) {\n cout << -1 << endl;\n return 0;\n }\n dl[i] = i - a[i];\n }\n\n int ans = 0;\n vector bans;\n for (int i = 0; i < n; i++) {\n int r = i;\n while (r + 1 < n && a[r] + 1 == a[r + 1]) {\n r++;\n }\n ans += a[r];\n i = r;\n bans.push_back(Ban(r - a[r], r, r - a[r]));\n }\n Sp::init(dl);\n for (auto t : bans) {\n if (Sp::get(t.l, t.r) > t.val) {\n cout << -1 << endl;\n return 0;\n }\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "4\n0\n1\n1\n2\n", "output": "3\n" } ] }, { "id": "s700369080", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ll x1, x2, y1, y2;\n cin >> x1 >> y1 >> x2 >> y2;\n const ll dx = x2 - x1, dy = y2 - y1;\n ll x3 = x2 - dy, y3 = y2 + dx;\n ll x4 = x1 - dy, y4 = y1 + dx;\n cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;\n return 0;\n}", "test_IO": [ { "input": "0 0 0 1\n", "output": "-1 1 -1 0\n" } ] }, { "id": "s241624152", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\n\nusing uint = unsigned int;\nusing ll = long long;\nusing ull = unsigned long long;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define all(x) (x).begin(), (x).end()\n\nvoid solve() {}\nint main() {\n int a, b;\n cin >> a >> b;\n string ans;\n if (a == 1 || b == 1) {\n if (a == 1 && b == 1) {\n ans = \"Draw\";\n } else if (a == 1) {\n ans = \"Alice\";\n } else {\n ans = \"Bob\";\n }\n } else {\n if (a == b) {\n ans = \"Draw\";\n } else if (a > b) {\n ans = \"Alice\";\n } else {\n ans = \"Bob\";\n }\n }\n cout << ans << endl;\n\n return 0;\n}", "test_IO": [ { "input": "8 6\n", "output": "Alice\n" } ] }, { "id": "s509329039", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i, b, e) for (int i = (b); i < (e); ++i)\n#define FORQ(i, b, e) for (int i = (b); i <= (e); ++i)\n#define FORD(i, b, e) for (int i = (b)-1; i >= (e); --i)\n#define REP(x, n) for (int x = 0; x < (n); ++x)\n\n#define ST first\n#define ND second\n#define PB push_back\n#define PF push_front\n#define MP make_pair\n#define LL long long\n#define ULL unsigned LL\n#define LD long double\n#define pii pair\n#define pll pair\n#define vi vector\n#define vl vector\n#define vii vector\n#define vll vector\n\nconst double pi = 3.14159265358979323846264;\nconst int mod = 1000000007;\n\nint main() {\n int n, m;\n cin >> n >> m;\n vi s(m), c(m);\n FOR(i, 0, m) {\n cin >> s[i] >> c[i];\n s[i]--;\n }\n FOR(i, 0, 1000) {\n string st = to_string(i);\n if (st.length() != n) {\n continue;\n }\n\n int f = 1;\n FOR(j, 0, m) {\n if (st[s[j]] == c[j] + '0') {\n } else {\n f = 0;\n }\n }\n if (f) {\n cout << i << endl;\n return 0;\n }\n }\n cout << -1 << endl;\n}", "test_IO": [ { "input": "3 3\n1 7\n3 2\n1 7\n", "output": "702\n" } ] }, { "id": "s102850254", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint d;\nstring map[105];\nint n;\n\nvoid visit() {\n int dx[4] = {0, 1, 0, -1};\n int dy[4] = {-1, 0, 1, 0};\n int sum, flg = 0;\n int x = 2, y = n;\n map[y][x] = ' ';\n int ab[4] = {2, 2, 2, 2};\n\n while (1) {\n sum = 0;\n while (1) {\n if (map[y + dy[flg] * 2][x + dx[flg] * 2] != '#' &&\n map[y + dy[flg]][x + dx[flg]] != ' ') {\n flg++;\n\n break;\n }\n\n map[y + dy[flg]][x + dx[flg]] = ' ';\n y = y + dy[flg];\n x = x + dx[flg];\n sum++;\n }\n if (flg == 4) flg = 0;\n if (sum == 0) break;\n ab[0] = ab[1];\n ab[1] = ab[2];\n ab[2] = sum;\n if (ab[0] == 1 && ab[2] == 1 && ab[1] == 1) break;\n }\n}\n\nint main() {\n cin >> d;\n\n for (int l = 0; l < d; l++) {\n cin >> n;\n\n if (n == 1) {\n cout << \"#\" << endl;\n if (l != d - 1) cout << endl;\n continue;\n }\n\n for (int i = 0; i <= n + 1; i++) {\n map[i].resize(n + 2);\n for (int j = 0; j <= n + 1; j++) {\n map[i][j] = '#';\n if (i == 0 || j == 0 || i == n + 1 || j == n + 1)\n map[i][j] = '.';\n }\n }\n\n visit();\n\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j < map[i].size() - 1; j++) {\n cout << map[i][j];\n }\n cout << endl;\n }\n if (l != d - 1) cout << endl;\n }\n return 0;\n}", "test_IO": [ { "input": "2\n5\n6\n", "output": "#####\n# #\n# # #\n# # #\n# ###\n\n######\n# #\n# ## #\n# # #\n# # #\n# ####\n" } ] }, { "id": "s663381244", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n vector m;\n m.push_back(10);\n m.push_back(50);\n m.push_back(100);\n m.push_back(500);\n\n bool first = true;\n for (int money; cin >> money, money;) {\n if (!first) cout << endl;\n\n first = false;\n int sum = 0;\n vector num(4);\n for (int i = 0; i < 4; ++i) {\n cin >> num[i];\n sum += num[i] * m[i];\n }\n\n int change = sum - money;\n for (int i = 3; i >= 0; --i) {\n if (change / m[i]) {\n num[i] = num[i] - change / m[i];\n change %= m[i];\n }\n }\n\n for (int i = 0; i < 4; ++i)\n if (num[i] > 0) cout << m[i] << \" \" << num[i] << endl;\n }\n\n return EXIT_SUCCESS;\n}", "test_IO": [ { "input": "160\n1 1 2 0\n160\n1 0 2 10\n0\n", "output": "10 1\n50 1\n100 1\n\n10 1\n100 2\n" } ] }, { "id": "s791749917", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define rep1(i, n) for (int i = 1; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nconst int INF = 1001001001;\n\nint main() {\n ll H, W;\n cin >> H >> W;\n\n ll ans;\n if (H == 1 || W == 1) {\n ans = 1;\n } else {\n ll m = H * W;\n if (m % 2 == 0)\n ans = m / 2;\n else\n ans = m / 2 + 1;\n }\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "4 5\n", "output": "10\n" } ] }, { "id": "s465977291", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nint main() {\n int n, d;\n cin >> n >> d;\n\n double a = d * 2 + 1;\n cout << ceil(n / a) << endl;\n\n return 0;\n}", "test_IO": [ { "input": "6 2\n", "output": "2\n" } ] }, { "id": "s023383699", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int x;\n cin >> x;\n cout << x * x * x << endl;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s605014348", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint div(int n);\n\nint main() {\n int num;\n cin >> num;\n cout << num << \":\";\n\n while (num != 1) {\n cout << \" \" << div(num);\n num = num / div(num);\n }\n cout << endl;\n}\n\nint div(int n) {\n if (n % 2 == 0) return 2;\n int s = sqrt(n);\n for (int i = 3; i <= s; i += 2) {\n if (n % i == 0) return i;\n }\n\n return n;\n}", "test_IO": [ { "input": "12\n", "output": "12: 2 2 3\n" } ] }, { "id": "s954770518", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \nusing namespace std;\nint main() {\n int s[11], i;\n for (i = 0; i < 10; i++) {\n scanf(\"%d\", &s[i]);\n }\n sort(s, s + 10);\n for (i = 9; i > 6; i--) {\n printf(\"%d\\n\", s[i]);\n }\n return 0;\n}", "test_IO": [ { "input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n", "output": "3776\n2848\n2840\n" } ] }, { "id": "s978355948", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n int N, X;\n cin >> N >> X;\n vector L(N);\n for (int i = 0; i < N; i++) cin >> L[i];\n\n int i;\n int d = 0;\n for (i = 0; i < N; i++) {\n d = d + L[i];\n if (d > X) break;\n }\n\n cout << i + 1 << endl;\n}", "test_IO": [ { "input": "3 6\n3 4 5\n", "output": "2\n" } ] }, { "id": "s847126533", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\nbool check(int n, int wei, vector book) {\n int tmp = wei;\n n--;\n for (int i = 0; i < book.size(); i++) {\n if (tmp < book[i]) {\n if (n > 0) {\n n--;\n tmp = wei;\n if (tmp < book[i]) return false;\n } else\n return false;\n }\n\n tmp -= book[i];\n }\n return true;\n}\nint main() {\n int m, n;\n for (; cin >> m >> n, m;) {\n vector book;\n for (int i = 0; i < n; i++) {\n int tmp;\n cin >> tmp;\n book.push_back(tmp);\n }\n\n int l = 0;\n int r = 1500000;\n int ans;\n while (l < r) {\n if (check(m, (l + r) / 2, book)) {\n ans = (l + r) / 2;\n if (r == (l + r) / 2) break;\n r = (l + r) / 2;\n\n } else {\n if (l == (l + r) / 2) break;\n l = (l + r) / 2;\n }\n }\n cout << ans << endl;\n }\n}", "test_IO": [ { "input": "3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1000\n0 0\n", "output": "1800\n1000\n" } ] }, { "id": "s296046823", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n int N, K;\n cin >> N >> K;\n\n vector v(N);\n for (int i = 0; i < N; ++i) cin >> v[i];\n\n int count = ((N - 1) + ((K - 1) - 1)) / (K - 1);\n cout << count << '\\n';\n}", "test_IO": [ { "input": "4 3\n2 3 1 4\n", "output": "2\n" } ] }, { "id": "s150958471", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n int train[2];\n int bus[2];\n\n cin >> train[0] >> train[1];\n cin >> bus[0] >> bus[1];\n\n cout << (train[0] < train[1] ? train[0] : train[1]) +\n (bus[0] < bus[1] ? bus[0] : bus[1])\n << endl;\n\n return 0;\n}", "test_IO": [ { "input": "600\n300\n220\n420\n", "output": "520\n" } ] }, { "id": "s085554271", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n#define prec std::cout << std::fixed << std::setprecision(15);\n#define endl \"\\n\"\n#define MOD 1000000007\n#define Int int64_t\n#define PI 3.14159265358979\n#define ssort(z) sort(z.begin(), z.end())\n#define rsort(z) sort(z.rbegin(), z.rend())\n#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())\n#define ccnt(z, w) count(z.begin(), z.end(), w)\n#define rep(i, a, n) for (Int(i) = (a); (i) < (n); (i)++)\n#define repq(i, a, n) for (Int(i) = (a); (i) <= (n); (i)++)\nconst int MAX_N = 1000000;\nconst Int MAX_N_Int = 1000000000000;\n\ntemplate \nvoid printV(const std::vector& v, const char* const separator = \" \") {\n if (!v.empty()) {\n std::copy(v.begin(), --v.end(),\n std::ostream_iterator(std::cout, separator));\n std::cout << v.back() << \"\\n\";\n }\n}\n\nbool isPrime(int num) {\n if (num < 2)\n return false;\n else if (num == 2)\n return true;\n else if (num % 2 == 0)\n return false;\n\n double sqrtNum = sqrt(num);\n for (int i = 3; i <= sqrtNum; i += 2) {\n if (num % i == 0) {\n return false;\n }\n }\n\n return true;\n}\nInt gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; }\n\nInt lcm(Int a, Int b) { return a / gcd(a, b) * b; }\n\nint Max(int a, int b, int c) {\n int temp = max(a, b);\n return max(temp, c);\n}\n\nint Min(int a, int b, int c) {\n int temp = min(a, b);\n return min(temp, c);\n}\n\nbool integer(double num) { return floor(num) == num; }\n\nInt fact(int num) {\n if (num == 0)\n return 1;\n else\n return num * fact(num - 1);\n}\n\nInt yakusu(int n) {\n int cnt = 0;\n for (int i = 1; i * i <= n; i++) {\n if (n % i == 0) {\n cnt++;\n if (i * i != n) cnt++;\n }\n }\n return cnt;\n}\n\nInt fact_mod(Int n, Int mod) {\n Int f = 1;\n repq(i, 2, n) f = f * (i % MOD) % MOD;\n return f;\n}\n\nInt mod_pow(Int x, Int n, Int mod) {\n Int res = 1;\n while (n > 0) {\n if (n & 1) res = (res * x) % mod;\n x = (x * x) % mod;\n n >>= 1;\n }\n return res;\n}\n\nInt combination_mod(Int n, Int r, Int mod) {\n if (r > n - r) r = n - r;\n if (r == 0) return 1;\n Int a = 1;\n rep(i, 0, r) a = a * ((n - i) % mod) % mod;\n Int b = mod_pow(fact_mod(r, mod), mod - 2, mod);\n return (a % mod) * (b % mod) % mod;\n}\n\nbool rev(string s) {\n string t = s;\n reverse(s.begin(), s.end());\n return s == t;\n}\nint main() {\n IOS;\n prec;\n Int a, b, c, n, m, k, x, y = 0, ans = 0;\n string str, s, t, u;\n cin >> k >> a >> b;\n for (int i = a; i <= b; ++i) {\n if (i % k == 0) {\n cout << \"OK\" << endl;\n return 0;\n }\n }\n cout << \"NG\";\n\n cout << endl;\n return 0;\n}", "test_IO": [ { "input": "7\n500 600\n", "output": "OK\n" } ] }, { "id": "s472228164", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nstd::string check(int x, int y) {\n if (y % 2 == 0) {\n int t = (int)(0.5 * y) - x;\n if (t >= 0 && (x - t) >= 0) return \"Yes\";\n }\n return \"No\";\n}\n\nint main() {\n int x, y;\n std::cin >> x >> y;\n\n std::cout << check(x, y) << std::endl;\n return 0;\n}", "test_IO": [ { "input": "3 8\n", "output": "Yes\n" } ] }, { "id": "s854821134", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int INF = 200000005;\n\nint main() {\n int a, b;\n cin >> a >> b;\n if (a <= 8 && b <= 8)\n cout << \"Yay!\" << endl;\n else\n cout << \":(\" << endl;\n return 0;\n}", "test_IO": [ { "input": "5 4\n", "output": "Yay!\n" } ] }, { "id": "s661446851", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mod 998244353\n#define int long long\n#define ld long double\n#define pb push_back\n#define vi vector\n#define co(x) cout << x << '\\n'\n#define dbg(x) cerr << #x << \" = \" << x << '\\n'\n#define bitcount(x) (int)__builtin_popcount(x)\n#define sz(x) (int)x.size()\n#define all(a) a.begin(), a.end()\n#define ff first\n#define ss second\n#define pii pair\n#define lcm(a, b) (a * b) / __gcd(a, b)\nusing namespace std;\n\ninline void solve() {\n int n, ans = 0;\n cin >> n;\n co(!n);\n}\n\nsigned main() {\n int n = 1;\n while (n--) solve();\n return 0;\n}", "test_IO": [ { "input": "1\n", "output": "0\n" } ] }, { "id": "s410514868", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\ntypedef long long ll;\nll n, k, ans, L, ans2;\nstring s;\n\nint main(void) {\n cin >> n >> k;\n cin >> s;\n L = s[0];\n ll cnt = 0;\n for (int i = 1; i < n; i++) {\n if (L == s[i])\n cnt++;\n else {\n L = s[i];\n ans += cnt;\n ans2++;\n cnt = 0;\n }\n }\n ans += cnt;\n ans2++;\n cout << ans + min(2 * k, ans2 - 1) << endl;\n}", "test_IO": [ { "input": "6 1\nLRLRRL\n", "output": "3\n" } ] }, { "id": "s683946919", "dataset": "codenet", "language": "C++", "code": "#define _USE_MATH_DEFINES\n#define INF 0x3f3f3f3f\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\ntypedef pair PP;\n\nint time2min(int month, int day, int hour, int min) {\n const int total_day_of_month[] = {31, 28, 31, 30, 31, 30,\n 31, 31, 30, 31, 30, 31};\n int total = 0;\n for (int i = 1; i < month; i++) {\n total += total_day_of_month[i] * 24 * 60;\n }\n for (int i = 1; i < day; i++) {\n total += 24 * 60;\n }\n total += hour * 60 + min;\n\n return total;\n}\n\nint main() {\n int N;\n while (~scanf(\"%d\", &N)) {\n if (N == 0) break;\n\n map > log;\n for (int i = 0; i < N; i++) {\n int month, day, hour, min, id;\n char action[2];\n scanf(\"%d/%d %d:%d %s %d\", &month, &day, &hour, &min, action, &id);\n\n int t = time2min(month, day, hour, min);\n log[id].push_back(t);\n }\n\n int total[1000];\n memset(total, 0, sizeof(total));\n\n for (int i = 0; i + 1 < log[0].size(); i += 2) {\n int god_start = log[0][i];\n int god_end = log[0][i + 1];\n\n for (map >::iterator it = log.begin();\n it != log.end(); it++) {\n int id = it->first;\n if (id == 0) continue;\n vector& schedule = it->second;\n for (int j = 0; j < schedule.size(); j += 2) {\n int ppl_start = schedule[j];\n int ppl_end = schedule[j + 1];\n int start = max(god_start, ppl_start);\n int end = min(god_end, ppl_end);\n total[id] += max(0, end - start);\n }\n }\n }\n\n int max_v = 0;\n for (int id = 0; id < 1000; id++) {\n max_v = max(total[id], max_v);\n }\n printf(\"%d\\n\", max_v);\n }\n}", "test_IO": [ { "input": "14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 09:30 O 001\n04/21 09:45 O 000\n04/21 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 O 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:00 I 001\n06/01 09:15 I 002\n06/01 09:15 I 003\n06/01 09:30 O 002\n06/01 10:00 I 000\n06/01 10:15 O 001\n06/01 10:30 I 002\n06/01 10:45 O 002\n06/01 11:00 I 001\n06/01 11:15 O 000\n06/01 11:30 I 002\n06/01 11:45 O 001\n06/01 12:00 O 002\n06/01 12:15 I 000\n06/01 12:30 I 002\n06/01 12:45 O 000\n06/01 13:00 I 000\n06/01 13:15 O 000\n06/01 13:30 O 002\n06/01 13:45 O 003\n0\n", "output": "45\n120\n" } ] }, { "id": "s526060174", "dataset": "codenet", "language": "C++", "code": "#include \n#define rep(S, L) for (int i = S; i < L; ++i)\nusing namespace std;\n\nint main() {\n int n, m;\n int k, a;\n int x[31] = {};\n cin >> n >> m;\n for (int i = 0; i < n; ++i) {\n cin >> k;\n for (int j = 0; j < k; ++j) {\n cin >> a;\n x[a]++;\n }\n }\n int ans = 0;\n for (int i = 1; i <= m; ++i) {\n if (x[i] == n) {\n ans++;\n }\n }\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n", "output": "1\n" } ] }, { "id": "s792884768", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\nstruct TSize {\n int r;\n int c;\n TSize() : r(0), c(0) {}\n TSize(int Ar, int Ac) : r(Ar), c(Ac) {}\n};\n\nclass TMcmSolver {\n typedef std::vector > TMatrix;\n TMatrix FMemo;\n const std::vector& FChain;\n\n static int Count(const TSize& Left, const TSize& Right) {\n return Left.r * Right.c * Left.c;\n }\n int Solve(int s, int l) {\n assert(s <= l);\n if (s == l) return 0;\n if (FMemo[s][l] != 0) return FMemo[s][l];\n if (s + 1 == l) {\n FMemo[s][l] = Count(FChain[s], FChain[l]);\n } else {\n int min = INT_MAX;\n for (int i = s; i < l; ++i) {\n int c = Solve(s, i) +\n Count(TSize(FChain[s].r, FChain[i].c),\n TSize(FChain[i + 1].r, FChain[l].c)) +\n Solve(i + 1, l);\n min = std::min(min, c);\n }\n FMemo[s][l] = min;\n }\n\n return FMemo[s][l];\n }\n\n public:\n TMcmSolver(const std::vector& Chain) : FChain(Chain) {\n FMemo.resize(Chain.size());\n for (std::size_t i = 0; i < FMemo.size(); ++i) {\n FMemo[i].resize(Chain.size(), 0);\n }\n }\n int Answer() { return Solve(0, FMemo.size() - 1); }\n void Print() const {\n for (std::size_t s = 0; s < FMemo.size(); ++s) {\n for (std::size_t l = 0; l < FMemo[0].size(); ++l) {\n std::cout << FMemo[s][l] << '\\t';\n }\n std::cout << '\\n';\n }\n }\n};\n\nint main() {\n int n;\n std::cin >> n;\n if (n == 1) {\n std::cout << 0 << std::endl;\n return 0;\n }\n std::vector Chain(n);\n for (int i = 0; i < n; ++i) {\n std::cin >> Chain[i].r >> Chain[i].c;\n }\n TMcmSolver Solver(Chain);\n\n std::cout << Solver.Answer() << std::endl;\n\n return 0;\n}", "test_IO": [ { "input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25\n", "output": "15125\n" } ] }, { "id": "s323743606", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n map m;\n for (int i = 0; i * 200 < 5001; i++) {\n for (int j = 0; j * 300 < 5001; j++) {\n for (int k = 0; k * 500 < 5001; k++) {\n int w = i * 200 + j * 300 + k * 500;\n int p = i / 5 * 5 * 380 * 0.8 + i % 5 * 380 +\n j / 4 * 4 * 550 * 0.85 + j % 4 * 550 +\n k / 3 * 3 * 850 * 0.88 + k % 3 * 850;\n if (m[w])\n m[w] = min(m[w], p);\n else\n m[w] = p;\n }\n }\n }\n int n;\n while (cin >> n, n) {\n cout << m[n] << endl;\n }\n}", "test_IO": [ { "input": "500\n2200\n0\n", "output": "850\n3390\n" } ] }, { "id": "s855845406", "dataset": "codenet", "language": "C++", "code": "#include \n\nint main() {\n int N, A;\n std::cin >> N;\n std::cin >> A;\n std::cout << N * N - A << std::endl;\n}", "test_IO": [ { "input": "3\n4\n", "output": "5\n" } ] }, { "id": "s146561572", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define sz(a) int((a).size())\n#define all(x) x.begin(), x.end()\n#define pb push_back\n#define endl '\\n'\n#define watch(x) cout << #x << \" : \" << x << endl;\n\n#define FastIO \\\n ios_base::sync_with_stdio(0); \\\n cin.tie(0); \\\n cout.tie(0);\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\n\nconst int N = int(2e5) + 10;\nconst int K = int(2e6) + 10;\nconst int MOD = int(1e9) + 7;\nconst int INF = int(1e9) + 5;\nconst ll INF64 = 2e18;\n\nvoid solve() {\n ll ans = 0;\n int n;\n cin >> n;\n\n for (int i = 1; i <= n; i++) {\n ans += i * 1ll * (n - i + 1);\n }\n for (int i = 1; i < n; i++) {\n int u, v;\n cin >> u >> v;\n int a = max(u, v);\n int b = min(u, v);\n ans -= b * 1ll * (n - a + 1);\n }\n cout << ans << endl;\n}\n\nint main() {\n FastIO\n\n int t;\n\n t = 1;\n while (t--) {\n solve();\n }\n return 0;\n}", "test_IO": [ { "input": "3\n1 3\n2 3\n", "output": "7\n" } ] }, { "id": "s472290172", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n string str;\n cin >> str;\n\n int max = 0, cnt = 0;\n for (auto sc : str) {\n if (sc == 'A' || sc == 'C' || sc == 'G' || sc == 'T') {\n cnt++;\n } else {\n cnt = 0;\n }\n max = max < cnt ? cnt : max;\n }\n\n cout << max << endl;\n}", "test_IO": [ { "input": "ATCODER\n", "output": "3\n" } ] }, { "id": "s917269550", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n long long x, y;\n cin >> x >> y;\n if (abs(x - y) <= 1)\n cout << \"Brown\" << endl;\n else\n cout << \"Alice\" << endl;\n}", "test_IO": [ { "input": "2 1\n", "output": "Brown\n" } ] }, { "id": "s271114101", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\n\nint main() {\n int a, b, c;\n cin >> a >> b >> c;\n cout << ((a + b == c || b + c == a || a + c == b) ? \"Yes\" : \"No\") << endl;\n}", "test_IO": [ { "input": "10 30 20\n", "output": "Yes\n" } ] }, { "id": "s129088151", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n int n;\n char str[10], com[13];\n map T;\n\n cin >> n;\n for (int i = 0; i < n; i++) {\n scanf(\"%s%s\", com, str);\n if (com[0] == 'i')\n T[string(str)] = true;\n else {\n if (T[string(str)])\n printf(\"yes\\n\");\n else\n printf(\"no\\n\");\n }\n }\n return 0;\n}", "test_IO": [ { "input": "5\ninsert A\ninsert T\ninsert C\nfind G\nfind A\n", "output": "no\nyes\n" } ] }, { "id": "s877835664", "dataset": "codenet", "language": "C++", "code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing ll = long long;\nusing vll = vector;\nusing sll = set;\n\ntemplate \nT gcd(T a, T b) {\n return b ? gcd(b, a % b) : a;\n}\ntemplate \nT lcm(T a, T b) {\n return a / gcd(a, b) * b;\n}\n\ntemplate \nmap getPrimeFactor(T n) {\n map res;\n for (T i = 2; i * i <= n; ++i) {\n while (n % i == 0) {\n res[i]++;\n n /= i;\n }\n }\n if (n != 1) res[n] = 1;\n return res;\n}\n\ntemplate \nbool IsPrimeNumber(T num) {\n if (num <= 2)\n return true;\n else if (num % 2 == 0)\n return false;\n\n double sqrtNum = sqrt(num);\n for (int i = 3; i <= sqrtNum; i += 2) {\n if (num % i == 0) {\n return false;\n }\n }\n\n return true;\n}\n\nlong long modinv(long long a, long long m) {\n long long b = m, u = 1, v = 0;\n while (b) {\n long long t = a / b;\n a -= t * b;\n swap(a, b);\n u -= t * v;\n swap(u, v);\n }\n u %= m;\n if (u < 0) u += m;\n return u;\n}\n\n#define rep(i, s, e) for (ll i = s; i < e; i++)\n#define repeq(i, s, e) for (ll i = s; i <= e; i++)\n\nint main() {\n ll N, K;\n std::cin >> N >> K;\n\n vll A(N + 1);\n repeq(i, 1, N) { std::cin >> A[i]; }\n\n ll cur = 1;\n vll dic(N + 1, -1);\n bool flg = false;\n repeq(i, 1, K) {\n if (dic[cur] < 0 || flg) {\n dic[cur] = i;\n cur = A[cur];\n } else if (!flg) {\n ll tmp = K - (dic[cur] - 1);\n tmp %= i - dic[cur];\n i = K - tmp;\n flg = true;\n }\n }\n\n std::cout << cur << endl;\n return 0;\n}", "test_IO": [ { "input": "4 5\n3 2 4 1\n", "output": "4\n" } ] }, { "id": "s754383079", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\nconst int M = 1010;\nchar a[M], b[M];\nint n, m, ans = M + 10;\n\nint main() {\n scanf(\"%s\", a + 1);\n n = strlen(a + 1);\n scanf(\"%s\", b + 1);\n m = strlen(b + 1);\n for (int i = 1; i + m - 1 <= n; i++) {\n int sum = 0;\n for (int j = 1; j <= m; j++)\n if (a[i + j - 1] != b[j]) sum++;\n ans = min(ans, sum);\n }\n printf(\"%d\\n\", ans);\n\n return 0;\n}", "test_IO": [ { "input": "cabacc\nabc\n", "output": "1\n" } ] }, { "id": "s814769071", "dataset": "codenet", "language": "C++", "code": "#pragma region\n#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\n#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))\n#define rrep(i, s) for (int(i) = (s)-1; (i) >= 0; --(i))\n#define all(x) x.begin(), x.end()\n#pragma endregion\n\nint main() {\n ll n, k;\n cin >> n >> k;\n ll MOD = 1e9 + 7;\n ll mx = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2;\n ll mn = k * (k - 1) / 2;\n ll res = 0;\n for (int i = k; i <= n + 1; ++i) {\n res += mx - mn + 1;\n mx += n - i;\n mn += i;\n res %= MOD;\n }\n cout << res << endl;\n}", "test_IO": [ { "input": "3 2\n", "output": "10\n" } ] }, { "id": "s860472409", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main() {\n int N, ans, i, count;\n cin >> N;\n int A[N];\n for (i = 0; i < N; i++) {\n cin >> A[i];\n }\n i = 0;\n ans = 0;\n count = 0;\n while (A[i + 1] != NULL) {\n if (A[i] == A[i + 1]) {\n count++;\n if (count % 2 != 0) ans++;\n } else\n count = 0;\n i++;\n }\n\n cout << ans << \"\\n\";\n return 0;\n}", "test_IO": [ { "input": "5\n1 1 2 2 2\n", "output": "2\n" } ] }, { "id": "s765257696", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\nconst ll MOD = 1000000007LL;\n\nint main() {\n cin.sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n int n;\n cin >> n;\n\n int p[n];\n for (int i = 0; i < n; i++) cin >> p[i];\n\n int ans = 0;\n for (int i = 0; i < n - 2; i++) {\n if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) ans++;\n if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ans++;\n }\n\n cout << ans << \"\\n\";\n return 0;\n}", "test_IO": [ { "input": "5\n1 3 5 4 2\n", "output": "2\n" } ] }, { "id": "s930643405", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef pair P;\n\nbool d[10] = {0};\nint n, k;\nbool hantei = true;\n\nint main() {\n cin >> n >> k;\n for (int i = 0; i < k; ++i) {\n int a;\n cin >> a;\n d[a] = 1;\n }\n while (1) {\n int x = n;\n hantei = 1;\n while (x) {\n if (d[x % 10]) {\n hantei = 0;\n break;\n }\n x /= 10;\n }\n if (hantei) {\n cout << n << endl;\n break;\n }\n n++;\n }\n}", "test_IO": [ { "input": "1000 8\n1 3 4 5 6 7 8 9\n", "output": "2000\n" } ] }, { "id": "s143031369", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst double PI = acos(-1.0);\nint sig(double d) { return fabs(d) < 1e-8 ? 0 : d < 0 ? -1 : 1; }\n\nstruct Point {\n double x, y;\n double k;\n Point() {}\n Point(double x, double y) : x(x), y(y) {}\n void set(double x, double y) {\n this->x = x;\n this->y = y;\n }\n double mod() { return sqrt(x * x + y * y); }\n double mod_pow() { return x * x + y * y; }\n void output() { printf(\"x = %f, y = %f\\n\", x, y); }\n bool operator<(const Point &p) const {\n return sig(x - p.x) != 0 ? x < p.x : sig(y - p.y) < 0;\n }\n} P[110];\nint ch[110];\ndouble ang[110], ans[110];\ndouble dot(Point &o, Point &a, Point &b) {\n return (a.x - o.x) * (b.x - o.x) + (a.y - o.y) * (b.y - o.y);\n}\n\ndouble dot(Point &a, Point &b) { return a.x * b.x + a.y * b.y; }\ndouble cross(Point o, Point a, Point b) {\n return (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);\n}\nint btw(Point &x, Point &a, Point &b) { return sig(dot(x, a, b)); }\ndouble dis(Point a, Point b) {\n return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));\n}\n\ndouble cos(Point o, Point a, Point b) {\n return dot(o, a, b) / dis(o, a) / dis(o, b);\n}\n\nint jarvis(Point *p, int n, int *ch) {\n static int d, i, o, s, l, t;\n for (d = i = 0; i < n; i++)\n if (p[i] < p[d]) d = i;\n l = s = *ch = d;\n d = 1;\n do {\n o = l;\n for (i = 0; i < n; i++)\n if ((t = sig(cross(p[o], p[l], p[i]))) > 0 ||\n (t == 0 && btw(p[l], p[o], p[i]) <= 0))\n l = i;\n ch[d++] = l;\n } while (l != s);\n return d - 1;\n}\n\nint main() {\n memset(ang, 0, sizeof(ang));\n memset(ans, 0, sizeof(ans));\n int n, xx, yy;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d%d\", &xx, &yy);\n P[i].set(xx, yy);\n }\n if (n == 2) {\n puts(\"0.5\");\n puts(\"0.5\");\n } else {\n int m = jarvis(P, n, ch);\n double sum = 0;\n\n if (m == 2) {\n ans[ch[0]] = 0.5;\n ans[ch[1]] = 0.5;\n } else {\n for (int i = 0; i < m; i++) {\n ang[ch[i]] = PI - acos(cos(P[ch[i]], P[ch[(i - 1 + m) % m]],\n P[ch[(i + 1) % m]]));\n }\n for (int i = 0; i < n; i++) {\n ans[i] = ang[i] / 2. / PI;\n }\n }\n for (int i = 0; i < n; i++) {\n printf(\"%.20f\\n\", ans[i]);\n }\n }\n return 0;\n}", "test_IO": [ { "input": "2\n0 0\n1 1\n", "output": "0.5\n0.5\n" } ] }, { "id": "s568362035", "dataset": "codenet", "language": "C++", "code": "#include \n\nconst int MAXN = 1E5 + 10;\n\nint n, m, Q;\nint a[MAXN];\nint b[MAXN], id[MAXN];\nbool vis[MAXN];\nint cnt[MAXN];\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n scanf(\"%d\", &Q);\n for (int i = 1; i <= Q; ++i) scanf(\"%d\", &a[i]);\n for (int k = 0, j = Q; j > 0; --j)\n if (!vis[a[j]]) b[++k] = a[j], vis[a[j]] = true;\n for (int j = m, i = m; i > 0; --i)\n if (!vis[i]) b[j--] = i;\n for (int i = 1; i <= m; ++i) id[b[i]] = i;\n\n bool flag = true;\n cnt[0] = n;\n for (int i = Q; i > 0; --i) {\n int t = id[a[i]];\n if (cnt[t - 1] > 0) {\n --cnt[t - 1];\n ++cnt[t];\n vis[t] = true;\n } else if (!vis[t]) {\n flag = false;\n break;\n }\n }\n\n int l;\n for (l = 0; cnt[l] == 0; ++l)\n ;\n for (int i = l + 1; i < m; ++i) flag &= b[i] < b[i + 1];\n puts(flag ? \"Yes\" : \"No\");\n return 0;\n}", "test_IO": [ { "input": "2 2\n3\n2 1 2\n", "output": "Yes\n" } ] }, { "id": "s783753345", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint main() {\n int a, b;\n char S;\n while (true) {\n cin >> a >> S >> b;\n if (S == '+') cout << a + b << endl;\n if (S == '-') cout << a - b << endl;\n if (S == '*') cout << a * b << endl;\n if (S == '/') cout << a / b << endl;\n if (S == '?') break;\n }\n}", "test_IO": [ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ] }, { "id": "s914373115", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nvoid A(void);\nvoid B(void);\nvoid C(void);\nvoid D(void);\n\nint main(void) { B(); }\n\nvoid B(void) {\n long long int x, sum;\n cin >> x;\n int i;\n sum = 100;\n for (i = 0; sum < x; ++i) {\n sum += sum / 100;\n }\n cout << i << endl;\n}", "test_IO": [ { "input": "103\n", "output": "3\n" } ] }, { "id": "s598010898", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n#define rep(i, n) for (int i = 0; i < n; i++)\nint main(void) {\n int n, a[100], b[100], sum = 0;\n cin >> n;\n rep(i, n) cin >> a[i];\n rep(i, n) {\n cin >> b[i];\n if (a[i] - b[i] > 0) {\n sum += a[i] - b[i];\n }\n }\n cout << sum << endl;\n}", "test_IO": [ { "input": "3\n10 2 5\n6 3 4\n", "output": "5\n" } ] }, { "id": "s259332673", "dataset": "codenet", "language": "C++", "code": "#include \n\n#define rep(i, n) for (int i = 0; i < n; i++)\n\nusing namespace std;\n\nint main() {\n int h1, h2, m1, m2, k;\n cin >> h1 >> m1 >> h2 >> m2 >> k;\n int ans = h2 * 60 + m2 - (h1 * 60 + m1);\n\n cout << ans - k << endl;\n\n return 0;\n}", "test_IO": [ { "input": "10 0 15 0 30\n", "output": "270\n" } ] }, { "id": "s726701284", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n string s;\n cin >> s;\n for (char i = 'a'; i <= 'z'; i++) {\n int a = 0;\n for (int j = 0; j < s.size(); j++) {\n if (i == s.at(j)) {\n a++;\n }\n }\n if (a == 0) {\n cout << i << endl;\n break;\n }\n if (i == 'z') {\n cout << \"None\" << endl;\n break;\n }\n }\n}", "test_IO": [ { "input": "atcoderregularcontest\n", "output": "b\n" } ] }, { "id": "s609497560", "dataset": "codenet", "language": "C++", "code": "#include \n\nusing namespace std;\n\nint main() {\n int a;\n cin >> a;\n cout << (a + (a * a) + (a * a * a)) << endl;\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "14\n" } ] }, { "id": "s864662146", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\n\nint main() {\n int N = 0;\n cin >> N;\n int A[N];\n for (int i = 0; i < N; i++) cin >> A[i];\n\n int m = A[0];\n int M = A[0];\n for (int i = 0; i < N; i++) {\n if (A[i] < m) m = A[i];\n if (A[i] > M) M = A[i];\n }\n\n cout << M - m << endl;\n\n return 0;\n}", "test_IO": [ { "input": "4\n1 4 6 3\n", "output": "5\n" } ] }, { "id": "s329154546", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)\n#define in(x) cin >> x\n#define out(str) cout << str << endl\n\ntemplate \nbool chmax(T &a, const T &b) {\n if (a < b) {\n a = b;\n return 1;\n }\n return 0;\n}\ntemplate \nbool chmin(T &a, const T &b) {\n if (b < a) {\n a = b;\n return 1;\n }\n return 0;\n}\n\nint L, N;\n\nint main() {\n cin >> N >> L;\n string S[N];\n rep(i, N) cin >> S[i];\n sort(S, S + N);\n rep(i, N) cout << S[i];\n cout << endl;\n}", "test_IO": [ { "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n" } ] }, { "id": "s375006529", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n string s;\n cin >> s;\n int n = s.size();\n int v[26] = {};\n for (int i = 0; i < n; i++) v[s[i] - 'a']++;\n string ans = \"Yes\";\n for (int i = 0; i < 26; i++) {\n if (v[i] % 2 != 0) {\n ans = \"No\";\n break;\n }\n }\n cout << ans << endl;\n}", "test_IO": [ { "input": "abaccaba\n", "output": "Yes\n" } ] }, { "id": "s113620820", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAX_N = 4000;\n\ntypedef long long ll;\n\nconst ll LINF = 1LL << 60;\n\nll wis[MAX_N], wsums[MAX_N + 1], dp[MAX_N][MAX_N + 1];\nint ks[MAX_N][MAX_N + 1];\n\nint main() {\n int n;\n cin >> n;\n\n wsums[0] = 0;\n for (int i = 0; i < n; i++) {\n cin >> wis[i];\n wsums[i + 1] = wsums[i] + wis[i];\n }\n\n for (int i = 0; i < n; i++) {\n for (int j = 0; j <= n; j++) dp[i][j] = LINF, ks[i][j] = -1;\n dp[i][i + 1] = 0;\n ks[i][i + 1] = i;\n }\n\n for (int l = 2; l <= n; l++)\n for (int i = 0, j = l; j <= n; i++, j++) {\n ll mind = LINF;\n ll wsum = wsums[j] - wsums[i];\n int mink = -1;\n for (int k = ks[i][j - 1]; k <= ks[i + 1][j]; k++) {\n ll d = dp[i][k] + dp[k][j] + wsum;\n if (mind > d) mind = d, mink = k;\n }\n dp[i][j] = mind;\n ks[i][j] = mink;\n }\n\n printf(\"%lld\\n\", dp[0][n]);\n return 0;\n}", "test_IO": [ { "input": "3\n1 2 3\n", "output": "9\n" } ] }, { "id": "s525470559", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nstruct task {\n string name;\n int time;\n};\n\nint main() {\n int n, q;\n int elaps = 0;\n queue Q;\n\n cin >> n >> q;\n\n for (int i = 0; i < n; i++) {\n task tmp;\n cin >> tmp.name >> tmp.time;\n Q.push(tmp);\n }\n\n while (!Q.empty()) {\n task p = Q.front();\n Q.pop();\n if (p.time <= q) {\n elaps += p.time;\n cout << p.name << \" \" << elaps << endl;\n } else {\n p.time -= q;\n elaps += q;\n Q.push(p);\n }\n }\n return 0;\n}", "test_IO": [ { "input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n", "output": "p2 180\np5 400\np1 450\np3 550\np4 800\n" } ] }, { "id": "s154250720", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int maxn = 200000 + 10;\nconst int INF = int(1e8);\nint maps[maxn];\nint num[maxn];\nint main() {\n int n;\n while (~scanf(\"%d\", &n)) {\n for (int i = 1; i <= n; i++) {\n scanf(\"%d\", &maps[i]);\n num[i] = maps[i];\n }\n sort(maps + 1, maps + n + 1);\n int m = n / 2;\n for (int i = 1; i <= n; i++) {\n if (num[i] <= maps[m])\n printf(\"%d\\n\", maps[m + 1]);\n else\n printf(\"%d\\n\", maps[m]);\n }\n }\n return 0;\n}", "test_IO": [ { "input": "4\n2 4 4 3\n", "output": "4\n3\n3\n4\n" } ] }, { "id": "s589139355", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\nint main() {\n int a, t = 0, h = 0, lt, lh, tt, hh, l;\n cin >> a;\n string taro, hana;\n for (int i = 0; i < a; ++i) {\n cin >> taro >> hana;\n lt = taro.length();\n lh = hana.length();\n if (lt > lh) {\n l = lt;\n } else {\n l = lh;\n }\n tt = 0;\n hh = 0;\n\n if (taro > hana) {\n t = t + 3;\n } else if (hana > taro) {\n h = h + 3;\n } else if (hana == taro) {\n h = h + 1;\n t = t + 1;\n }\n }\n cout << t << \" \" << h << endl;\n\n return 0;\n}", "test_IO": [ { "input": "3\ncat dog\nfish fish\nlion tiger\n", "output": "1 7\n" } ] }, { "id": "s611392782", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n\nusing namespace std;\n\nint mul(const string& str, int& idx) {\n int res = str[idx] - '0';\n while (idx + 1 < str.size() && str[idx + 1] == '*') {\n idx += 2;\n res *= str[idx] - '0';\n }\n return res;\n}\n\nint add(const string& str, int& idx) {\n int res = mul(str, idx);\n while (idx + 1 < str.size() && str[idx + 1] == '+') {\n idx += 2;\n res += mul(str, idx);\n }\n return res;\n}\n\nint bob(const string& str, int& idx) {\n int res = str[idx] - '0';\n while (idx + 1 < str.size()) {\n if (str[idx + 1] == '+')\n res += str[idx + 2] - '0';\n else\n res *= str[idx + 2] - '0';\n idx += 2;\n }\n return res;\n}\n\nint main() {\n string s;\n int d;\n while (cin >> s >> d) {\n int idx = 0;\n int a = add(s, idx);\n idx = 0;\n int b = bob(s, idx);\n if (a == d) {\n cout << (b == d ? \"U\" : \"M\") << endl;\n } else {\n cout << (b == d ? \"L\" : \"I\") << endl;\n }\n }\n}", "test_IO": [ { "input": "1+2*3+4\n11\n", "output": "M\n" } ] }, { "id": "s573429823", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main(void) {\n unsigned long n;\n cin >> n;\n bool flg = false;\n if (n < 4) {\n cout << \"No\" << endl;\n } else {\n for (int i = 0; i <= (n / 4); i++) {\n for (int j = 0; j <= (n / 7); j++) {\n if ((i * 4 + j * 7) == n) {\n flg = true;\n break;\n }\n }\n if (flg) break;\n }\n if (flg) {\n cout << \"Yes\" << endl;\n } else {\n cout << \"No\" << endl;\n }\n }\n}", "test_IO": [ { "input": "11\n", "output": "Yes\n" } ] }, { "id": "s522742913", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n string source = \"\";\n cin >> source;\n\n if (source.length() > 10 || source.length() < 1) {\n return -1;\n }\n\n int max_i = static_cast(pow(2, source.length() - 1));\n\n double sum = 0;\n\n for (int i = 0; i < max_i; ++i) {\n bitset<100> plus(i);\n\n double number = 0;\n\n string working = source;\n while (plus.any()) {\n int i = 0;\n while (!plus[i]) ++i;\n sum += atof(working.substr(0, i + 1).c_str());\n plus >>= i + 1;\n working = working.substr(i + 1);\n }\n sum += atof(working.c_str());\n }\n\n cout.precision(0);\n cout << fixed << sum << endl;\n\n return 0;\n}", "test_IO": [ { "input": "125\n", "output": "176\n" } ] }, { "id": "s644382798", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#define LEN 100005\n\ntypedef struct pp {\n char name[100];\n int t;\n} P;\n\nP Q[LEN];\nint head, tail, n;\n\nvoid enqueue(P x) {\n Q[tail] = x;\n tail = (tail + 1) % LEN;\n}\n\nP dequeue() {\n P x = Q[head];\n head = (head + 1) % LEN;\n return x;\n}\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint main() {\n int elaps = 0, c;\n int i, q;\n P u;\n scanf(\"%d %d\", &n, &q);\n\n for (i = 1; i <= n; i++) {\n scanf(\"%s\", Q[i].name);\n scanf(\"%d\", &Q[i].t);\n }\n head = 1;\n tail = n + 1;\n\n while (head != tail) {\n u = dequeue();\n c = min(q, u.t);\n u.t -= c;\n elaps += c;\n if (u.t > 0)\n enqueue(u);\n else\n printf(\"%s %d\\n\", u.name, elaps);\n }\n\n return 0;\n}", "test_IO": [ { "input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n", "output": "p2 180\np5 400\np1 450\np3 550\np4 800\n" } ] }, { "id": "s786032937", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n int n;\n cin >> n;\n cout << (n - 2) * 180 << endl;\n return 0;\n}", "test_IO": [ { "input": "3\n", "output": "180\n" } ] }, { "id": "s970063640", "dataset": "codenet", "language": "C++", "code": "#include \n#include \nusing namespace std;\nint main() {\n int n;\n cin >> n;\n int a;\n cin >> a;\n int sum = 0;\n int s[n];\n for (int i = 0; i < n; i++) {\n cin >> s[i];\n }\n sort(s, s + n);\n for (int i = n - 1; i > n - a - 1; i--) {\n sum += s[i];\n }\n cout << sum << endl;\n return 0;\n}", "test_IO": [ { "input": "5 3\n1 2 3 4 5\n", "output": "12\n" } ] }, { "id": "s146177123", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define rep(i, n) for (int i = 0; i < n; i++)\n#define all(c) (c).begin(), (c).end()\n#define mp make_pair\n#define pb push_back\n#define rp(i, c) rep(i, (c).size())\n#define fr(i, c) \\\n for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)\n#define dbg(x) cerr << #x << \" = \" << (x) << endl\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pi;\nconst int inf = 1 << 28;\nconst double INF = 1e12, EPS = 1e-9;\n\nbool seg[][7] = {\n {0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1},\n {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0},\n\n {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0, 1}, {0, 1, 0, 0, 1, 1, 1},\n {1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 1, 1, 1, 1}};\n\nint main() {\n int n, t;\n bool st[7];\n while (cin >> n, ~n) {\n rep(i, 7) st[i] = 0;\n rep(i, n) {\n cin >> t;\n char ans[8] = {0};\n rep(i, 7) {\n ans[i] = st[i] ^ seg[t][i] ? '1' : '0';\n st[i] = seg[t][i];\n }\n cout << ans << endl;\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "3\n0\n5\n1\n1\n0\n-1\n", "output": "0111111\n1010010\n1101011\n0111111\n" } ] }, { "id": "s615507008", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#define REP(i, n) for (int i = 0; i < (n); i++)\nusing namespace std;\n\nvoid solve(long long N, std::vector T, long long M,\n std::vector P, std::vector X) {\n REP(i, M) {\n long long ans = 0;\n REP(j, N) {\n if (j == P[i] - 1)\n ans += X[i];\n else\n ans += T[j];\n }\n cout << ans << '\\n';\n }\n}\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n long long N;\n cin >> N;\n std::vector T(N);\n REP(i, N) cin >> T[i];\n long long M;\n cin >> M;\n std::vector P(M);\n std::vector X(M);\n REP(i, M) cin >> P[i] >> X[i];\n solve(N, std::move(T), M, std::move(P), std::move(X));\n return 0;\n}", "test_IO": [ { "input": "3\n2 1 4\n2\n1 1\n2 3\n", "output": "6\n9\n" } ] }, { "id": "s391054810", "dataset": "codenet", "language": "C++", "code": "#include \n\nint main() {\n int h, w, hh, ww;\n std::cin >> h >> w >> hh >> ww;\n std::cout << (h - hh) * (w - ww) << '\\n';\n return 0;\n}", "test_IO": [ { "input": "3 2\n2 1\n", "output": "1\n" } ] }, { "id": "s698030085", "dataset": "codenet", "language": "C++", "code": "#include \nusing namespace std;\nint main(void) {\n long long int a, b;\n cin >> a >> b;\n if ((a + b) % 2 == 0) {\n cout << (a + b) / 2 << \"\\n\";\n } else {\n cout << \"IMPOSSIBLE\\n\";\n }\n}", "test_IO": [ { "input": "2 16\n", "output": "9\n" } ] }, { "id": "s876796799", "dataset": "codenet", "language": "C++", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nlong long a[200000];\nint ind_a[200000];\nint main() {\n int N;\n cin >> N;\n for (int i = 0; i < N; i++) {\n cin >> a[i];\n }\n for (int i = 0; i < N; i++) {\n ind_a[a[i] - 1] = i;\n }\n\n set used_inds;\n long long ans = 0;\n for (int i = 0; i < N; i++) {\n long long left_border;\n long long right_border;\n long long cur_ind = ind_a[i];\n auto left_it = used_inds.lower_bound(cur_ind);\n auto right_it = used_inds.lower_bound(cur_ind + 1);\n\n if (left_it == used_inds.begin()) {\n left_border = -1;\n } else {\n if (left_it == used_inds.end() || *left_it > cur_ind) {\n left_it--;\n }\n left_border = *left_it;\n }\n if (right_it == used_inds.end()) {\n right_border = N;\n } else {\n right_border = *right_it;\n }\n ans += (cur_ind - left_border) * (right_border - cur_ind) *\n ((long long)i + 1);\n\n used_inds.insert(cur_ind);\n }\n\n cout << ans << endl;\n return 0;\n}", "test_IO": [ { "input": "3\n2 1 3\n", "output": "9\n" } ] }, { "id": "s635143344", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tin := make([]int, 3)\n\tfmt.Scan(&in[0], &in[1], &in[2])\n\tsort.Ints(in)\n\n\tfmt.Println(in[2]*10 + in[1] + in[0])\n}\n", "test_IO": [ { "input": "1 5 2\n", "output": "53\n" } ] }, { "id": "s217679680", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar stdin = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tarr := scanArrayInt()\n\ta, b := arr[0], arr[1]\n\ttap := 0\n\tconsent := 1\n\tfor consent < b {\n\t\tconsent = consent + a - 1\n\t\ttap++\n\t}\n\tfmt.Println(tap)\n}\n\nfunc scanArrayInt() []int {\n\tvar ret = []int{}\n\tstdin.Scan()\n\tfor _, s := range strings.Split(stdin.Text(), \" \") {\n\t\ti, _ := strconv.Atoi(s)\n\t\tret = append(ret, i)\n\t}\n\treturn ret\n}\n", "test_IO": [ { "input": "4 10\n", "output": "3\n" } ] }, { "id": "s480530100", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc out(x ...interface{}) {\n\tfmt.Println(x...)\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer([]byte{}, 1000000)\n\tn, q := getInt(), getInt()\n\n\tfw := FenwickTree(n)\n\tfor i := 0; i < n; i++ {\n\t\ta := getInt()\n\t\tfw.Add(i, a)\n\t}\n\n\tfor i := 0; i < q; i++ {\n\t\tt := getInt()\n\t\tif t == 0 {\n\t\t\tp, x := getInt(), getInt()\n\t\t\tfw.Add(p, x)\n\t\t} else {\n\t\t\tl, r := getInt(), getInt()\n\t\t\tout(fw.Sum(l, r))\n\t\t}\n\n\t}\n\n}\n\ntype BIT struct {\n\tn int\n\tdata []int\n}\n\nfunc FenwickTree(n int) *BIT {\n\tvar ret BIT\n\tret.n = n\n\tret.data = make([]int, n)\n\treturn &ret\n}\n\nfunc (b *BIT) Add(p, x int) {\n\tp++\n\tfor p <= b.n {\n\t\tb.data[p-1] += x\n\t\tp += p & -p\n\t}\n}\n\nfunc (b *BIT) Sum(l, r int) int {\n\treturn b.sum(r) - b.sum(l)\n}\n\nfunc (b *BIT) sum(r int) int {\n\ts := 0\n\tfor r > 0 {\n\t\ts += b.data[r-1]\n\t\tr -= r & -r\n\t}\n\treturn s\n}\n", "test_IO": [ { "input": "5 5\n1 2 3 4 5\n1 0 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n", "output": "15\n7\n25\n6\n" } ] }, { "id": "s495252714", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n\nfunc scanInt() int {\n\tsc.Scan()\n\ta, _ := strconv.Atoi(sc.Text())\n\treturn a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta, _ := strconv.ParseInt(sc.Text(), 10, 64)\n\treturn a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = scanInt()\n\t}\n\treturn res\n}\n\nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 {\n\t\t\tfmt.Fprint(wr, \" \")\n\t\t}\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\n\tn := scanInt()\n\n\tc := scanInts(n)\n\n\tans := 0\n\tsort.Ints(c)\n\n\tfor i := 0; i < n; i++ {\n\t\tans = (ans + (n+1-i)*c[i]%mod) % mod\n\t}\n\n\tfmt.Println(ans * modpow(4, n-1) % mod)\n}\n\nconst mod = 1000000007\n\nfunc modpow(a, n int) int {\n\tres := 1\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tres = res * a % mod\n\t\t}\n\t\ta = a * a % mod\n\t\tn = n >> 1\n\t}\n\treturn res\n}\n", "test_IO": [ { "input": "1\n1000000000\n", "output": "999999993\n" } ] }, { "id": "s053342495", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar day int\n\tfmt.Scan(&day)\n\n\tswitch day {\n\tcase 25:\n\t\tfmt.Println(\"Christmas\")\n\tcase 24:\n\t\tfmt.Println(\"Christmas Eve\")\n\tcase 23:\n\t\tfmt.Println(\"Christmas Eve Eve\")\n\tcase 22:\n\t\tfmt.Println(\"Christmas Eve Eve Eve\")\n\t}\n}\n", "test_IO": [ { "input": "25\n", "output": "Christmas\n" } ] }, { "id": "s228769347", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextUint64(scanner *bufio.Scanner) uint64 {\n\ti, _ := strconv.ParseUint(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextFloat64(scanner *bufio.Scanner) float64 {\n\ti, _ := strconv.ParseFloat(getNextString(scanner), 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\twfp := os.Stdout\n\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t\tif len(os.Args) > 2 {\n\t\t\twfp, _ = os.Create(os.Args[2])\n\t\t}\n\t}\n\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(wfp)\n\n\tn := getNextInt(scanner)\n\tll := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tll[i] = getNextInt(scanner)\n\t}\n\n\tsort.Ints(ll)\n\n\tans := 0\n\tfor i := 0; i < n-2; i++ {\n\t\tfor j := i + 1; j < n-1; j++ {\n\t\t\tl := j + 1\n\t\t\tr := n\n\t\t\tfor l < r {\n\t\t\t\tm := (l + r) >> 1\n\t\t\t\tif ll[m] < ll[i]+ll[j] {\n\t\t\t\t\tl = m + 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tr = m\n\t\t\t}\n\n\t\t\tans += l - (j + 1)\n\t\t}\n\t}\n\tfmt.Fprintln(writer, ans)\n\n\twriter.Flush()\n}\n", "test_IO": [ { "input": "4\n3 4 2 1\n", "output": "1\n" } ] }, { "id": "s407800036", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar A, B, C int\n\tfmt.Scanf(\"%d %d %d\", &A, &B, &C)\n\n\tif C >= A && C <= B {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1 3 2\n", "output": "Yes\n" } ] }, { "id": "s791445247", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar in = NewScanner(os.Stdin, 0)\n\nfunc main() {\n\tn, k := in.Int(), in.Int()\n\tif n%k == 0 {\n\t\tPln(0)\n\t} else {\n\t\tPln(1)\n\t}\n}\n\ntype Scanner struct {\n\t*bufio.Scanner\n}\n\nfunc NewScanner(r io.Reader, max int) *Scanner {\n\ts := bufio.NewScanner(r)\n\ts.Split(scanWords)\n\tif max <= 0 {\n\t\tmax = 1048576\n\t}\n\ts.Buffer([]byte{}, max)\n\treturn &Scanner{s}\n}\nfunc (s *Scanner) Int() int {\n\ts.Scan()\n\ti, e := strconv.ParseInt(s.Text(), 10, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn int(i)\n}\nfunc isSpace(b byte) bool {\n\treturn b == ' ' || b == '\\n' || b == '\\r' || b == '\\t'\n}\nfunc scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tstart := 0\n\tfor start < len(data) && isSpace(data[start]) {\n\t\tstart++\n\t}\n\tfor i := start; i < len(data); i++ {\n\t\tif isSpace(data[i]) {\n\t\t\treturn i + 1, data[start:i], nil\n\t\t}\n\t}\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\treturn start, nil, nil\n}\nfunc Pln(s ...interface{}) {\n\tfmt.Println(s...)\n}\n", "test_IO": [ { "input": "7 3\n", "output": "1\n" } ] }, { "id": "s278875041", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar a string\n\tfmt.Scan(&a)\n\ttmp := strings.Replace(a, \"1\", \"0\", -1)\n\tb := strings.Replace(tmp, \"9\", \"1\", -1)\n\tans := strings.Replace(b, \"0\", \"9\", -1)\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "119\n", "output": "991\n" } ] }, { "id": "s819591647", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nconst (\n\tconstMod = int(1e9) + 7\n)\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getIntSlice(n int) []int {\n\tns := []int{}\n\tfor i := 0; i < n; i++ {\n\t\tns = append(ns, getInt())\n\t}\n\treturn ns\n}\n\nfunc getIntDoubleSlice(m int, n int) [][]int {\n\tvar nds [][]int\n\tfor i := 0; i < m; i++ {\n\t\tns := getIntSlice(n)\n\t\tnds = append(nds, ns)\n\t}\n\n\treturn nds\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc getStringSlice(n int) []string {\n\tss := []string{}\n\tfor i := 0; i < n; i++ {\n\t\tss = append(ss, getString())\n\t}\n\treturn ss\n}\n\nfunc getStringDoubleSlice(m int, n int) [][]string {\n\tsds := [][]string{}\n\tfor i := 0; i < m; i++ {\n\t\tss := getStringSlice(n)\n\t\tsds = append(sds, ss)\n\t}\n\n\treturn sds\n\n}\n\nfunc sortIntSlice(ns []int) []int {\n\tsort.Sort(sort.IntSlice(ns))\n\treturn ns\n}\n\nfunc sortIntReverseSlice(ns []int) []int {\n\tsort.Sort(sort.Reverse(sort.IntSlice(ns)))\n\treturn ns\n}\n\nfunc numAbs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\n\treturn x\n}\n\nfunc numModPow(a int, n int, m int) int {\n\tresult := 1\n\n\tfor n > 0 {\n\t\tif n%2 == 1 {\n\t\t\tresult = (result * a) % m\n\t\t}\n\n\t\ta = (a * a) % m\n\t\tn >>= 1\n\t}\n\n\treturn result\n}\n\nfunc numGcd(a int, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\n\treturn numGcd(b, a%b)\n}\n\nfunc numLcm(a int, b int) int {\n\treturn a * b / numGcd(a, b)\n}\n\nfunc numModInv(a int, p int) int {\n\tif a == 1 {\n\t\treturn 1\n\t}\n\n\treturn p - numModInv(p%a, p)*(p/a)%p\n}\n\nfunc numModFrac(n int) []int {\n\tfrac := []int{1}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfrac = append(frac, i*frac[i-1]%constMod)\n\t}\n\n\treturn frac\n}\n\nfunc numModConb(n int, r int) int {\n\tfrac := numModFrac(n)\n\n\treturn (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod\n}\n\nfunc solve() {\n\n\tn, m := getInt(), getInt()\n\ta := getIntSlice(n)\n\n\tsum := 0\n\tfor _, v := range a {\n\t\tsum += v\n\t}\n\n\tcount := 0\n\tfor _, v := range a {\n\t\trate := float64(sum) / float64(4*m)\n\t\tif float64(v) >= rate {\n\t\t\tcount++\n\t\t}\n\t}\n\n\tif count >= m {\n\t\tfmt.Fprintln(wr, \"Yes\")\n\t} else {\n\t\tfmt.Fprintln(wr, \"No\")\n\t}\n\n}\n\nfunc main() {\n\tmaxBufSize := int(1e8)\n\tsc.Buffer(make([]byte, 4096), maxBufSize)\n\tsc.Split(bufio.ScanWords)\n\tsolve()\n\twr.Flush()\n}\n", "test_IO": [ { "input": "4 1\n5 4 2 1\n", "output": "Yes\n" } ] }, { "id": "s583952795", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype Pair struct {\n\tp1, p2 interface{}\n}\n\nconst (\n\tinitialBufSize = 1e4\n\tmaxBufSize = 1e8\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tbuf := make([]byte, initialBufSize)\n\tscanner.Buffer(buf, maxBufSize)\n\tscanner.Split(bufio.ScanWords)\n\n\tN, K := readInt(), readInt()\n\ts := TenToN(N, K)\n\tfmt.Println(len(s))\n}\n\nfunc TenToN(number int, n int) string {\n\tvar s string\n\ttmp := number\n\tfor {\n\t\ts = i2s(tmp%n) + s\n\t\tif tmp < n {\n\t\t\tbreak\n\t\t}\n\t\ttmp /= n\n\t}\n\treturn s\n}\n\nfunc write(s string) {\n\twriter.WriteString(s)\n}\n\nfunc print() {\n\twriter.Flush()\n}\n\nfunc readLine() (s string) {\n\tif scanner.Scan() {\n\t\ts = scanner.Text()\n\t}\n\treturn s\n}\n\nfunc readInt() (read int) {\n\tscanner.Scan()\n\tread, err := strconv.Atoi(scanner.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}\n\nfunc readFloat() (read float64) {\n\tscanner.Scan()\n\tread, err := strconv.ParseFloat(scanner.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}\n\nfunc readRunes() (read []rune) {\n\tscanner.Scan()\n\tfor _, v := range scanner.Text() {\n\t\tread = append(read, v)\n\t}\n\treturn\n}\n\nfunc readString() (read string) {\n\tscanner.Scan()\n\tread = scanner.Text()\n\treturn\n}\n\nfunc readStrings() (read []string) {\n\tscanner.Scan()\n\tfor _, v := range scanner.Text() {\n\t\tread = append(read, string(v))\n\t}\n\treturn\n}\n\nfunc s2i(s string) int {\n\tvar intVal, e = strconv.Atoi(s)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn intVal\n}\n\nfunc i2s(i int) string {\n\tvar strVal = strconv.Itoa(i)\n\treturn strVal\n}\n\nfunc s2f(s string) float64 {\n\tvar floatVal, e = strconv.ParseFloat(s, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn floatVal\n}\n\nfunc sum(i []int) int {\n\tsum := 0\n\tfor _, val := range i {\n\t\tsum += val\n\t}\n\treturn sum\n}\n\nfunc split(s string) []string {\n\treturn strings.Fields(s)\n}\n\nfunc strAry2intAry(strs []string) []int {\n\tvar ret = make([]int, 0, len(strs))\n\tfor _, str := range strs {\n\t\tvar intVal, e = strconv.Atoi(string(str))\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\tret = append(ret, intVal)\n\t}\n\treturn ret\n}\n\nfunc intAry2strAry(nums []int) []string {\n\tvar ret = make([]string, 0, len(nums))\n\tfor _, num := range nums {\n\t\tvar strVal = strconv.Itoa(num)\n\t\tret = append(ret, strVal)\n\t}\n\treturn ret\n}\n\nfunc ary2str(strs []string) string {\n\treturn strings.Join(strs, \" \")\n}\n\nfunc reverse(res []int) []int {\n\tfor i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {\n\t\tres[i], res[j] = res[j], res[i]\n\t}\n\treturn res\n}\n\nfunc initalize(res []int, init int) {\n\tif len(res) == 0 {\n\t\treturn\n\t}\n\tres[0] = init\n\tfor i := 0; i < len(res); i++ {\n\t\tcopy(res[i:], res[:i])\n\t}\n}\n", "test_IO": [ { "input": "11 2\n", "output": "4\n" } ] }, { "id": "s876834921", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\ts = strings.Replace(s, \"dream\", \"D\", -1)\n\ts = strings.Replace(s, \"erase\", \"E\", -1)\n\ts = strings.Replace(s, \"Der\", \"\", -1)\n\ts = strings.Replace(s, \"Er\", \"\", -1)\n\ts = strings.Replace(s, \"D\", \"\", -1)\n\ts = strings.Replace(s, \"E\", \"\", -1)\n\ts = strings.TrimSpace(s)\n\n\tif s == \"\" {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "test_IO": [ { "input": "erasedream\n", "output": "YES\n" } ] }, { "id": "s493522692", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc nextStr() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc maxInt(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}\n\nfunc absInt(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc absFloat64(a float64) float64 {\n\tif a >= 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxFloat64(a, b float64) float64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minFloat64(a, b float64) float64 {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}\n\nfunc str2Int(s string) int {\n\tn, _ := strconv.Atoi(s)\n\treturn n\n}\n\nfunc reverse(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}\n\nfunc powInt(p, q int) int {\n\treturn int(math.Pow(float64(p), float64(q)))\n}\n\nfunc isPrime(x int) bool {\n\tif x == 1 {\n\t\treturn false\n\t}\n\tif x == 2 {\n\t\treturn true\n\t}\n\tif x%2 == 0 {\n\t\treturn false\n\t}\n\n\tb := true\n\trootx := int(math.Sqrt(float64(x)))\n\ti := 3\n\tfor i <= rootx {\n\t\tif x%i == 0 {\n\t\t\tb = false\n\t\t\tbreak\n\t\t}\n\t\ti += 2\n\t}\n\treturn b\n}\n\nfunc PrimeFactors(n int) (pfs []int) {\n\n\tfor n%2 == 0 {\n\t\tpfs = append(pfs, 2)\n\t\tn = n / 2\n\t}\n\n\tfor i := 3; i*i <= n; i = i + 2 {\n\n\t\tfor n%i == 0 {\n\t\t\tpfs = append(pfs, i)\n\t\t\tn = n / i\n\t\t}\n\t}\n\n\tif n > 2 {\n\t\tpfs = append(pfs, n)\n\t}\n\n\treturn\n}\n\nfunc PrimeFactorsMap(n int) map[int]int {\n\tpfs := map[int]int{}\n\n\tfor n%2 == 0 {\n\t\tif _, ok := pfs[2]; ok {\n\t\t\tpfs[2]++\n\t\t} else {\n\t\t\tpfs[2] = 1\n\t\t}\n\n\t\tn = n / 2\n\t}\n\n\tfor i := 3; i*i <= n; i = i + 2 {\n\n\t\tfor n%i == 0 {\n\t\t\tif _, ok := pfs[i]; ok {\n\t\t\t\tpfs[i]++\n\t\t\t} else {\n\t\t\t\tpfs[i] = 1\n\t\t\t}\n\t\t\tn = n / i\n\t\t}\n\t}\n\n\tif n > 2 {\n\t\tif _, ok := pfs[n]; ok {\n\t\t\tpfs[n]++\n\t\t} else {\n\t\t\tpfs[n] = 1\n\t\t}\n\t}\n\n\treturn pfs\n}\n\nfunc sumInts(x []int) int {\n\n\ttotal := 0\n\tfor _, v := range x {\n\t\ttotal += v\n\t}\n\n\treturn total\n}\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc lcm(x, y int) int {\n\n\treturn x * y / gcd(x, y)\n\n}\n\nconst (\n\tinitialBufSize = 10000\n\tmaxBufSize = 1000000\n\tmod = 1e9 + 7\n)\n\nvar (\n\tsc *bufio.Scanner = func() *bufio.Scanner {\n\t\tsc := bufio.NewScanner(os.Stdin)\n\t\tbuf := make([]byte, initialBufSize)\n\t\tsc.Buffer(buf, maxBufSize)\n\t\treturn sc\n\t}()\n)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\n\tN, M := nextInt(), nextInt()\n\ttmp := minInt(N, M/2)\n\tans := 0\n\tans += tmp\n\tN -= tmp\n\tM -= tmp * 2\n\n\tfmt.Println(ans + M/4)\n}\n", "test_IO": [ { "input": "1 6\n", "output": "2\n" } ] }, { "id": "s554610878", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tinitialBufSize = 10000\n\tmaxBufSize = 1000000\n)\n\nvar (\n\tsc *bufio.Scanner = func() *bufio.Scanner {\n\t\tsc := bufio.NewScanner(os.Stdin)\n\t\tbuf := make([]byte, initialBufSize)\n\t\tsc.Buffer(buf, maxBufSize)\n\t\tsc.Split(bufio.ScanWords)\n\t\treturn sc\n\t}()\n\tmod int = 1e9 + 7\n)\n\nfunc main() {\n\tweek := []string{\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"}\n\ts := getString()\n\tindex := -1\n\tfor i, day := range week {\n\t\tif s == day {\n\t\t\tindex = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(7 - index)\n}\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc abs(a int) int {\n\treturn int(math.Abs(float64(a)))\n}\n\nfunc pow(p, q int) int {\n\treturn int(math.Pow(float64(p), float64(q)))\n}\n\nfunc min(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton min() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Min(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton max() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Max(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc strSearch(a []string, b string) bool {\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] == b {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc printIntArray(array []int) {\n\tstrArray := fmt.Sprint(array)\n\tfmt.Println(strArray[1 : len(strArray)-1])\n}\n\nfunc calcMod(x int) int {\n\treturn x % mod\n}\n", "test_IO": [ { "input": "SAT\n", "output": "1\n" } ] }, { "id": "s032855181", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc group(n int) string {\n\tif n == 4 || n == 6 || n == 9 || n == 11 {\n\t\treturn \"B\"\n\t} else {\n\t\treturn \"A\"\n\t}\n}\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scan(&x, &y)\n\n\tif x == 2 || y == 2 {\n\t\tfmt.Println(\"No\")\n\t\treturn\n\t}\n\n\txg := group(x)\n\tyg := group(y)\n\n\tif xg == yg {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1 3\n", "output": "Yes\n" } ] }, { "id": "s557024716", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tMOD = 1000000000 + 7\n\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, c int\n\tk int\n)\n\nfunc main() {\n\ta, b, c = ReadInt3()\n\tk = ReadInt()\n\n\tpatterns := DuplicatePatterns([]int{0, 1, 2, 3}, k)\n\n\tfor _, P := range patterns {\n\t\tr, g, b := a, b, c\n\t\tfor i := 0; i < len(P); i++ {\n\t\t\tif P[i] == 0 {\n\t\t\t\tcontinue\n\t\t\t} else if P[i] == 1 {\n\t\t\t\tr *= 2\n\t\t\t} else if P[i] == 2 {\n\t\t\t\tg *= 2\n\t\t\t} else if P[i] == 3 {\n\t\t\t\tb *= 2\n\t\t\t}\n\t\t}\n\n\t\tif g > r && b > g {\n\t\t\tfmt.Println(\"Yes\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"No\")\n}\n\nfunc DuplicatePatterns(elems []int, k int) [][]int {\n\treturn dupliRec([]int{}, elems, k)\n}\n\nfunc dupliRec(pattern, elems []int, k int) [][]int {\n\tif len(pattern) == k {\n\t\treturn [][]int{pattern}\n\t}\n\n\tres := [][]int{}\n\tfor _, e := range elems {\n\t\tnewPattern := make([]int, len(pattern))\n\t\tcopy(newPattern, pattern)\n\t\tnewPattern = append(newPattern, e)\n\n\t\tres = append(res, dupliRec(newPattern, elems, k)...)\n\t}\n\n\treturn res\n}\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10)\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "test_IO": [ { "input": "7 2 5\n3\n", "output": "Yes\n" } ] }, { "id": "s273611899", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, x int\n\n\tfor {\n\t\tfmt.Scan(&n, &x)\n\t\tif n == 0 && x == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tc := 0\n\t\tfor i := 1; i <= n-2; i++ {\n\t\t\tfor j := i + 1; j <= n-1; j++ {\n\t\t\t\tfor k := j + 1; k <= n; k++ {\n\t\t\t\t\tif i+j+k == x {\n\t\t\t\t\t\tc++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Println(c)\n\t}\n}\n", "test_IO": [ { "input": "5 9\n0 0\n", "output": "2\n" } ] }, { "id": "s482866535", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t}\n\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(os.Stdout)\n\n\tn := getNextInt(scanner)\n\tmm := make([]int, n+1)\n\tdp := make([][]int, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tdp[i] = make([]int, n+1)\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tmm[i] = getNextInt(scanner)\n\t\tmm[i+1] = getNextInt(scanner)\n\t}\n\n\tfor l := 2; l <= n; l++ {\n\t\tfor i := 1; i <= n-l+1; i++ {\n\t\t\tj := i + l - 1\n\t\t\tfor k := i; k <= j-1; k++ {\n\t\t\t\td := dp[i][k] + dp[k+1][j] + mm[i-1]*mm[k]*mm[j]\n\t\t\t\tif dp[i][j] == 0 || dp[i][j] > d {\n\t\t\t\t\tdp[i][j] = d\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Fprintln(writer, dp[1][n])\n\n\twriter.Flush()\n}\n", "test_IO": [ { "input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25\n", "output": "15125\n" } ] }, { "id": "s426245140", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1118\n", "output": "Yes\n" } ] }, { "id": "s562422877", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\n\tvar N int\n\tfmt.Scanf(\"%d\", &N)\n\n\tA := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%d\", &A[i])\n\t}\n\n\tsort.Sort(sort.IntSlice(A))\n\n\tvar ans int\n\tfor i := 1; i < N; i++ {\n\t\tans += A[i] - A[i-1]\n\t}\n\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4\n2 3 7 9\n", "output": "7\n" } ] }, { "id": "s503150457", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s1, s2, s3 string\n\tfmt.Scan(&s1, &s2, &s3)\n\n\ts1s := strings.Split(s1, \"\")\n\ts2s := strings.Split(s2, \"\")\n\ts3s := strings.Split(s3, \"\")\n\n\tfmt.Println(strings.ToUpper(s1s[0]) + strings.ToUpper(s2s[0]) + strings.ToUpper(s3s[0]))\n}\n", "test_IO": [ { "input": "atcoder beginner contest\n", "output": "ABC\n" } ] }, { "id": "s695286684", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tfmt.Println(strings.Replace(s, \"2017\", \"2018\", -1))\n}\n", "test_IO": [ { "input": "2017/01/07\n", "output": "2018/01/07\n" } ] }, { "id": "s206203202", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc Abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\nfunc min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar N, K int\n\tfmt.Scan(&N, &K)\n\n\tvar x int\n\tx = N % K\n\tx = min(Abs(x-K), x)\n\tfmt.Println(x)\n}\n", "test_IO": [ { "input": "7 4\n", "output": "1\n" } ] }, { "id": "s998080221", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype bufReader struct {\n\tr *bufio.Reader\n\tbuf []byte\n\ti int\n}\n\nvar reader = &bufReader{\n\tbufio.NewReader(os.Stdin),\n\tmake([]byte, 0),\n\t0,\n}\n\nfunc (r *bufReader) readLine() {\n\tif r.i < len(r.buf) {\n\t\treturn\n\t}\n\tr.buf = make([]byte, 0)\n\tr.i = 0\n\tfor {\n\t\tline, isPrefix, err := r.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tr.buf = append(r.buf, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc (r *bufReader) next() string {\n\tr.readLine()\n\tfrom := r.i\n\tfor ; r.i < len(r.buf); r.i++ {\n\t\tif r.buf[r.i] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\ts := string(r.buf[from:r.i])\n\tr.i++\n\treturn s\n}\n\nfunc (r *bufReader) nextLine() string {\n\tr.readLine()\n\ts := string(r.buf[r.i:])\n\tr.i = len(r.buf)\n\treturn s\n}\n\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n\treturn reader.next()\n}\n\nfunc nextInt64() int64 {\n\ti, err := strconv.ParseInt(reader.next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc nextInt() int {\n\treturn int(nextInt64())\n}\n\nfunc nextLine() string {\n\treturn reader.nextLine()\n}\n\nfunc out(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc max64(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc max(x, y int) int {\n\treturn int(max64(int64(x), int64(y)))\n}\n\nfunc min64(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\treturn int(min64(int64(x), int64(y)))\n}\n\nfunc abs64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc abs(x int) int {\n\treturn int(abs64(int64(x)))\n}\n\nfunc joinInt64s(a []int64, sep string) string {\n\tb := make([]string, len(a))\n\tfor i, v := range a {\n\t\tb[i] = strconv.FormatInt(v, 10)\n\t}\n\treturn strings.Join(b, sep)\n}\n\nfunc joinInts(a []int, sep string) string {\n\tb := make([]string, len(a))\n\tfor i, v := range a {\n\t\tb[i] = strconv.Itoa(v)\n\t}\n\treturn strings.Join(b, sep)\n}\n\nfunc divUp64(x, y int64) int64 {\n\treturn (x + y - 1) / y\n}\n\nfunc divUp(x, y int) int {\n\treturn int(divUp64(int64(x), int64(y)))\n}\n\nfunc gcd64(x, y int64) int64 {\n\tif x < y {\n\t\tx, y = y, x\n\t}\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc gcd(x, y int) int {\n\treturn int(gcd64(int64(x), int64(y)))\n}\n\nfunc lcm64(x, y int64) int64 {\n\treturn x * y / gcd64(x, y)\n}\n\nfunc lcm(x, y int) int {\n\treturn int(lcm64(int64(x), int64(y)))\n}\n\nfunc pow64(x, y int64) int64 {\n\treturn int64(math.Pow(float64(x), float64(y)))\n}\n\nfunc pow(x, y int) int {\n\treturn int(pow64(int64(x), int64(y)))\n}\n\nfunc main() {\n\tsolve()\n\twriter.Flush()\n}\n\nfunc solve() {\n\tN, _ := nextInt(), nextInt()\n\tA := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tA[i] = nextInt()\n\t}\n\tmaxProfit := 0\n\tmaxCnt := 0\n\tmaxA := A[N-1]\n\tfor i := N - 2; i >= 0; i-- {\n\t\tprofit := max(0, maxA-A[i])\n\t\tif maxProfit < profit {\n\t\t\tmaxProfit = profit\n\t\t\tmaxCnt = 1\n\t\t} else if maxProfit == profit {\n\t\t\tmaxCnt++\n\t\t}\n\t\tmaxA = max(maxA, A[i])\n\t}\n\tout(maxCnt)\n}\n", "test_IO": [ { "input": "3 2\n100 50 200\n", "output": "1\n" } ] }, { "id": "s963048401", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc Scanner() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc intScanner() int {\n\tn, _ := strconv.Atoi(Scanner())\n\treturn n\n}\n\nfunc floatScanner() float64 {\n\tn, _ := strconv.ParseFloat(Scanner(), 64)\n\treturn n\n}\nfunc stringToInt(s string) int {\n\tn, _ := strconv.Atoi(s)\n\treturn n\n}\n\nvar mod int\n\nfunc main() {\n\tmod = 1000000007\n\tbuf := make([]byte, 0)\n\tsc.Buffer(buf, mod)\n\tsc.Split(bufio.ScanWords)\n\tn := intScanner()\n\tas := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tas[i] = intScanner()\n\t}\n\txs := []int{as[0]}\n\tfor j := 1; j < n; j++ {\n\t\tidx := sort.Search(len(xs), func(i int) bool { return xs[i] < as[j] })\n\t\tif idx == len(xs) {\n\t\t\txs = append(xs, as[j])\n\t\t} else {\n\t\t\txs[idx] = as[j]\n\t\t}\n\t}\n\tfmt.Println(len(xs))\n}\n", "test_IO": [ { "input": "5\n2\n1\n4\n5\n3\n", "output": "2\n" } ] }, { "id": "s099670837", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nvar n, ans int\n\nconst arraySize = 101\n\nvar a = [arraySize][arraySize]int{}\n\nfunc findAns(i, j, sum int) {\n\tif i == 1 && j == n-1 && sum+a[i][j] > ans {\n\t\tans = sum + a[i][j]\n\t\treturn\n\t}\n\tif i == 0 {\n\t\tfindAns(i+1, j, sum+a[i][j])\n\t}\n\tif j+1 < n {\n\t\tfindAns(i, j+1, sum+a[i][j])\n\t}\n}\nfunc main() {\n\n\tfmt.Scanf(\"%d\", &n)\n\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tfmt.Scanf(\"%d\", &a[i][j])\n\t\t}\n\t}\n\tfindAns(0, 0, 0)\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "5\n3 2 2 4 1\n1 2 2 2 1\n", "output": "14\n" } ] }, { "id": "s376370885", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar in = NewScanner(os.Stdin, 0)\n\nfunc main() {\n\tn, k := in.Int(), in.Int()\n\tif n%k == 0 {\n\t\tPln(0)\n\t} else {\n\t\tPln(1)\n\t}\n}\n\ntype Scanner struct {\n\t*bufio.Scanner\n}\n\nfunc NewScanner(r io.Reader, max int) *Scanner {\n\ts := bufio.NewScanner(r)\n\ts.Split(scanWords)\n\tif max <= 0 {\n\t\tmax = 1048576\n\t}\n\ts.Buffer([]byte{}, max)\n\treturn &Scanner{s}\n}\nfunc (s *Scanner) Int() int {\n\ts.Scan()\n\ti, e := strconv.ParseInt(s.Text(), 10, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn int(i)\n}\nfunc isSpace(b byte) bool {\n\treturn b == ' ' || b == '\\n' || b == '\\r' || b == '\\t'\n}\nfunc scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tstart := 0\n\tfor start < len(data) && isSpace(data[start]) {\n\t\tstart++\n\t}\n\tfor i := start; i < len(data); i++ {\n\t\tif isSpace(data[i]) {\n\t\t\treturn i + 1, data[start:i], nil\n\t\t}\n\t}\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\treturn start, nil, nil\n}\nfunc Pln(s ...interface{}) {\n\tfmt.Println(s...)\n}\n", "test_IO": [ { "input": "7 3\n", "output": "1\n" } ] }, { "id": "s330691347", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc out(x ...interface{}) {\n\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc nextString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\ntype Data struct {\n\tX string\n}\n\ntype Datas []Data\n\nfunc (p Datas) Len() int {\n\treturn len(p)\n}\n\nfunc (p Datas) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p Datas) Less(i, j int) bool {\n\treturn p[i].X < p[j].X\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tN := nextInt()\n\tL := nextInt()\n\ts := make(Datas, N)\n\n\tfor i := 0; i < N; i++ {\n\t\ts[i].X = nextString()\n\t}\n\n\tout(N, L, s)\n\tsort.Sort(s)\n\tout(s)\n\n\tans := \"\"\n\tfor i := 0; i < N; i++ {\n\t\tans = ans + s[i].X\n\t}\n\tfmt.Println(ans)\n\n}\n", "test_IO": [ { "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n" } ] }, { "id": "s984784526", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a [3]int\n\n\tfmt.Scan(&a[0], &a[1], &a[2])\n\n\tfive := 0\n\tseven := 0\n\n\tfor i := 0; i < 3; i++ {\n\t\tif a[i] == 5 {\n\t\t\tfive++\n\t\t}\n\t\tif a[i] == 7 {\n\t\t\tseven++\n\t\t}\n\n\t}\n\n\tif five == 2 && seven == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n", "test_IO": [ { "input": "5 5 7\n", "output": "YES\n" } ] }, { "id": "s726858931", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tscanInit()\n\n\ts := nextStr()\n\n\tc := 'a'\n\n\tfor j := 0; j < 26; j++ {\n\t\tfound := false\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tif s[i] == byte(c) {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif found == false {\n\t\t\tfmt.Println(string(c))\n\t\t\treturn\n\t\t}\n\t\tc++\n\t}\n\n\tfmt.Println(\"None\")\n\n}\n\nfunc scanInit() {\n\tconst cap = 1000 * 1024\n\tvar buf = make([]byte, cap)\n\tsc.Buffer(buf, cap)\n\tsc.Split(bufio.ScanWords)\n\treturn\n}\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\nfunc nextStr() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n", "test_IO": [ { "input": "atcoderregularcontest\n", "output": "b\n" } ] }, { "id": "s306917423", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tans := 0\n\tfor _, c := range s {\n\t\tif c == '1' {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "111100\n", "output": "4\n" } ] }, { "id": "s476359676", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc *bufio.Scanner\n\nfunc nextStr() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc main() {\n\tsc = bufio.NewScanner(os.Stdin)\n\tsc.Buffer(make([]byte, 0), 1000000001*3)\n\tsc.Split(bufio.ScanWords)\n\tn := nextInt()\n\n\tans := 0\n\taPrev := 0\n\tfor i := 0; i < n; i++ {\n\t\ta := nextInt()\n\t\tswitch {\n\t\tcase a > i || a > aPrev+1:\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\tcase a == aPrev+1:\n\t\t\tans++\n\t\tdefault:\n\t\t\tans += a\n\t\t}\n\t\taPrev = a\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4\n0\n1\n1\n2\n", "output": "3\n" } ] }, { "id": "s648707342", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc scanInt() int {\n\tsc.Scan()\n\tiv, _ := strconv.Atoi(sc.Text())\n\treturn iv\n}\n\nfunc init() {\n\tsc.Split(bufio.ScanWords)\n}\n\nfunc main() {\n\tn := scanInt()\n\ttype arm struct{ l, r int }\n\tas := make([]arm, n)\n\tfor i := range as {\n\t\tx, l := scanInt(), scanInt()\n\t\tas[i].l = x - l\n\t\tas[i].r = x + l\n\n\t}\n\tsort.Slice(as, func(i, j int) bool { return as[i].r < as[j].r })\n\n\tans := 1\n\tr := as[0].r\n\tfor i := 1; i < n; i++ {\n\t\tif as[i].l >= r {\n\t\t\tans++\n\t\t\tr = as[i].r\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4\n2 4\n4 3\n9 3\n100 5\n", "output": "3\n" } ] }, { "id": "s219662687", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tINF := int(math.Pow10(11))\n\tA := nextInt()\n\tB := nextInt()\n\tQ := nextInt()\n\ts := make([]int, A+2)\n\ts[0], s[A+1] = -INF, INF\n\tfor i := 1; i <= A; i++ {\n\t\ts[i] = nextInt()\n\n\t}\n\n\tt := make([]int, B+2)\n\tt[0], t[B+1] = -INF, INF\n\tfor i := 1; i <= B; i++ {\n\t\tt[i] = nextInt()\n\t}\n\n\tfor i := 0; i < Q; i++ {\n\t\tx := nextInt()\n\t\tb, d := sort.SearchInts(s, x), sort.SearchInts(t, x)\n\t\tres := INF\n\t\tfor _, S := range []int{s[b-1], s[b]} {\n\t\t\tfor _, T := range []int{t[d-1], t[d]} {\n\t\t\t\td1, d2 := abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)\n\t\t\t\tres = min(res, min(d1, d2))\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(res)\n\t}\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tsc.Buffer([]byte{}, math.MaxInt64)\n\tsc.Split(bufio.ScanWords)\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, err := strconv.Atoi(sc.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn i\n}\n\nfunc nextFloat() float64 {\n\tsc.Scan()\n\tf64, err := strconv.ParseFloat(sc.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn f64\n}\n\nfunc nextString() string {\n\tsc.Scan()\n\tif err := sc.Err(); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn sc.Text()\n}\n\nfunc abs(x int) int {\n\treturn int(math.Abs(float64(x)))\n}\n\nfunc min(x, y int) int {\n\treturn int(math.Min(float64(x), float64(y)))\n}\n\nfunc max(x, y int) int {\n\treturn int(math.Max(float64(x), float64(y)))\n}\n", "test_IO": [ { "input": "2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799\n", "output": "350\n1400\n301\n399\n" } ] }, { "id": "s733602892", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tN, K := ReadInt(), ReadInt()\n\tAs := ReadInts(N)\n\tFs := ReadInts(N)\n\n\tsort.Ints(As)\n\tsort.Sort(sort.Reverse(sort.IntSlice(Fs)))\n\tscores := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tscores[i] = As[i] * Fs[i]\n\t}\n\tsort.Sort(sort.Reverse(sort.IntSlice(scores)))\n\n\tok := scores[0]\n\tng := -1\n\tfor ok-ng > 1 {\n\t\tmid := (ok + ng) / 2\n\n\t\tisOK := true\n\t\tk := K\n\t\tfor i := 0; isOK && i < N; i++ {\n\t\t\tif As[i]*Fs[i] > mid {\n\t\t\t\tk -= As[i] - mid/Fs[i]\n\t\t\t}\n\t\t\tif k < 0 {\n\t\t\t\tisOK = false\n\t\t\t}\n\t\t}\n\n\t\tif isOK {\n\t\t\tok = mid\n\t\t} else {\n\t\t\tng = mid\n\t\t}\n\n\t}\n\tfmt.Println(ok)\n}\n\nfunc ReadInts(n int) []int {\n\tret := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tret[i] = ReadInt()\n\t}\n\treturn ret\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc init() { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }\nfunc Read() string { sc.Scan(); return sc.Text() }\n\nfunc ReadInt() int {\n\tv, e := strconv.Atoi(Read())\n\tif e != nil {\n\t\tpanic(e.Error())\n\t}\n\treturn v\n}\n", "test_IO": [ { "input": "3 5\n4 2 1\n2 3 1\n", "output": "2\n" } ] }, { "id": "s178339312", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\tfmt.Scan(&x)\n\tfmt.Println(x * x * x)\n}\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s563519278", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scan(&N)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tv := make([]int, N)\n\tvar a int\n\n\tfor i := 1; i < N; i++ {\n\t\tscanner.Scan()\n\t\ta, _ = strconv.Atoi(scanner.Text())\n\t\tv[a-1]++\n\t}\n\n\tw := bufio.NewWriter(os.Stdout)\n\tfor _, e := range v {\n\t\tfmt.Fprintln(w, e)\n\t}\n\tw.Flush()\n\n}\n", "test_IO": [ { "input": "5\n1 1 2 2\n", "output": "2\n2\n0\n0\n0\n" } ] }, { "id": "s400924672", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar r, D, x int\n\tfmt.Scan(&r, &D, &x)\n\n\tfor i := 1; i <= 10; i++ {\n\t\tfmt.Println(r*x - D)\n\t\tx = r*x - D\n\t}\n}\n", "test_IO": [ { "input": "2 10 20\n", "output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n" } ] }, { "id": "s079891640", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar (\n\ts string\n)\n\nfunc main() {\n\tfmt.Scan(&s)\n\n\tfor i := 0; i < len(s); i++ {\n\t\tif strings.Contains(s[i+1:], string(s[i])) {\n\t\t\tfmt.Println(\"no\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tfmt.Println(\"yes\")\n}\n", "test_IO": [ { "input": "uncopyrightable\n", "output": "yes\n" } ] }, { "id": "s954015601", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc genid(a, b int) int {\n\tif b < a {\n\t\ta, b = b, a\n\t}\n\treturn a*100000 + b\n}\n\nfunc main() {\n\tN := readInt()\n\n\tab := make([][2]int, N-1)\n\tedges := make([][]int, N)\n\tfor i := 0; i < N-1; i++ {\n\t\ta := readInt() - 1\n\t\tb := readInt() - 1\n\t\tab[i][0], ab[i][1] = a, b\n\t\tedges[a] = append(edges[a], b)\n\t\tedges[b] = append(edges[b], a)\n\t}\n\n\tcolors := make(map[int]int)\n\tq := make([][3]int, 0)\n\tq = append(q, [3]int{0, -1, -1})\n\tfor len(q) != 0 {\n\t\tcurrentNode, usedColor, parentNode := q[len(q)-1][0], q[len(q)-1][1], q[len(q)-1][2]\n\t\tq = q[:len(q)-1]\n\t\tcolor := 1\n\t\tfor _, childNode := range edges[currentNode] {\n\t\t\tif childNode == parentNode {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif color == usedColor {\n\t\t\t\tcolor++\n\t\t\t}\n\t\t\tcolors[genid(currentNode, childNode)] = color\n\t\t\tq = append(q, [3]int{childNode, color, currentNode})\n\t\t\tcolor++\n\t\t}\n\t}\n\n\tK := -1\n\tfor i := 0; i < N; i++ {\n\t\tt := len(edges[i])\n\t\tif t > K {\n\t\t\tK = t\n\t\t}\n\t}\n\tfmt.Println(K)\n\n\tfor i := 0; i < N-1; i++ {\n\t\tfmt.Println(colors[genid(ab[i][0], ab[i][1])])\n\t}\n}\n\nconst (\n\tioBufferSize = 1 * 1024 * 1024\n)\n\nvar stdinScanner = func() *bufio.Scanner {\n\tresult := bufio.NewScanner(os.Stdin)\n\tresult.Buffer(make([]byte, ioBufferSize), ioBufferSize)\n\tresult.Split(bufio.ScanWords)\n\treturn result\n}()\n\nfunc readString() string {\n\tstdinScanner.Scan()\n\treturn stdinScanner.Text()\n}\n\nfunc readInt() int {\n\tresult, err := strconv.Atoi(readString())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn result\n}\n", "test_IO": [ { "input": "3\n1 2\n2 3\n", "output": "2\n1\n2\n" } ] }, { "id": "s283266035", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tans := 0\n\tfor i := 1; i*i < n; i++ {\n\t\tif n%i == 0 && n%(n/i-1) == i {\n\t\t\tans += n/i - 1\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "8\n", "output": "10\n" } ] }, { "id": "s620841407", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tMOD = 1000000000 + 7\n\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, m int\n\tedges [][]int\n)\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < n-1; i++ {\n\t\tx, y := ReadInt2()\n\t\tx--\n\t\ty--\n\n\t\te := []int{x, y}\n\t\tedges = append(edges, e)\n\t}\n\n\tf := func(x, y T) T { return T(int(x) * int(y) % m) }\n\tg := func(v T, p int) T { return v + 1 }\n\ts := NewReRootingSolver(n, edges, 1, f, g)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Println(s.Query(i) - 1)\n\t}\n}\n\ntype T int\n\ntype ReRootingSolver struct {\n\tNodeCount int\n\n\tAdjacents [][]int\n\tIndexForAdjacents [][]int\n\n\tRes []T\n\tDP [][]T\n\n\tIdentity T\n\tOperate func(l, r T) T\n\tOperateNode func(v T, p int) T\n}\n\nfunc NewReRootingSolver(\n\tnodeCount int, edges [][]int, identity T, operate func(l, r T) T, operateNode func(v T, p int) T,\n) *ReRootingSolver {\n\ts := new(ReRootingSolver)\n\n\ts.NodeCount = nodeCount\n\ts.Identity = identity\n\ts.Operate = operate\n\ts.OperateNode = operateNode\n\n\ts.Adjacents = make([][]int, nodeCount)\n\ts.IndexForAdjacents = make([][]int, nodeCount)\n\tfor _, e := range edges {\n\t\ts.IndexForAdjacents[e[0]] = append(s.IndexForAdjacents[e[0]], len(s.Adjacents[e[1]]))\n\t\ts.IndexForAdjacents[e[1]] = append(s.IndexForAdjacents[e[1]], len(s.Adjacents[e[0]]))\n\t\ts.Adjacents[e[0]] = append(s.Adjacents[e[0]], e[1])\n\t\ts.Adjacents[e[1]] = append(s.Adjacents[e[1]], e[0])\n\t}\n\n\ts.DP = make([][]T, len(s.Adjacents))\n\ts.Res = make([]T, len(s.Adjacents))\n\n\tfor i := 0; i < len(s.Adjacents); i++ {\n\t\ts.DP[i] = make([]T, len(s.Adjacents[i]))\n\t}\n\n\tif s.NodeCount > 1 {\n\t\ts.Initialize()\n\t} else {\n\t\ts.Res[0] = s.OperateNode(s.Identity, 0)\n\t}\n\n\treturn s\n}\n\nfunc (s *ReRootingSolver) Query(node int) T {\n\treturn s.Res[node]\n}\n\nfunc (s *ReRootingSolver) Initialize() {\n\tparents, order := make([]int, s.NodeCount), make([]int, s.NodeCount)\n\n\tindex := 0\n\tstack := []int{}\n\tstack = append(stack, 0)\n\tparents[0] = -1\n\tfor len(stack) > 0 {\n\t\tnode := stack[len(stack)-1]\n\t\tstack = stack[:len(stack)-1]\n\t\torder[index] = node\n\t\tindex++\n\t\tfor i := 0; i < len(s.Adjacents[node]); i++ {\n\t\t\tadjacent := s.Adjacents[node][i]\n\t\t\tif adjacent == parents[node] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tstack = append(stack, adjacent)\n\t\t\tparents[adjacent] = node\n\t\t}\n\t}\n\n\tfor i := len(order) - 1; i >= 1; i-- {\n\t\tnode := order[i]\n\t\tparent := parents[node]\n\n\t\taccum := s.Identity\n\t\tparentIndex := -1\n\t\tfor j := 0; j < len(s.Adjacents[node]); j++ {\n\t\t\tif s.Adjacents[node][j] == parent {\n\t\t\t\tparentIndex = j\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\taccum = s.Operate(accum, s.DP[node][j])\n\t\t}\n\t\ts.DP[parent][s.IndexForAdjacents[node][parentIndex]] = s.OperateNode(accum, node)\n\t}\n\n\tfor i := 0; i < len(order); i++ {\n\t\tnode := order[i]\n\t\taccum := s.Identity\n\t\taccumsFromTail := make([]T, len(s.Adjacents[node]))\n\t\taccumsFromTail[len(accumsFromTail)-1] = s.Identity\n\t\tfor j := len(accumsFromTail) - 1; j >= 1; j-- {\n\t\t\taccumsFromTail[j-1] = s.Operate(s.DP[node][j], accumsFromTail[j])\n\t\t}\n\t\tfor j := 0; j < len(accumsFromTail); j++ {\n\t\t\ts.DP[s.Adjacents[node][j]][s.IndexForAdjacents[node][j]] = s.OperateNode(s.Operate(accum, accumsFromTail[j]), node)\n\t\t\taccum = s.Operate(accum, s.DP[node][j])\n\t\t}\n\t\ts.Res[node] = s.OperateNode(accum, node)\n\t}\n}\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10)\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "test_IO": [ { "input": "3 100\n1 2\n2 3\n", "output": "3\n4\n3\n" } ] }, { "id": "s497491075", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc Run(r io.Reader, w io.Writer) {\n\tsc := NewScanner(r)\n\n\ta := sc.ReadLine().Ints()\n\tN, D := a[0], a[1]\n\n\tlines := sc.ReadLines(N).Ints()\n\n\tcount := 0\n\tfor _, line := range lines {\n\t\td := math.Sqrt(float64(line[0]*line[0] + line[1]*line[1]))\n\t\tif float64(D) >= d {\n\t\t\tcount++\n\t\t}\n\t}\n\tfmt.Fprintln(w, count)\n}\n\nfunc main() {\n\tRun(os.Stdin, os.Stdout)\n}\n\ntype Scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc NewScanner(r io.Reader) *Scanner {\n\treturn &Scanner{sc: bufio.NewScanner(r)}\n}\n\nfunc (s *Scanner) ReadLine() Value {\n\tif s.sc.Scan() {\n\t\treturn Value(s.sc.Text())\n\t}\n\tpanic(\"scan error\")\n}\n\nfunc (s *Scanner) ReadLines(n int) Values {\n\tvar a Values\n\tfor i := 0; i < n; i++ {\n\t\ta = append(a, s.ReadLine())\n\t}\n\treturn a\n}\n\ntype Value string\n\nfunc (v Value) String() string {\n\treturn string(v)\n}\n\nfunc (v Value) Int() int {\n\tn, err := strconv.Atoi(v.String())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc (v Value) Float64() float64 {\n\tf, err := strconv.ParseFloat(v.String(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn f\n}\n\nfunc (v Value) Strings() []string {\n\treturn strings.Split(v.String(), \" \")\n}\n\nfunc (v Value) Ints() []int {\n\tvar a []int\n\tfor _, s := range v.Strings() {\n\t\tn, err := strconv.Atoi(s)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\ta = append(a, n)\n\t}\n\treturn a\n}\n\nfunc (v Value) Float64s() []float64 {\n\tvar a []float64\n\tfor _, s := range v.Strings() {\n\t\tf, err := strconv.ParseFloat(s, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\ta = append(a, f)\n\t}\n\treturn a\n}\n\nfunc (v Value) Runes() []rune {\n\treturn []rune(v.String())\n}\n\ntype Values []Value\n\nfunc (v Values) Strings() [][]string {\n\tvar a [][]string\n\tfor _, value := range v {\n\t\ta = append(a, value.Strings())\n\t}\n\treturn a\n}\n\nfunc (v Values) Ints() [][]int {\n\tvar a [][]int\n\tfor _, value := range v {\n\t\ta = append(a, value.Ints())\n\t}\n\treturn a\n}\n\nfunc (v Values) Float64s() [][]float64 {\n\tvar a [][]float64\n\tfor _, value := range v {\n\t\ta = append(a, value.Float64s())\n\t}\n\treturn a\n}\n\nfunc (v Values) Runes() [][]rune {\n\tvar a [][]rune\n\tfor _, value := range v {\n\t\ta = append(a, value.Runes())\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n", "output": "3\n" } ] }, { "id": "s406008869", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nvar e [][]int\nvar n, m int\n\nfunc printEdge(e [][]int) {\n\tfor i := 1; i < n+1; i++ {\n\t\tfmt.Printf(\"%d: \", i)\n\t\tfor _, v := range e[i] {\n\t\t\tfmt.Printf(\"%d \", v)\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n\nfunc dfs(v int, visited []bool) int {\n\n\tcomp := true\n\tfor i := 1; i < n+1; i++ {\n\t\tif !visited[i] {\n\t\t\tcomp = false\n\t\t}\n\t}\n\n\tif comp {\n\t\treturn 1\n\t}\n\n\tcount := 0\n\tfor _, ne := range e[v] {\n\n\t\tif visited[ne] {\n\t\t\tcontinue\n\t\t}\n\t\tvisited[ne] = true\n\n\t\trst := dfs(ne, visited)\n\n\t\tcount += rst\n\t\tvisited[ne] = false\n\t}\n\treturn count\n}\n\nfunc main() {\n\tfmt.Scan(&n, &m)\n\n\te = make([][]int, n+1)\n\tfor i := 1; i < n+1; i++ {\n\t\te[i] = make([]int, 0)\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tvar a, b int\n\t\tfmt.Scan(&a, &b)\n\t\te[a] = append(e[a], b)\n\t\te[b] = append(e[b], a)\n\t}\n\n\tvisited := make([]bool, n+1)\n\tvisited[1] = true\n\tcount := dfs(1, visited)\n\tfmt.Println(count)\n}\n", "test_IO": [ { "input": "3 3\n1 2\n1 3\n2 3\n", "output": "2\n" } ] }, { "id": "s201004620", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar S string\n\tfmt.Scan(&S)\n\tswitch S {\n\tcase \"Sunny\":\n\t\tfmt.Println(\"Cloudy\")\n\tcase \"Cloudy\":\n\t\tfmt.Println(\"Rainy\")\n\tcase \"Rainy\":\n\t\tfmt.Println(\"Sunny\")\n\n\t}\n}\n", "test_IO": [ { "input": "Sunny\n", "output": "Cloudy\n" } ] }, { "id": "s462906333", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar inf int = 1e14\n\nfunc main() {\n\tlog.SetFlags(log.Lshortfile)\n\tnext := newScanner()\n\tn := next.Int()\n\tx := next.Int()\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = next.Int()\n\t}\n\tv := make([]int, n)\n\tcopy(v, a)\n\tans := inf\n\tfor k := 0; k < n; k++ {\n\t\tkans := 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif i-k < 0 {\n\t\t\t\tv[i] = min(v[i], a[n+i-k])\n\t\t\t} else {\n\t\t\t\tv[i] = min(v[i], a[i-k])\n\t\t\t}\n\t\t\tkans += v[i]\n\t\t}\n\t\tans = min(ans, kans+k*x)\n\t}\n\n\tfmt.Println(ans)\n}\n\ntype Pair struct {\n\ta, b int\n}\n\ntype Pairs []Pair\n\nfunc (p Pairs) Len() int {\n\treturn len(p)\n}\nfunc (p Pairs) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p Pairs) Less(i, j int) bool {\n\tif p[i].a < p[j].a {\n\t\treturn true\n\t} else if p[i].a == p[j].a {\n\t\treturn p[i].b < p[j].b\n\t}\n\treturn false\n}\n\nfunc in(c, a, z int) bool {\n\treturn c >= a && c < z\n}\n\nfunc btoi(b bool) int {\n\tif b {\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc itob(a int) bool {\n\tif a == 0 {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc max(a ...int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r < a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc min(a ...int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r > a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc minmax(a, b int) (int, int) {\n\tif a > b {\n\t\treturn b, a\n\t}\n\treturn a, b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc sum(a ...int) int {\n\tr := a[0]\n\tif len(a) > 1 {\n\t\tfor i := 1; i < len(a); i++ {\n\t\t\tr += a[i]\n\t\t}\n\t}\n\treturn r\n}\n\ntype scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc newScanner() *scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 10000)\n\treturn &scanner{r: rdr}\n}\nfunc (s *scanner) next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *scanner) Line() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *scanner) Int() int {\n\tv, _ := strconv.Atoi(s.next())\n\treturn v\n}\nfunc (s *scanner) Int64() int64 {\n\tv, _ := strconv.ParseInt(s.next(), 10, 64)\n\treturn v\n}\nfunc (s *scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "2 10\n1 100\n", "output": "12\n" } ] }, { "id": "s879077700", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a string\n\tfmt.Scan(&a)\n\tvar ans = \"Good\"\n\tfor i := 0; i < 3; i++ {\n\t\tif a[i] == a[i+1] {\n\t\t\tans = \"Bad\"\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "3776\n", "output": "Bad\n" } ] }, { "id": "s680776563", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tA, B, C := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()\n\tif B-A == C-B {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1024)\n\treturn &FastScanner{r: rdr}\n}\nfunc (s *FastScanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *FastScanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *FastScanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *FastScanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *FastScanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc IntMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Max(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Max(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc IntMin(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Int64Min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\nfunc Float64Min(a, b float64) float64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc IntGcd(a, b int) int {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn IntGcd(b, a%b)\n}\nfunc Int64Gcd(a, b int64) int64 {\n\tif a < b {\n\t\tb, a = a, b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn Int64Gcd(b, a%b)\n}\n\nfunc IntAbs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc Int64Abs(a int64) int64 {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "2 4 6\n", "output": "YES\n" } ] }, { "id": "s712890349", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Block struct {\n\tValue string\n\tLen int\n}\n\nfunc main() {\n\tvar N, K, ans int\n\tfmt.Scan(&N, &K)\n\tvar S string\n\ts := bufio.NewScanner(os.Stdin)\n\tb := make([]byte, 1000000)\n\ts.Buffer(b, 1000000)\n\ts.Scan()\n\tS = s.Text()\n\tblocks := RunLength(S)\n\tsum, zero, l := 0, 0, 0\n\tfor r := 0; r < len(blocks); r++ {\n\t\tsum += blocks[r].Len\n\t\tif blocks[r].Value == \"0\" {\n\t\t\tzero++\n\t\t}\n\t\tfor K < zero {\n\t\t\tsum -= blocks[l].Len\n\t\t\tif blocks[l].Value == \"0\" {\n\t\t\t\tzero--\n\t\t\t}\n\t\t\tl++\n\t\t}\n\t\tans = Max(ans, sum)\n\t}\n\tfmt.Println(ans)\n}\n\nfunc RunLength(s string) []Block {\n\tvar r []Block\n\tif len(s) == 0 {\n\t\treturn r\n\t}\n\tt := Block{Value: string(s[0]), Len: 1}\n\tfor _, v := range s[1:] {\n\t\tif t.Value == string(v) {\n\t\t\tt.Len++\n\t\t} else {\n\t\t\tr = append(r, t)\n\t\t\tt = Block{Value: string(v), Len: 1}\n\t\t}\n\t}\n\tr = append(r, t)\n\treturn r\n}\n\nfunc Max(a, b int) int {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "5 1\n00010\n", "output": "4\n" } ] }, { "id": "s684434772", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\n\tn := sc.ReadInt()\n\tk := sc.ReadInt()\n\n\ttotal := int64(0)\n\tfor i := k; i <= n+1; i++ {\n\t\ttotal += combi(n, i)\n\t\ttotal = total % (Pow64(10, 9) + 7)\n\t}\n\tfmt.Println(total)\n}\n\nfunc combi(n int, k int) int64 {\n\tmin := int64(k-1) * int64(k) / 2\n\tmax := int64(2*n-k+1) * int64(k) / 2\n\treturn max - min + 1\n}\n\nfunc Abs(x int) int {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc Min(values ...int) int {\n\tif len(values) == 0 {\n\t\tpanic(\"no values\")\n\t}\n\tmin := values[0]\n\tfor _, v := range values {\n\t\tif v < min {\n\t\t\tmin = v\n\t\t}\n\t}\n\treturn min\n}\n\nfunc Max(values ...int) int {\n\tif len(values) == 0 {\n\t\tpanic(\"no values\")\n\t}\n\tmax := values[0]\n\tfor _, v := range values {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max\n}\n\nfunc Pow(base int, exponent uint) int {\n\tanswer := 1\n\tfor i := uint(0); i < exponent; i++ {\n\t\tanswer *= base\n\t}\n\treturn answer\n}\n\nfunc Abs64(x int64) int64 {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc Min64(values ...int64) int64 {\n\tif len(values) == 0 {\n\t\tpanic(\"no values\")\n\t}\n\tmin := values[0]\n\tfor _, v := range values {\n\t\tif v < min {\n\t\t\tmin = v\n\t\t}\n\t}\n\treturn min\n}\n\nfunc Max64(values ...int64) int64 {\n\tif len(values) == 0 {\n\t\tpanic(\"no values\")\n\t}\n\tmax := values[0]\n\tfor _, v := range values {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max\n}\n\nfunc Pow64(base int64, exponent uint) int64 {\n\tanswer := int64(1)\n\tfor i := uint(0); i < exponent; i++ {\n\t\tanswer *= base\n\t}\n\treturn answer\n}\n\ntype Scanner struct {\n\tbufScanner *bufio.Scanner\n}\n\nfunc NewScanner() *Scanner {\n\tbufSc := bufio.NewScanner(os.Stdin)\n\tbufSc.Split(bufio.ScanWords)\n\treturn &Scanner{bufSc}\n}\n\nfunc (sc *Scanner) ReadString() string {\n\tbufSc := sc.bufScanner\n\tbufSc.Scan()\n\treturn bufSc.Text()\n}\n\nfunc (sc *Scanner) ReadInt() int {\n\tbufSc := sc.bufScanner\n\tbufSc.Scan()\n\ttext := bufSc.Text()\n\n\tnum, err := strconv.Atoi(text)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn num\n}\n\nfunc (sc *Scanner) ReadInt64() int64 {\n\tbufSc := sc.bufScanner\n\tbufSc.Scan()\n\ttext := bufSc.Text()\n\n\tnum, err := strconv.ParseInt(text, 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn num\n}\n", "test_IO": [ { "input": "3 2\n", "output": "10\n" } ] }, { "id": "s716019902", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst mod = 998244353\nconst facNum = 300001\n\nfunc main() {\n\tsc := newScanner(os.Stdin)\n\tN := sc.i()\n\tsum := 0\n\tfor i := 1; i <= N; i++ {\n\t\tif i%3 == 0 || i%5 == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tsum += i\n\t}\n\tfmt.Println(sum)\n}\n\ntype scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc newScanner(input io.Reader) *scanner {\n\tsc := bufio.NewScanner(input)\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 1024), int(1e+9))\n\treturn &scanner{sc}\n}\n\nfunc (s *scanner) s() string {\n\ts.sc.Scan()\n\treturn s.sc.Text()\n}\n\nfunc (s *scanner) i() int {\n\ti, e := strconv.Atoi(s.s())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (s *scanner) f() float64 {\n\tf, e := strconv.ParseFloat(s.s(), 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn f\n}\n\nfunc (s *scanner) bs() []byte {\n\treturn []byte(s.s())\n}\n\nfunc (s *scanner) is(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.i()\n\t}\n\treturn res\n}\n\nfunc (s *scanner) fs(n int) []float64 {\n\tres := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.f()\n\t}\n\treturn res\n}\n\nfunc Pow(a, n int) int {\n\tans := 1\n\tfor n > 0 {\n\t\tif (n & 1) == 1 {\n\t\t\tans = ans * a % mod\n\t\t}\n\t\ta = a * a % mod\n\t\tn = n >> 1\n\t}\n\treturn ans\n}\n\nfunc Gcd(a, b int) int {\n\tif a < b {\n\t\treturn Gcd(b, a)\n\t}\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc combination(n, k int, fac, ifac []int) int {\n\tif n < k || n < 0 {\n\t\treturn 0\n\t}\n\tif k == 0 {\n\t\treturn 1\n\t}\n\n\tans := ifac[k] * ifac[n-k] % mod\n\treturn ans * fac[n] % mod\n}\n\nfunc factorial() (fac []int, ifac []int) {\n\tfac = make([]int, facNum)\n\tfac[0] = 1\n\tifac = make([]int, facNum)\n\tifac[0] = 1\n\tfor i := 1; i < facNum; i++ {\n\t\tfac[i] = fac[i-1] * i % mod\n\t\tifac[i] = ifac[i-1] * Pow(i, mod-2) % mod\n\t}\n\treturn\n}\n\nfunc lowerBound(vs []int, v int) (index int) {\n\tn := len(vs) / 2\n\tm := len(vs)\n\tfor m != n {\n\t\tif vs[n] < v {\n\t\t\tn = (m-n+1)/2 + n\n\n\t\t} else {\n\t\t\tm = n\n\t\t\tn = n / 2\n\t\t}\n\t}\n\treturn n\n}\n\nfunc IntSlice(n, init int) []int {\n\tr := make([]int, n)\n\tfor i := range r {\n\t\tr[i] = init\n\t}\n\treturn r\n}\n", "test_IO": [ { "input": "15\n", "output": "60\n" } ] }, { "id": "s209996417", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n float64\n\tvar k float64\n\tfmt.Scan(&n, &k)\n\n\tvar x float64 = 0.0\n\tfor {\n\t\tunder := math.Pow(k, x)\n\t\tupper := math.Pow(k, x+1)\n\n\t\tif under <= n && n < upper {\n\t\t\tfmt.Println(x + 1)\n\t\t\treturn\n\t\t}\n\t\tx++\n\t}\n\n}\n", "test_IO": [ { "input": "11 2\n", "output": "4\n" } ] }, { "id": "s060770256", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solution(n, m int) int {\n\tn = n - 2\n\tm = m - 2\n\tif n < 0 {\n\t\tn = 1\n\t}\n\tif m < 0 {\n\t\tm = 1\n\t}\n\treturn n * m\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tfmt.Println(solution(n, m))\n}\n", "test_IO": [ { "input": "2 2\n", "output": "0\n" } ] }, { "id": "s632215495", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype node struct {\n\tkey int\n\tparent *node\n\tleft *node\n\tright *node\n}\n\ntype tree struct {\n\troot *node\n}\n\nfunc (tree *tree) insert(key int) {\n\tif tree.root == nil {\n\t\ttree.root = &node{key: key}\n\t\treturn\n\t}\n\n\tvar currentNode, prevNode *node\n\tcurrentNode = tree.root\n\tfor currentNode != nil {\n\t\tprevNode = currentNode\n\t\tif currentNode.key < key {\n\t\t\tcurrentNode = currentNode.right\n\t\t} else {\n\t\t\tcurrentNode = currentNode.left\n\t\t}\n\t}\n\n\tnewNode := &node{key: key}\n\tnewNode.parent = prevNode\n\tif prevNode.key < key {\n\t\tprevNode.right = newNode\n\t} else {\n\t\tprevNode.left = newNode\n\t}\n}\n\nfunc (tree tree) print() {\n\tvar acc []int\n\tif tree.root == nil {\n\t\tfmt.Println(\"\")\n\t\tfmt.Println(\"\")\n\t} else {\n\t\tfmt.Println(\" \" + strings.Join(isToAs(visitInorder(tree.root, acc)), \" \"))\n\t\tfmt.Println(\" \" + strings.Join(isToAs(visitPreorder(tree.root, acc)), \" \"))\n\t}\n}\n\nfunc visitPreorder(node *node, acc []int) []int {\n\tif node == nil {\n\t\treturn acc\n\t}\n\tacc = append(acc, int(node.key))\n\tif node.left != nil {\n\t\tacc = visitPreorder(node.left, acc)\n\t}\n\tif node.right != nil {\n\t\tacc = visitPreorder(node.right, acc)\n\t}\n\treturn acc\n}\n\nfunc visitInorder(node *node, acc []int) []int {\n\tif node == nil {\n\t\treturn acc\n\t}\n\tif node.left != nil {\n\t\tacc = visitInorder(node.left, acc)\n\t}\n\tacc = append(acc, int(node.key))\n\tif node.right != nil {\n\t\tacc = visitInorder(node.right, acc)\n\t}\n\treturn acc\n}\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\n\tn, err := nextInt(sc)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttree := &tree{}\n\tfor i := 0; i < n; i++ {\n\t\tcommand := nextText(sc)\n\t\tswitch command {\n\t\tcase \"insert\":\n\t\t\tkey, err := nextInt(sc)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\ttree.insert(key)\n\t\tcase \"print\":\n\t\t\ttree.print()\n\t\tdefault:\n\t\t\tpanic(\"unknown command: \" + command)\n\t\t}\n\t}\n}\n\nfunc nextText(sc *bufio.Scanner) string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt(sc *bufio.Scanner) (int, error) {\n\treturn strconv.Atoi(nextText(sc))\n}\n\nfunc isToAs(is []int) []string {\n\tn := len(is)\n\tas := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tas[i] = strconv.Itoa(is[i])\n\t}\n\treturn as\n}\n", "test_IO": [ { "input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n", "output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n" } ] }, { "id": "s684610901", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype pair struct {\n\tindex int64\n\tp1, p2 interface{}\n}\ntype pairs []pair\n\nfunc (slice pairs) Len() int {\n\treturn len(slice)\n}\n\nfunc (slice pairs) Less(i, j int) bool {\n\treturn slice[i].index < slice[j].index\n}\n\nfunc (slice pairs) Swap(i, j int) {\n\tslice[i], slice[j] = slice[j], slice[i]\n}\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int {\n\treturn len(slice)\n}\n\nfunc (slice Int64Slice) Less(i, j int) bool {\n\treturn slice[i] < slice[j]\n}\n\nfunc (slice Int64Slice) Swap(i, j int) {\n\tslice[i], slice[j] = slice[j], slice[i]\n}\nfunc Int64s(a []int64) { sort.Sort(Int64Slice(a)) }\nfunc Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }\n\nconst (\n\tinitialBufSize = 1e4\n\tmaxBufSize = 1e8\n\tINF = 1e8\n)\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tdi = []int64{-1, 0, 1, 0}\n\tdj = []int64{0, -1, 0, 1}\n)\n\nfunc main() {\n\tbuf := make([]byte, initialBufSize)\n\tscanner.Buffer(buf, maxBufSize)\n\tscanner.Split(bufio.ScanWords)\n\tA, B, C := readInt(), readInt(), readInt()\n\tif C >= A && C <= B {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n\nfunc NextPermutation(x sort.Interface) bool {\n\tn := x.Len() - 1\n\tif n < 1 {\n\t\treturn false\n\t}\n\tj := n - 1\n\tfor ; !x.Less(j, j+1); j-- {\n\t\tif j == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\tl := n\n\tfor !x.Less(j, l) {\n\t\tl--\n\t}\n\tx.Swap(j, l)\n\tfor k, l := j+1, n; k < l; {\n\t\tx.Swap(k, l)\n\t\tk++\n\t\tl--\n\t}\n\treturn true\n}\nfunc doubleAry(h int64, w int64, init int64) (res [][]int64) {\n\tres = make([][]int64, h)\n\tfor i := int64(0); i < h; i++ {\n\t\tres[i] = make([]int64, w)\n\t\tfor j := int64(0); j < w; j++ {\n\t\t\tres[i][j] = init\n\t\t}\n\t}\n\treturn\n}\n\nfunc aryEq(a []int64, b []int64) bool {\n\treturn reflect.DeepEqual(a, b)\n}\n\nfunc clone(n []int64) (r []int64) {\n\tr = make([]int64, len(n))\n\tfor i := 0; i < len(n); i++ {\n\t\tr[i] = n[i]\n\t}\n\treturn\n}\nfunc write(s string) {\n\twriter.WriteString(s)\n}\n\nfunc print() {\n\twriter.Flush()\n}\n\nfunc readLine() (s string) {\n\tif scanner.Scan() {\n\t\ts = scanner.Text()\n\t}\n\treturn s\n}\n\nfunc readInt() (read int64) {\n\tscanner.Scan()\n\tread, err := strconv.ParseInt(scanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}\n\nfunc readFloat() (read float64) {\n\tscanner.Scan()\n\tread, err := strconv.ParseFloat(scanner.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}\n\nfunc readRunes() (read []rune) {\n\tscanner.Scan()\n\tfor _, v := range scanner.Text() {\n\t\tread = append(read, v)\n\t}\n\treturn\n}\n\nfunc readString() (read string) {\n\tscanner.Scan()\n\tread = scanner.Text()\n\treturn\n}\n\nfunc readStrings() (read []string) {\n\tscanner.Scan()\n\tfor _, v := range scanner.Text() {\n\t\tread = append(read, string(v))\n\t}\n\treturn\n}\n\nfunc s2i(s string) int64 {\n\tvar intVal, e = strconv.ParseInt(s, 10, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn intVal\n}\n\nfunc i2s(i int64) string {\n\tvar strVal = strconv.FormatInt(i, 10)\n\treturn strVal\n}\n\nfunc s2f(s string) float64 {\n\tvar floatVal, e = strconv.ParseFloat(s, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn floatVal\n}\n\nfunc abs(i int64) int64 {\n\treturn int64(math.Abs(float64(i)))\n}\n\nfunc max(a ...int64) int64 {\n\tans := int64(0)\n\tfor i, v := range a {\n\t\tif i == 0 {\n\t\t\tans = v\n\t\t}\n\t\tif ans < v {\n\t\t\tans = v\n\t\t}\n\t}\n\treturn ans\n}\nfunc min(a ...int64) int64 {\n\tans := int64(0)\n\tfor i, v := range a {\n\t\tif i == 0 {\n\t\t\tans = v\n\t\t}\n\t\tif ans > v {\n\t\t\tans = v\n\t\t}\n\t}\n\treturn ans\n}\n\nfunc sum(i []int64) int64 {\n\tsum := int64(0)\n\tfor _, val := range i {\n\t\tsum += val\n\t}\n\treturn sum\n}\n\nfunc split(s string) []string {\n\treturn strings.Fields(s)\n}\n\nfunc strAry2intAry(strs []string) []int64 {\n\tvar ret = make([]int64, 0, len(strs))\n\tfor _, str := range strs {\n\t\tvar intVal = s2i(str)\n\t\tret = append(ret, intVal)\n\t}\n\treturn ret\n}\n\nfunc intAry2strAry(nums []int64) []string {\n\tvar ret = make([]string, 0, len(nums))\n\tfor _, num := range nums {\n\t\tvar strVal = i2s(num)\n\t\tret = append(ret, strVal)\n\t}\n\treturn ret\n}\n\nfunc ary2str(strs []string) string {\n\treturn strings.Join(strs, \" \")\n}\n\nfunc reverse(res []int64) []int64 {\n\tfor i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {\n\t\tres[i], res[j] = res[j], res[i]\n\t}\n\treturn res\n}\nfunc reverseStr(res []string) []string {\n\tfor i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {\n\t\tres[i], res[j] = res[j], res[i]\n\t}\n\treturn res\n}\n\nfunc ini(res []int, init int) {\n\tif len(res) == 0 {\n\t\treturn\n\t}\n\tres[0] = init\n\tfor i := 0; i < len(res); i++ {\n\t\tcopy(res[i:], res[:i])\n\t}\n}\n", "test_IO": [ { "input": "1 3 2\n", "output": "Yes\n" } ] }, { "id": "s824543330", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\n\tif a*b%2 == 0 {\n\t\tfmt.Println(\"Even\")\n\t} else {\n\t\tfmt.Println(\"Odd\")\n\t}\n}\n", "test_IO": [ { "input": "3 4\n", "output": "Even\n" } ] }, { "id": "s537465285", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader = bufio.NewReaderSize(os.Stdin, 1000000)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc NextLine() string {\n\tvar line, buffer []byte\n\tvar isPrefix bool = true\n\tvar err error\n\tfor isPrefix {\n\t\tline, isPrefix, err = reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t}\n\treturn string(buffer)\n}\nfunc NextInt() int {\n\tvar n int\n\tn, _ = strconv.Atoi(NextLine())\n\treturn n\n}\nfunc Write(s interface{}) {\n\tfmt.Fprintln(writer, s)\n}\nfunc Output() {\n\t_ = writer.Flush()\n}\n\nfunc Bipartite(S *[]string) bool {\n\tN := len((*S))\n\tD := make([]int, N)\n\tD[0] = 1\n\tQ := make([]int, N)\n\tret := true\n\tpos := 1\n\tfor i := 0; i < N; i++ {\n\t\tif !ret {\n\t\t\tbreak\n\t\t}\n\t\tq := Q[i]\n\t\tfor j, s := range (*S)[q] {\n\t\t\tif s == '0' {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif D[j] == 0 {\n\t\t\t\tD[j] = D[q] + 1\n\t\t\t\tQ[pos] = j\n\t\t\t\tpos++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif D[j]%2 == D[q]%2 {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc WarshallFloyd(S *[]string) int {\n\tN := len(*(S))\n\tG := make([][]int, N)\n\tfor i := range G {\n\t\tG[i] = make([]int, N)\n\t\tfor j := range G[i] {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (*S)[i][j] == '0' {\n\t\t\t\tG[i][j] = N\n\t\t\t} else {\n\t\t\t\tG[i][j] = 1\n\t\t\t}\n\t\t}\n\t}\n\tfor k := 0; k < N; k++ {\n\t\tfor i := 0; i < N; i++ {\n\t\t\tfor j := 0; j < N; j++ {\n\t\t\t\tif G[i][k]+G[k][j] < G[i][j] {\n\t\t\t\t\tG[i][j] = G[i][k] + G[k][j]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tif ans < G[i][j] {\n\t\t\t\tans = G[i][j]\n\t\t\t}\n\t\t}\n\t}\n\treturn ans + 1\n}\n\nfunc main() {\n\tN := NextInt()\n\tS := make([]string, N)\n\tfor i := range S {\n\t\tS[i] = NextLine()\n\t}\n\tif !Bipartite(&S) {\n\t\tWrite(-1)\n\t} else {\n\t\tWrite(WarshallFloyd(&S))\n\t}\n\tOutput()\n}\n", "test_IO": [ { "input": "2\n01\n10\n", "output": "2\n" } ] }, { "id": "s336868078", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar in = bufio.NewReader(os.Stdin)\n\nfunc solve(a, b, c int) int {\n\tvar temp_ int\n\tif c == a+b {\n\t\ttemp_ = b + c\n\t} else if c-1 > a+b {\n\t\ttemp := (c - 1) - (a + b)\n\t\ttemp_ = b + c - temp\n\t} else {\n\t\ttemp_ = b + c\n\t}\n\n\treturn temp_\n}\nfunc main() {\n\tvar a, b, c int\n\tfmt.Fscanf(in, \"%d %d %d\u00a5n\", &a, &b, &c)\n\n\tans := solve(a, b, c)\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "3 1 4\n", "output": "5\n" } ] }, { "id": "s479324991", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\n\t\"sort\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\n\tn := sc.NextInt()\n\tarr := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = float64(sc.NextInt())\n\t}\n\tsort.Float64s(arr)\n\tprev := arr[0]\n\tfor i := 1; i < len(arr); i++ {\n\t\tprev = (prev + arr[i]) / 2\n\t}\n\n\tfmt.Printf(\"%v\\n\", prev)\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tresult = append(result, v)\n\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "2\n3 4\n", "output": "3.5\n" } ] }, { "id": "s753839476", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tio, flash := NewIO()\n\tdefer flash()\n\n\tn, t, a := io.ScanInt(), io.ScanFloat64(), io.ScanFloat64()\n\theights := io.ScanFloat64s(n)\n\n\tminDiff := AbsDiffFloat64(t-heights[0]*0.006, a)\n\tminIdx := 0\n\tfor i, h := range heights[1:] {\n\t\tdiff := AbsDiffFloat64(t-h*0.006, a)\n\t\tif diff < minDiff {\n\t\t\tminDiff = diff\n\t\t\tminIdx = i + 1\n\t\t}\n\t}\n\tfmt.Println(minIdx + 1)\n}\n\nfunc AbsDiffFloat64(n1, n2 float64) float64 {\n\treturn math.Abs(n1 - n2)\n}\n\ntype IO struct {\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n}\n\nfunc NewIO() (*IO, func()) {\n\tio := &IO{\n\t\tscanner: newScanner(),\n\t\twriter: newWriter(),\n\t}\n\treturn io, func() { io.writer.Flush() }\n}\n\nfunc newScanner() *bufio.Scanner {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Buffer(make([]byte, 10000000), 10000000)\n\ts.Split(bufio.ScanWords)\n\treturn s\n}\n\nfunc newWriter() *bufio.Writer {\n\treturn bufio.NewWriter(os.Stdout)\n}\n\nfunc (io *IO) ScanBytes() []byte {\n\tif !io.scanner.Scan() {\n\t\tpanic(\"scan string failed\")\n\t}\n\treturn io.scanner.Bytes()\n}\n\nfunc (io *IO) ScanString() string {\n\tif !io.scanner.Scan() {\n\t\tpanic(\"scan string failed\")\n\t}\n\treturn io.scanner.Text()\n}\n\nfunc (io *IO) ScanStrings(n int) []string {\n\tstrs := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tstrs[i] = io.ScanString()\n\t}\n\treturn strs\n}\n\nfunc (io *IO) Scan2DStrings(y, x int) [][]string {\n\tstrings := make([][]string, y)\n\tfor i := 0; i < y; i++ {\n\t\tstrings[i] = io.ScanStrings(x)\n\t}\n\treturn strings\n}\n\nfunc (io *IO) Scan2DGraph(y int) [][]string {\n\tstrs := make([][]string, y)\n\tfor i := 0; i < y; i++ {\n\t\tstrs[i] = strings.Split(io.ScanString(), \"\")\n\t}\n\treturn strs\n}\n\nfunc (io *IO) ScanInt() int {\n\treturn int(io.ScanInt64())\n}\n\nfunc (io *IO) ScanInt2() (int, int) {\n\treturn int(io.ScanInt64()), int(io.ScanInt64())\n}\n\nfunc (io *IO) ScanInt3() (int, int, int) {\n\treturn int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())\n}\n\nfunc (io *IO) ScanInt4() (int, int, int, int) {\n\treturn int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())\n}\n\nfunc (io *IO) ScanInts(n int) []int {\n\tints := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tints[i] = io.ScanInt()\n\t}\n\treturn ints\n}\n\nfunc (io *IO) Scan2DInts(y, x int) [][]int {\n\tints := make([][]int, y)\n\tfor i := 0; i < y; i++ {\n\t\tints[i] = io.ScanInts(x)\n\t}\n\treturn ints\n}\n\nfunc (io *IO) ScanInt64() int64 {\n\ti, err := strconv.ParseInt(io.ScanString(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *IO) ScanFloat64() float64 {\n\ti, _ := strconv.ParseFloat(io.ScanString(), 64)\n\treturn i\n}\n\nfunc (io *IO) ScanFloat64s(n int) []float64 {\n\tfloats := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tfloats[i] = io.ScanFloat64()\n\t}\n\treturn floats\n}\n\nfunc (io *IO) Println(a ...interface{}) {\n\tfmt.Fprintln(io.writer, a...)\n}\n", "test_IO": [ { "input": "2\n12 5\n1000 2000\n", "output": "1\n" } ] }, { "id": "s446670437", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\ntype Dice struct {\n\tNums []int\n}\n\nfunc (d *Dice) rotate(direction string, times int) {\n\ttimes %= 4\n\tswitch direction {\n\tcase \"W\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[2], d.Nums[5], d.Nums[3], d.Nums[0]\n\t\t}\n\tcase \"E\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[3], d.Nums[0], d.Nums[2], d.Nums[5]\n\t\t}\n\tcase \"N\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[0], d.Nums[4], d.Nums[5], d.Nums[1] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]\n\t\t}\n\tcase \"S\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[5], d.Nums[1], d.Nums[0], d.Nums[4] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]\n\t\t}\n\t}\n}\n\nfunc (d *Dice) roll(direction string, times int) {\n\ttimes %= 4\n\tswitch direction {\n\tcase \"R\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[3]\n\t\t}\n\tcase \"L\":\n\t\tfor i := 0; i < times; i++ {\n\t\t\td.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[4], d.Nums[3], d.Nums[1], d.Nums[2]\n\t\t}\n\t}\n}\n\nfunc (d *Dice) printStatus() {\n\tstatus :=\n\t\t`\t\u3000\u3000\u3000 _ _ _ _\n _ _ _|_%3d_|_ _ _ _ _ _\n |_%3d_|_%3d_|_%3d_|_%3d_|\n \u3000 |_%3d_|\n`\n\tfmt.Printf(status, d.Nums[0], d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[5])\n\tfmt.Println()\n}\n\nfunc getIndex(nums []int, target int) (index int) {\n\tfor i, v := range nums {\n\t\tif target == v {\n\t\t\tindex = i\n\t\t\tbreak\n\t\t} else {\n\t\t\tindex = -1\n\t\t}\n\t}\n\treturn index\n}\n\nfunc (d *Dice) isEqual(other Dice) bool {\n\tfor i, v := range d.Nums {\n\t\tif v != other.Nums[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdice1 := Dice{\n\t\tmake([]int, 6),\n\t}\n\tdice2 := Dice{\n\t\tmake([]int, 6),\n\t}\n\tfor i := 0; i < 6; i++ {\n\t\tvar n int\n\t\tfmt.Scan(&n)\n\t\tdice1.Nums[i] = n\n\t}\n\tfor i := 0; i < 6; i++ {\n\t\tvar n int\n\t\tfmt.Scan(&n)\n\t\tdice2.Nums[i] = n\n\t}\n\n\tdirectionOrder := []string{\"N\", \"S\", \"W\", \"E\"}\n\trollOrder := []string{\"R\", \"L\"}\n\tflag := false\n\nCHECK:\n\tfor i := 0; i <= 2; i++ {\n\t\tfor j := 0; j <= 2; j++ {\n\t\t\tfor _, direction := range directionOrder {\n\t\t\t\tfor _, roll := range rollOrder {\n\t\t\t\t\ttmp := new(Dice)\n\t\t\t\t\ttmp.Nums = append([]int{}, dice2.Nums...)\n\t\t\t\t\ttmp.rotate(direction, i)\n\t\t\t\t\ttmp.roll(roll, j)\n\t\t\t\t\tif tmp.isEqual(dice1) {\n\t\t\t\t\t\tflag = true\n\t\t\t\t\t\tbreak CHECK\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1 2 3 4 5 6\n6 2 4 3 5 1\n", "output": "Yes\n" } ] }, { "id": "s853386130", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar mod = 1000000007\nvar INF = 1000000007\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\tvar n, m, R int\n\tfmt.Fscan(r, &n)\n\tfmt.Fscan(r, &m)\n\tfmt.Fscan(r, &R)\n\n\trs := make([]int, R)\n\tfor i := 0; i < R; i++ {\n\t\tfmt.Fscan(r, &rs[i])\n\t\trs[i]--\n\t}\n\n\tcosts := make([][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tcosts[i] = make([]int, n)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tcosts[i][j] = INF\n\t\t}\n\t\tcosts[i][i] = 0\n\t}\n\tvar a, b, c int\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscan(r, &a)\n\t\tfmt.Fscan(r, &b)\n\t\tfmt.Fscan(r, &c)\n\t\ta--\n\t\tb--\n\t\tcosts[a][b] = c\n\t\tcosts[b][a] = c\n\t}\n\n\tfor k := 0; k < n; k++ {\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfor j := 0; j < n; j++ {\n\t\t\t\tcosts[i][j] = min(costs[i][j], costs[i][k]+costs[k][j])\n\t\t\t}\n\t\t}\n\t}\n\n\tperms := permutations(rs)\n\tans := INF\n\tfor _, perm := range perms {\n\t\ttmp := 0\n\t\tfor j := 1; j < len(perm); j++ {\n\t\t\tfrom := perm[j-1]\n\t\t\tto := perm[j]\n\t\t\ttmp += costs[from][to]\n\t\t}\n\t\tans = min(ans, tmp)\n\t}\n\tfmt.Println(ans)\n}\n\nfunc permutations(arr []int) [][]int {\n\tvar helper func([]int, int)\n\tres := [][]int{}\n\n\thelper = func(arr []int, n int) {\n\t\tif n == 1 {\n\t\t\ttmp := make([]int, len(arr))\n\t\t\tcopy(tmp, arr)\n\t\t\tres = append(res, tmp)\n\t\t} else {\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\thelper(arr, n-1)\n\t\t\t\tif n%2 == 1 {\n\t\t\t\t\ttmp := arr[i]\n\t\t\t\t\tarr[i] = arr[n-1]\n\t\t\t\t\tarr[n-1] = tmp\n\t\t\t\t} else {\n\t\t\t\t\ttmp := arr[0]\n\t\t\t\t\tarr[0] = arr[n-1]\n\t\t\t\t\tarr[n-1] = tmp\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\thelper(arr, len(arr))\n\treturn res\n}\n\ntype unionFind struct {\n\td []int\n}\n\nfunc newUnionFind(n int) *unionFind {\n\tuf := new(unionFind)\n\tuf.d = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tuf.d[i] = -1\n\t}\n\treturn uf\n}\n\nfunc (uf *unionFind) find(x int) int {\n\tif uf.d[x] < 0 {\n\t\treturn x\n\t}\n\tuf.d[x] = uf.find(uf.d[x])\n\treturn uf.d[x]\n}\n\nfunc (uf *unionFind) unite(x, y int) bool {\n\trootX := uf.find(x)\n\trootY := uf.find(y)\n\tif rootX == rootY {\n\t\treturn false\n\t}\n\n\tif uf.d[rootX] < uf.d[rootY] {\n\t\tuf.d[rootX] += uf.d[rootY]\n\t\tuf.d[rootY] = rootX\n\t} else {\n\t\tuf.d[rootY] += uf.d[rootX]\n\t\tuf.d[rootX] = rootY\n\t}\n\n\treturn true\n}\n\nfunc (uf *unionFind) same(x, y int) bool {\n\treturn uf.find(x) == uf.find(y)\n}\n\nfunc (uf *unionFind) size(x int) int {\n\treturn -uf.d[uf.find(x)]\n}\n\nfunc modpow(a, n, mod int) int {\n\tres := 1\n\tfor n > 0 {\n\t\tif n%2 != 0 {\n\t\t\tres = res * a % mod\n\t\t}\n\t\ta = a * a % mod\n\t\tn = n / 2\n\t}\n\treturn res\n}\n\nfunc modinv(n, mod int) int {\n\treturn modpow(n, mod-2, mod)\n}\n\nfunc modcomb(n, a, mod int) int {\n\tx := 1\n\ty := 1\n\tfor i := 0; i < a; i++ {\n\t\tx = x * (n - i)\n\t\tx %= mod\n\t\ty = y * (i + 1)\n\t\ty %= mod\n\t}\n\treturn x * modpow(y, mod-2, mod) % mod\n}\n\nfunc modfactorial(n, mod int) int {\n\tresult := 1\n\tfor i := 1; i <= n; i++ {\n\t\tresult = (result * i) % mod\n\t}\n\treturn result\n}\n\ntype Combination struct {\n\tfacts, invs []int\n\tmod int\n}\n\nfunc NewCombination(n, mod int) Combination {\n\treturn Combination{\n\t\tfacts: make([]int, n+1),\n\t\tinvs: make([]int, n+1),\n\t\tmod: mod,\n\t}\n}\n\nfunc (cmb *Combination) calc(n, k int) int {\n\tret := cmb.facts[n] * cmb.invs[k]\n\tret %= cmb.mod\n\tret = ret * cmb.invs[n-k]\n\tret %= cmb.mod\n\treturn ret\n}\n\nfunc (cmb *Combination) init(n int) {\n\tcmb.facts[0] = 1\n\n\tfor i := 1; i <= n; i++ {\n\t\tcmb.facts[i] = cmb.facts[i-1] * i % cmb.mod\n\t}\n\n\tcmb.invs[n] = modinv(cmb.facts[n], cmb.mod)\n\tfor i := n - 1; i >= 0; i-- {\n\t\tcmb.invs[i] = cmb.invs[i+1] * (i + 1) % cmb.mod\n\t}\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc primeFactor(x int) map[int]int {\n\tres := make(map[int]int)\n\tfor i := 2; i*i <= x; i++ {\n\t\tfor x%i == 0 {\n\t\t\tres[i]++\n\t\t\tx = x / i\n\t\t}\n\t}\n\tif x != 1 {\n\t\tres[x] = 1\n\t}\n\treturn res\n}\n\nfunc divisor(x int) []int {\n\tres := make([]int, 0)\n\tfor i := 1; i*i <= x; i++ {\n\t\tif x%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tif i != x/i {\n\t\t\t\tres = append(res, x/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}\n\nfunc gcd(x, y int) int {\n\tif y == 0 {\n\t\treturn x\n\t}\n\treturn gcd(y, x%y)\n}\n\nfunc lcm(x, y int) int {\n\treturn x / gcd(x, y) * y\n}\n\nfunc reverseString(s string) string {\n\tr := []rune(s)\n\tfor i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {\n\t\tr[i], r[j] = r[j], r[i]\n\t}\n\treturn string(r)\n}\n\nfunc pow(a, n int) int {\n\tret := 1\n\tfor i := 1; i <= n; i++ {\n\t\tret *= a\n\t}\n\treturn ret\n}\n\ntype Queue []int\n\nfunc (q *Queue) empty() bool {\n\treturn len(*q) == 0\n}\n\nfunc (q *Queue) push(i int) {\n\t*q = append(*q, i)\n}\n\nfunc (q *Queue) pop() (int, bool) {\n\tif q.empty() {\n\t\treturn 0, false\n\t} else {\n\t\tres := (*q)[0]\n\t\t*q = (*q)[1:]\n\t\treturn res, true\n\t}\n}\n\ntype Stack []int\n\nfunc (s *Stack) empty() bool {\n\treturn len(*s) == 0\n}\n\nfunc (s *Stack) push(i int) {\n\t*s = append(*s, i)\n}\n\nfunc (s *Stack) pop() (int, bool) {\n\tif s.empty() {\n\t\treturn 0, false\n\t} else {\n\t\tindex := len(*s) - 1\n\t\tres := (*s)[index]\n\t\t*s = (*s)[:index]\n\t\treturn res, true\n\t}\n}\n\ntype intHeap []int\n\nfunc (h intHeap) Len() int { return len(h) }\nfunc (h intHeap) Less(i, j int) bool { return h[i] > h[j] }\nfunc (h intHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }\nfunc (h *intHeap) Push(x interface{}) {\n\t*h = append(*h, x.(int))\n}\nfunc (h *intHeap) Pop() interface{} {\n\told := *h\n\tn := len(old)\n\tx := old[n-1]\n\t*h = old[0 : n-1]\n\treturn x\n}\n\ntype point struct {\n\tx int\n\ty int\n}\n\ntype points []point\n\nfunc (p points) Len() int {\n\treturn len(p)\n}\n\nfunc (p points) Less(i, j int) bool {\n\treturn p[i].x < p[j].x\n}\n\nfunc (p points) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n", "test_IO": [ { "input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n", "output": "2\n" } ] }, { "id": "s301190573", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst size = 1000000\n\nvar reader = bufio.NewReaderSize(os.Stdin, size)\n\nfunc NextLine() string {\n\tvar line, buffer []byte\n\tvar isPrefix bool = true\n\tvar err error\n\tfor isPrefix {\n\t\tline, isPrefix, err = reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t}\n\treturn string(buffer)\n}\nfunc NextInts() (int, int) {\n\tvar x, y int\n\tvar s []string = strings.Split(NextLine(), \" \")\n\tx, _ = strconv.Atoi(s[0])\n\ty, _ = strconv.Atoi(s[1])\n\treturn x, y\n}\nfunc NextIntArray() []int {\n\tvar s []string = strings.Split(NextLine(), \" \")\n\tvar a []int = make([]int, len(s))\n\tfor i := 0; i < len(s); i++ {\n\t\ta[i], _ = strconv.Atoi(s[i])\n\t\ta[i]--\n\t}\n\treturn a\n}\n\nvar par, rank []int\n\nfunc main() {\n\tvar n, m int = NextInts()\n\tvar p []int = NextIntArray()\n\tvar x, y int\n\tinitialize(n)\n\tfor i := 0; i < m; i++ {\n\t\tx, y = NextInts()\n\t\tunite(x-1, y-1)\n\t}\n\tvar s int\n\tfor i := 0; i < n; i++ {\n\t\tif same(i, p[i]) {\n\t\t\ts++\n\t\t}\n\t}\n\tfmt.Println(s)\n}\nfunc initialize(n int) {\n\tpar = make([]int, n)\n\trank = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tpar[i] = i\n\t}\n}\nfunc root(i int) int {\n\tif par[i] == i {\n\t\treturn i\n\t}\n\tpar[i] = root(par[i])\n\treturn par[i]\n}\nfunc same(i, j int) bool {\n\treturn root(i) == root(j)\n}\nfunc unite(i, j int) {\n\ti = root(i)\n\tj = root(j)\n\tif i == j {\n\t\treturn\n\t}\n\tif rank[i] < rank[j] {\n\t\tpar[i] = j\n\t} else {\n\t\tpar[j] = i\n\t\tif rank[i] == rank[j] {\n\t\t\trank[i]++\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "5 2\n5 3 1 4 2\n1 3\n5 4\n", "output": "2\n" } ] }, { "id": "s302163336", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn := nextInt()\n\tm := nextInt()\n\th := make([]int, n)\n\tgood := make([]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\th[i] = nextInt()\n\t\tgood[i] = true\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tai := nextInt() - 1\n\t\tbi := nextInt() - 1\n\t\tif h[ai] > h[bi] {\n\t\t\tgood[bi] = false\n\t\t} else if h[ai] < h[bi] {\n\t\t\tgood[ai] = false\n\t\t} else {\n\t\t\tgood[ai] = false\n\t\t\tgood[bi] = false\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tif good[i] {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n", "test_IO": [ { "input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n", "output": "2\n" } ] }, { "id": "s860368733", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\th := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&h[i])\n\t}\n\tvar a, b int\n\tcounter := make(map[int]struct{})\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d %d\", &a, &b)\n\t\tif h[a-1] < h[b-1] {\n\t\t\tcounter[a] = struct{}{}\n\t\t} else if h[a-1] > h[b-1] {\n\t\t\tcounter[b] = struct{}{}\n\t\t} else if h[a-1] == h[b-1] {\n\t\t\tcounter[a] = struct{}{}\n\t\t\tcounter[b] = struct{}{}\n\t\t}\n\t}\n\tfmt.Println(n - len(counter))\n}\n", "test_IO": [ { "input": "4 3\n1 2 3 4\n1 3\n2 3\n2 4\n", "output": "2\n" } ] }, { "id": "s451489327", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tas := make([]int, n+1)\n\tbs := make([]int, n)\n\n\tfor i := range as {\n\t\tfmt.Scan(&as[i])\n\t}\n\n\tfor i := range bs {\n\t\tfmt.Scan(&bs[i])\n\t}\n\n\tvar sum int\n\tfor i := 0; i <= n-1; i++ {\n\t\ta := as[i]\n\t\tb := bs[i]\n\t\tif a <= b {\n\t\t\tsum += a\n\t\t\tb -= a\n\t\t\tif i+1 <= n {\n\t\t\t\tan := as[i+1]\n\t\t\t\tif an <= b {\n\t\t\t\t\tsum += an\n\t\t\t\t\tas[i+1] = 0\n\t\t\t\t} else {\n\t\t\t\t\tsum += b\n\t\t\t\t\tas[i+1] -= b\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tsum += b\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n", "test_IO": [ { "input": "2\n3 5 2\n4 5\n", "output": "9\n" } ] }, { "id": "s699619001", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\ntype problem struct {\n\tnumber, bonus int\n}\n\nfunc min(a, b int) int {\n\tif a >= b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar D, G int\n\tfmt.Scan(&D, &G)\n\tproblems := make([]problem, D)\n\tfor i := range problems {\n\t\tfmt.Scan(&problems[i].number)\n\t\tfmt.Scan(&problems[i].bonus)\n\t}\n\n\tans := 10000\n\tfor bit := 0; bit < (1 << uint(D)); bit++ {\n\t\tscore := 0\n\t\tsolved := 0\n\t\tok := false\n\t\tfor j := 0; j < D; j++ {\n\t\t\tif bit&(1<= 0; j-- {\n\t\t\t\tif bit&(1<= G {\n\t\t\t\t\tok = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\tscore += problems[j].bonus\n\t\t\t\tif score >= G {\n\t\t\t\t\tok = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tok = true\n\t\t}\n\t\tif ok {\n\t\t\tans = min(ans, solved)\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "2 700\n3 500\n5 800\n", "output": "3\n" } ] }, { "id": "s033683118", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextUint64(scanner *bufio.Scanner) uint64 {\n\ti, _ := strconv.ParseUint(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextFloat64(scanner *bufio.Scanner) float64 {\n\ti, _ := strconv.ParseFloat(getNextString(scanner), 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\twfp := os.Stdout\n\tcnt := 0\n\n\tif os.Getenv(\"MASPY\") == \"\u307e\u3059\u30d4\" {\n\t\tfp, _ = os.Open(os.Getenv(\"BEET_THE_HARMONY_OF_PERFECT\"))\n\t\tcnt = 2\n\t}\n\tif os.Getenv(\"MASPYPY\") == \"\u307e\u3059\u30d4\u30c3\u30d4\" {\n\t\twfp, _ = os.Create(os.Getenv(\"NGTKANA_IS_GENIUS10\"))\n\t}\n\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(wfp)\n\tsolve(scanner, writer)\n\tfor i := 0; i < cnt; i++ {\n\t\tfmt.Fprintln(writer, \"-----------------------------------\")\n\t\tsolve(scanner, writer)\n\t}\n\twriter.Flush()\n}\n\nfunc solve(scanner *bufio.Scanner, writer *bufio.Writer) {\n\tk := getNextInt(scanner)\n\tx := getNextInt(scanner)\n\n\tans := \"No\"\n\tif k*500 >= x {\n\t\tans = \"Yes\"\n\t}\n\tfmt.Fprintln(writer, ans)\n}\n", "test_IO": [ { "input": "2 900\n", "output": "Yes\n" } ] }, { "id": "s032857139", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+11))\n\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc GetNthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc CeilInt(a, b int) int {\n\tres := a / b\n\tif a%b > 0 {\n\t\tres++\n\t}\n\treturn res\n}\n\nfunc FloorInt(a, b int) int {\n\tres := a / b\n\treturn res\n}\n\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\tgcd := Gcd(a, b)\n\n\treturn (a / gcd) * b\n}\n\nfunc DeleteElement(s []int, i int) []int {\n\tif i < 0 || len(s) <= i {\n\t\tpanic(errors.New(\"[index error]\"))\n\t}\n\n\tn := make([]int, 0, len(s)-1)\n\tn = append(n, s[:i]...)\n\tn = append(n, s[i+1:]...)\n\treturn n\n}\n\nfunc Concat(s, t []rune) []rune {\n\tn := make([]rune, 0, len(s)+len(t))\n\tn = append(n, s...)\n\tn = append(n, t...)\n\treturn n\n}\n\nfunc UpperRune(r rune) rune {\n\tstr := strings.ToUpper(string(r))\n\treturn []rune(str)[0]\n}\n\nfunc LowerRune(r rune) rune {\n\tstr := strings.ToLower(string(r))\n\treturn []rune(str)[0]\n}\n\nfunc ToggleRune(r rune) rune {\n\tvar str string\n\tif 'a' <= r && r <= 'z' {\n\t\tstr = strings.ToUpper(string(r))\n\t} else if 'A' <= r && r <= 'Z' {\n\t\tstr = strings.ToLower(string(r))\n\t} else {\n\t\tstr = string(r)\n\t}\n\treturn []rune(str)[0]\n}\n\nfunc ToggleString(s string) string {\n\tinputRunes := []rune(s)\n\toutputRunes := make([]rune, 0, len(inputRunes))\n\tfor _, r := range inputRunes {\n\t\toutputRunes = append(outputRunes, ToggleRune(r))\n\t}\n\treturn string(outputRunes)\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc CalcFactorialPatterns(elements []rune) [][]rune {\n\tcopiedResidual := make([]rune, len(elements))\n\tcopy(copiedResidual, elements)\n\treturn factorialRecursion([]rune{}, copiedResidual)\n}\nfunc factorialRecursion(interim, residual []rune) [][]rune {\n\tif len(residual) == 0 {\n\t\treturn [][]rune{interim}\n\t}\n\n\tres := [][]rune{}\n\tfor idx, elem := range residual {\n\t\tcopiedInterim := make([]rune, len(interim))\n\t\tcopy(copiedInterim, interim)\n\t\tcopiedInterim = append(copiedInterim, elem)\n\t\tcopiedResidual := genDeletedSlice(idx, residual)\n\t\tres = append(res, factorialRecursion(copiedInterim, copiedResidual)...)\n\t}\n\n\treturn res\n}\nfunc genDeletedSlice(delId int, S []rune) []rune {\n\tres := []rune{}\n\tres = append(res, S[:delId]...)\n\tres = append(res, S[delId+1:]...)\n\treturn res\n}\n\nfunc CalcDuplicatePatterns(elements []rune, digit int) [][]rune {\n\treturn duplicateRecursion([]rune{}, elements, digit)\n}\nfunc duplicateRecursion(interim, elements []rune, digit int) [][]rune {\n\tif len(interim) == digit {\n\t\treturn [][]rune{interim}\n\t}\n\n\tres := [][]rune{}\n\tfor i := 0; i < len(elements); i++ {\n\t\tcopiedInterim := make([]rune, len(interim))\n\t\tcopy(copiedInterim, interim)\n\t\tcopiedInterim = append(copiedInterim, elements[i])\n\t\tres = append(res, duplicateRecursion(copiedInterim, elements, digit)...)\n\t}\n\n\treturn res\n}\n\nfunc GeneralLowerBound(s []int, key int) int {\n\tisOK := func(index, key int) bool {\n\t\tif s[index] >= key {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tng, ok := -1, len(s)\n\tfor int(math.Abs(float64(ok-ng))) > 1 {\n\t\tmid := (ok + ng) / 2\n\t\tif isOK(mid, key) {\n\t\t\tok = mid\n\t\t} else {\n\t\t\tng = mid\n\t\t}\n\t}\n\n\treturn ok\n}\n\nfunc GeneralUpperBound(s []int, key int) int {\n\tisOK := func(index, key int) bool {\n\t\tif s[index] > key {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tng, ok := -1, len(s)\n\tfor int(math.Abs(float64(ok-ng))) > 1 {\n\t\tmid := (ok + ng) / 2\n\t\tif isOK(mid, key) {\n\t\t\tok = mid\n\t\t} else {\n\t\t\tng = mid\n\t\t}\n\t}\n\n\treturn ok\n}\n\nfunc InitParents(parents []int, maxNodeId int) {\n\tfor i := 0; i <= maxNodeId; i++ {\n\t\tparents[i] = i\n\t}\n}\n\nfunc unite(x, y int, parents []int) {\n\txp, yp := root(x, parents), root(y, parents)\n\tif xp == yp {\n\t\treturn\n\t}\n\n\tparents[xp] = yp\n}\n\nfunc same(x, y int, parents []int) bool {\n\treturn root(x, parents) == root(y, parents)\n}\n\nfunc root(x int, parents []int) int {\n\tif parents[x] == x {\n\t\treturn x\n\t}\n\n\tparents[x] = root(parents[x], parents)\n\treturn parents[x]\n}\n\nfunc TrialDivision(n int) map[int]int {\n\tif n <= 1 {\n\t\tpanic(errors.New(\"[argument error]: TrialDivision only accepts a NATURAL number\"))\n\t}\n\n\tp := map[int]int{}\n\tfor i := 2; i*i <= n; i++ {\n\t\texp := 0\n\t\tfor n%i == 0 {\n\t\t\texp++\n\t\t\tn /= i\n\t\t}\n\n\t\tif exp == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp[i] = exp\n\t}\n\tif n > 1 {\n\t\tp[n] = 1\n\t}\n\n\treturn p\n}\n\nfunc IsPrime(n int) bool {\n\tif n == 1 {\n\t\treturn false\n\t}\n\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc CalcNegativeMod(val, m int) int {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\nfunc modpow(a, e, m int) int {\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := modpow(a, halfE, m)\n\t\treturn half * half % m\n\t}\n\n\treturn a * modpow(a, e-1, m) % m\n}\n\nfunc CalcModInv(a, m int) int {\n\treturn modpow(a, m-2, m)\n}\n\ntype IntHeap []int\n\nfunc (h IntHeap) Len() int { return len(h) }\nfunc (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }\nfunc (h IntHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }\nfunc (h *IntHeap) Push(x interface{}) {\n\t*h = append(*h, x.(int))\n}\nfunc (h *IntHeap) Pop() interface{} {\n\told := *h\n\tn := len(old)\n\tx := old[n-1]\n\t*h = old[0 : n-1]\n\treturn x\n}\n\ntype Mono struct {\n\tkey, value int\n}\ntype MonoList []*Mono\n\nfunc (ml MonoList) Len() int {\n\treturn len(ml)\n}\nfunc (ml MonoList) Swap(i, j int) {\n\tml[i], ml[j] = ml[j], ml[i]\n}\nfunc (ml MonoList) Less(i, j int) bool {\n\treturn ml[i].value < ml[j].value\n}\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\n\nvar n, x int\nvar A []int\n\nfunc main() {\n\tn, x = ReadInt(), ReadInt()\n\tA = ReadIntSlice(n)\n\n\tsort.Sort(sort.IntSlice(A))\n\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tif x >= A[i] {\n\t\t\tans++\n\t\t\tx -= A[i]\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tif ans == n && x > 0 {\n\t\tans--\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "3 70\n20 30 10\n", "output": "2\n" } ] }, { "id": "s134607050", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc searchRange(text *string, start, limit int) (int, int, int) {\n\tmiddle := -1\n\n\tfor i := start; i < limit; i++ {\n\t\tif (*text)[i] != 'R' {\n\t\t\tmiddle = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tend := limit\n\n\tfor i := middle; i < limit; i++ {\n\t\tif (*text)[i] != 'L' {\n\t\t\tend = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn start, middle, end\n}\n\nfunc answer() {\n\tvar text string\n\tfmt.Scan(&text)\n\tlimit := len(text)\n\n\tstart := 0\n\tmiddle := 0\n\tend := 0\n\tfirstPrinted := false\n\n\tfor end < limit {\n\t\tstart, middle, end = searchRange(&text, start, limit)\n\t\tlen1 := middle - start\n\t\tlen2 := end - middle\n\n\t\tfor i := start; i < middle-1; i++ {\n\t\t\tif firstPrinted {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(\"0\")\n\t\t\tfirstPrinted = true\n\t\t}\n\n\t\tcount1 := (len1+1)/2 + len2/2\n\t\tcount2 := len1/2 + (len2+1)/2\n\n\t\tif firstPrinted {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t\tfmt.Printf(\"%v %v\", count1, count2)\n\t\tfirstPrinted = true\n\n\t\tfor i := middle + 1; i < end; i++ {\n\t\t\tif firstPrinted {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(\"0\")\n\t\t\tfirstPrinted = true\n\t\t}\n\t\tstart = end\n\t\tfirstPrinted = true\n\t}\n\tfmt.Println()\n}\n\nfunc main() {\n\tanswer()\n}\n", "test_IO": [ { "input": "RRLRL\n", "output": "0 1 2 1 1\n" } ] }, { "id": "s120583500", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tcount := 0\n\tvar counter []int\n\n\tif s == \"\" {\n\t\treturn\n\t}\n\tcounter = append(counter, 0)\n\tli := strings.Split(s, \"\")\n\n\tfor _, s := range li {\n\t\tif s == \"A\" || s == \"C\" || s == \"G\" || s == \"T\" {\n\t\t\tcount++\n\t\t} else {\n\t\t\tcounter = append(counter, count)\n\t\t\tcount = 0\n\t\t}\n\t}\n\n\tcounter = append(counter, count)\n\tsort.Ints(counter)\n\tfmt.Println(counter[len(counter)-1])\n}\n", "test_IO": [ { "input": "ATCODER\n", "output": "3\n" } ] }, { "id": "s344381425", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scanf(\"%d %d %d\", &a, &b, &c)\n\tif a < b && b < c {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n\treturn\n}\n", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s716011659", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nconst inf = 10000000000.0\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tarrA := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arrA[i])\n\t}\n\n\tcumSumA := make([]int, n+1)\n\tcumSumA[0] = 0\n\tfor i, a := range arrA {\n\t\tcumSumA[i+1] = cumSumA[i] + a\n\t}\n\n\tans := inf\n\tfor i := 1; i < n; i++ {\n\t\tif math.Abs(float64(cumSumA[n]-(cumSumA[i]*2))) < ans {\n\t\t\tans = math.Abs(float64(cumSumA[n] - cumSumA[i]*2))\n\t\t}\n\t}\n\n\tfmt.Println(int(ans))\n}\n", "test_IO": [ { "input": "6\n1 2 3 4 5 6\n", "output": "1\n" } ] }, { "id": "s841275808", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tN := ScanInt(scanner)\n\tX := make([]int, N)\n\tY := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tX[i] = ScanInt(scanner)\n\t\tY[i] = X[i]\n\t}\n\n\tsort.Sort(sort.IntSlice(Y))\n\tm1 := Y[N/2-1]\n\tm2 := Y[N/2]\n\tfor i := 0; i < N; i++ {\n\t\tif X[i] <= m1 {\n\t\t\tfmt.Println(m2)\n\t\t} else {\n\t\t\tfmt.Println(m1)\n\t\t}\n\t}\n\n}\n\nfunc ScanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\ti, e := strconv.Atoi(scanner.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc ScanFloat64(scanner *bufio.Scanner) float64 {\n\tscanner.Scan()\n\tf, e := strconv.ParseFloat(scanner.Text(), 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn f\n}\n\nfunc ScanText(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc Max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Abs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "4\n2 4 4 3\n", "output": "4\n3\n3\n4\n" } ] }, { "id": "s394238127", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tvar c [3][3]int\n\tvar a, b [3]int\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tscanner.Scan()\n\t\t\tc[i][j], _ = strconv.Atoi(scanner.Text())\n\t\t}\n\t}\n\n\tb[0] = c[0][0] - a[0]\n\tb[1] = c[0][1] - a[0]\n\tb[2] = c[0][2] - a[0]\n\ta[1] = c[1][0] - c[0][0]\n\ta[2] = c[2][0] - c[0][0]\n\tif a[1] == c[1][1]-c[0][1] && a[1] == c[1][2]-c[0][2] &&\n\t\ta[2] == c[2][1]-c[0][1] && a[2] == c[2][2]-c[0][2] {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1 0 1\n2 1 2\n1 0 1\n", "output": "Yes\n" } ] }, { "id": "s414601790", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n, &s)\n\n\tmax := 0\n\tcnt := 0\n\tfor _, r := range s {\n\t\tif r == 'I' {\n\t\t\tcnt++\n\t\t} else {\n\t\t\tcnt--\n\t\t}\n\n\t\tif cnt > max {\n\t\t\tmax = cnt\n\t\t}\n\t}\n\n\tfmt.Println(max)\n}\n", "test_IO": [ { "input": "5\nIIDID\n", "output": "2\n" } ] }, { "id": "s934374308", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar N, K, R, S, P int\n\tvar T string\n\tfmt.Scan(&N, &K, &R, &S, &P)\n\tfmt.Scan(&T)\n\n\tdict := map[string]int{\"r\": 0, \"s\": 0, \"p\": 0}\n\tchar := \"\"\n\ts := make([]bool, N)\n\tfor i := 0; i < N; i++ {\n\t\ts[i] = true\n\t}\n\tr := make([]bool, N)\n\tp := make([]bool, N)\n\tcopy(r, s)\n\tcopy(p, s)\n\tfor i := 0; i < len(T); i++ {\n\t\tchar = T[i : i+1]\n\t\tif i >= K {\n\t\t\tif char == T[i-K:i+1-K] {\n\n\t\t\t\tswitch char {\n\t\t\t\tcase \"s\":\n\t\t\t\t\tif s[i%K] {\n\t\t\t\t\t\ts[i%K] = false\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\ts[i%K] = true\n\t\t\t\t\t}\n\n\t\t\t\tcase \"r\":\n\t\t\t\t\tif r[i%K] {\n\t\t\t\t\t\tr[i%K] = false\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr[i%K] = true\n\n\t\t\t\t\t}\n\n\t\t\t\tcase \"p\":\n\t\t\t\t\tif p[i%K] {\n\t\t\t\t\t\tp[i%K] = false\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tp[i%K] = true\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tswitch char {\n\t\t\t\tcase \"s\":\n\t\t\t\t\ts[i%K] = true\n\t\t\t\tcase \"r\":\n\t\t\t\t\tr[i%K] = true\n\t\t\t\tcase \"p\":\n\t\t\t\t\tp[i%K] = true\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\tswitch char {\n\t\tcase \"s\":\n\t\t\tdict[\"s\"] = dict[\"s\"] + 1\n\t\tcase \"r\":\n\t\t\tdict[\"r\"] = dict[\"r\"] + 1\n\t\tcase \"p\":\n\t\t\tdict[\"p\"] = dict[\"p\"] + 1\n\t\t}\n\t}\n\n\tres := P*dict[\"r\"] + S*dict[\"p\"] + R*dict[\"s\"]\n\tfmt.Println(res)\n\n}\n", "test_IO": [ { "input": "5 2\n8 7 6\nrsrpr\n", "output": "27\n" } ] }, { "id": "s760945395", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfor i := 0; i < 5; i++ {\n\t\tvar a int\n\t\tfmt.Scan(&a)\n\t\tif a == 0 {\n\t\t\tfmt.Println(i + 1)\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "0 2 3 4 5\n", "output": "1\n" } ] }, { "id": "s783520158", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tif b-a == c-b {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "test_IO": [ { "input": "2 4 6\n", "output": "YES\n" } ] }, { "id": "s808499721", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\tfmt.Scan(&x)\n\n\tans := 0\n\tif x >= 400 && x <= 599 {\n\t\tans = 8\n\t}\n\tif x >= 600 && x <= 799 {\n\t\tans = 7\n\t}\n\tif x >= 800 && x <= 999 {\n\t\tans = 6\n\t}\n\tif x >= 1000 && x <= 1199 {\n\t\tans = 5\n\t}\n\tif x >= 1200 && x <= 1399 {\n\t\tans = 4\n\t}\n\tif x >= 1400 && x <= 1599 {\n\t\tans = 3\n\t}\n\tif x >= 1600 && x <= 1799 {\n\t\tans = 2\n\t}\n\tif x >= 1800 && x <= 9999 {\n\t\tans = 1\n\t}\n\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "725\n", "output": "7\n" } ] }, { "id": "s443186486", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\ts := make([]int, n+1)\n\tfor i := 0; i < n; i++ {\n\t\ts[i+1] = s[i] + a[i]\n\t}\n\n\tsort.Sort(sort.IntSlice(s))\n\n\tans := 0\n\tcount := 0\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == s[i+1] {\n\t\t\tcount++\n\t\t} else if count > 0 {\n\t\t\tans += combi(count+1, 2)\n\t\t\tcount = 0\n\t\t}\n\t}\n\tif count > 0 {\n\t\tans += combi(count+1, 2)\n\t}\n\n\tfmt.Println(ans)\n}\n\nfunc combi(n, r int) int {\n\tc := 1\n\tfor i := 1; i <= r; i++ {\n\t\tc = c * (n - i + 1) / i\n\t}\n\treturn c\n}\n", "test_IO": [ { "input": "6\n1 3 -4 2 2 -2\n", "output": "3\n" } ] }, { "id": "s235491884", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tn := strings.Count(s, \"o\")\n\tfmt.Println(700 + n*100)\n}\n", "test_IO": [ { "input": "oxo\n", "output": "900\n" } ] }, { "id": "s390866994", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc out(x ...interface{}) {\n\tfmt.Println(x...)\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc asub(a, b int) int {\n\tif a > b {\n\t\treturn a - b\n\t}\n\treturn b - a\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\treturn -a\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\n\tN, C, K := getInt(), getInt(), getInt()\n\tt := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tt[i] = getInt()\n\t}\n\n\tsort.Ints(t)\n\n\tans := 1\n\tcnt := 1\n\tend := t[0] + K\n\tfor i := 1; i < N; i++ {\n\t\tif cnt < C && t[i] <= end {\n\t\t\tcnt++\n\n\t\t} else {\n\n\t\t\tcnt = 1\n\t\t\tend = t[i] + K\n\t\t\tans++\n\t\t}\n\t}\n\tout(ans)\n}\n", "test_IO": [ { "input": "5 3 5\n1\n2\n3\n6\n12\n", "output": "3\n" } ] }, { "id": "s101529434", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar K, X int\n\tfmt.Scan(&K, &X)\n\tif 500*K >= X {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "2 900\n", "output": "Yes\n" } ] }, { "id": "s114239323", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\n\tN := nextInt()\n\th := nextInts(N)\n\n\tdp := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tdp[i] = 0\n\t}\n\tdp[1] = Abs(h[0] - h[1])\n\n\tfor i := 2; i < N; i++ {\n\t\tdp[i] = Min([]int{dp[i-1] + Abs(h[i]-h[i-1]),\n\t\t\tdp[i-2] + Abs(h[i]-h[i-2])})\n\t}\n\n\tfmt.Println(dp[N-1])\n}\n\nfunc Max(a []int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r < a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc Min(a []int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r > a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc Sum(a []int) (r int) {\n\tfor i := range a {\n\t\tr += a[i]\n\t}\n\treturn r\n}\n\nfunc Abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\ntype Pair struct {\n\ta, b int\n}\n\ntype Pairs []Pair\n\nfunc (p Pairs) Len() int {\n\treturn len(p)\n}\n\nfunc (p Pairs) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p Pairs) Less(i, j int) bool {\n\treturn p[i].b < p[j].b\n}\n\nvar nextReader func() string\n\nfunc init() {\n\tnextReader = NewScanner()\n}\n\nfunc NewScanner() func() string {\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Buffer(make([]byte, 1024), int(1e+11))\n\tr.Split(bufio.ScanWords)\n\treturn func() string {\n\t\tr.Scan()\n\t\treturn r.Text()\n\t}\n}\n\nfunc nextString() string {\n\treturn nextReader()\n}\n\nfunc nextInt64() int64 {\n\tv, _ := strconv.ParseInt(nextReader(), 10, 64)\n\treturn v\n}\n\nfunc nextInt() int {\n\tv, _ := strconv.Atoi(nextReader())\n\treturn v\n}\n\nfunc nextInts(n int) []int {\n\tr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tr[i] = nextInt()\n\t}\n\treturn r\n}\n\nfunc nextStrings(n int) []string {\n\tr := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tr[i] = nextString()\n\t}\n\treturn r\n}\n\nfunc nextFloat64() float64 {\n\tf, _ := strconv.ParseFloat(nextReader(), 64)\n\treturn f\n}\n", "test_IO": [ { "input": "4\n10 30 40 20\n", "output": "30\n" } ] }, { "id": "s894183124", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scanf(\"%d\", &n)\n\tfmt.Scanf(\"%s\", &s)\n\tfmt.Printf(\"%d\\n\", strings.Count(s, \"ABC\"))\n}\n", "test_IO": [ { "input": "10\nZABCDBABCQ\n", "output": "2\n" } ] }, { "id": "s635098814", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\tgcd := Gcd(a, b)\n\n\treturn (a / gcd) * b\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar memo [ALPHABET_NUM]int\nvar str string\n\nfunc main() {\n\tvar sc = bufio.NewScanner(os.Stdin)\n\n\tfor {\n\t\tif sc.Scan() {\n\t\t\tstr = sc.Text()\n\t\t\tS := []rune(str)\n\t\t\tif len(S) == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor i := 0; i < len(S); i++ {\n\t\t\t\tc := S[i]\n\n\t\t\t\tif 'a' <= c && c <= 'z' {\n\n\t\t\t\t\tmemo[c-'a']++\n\t\t\t\t} else if 'A' <= c && c <= 'Z' {\n\n\t\t\t\t\tmemo[c-'A']++\n\t\t\t\t} else {\n\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := 0; i < ALPHABET_NUM; i++ {\n\t\tfmt.Printf(\"%c : %d\\n\", rune(i)+'a', memo[i])\n\t}\n}\n", "test_IO": [ { "input": "This is a pen.\n", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n" } ] }, { "id": "s469293815", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar A, B, C int\n\tfmt.Scan(&A, &B, &C)\n\n\tif A+B >= C {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "50 100 120\n", "output": "Yes\n" } ] }, { "id": "s108967797", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc ri() (n int) {\n\tsc.Scan()\n\tfor _, v := range sc.Bytes() {\n\t\tn = n*10 + int(v-48)\n\t}\n\treturn\n}\n\nfunc ave(s []float64) float64 {\n\tvar sum float64\n\tfor _, v := range s {\n\t\tsum += v\n\t}\n\treturn float64(sum) / float64(len(s))\n}\n\nfunc diff(a, b float64) float64 {\n\tif a > b {\n\t\treturn a - b\n\t}\n\treturn b - a\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn := ri()\n\ta := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = float64(ri())\n\t}\n\n\tave := ave(a)\n\n\tminDiff := 999999.9\n\tansIndex := -1\n\tfor i, v := range a {\n\t\tdiff := diff(v, ave)\n\t\tif diff < minDiff {\n\t\t\tminDiff = diff\n\t\t\tansIndex = i\n\t\t}\n\t}\n\tfmt.Println(ansIndex)\n}\n", "test_IO": [ { "input": "3\n1 2 3\n", "output": "1\n" } ] }, { "id": "s006130616", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, x int\n\tfmt.Scan(&n, &m, &x)\n\n\ta := make([][]int, n)\n\tp := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\n\t\tfmt.Scan(&p[i])\n\t\ta[i] = make([]int, m)\n\t\tfor j := 0; j < m; j++ {\n\t\t\tfmt.Scan(&a[i][j])\n\t\t}\n\t}\n\n\tans := 1200001\n\tvar tot int\n\tvar ok bool\n\tfor bits := 0; bits < 1<>i)&1 == 1 {\n\t\t\t\ttot += p[i]\n\t\t\t\tfor j := 0; j < m; j++ {\n\t\t\t\t\tskill[j] += a[i][j]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor _, v := range skill {\n\t\t\tif v < x {\n\t\t\t\tok = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif ok {\n\t\t\tif ans > tot {\n\t\t\t\tans = tot\n\t\t\t}\n\t\t}\n\t}\n\n\tif ans != 1200001 {\n\t\tfmt.Println(ans)\n\t} else {\n\t\tfmt.Println(\"-1\")\n\t}\n\n}\n", "test_IO": [ { "input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n", "output": "120\n" } ] }, { "id": "s832289582", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := newInputScanner(true, 256)\n\tN, P, S := sc.nextInt(), sc.nextInt(), sc.nextStr()\n\tanswer := checkSubNumbers(N, P, S)\n\tfmt.Println(answer)\n}\n\nfunc checkSubNumbers(N int, P int, S string) int {\n\tswitch P {\n\tcase 2, 5:\n\t\treturn checkTwoOrFive(N, P, S)\n\tdefault:\n\t\treturn checkNotTwoNorFive(N, P, S)\n\t}\n}\n\nfunc checkTwoOrFive(N int, P int, S string) int {\n\tanswer := 0\n\tvar n int\n\tfor i := N - 1; i >= 0; i-- {\n\t\tn, _ = strconv.Atoi(S[i : i+1])\n\t\tif n%P == 0 {\n\t\t\tanswer += i + 1\n\t\t}\n\t}\n\treturn answer\n}\n\nfunc checkNotTwoNorFive(N int, P int, S string) int {\n\tmultiplier := 1\n\tanswer := 0\n\tremainderLookup := make([]int, P)\n\tprevRemaider := -1\n\tvar digit, remainder, count int\n\tfor i := N - 1; i >= 0; i-- {\n\t\tdigit = int(S[i] - '0')\n\t\tif prevRemaider == -1 {\n\t\t\tremainder = digit % P\n\t\t} else {\n\t\t\tremainder = (((multiplier * digit) % P) + prevRemaider) % P\n\t\t}\n\t\tif remainder == 0 {\n\t\t\tanswer++\n\t\t}\n\t\tcount = remainderLookup[remainder]\n\t\tanswer += count\n\t\tcount++\n\t\tremainderLookup[remainder] = count\n\t\tprevRemaider = remainder\n\t\tmultiplier = (multiplier * 10) % P\n\t}\n\treturn answer\n}\n\ntype inputScanner struct {\n\t*bufio.Scanner\n}\n\nfunc newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tif enabledScanWords {\n\t\tscanner.Split(bufio.ScanWords)\n\t}\n\tcapacity := sizeInKB * 1024\n\tbuf := make([]byte, capacity)\n\tscanner.Buffer(buf, capacity)\n\treturn &inputScanner{\n\t\tScanner: scanner,\n\t}\n}\n\nfunc (inputSc *inputScanner) nextInt() int {\n\ti, e := strconv.Atoi(inputSc.nextStr())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (inputSc *inputScanner) nextUInt64() uint64 {\n\ti, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (inputSc *inputScanner) nextStr() string {\n\tinputSc.Scan()\n\treturn inputSc.Text()\n}\n", "test_IO": [ { "input": "4 3\n3543\n", "output": "6\n" } ] }, { "id": "s201528373", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar x int\n\tvar l []int\n\tfmt.Scan(&n)\n\tfmt.Scan(&x)\n\tfor i := 0; i < n; i++ {\n\t\tvar tmpL int\n\t\tfmt.Scan(&tmpL)\n\t\tl = append(l, tmpL)\n\t}\n\n\tvar tmpSum int\n\tvar rs int\n\tfor i, v := range l {\n\t\ttmpSum += v\n\t\tif i >= n {\n\t\t\trs = n\n\t\t\tbreak\n\t\t}\n\t\tif tmpSum <= x {\n\t\t\trs = i + 2\n\t\t} else if tmpSum > x {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(rs)\n}\n", "test_IO": [ { "input": "3 6\n3 4 5\n", "output": "2\n" } ] }, { "id": "s801212431", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tinitialBufSize = 1e4\n\tmaxBufSize = 1e8\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tbuf := make([]byte, initialBufSize)\n\tsc.Buffer(buf, maxBufSize)\n\tsc.Split(bufio.ScanWords)\n}\n\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc min(x, y int) int {\n\tif x > y {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc main() {\n\tS := next()\n\n\tl0, l1 := 0, 0\n\tfor i := 0; i < len(S); i++ {\n\t\tif S[i] == '0' {\n\t\t\tl0++\n\t\t} else {\n\t\t\tl1++\n\t\t}\n\t}\n\tfmt.Println(2 * min(l0, l1))\n}\n", "test_IO": [ { "input": "0011\n", "output": "4\n" } ] }, { "id": "s672628848", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c, d, e int\n\n\tfmt.Scan(&a, &b, &c, &d, &e)\n\n\tal := []int{a, b, c, d, e}\n\n\tfor n, i := range al {\n\t\tif i == 0 {\n\t\t\tfmt.Println(n + 1)\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "0 2 3 4 5\n", "output": "1\n" } ] }, { "id": "s068639994", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc mainFn() {\n\tn := getInt()\n\tls := getIntSlice(n)\n\tlsRev := make([]int, n)\n\tcopy(lsRev, ls)\n\tsort.Ints(ls)\n\tsort.Sort(sort.Reverse(sort.IntSlice(lsRev)))\n\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tp, q := min(ls[i], ls[j]), max(ls[i], ls[j])\n\t\t\tx, y := q-p, q+p\n\n\t\t\tl := sort.Search(len(ls), func(i int) bool { return ls[i] > x })\n\t\t\tr := n - sort.Search(len(lsRev), func(i int) bool { return lsRev[i] < y })\n\n\t\t\tsum := r - l\n\t\t\tif (i >= l) && (i <= r) {\n\t\t\t\tsum--\n\t\t\t}\n\t\t\tif (j >= l) && (j <= r) {\n\t\t\t\tsum--\n\t\t\t}\n\t\t\tsum = max(0, sum)\n\t\t\tans += sum\n\t\t}\n\t}\n\n\tans /= 3\n\tputs(ans)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar (\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\n\tscanner.Split(bufio.ScanWords)\n\tmainFn()\n\twriter.Flush()\n}\n\nfunc getInt() int {\n\tscanner.Scan()\n\ti, err := strconv.Atoi(scanner.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc getIntSlice(n int) []int {\n\tis := make([]int, n)\n\tfor i := range is {\n\t\tis[i] = getInt()\n\t}\n\treturn is\n}\n\nfunc getString() string {\n\tscanner.Scan()\n\ts := scanner.Text()\n\treturn s\n}\n\nfunc puts(a ...interface{}) {\n\tif _, err := fmt.Fprintln(writer, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\n", "test_IO": [ { "input": "4\n3 4 2 1\n", "output": "1\n" } ] }, { "id": "s864554008", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\ntype data struct {\n\tn, m int\n\tnImg, mImg []string\n}\n\nfunc main() {\n\td := newData()\n\tif d.exist() {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n\nfunc newData() data {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tnImg := load(n)\n\tmImg := load(m)\n\n\treturn data{n: n, m: m, nImg: nImg, mImg: mImg}\n}\n\nfunc load(cnt int) []string {\n\tret := make([]string, cnt)\n\tfor i := 0; i < cnt; i++ {\n\t\tfmt.Scanf(\"%s\", &ret[i])\n\t}\n\n\treturn ret\n}\n\nfunc (d data) exist() bool {\n\tfor i := 0; i <= d.n-d.m; i++ {\n\t\tfor j := 0; j <= d.n-d.m; j++ {\n\t\t\tif d.match(i, j) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc (d data) match(x, y int) bool {\n\tfor i := 0; i < d.m; i++ {\n\t\tfor j := 0; j < d.m; j++ {\n\t\t\tif d.nImg[x+i][y+j] != d.mImg[i][j] {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}\n", "test_IO": [ { "input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n", "output": "Yes\n" } ] }, { "id": "s054878611", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solution(n int, a []int) int {\n\tvar memo [1e5 + 2]int\n\tfor _, num := range a {\n\t\tmemo[num]++\n\t\tmemo[num+1]++\n\t\tmemo[num+2]++\n\t}\n\tout := 0\n\tfor _, num := range memo {\n\t\tif num > 0 {\n\t\t\tout = max(out, num)\n\t\t}\n\t}\n\treturn out\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfmt.Println(solution(n, a))\n}\n", "test_IO": [ { "input": "7\n3 1 4 1 5 9 2\n", "output": "4\n" } ] }, { "id": "s356695182", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc nextInt() int {\n\tsc.Scan()\n\tt, err := strconv.Atoi(sc.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn t\n}\n\nfunc scanNums(len int) (nums []int) {\n\tvar num int\n\tfor i := 0; i < len; i++ {\n\t\tfmt.Scan(&num)\n\t\tnums = append(nums, num)\n\t}\n\treturn\n}\n\nfunc pattern1(l []int) int {\n\tn := (l[0] * l[3]) + (l[1] * l[4])\n\treturn n\n}\nfunc pattern2(l []int) int {\n\tn := 2 * l[2] * max(l[3], l[4])\n\treturn n\n}\nfunc pattern3(l []int) int {\n\tn := 2*l[2]*min(l[3], l[4]) + (doch(l))\n\treturn n\n}\n\nfunc min(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton min() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Min(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton max() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Max(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc doch(l []int) int {\n\tif l[3] > l[4] {\n\t\treturn l[0] * (l[3] - l[4])\n\t} else {\n\t\treturn l[1] * (l[4] - l[3])\n\t}\n}\n\nfunc main() {\n\tlen := 5\n\tl := scanNums(len)\n\tfmt.Println(min(pattern1(l), pattern2(l), pattern3(l)))\n\n}\n", "test_IO": [ { "input": "1500 2000 1600 3 2\n", "output": "7900\n" } ] }, { "id": "s211556675", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype Scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc NewScanner() *Scanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 1024), int(1e+9))\n\treturn &Scanner{sc}\n}\n\nfunc (s *Scanner) nextStr() string {\n\ts.sc.Scan()\n\treturn s.sc.Text()\n}\n\nfunc (s *Scanner) nextInt() int {\n\ti, e := strconv.Atoi(s.nextStr())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (s *Scanner) nextFloat() float64 {\n\tf, e := strconv.ParseFloat(s.nextStr(), 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn f\n}\n\nfunc (s *Scanner) nextRuneSlice() []rune {\n\treturn []rune(s.nextStr())\n}\n\nfunc (s *Scanner) nextIntSlice(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextInt()\n\t}\n\treturn res\n}\n\nfunc (s *Scanner) nextFloatSlice(n int) []float64 {\n\tres := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextFloat()\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tm := nums[0]\n\tfor _, i := range nums {\n\t\tif m < i {\n\t\t\tm = i\n\t\t}\n\t}\n\treturn m\n}\n\nfunc min(nums ...int) int {\n\tm := nums[0]\n\tfor _, i := range nums {\n\t\tif m > i {\n\t\t\tm = i\n\t\t}\n\t}\n\treturn m\n}\n\nfunc abs(x int) int {\n\tif x > 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc pow(x, y int) int {\n\tres := 1\n\tfor i := 0; i < y; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\ntype Val struct {\n\tid, num int\n}\ntype ByNum []Val\n\nfunc (a ByNum) Len() int { return len(a) }\nfunc (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }\nfunc (a ByNum) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\n\nfunc main() {\n\tsc := NewScanner()\n\twtr := bufio.NewWriter(os.Stdout)\n\tA, B, C, K := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()\n\tma := max(A, B, C)\n\trest := 0\n\tif ma == A {\n\t\trest += B + C\n\t} else if ma == B {\n\t\trest += A + C\n\t} else {\n\t\trest += A + B\n\t}\n\tfor i := 1; i <= K; i++ {\n\t\tma *= 2\n\t}\n\n\tfmt.Fprintln(wtr, ma+rest)\n\twtr.Flush()\n}\n", "test_IO": [ { "input": "5 3 11\n1\n", "output": "30\n" } ] }, { "id": "s739018217", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tx := m*1900 + (n-m)*100\n\tfmt.Println(x * int(math.Pow(2.0, float64(m))))\n}\n", "test_IO": [ { "input": "1 1\n", "output": "3800\n" } ] }, { "id": "s909858822", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar A, B int\n\tfmt.Scanln(&A, &B)\n\n\tvar ans int\n\tif 6 <= A && A <= 12 {\n\t\tans = B / 2\n\t} else if 12 < A {\n\t\tans = B\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "30 100\n", "output": "100\n" } ] }, { "id": "s658739453", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nconst d = 1000000007\n\nfunc main() {\n\tvar n, p int\n\tfmt.Scan(&n)\n\tfmt.Scan(&p)\n\n\tmdans := map[int64]int64{}\n\tfor index := 0; index < p; index++ {\n\t\tvar n1 int64\n\t\tfmt.Scan(&n1)\n\t\tmdans[n1] = n1\n\t}\n\n\tdp := make([]int64, n+1, n+1)\n\tdp[0] = 1\n\tdp[1] = 1\n\n\tif _, ok := mdans[1]; ok {\n\t\tdp[1] = 0\n\t}\n\n\tfor i := 2; i <= n; i++ {\n\t\tif _, ok := mdans[int64(i)]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tdp[i] = (dp[i-1] + dp[i-2]) % d\n\n\t}\n\n\tfmt.Printf(\"%#v\\n\", dp[n])\n}\n", "test_IO": [ { "input": "6 1\n3\n", "output": "4\n" } ] }, { "id": "s876981782", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scanf(\"%d\", &N)\n\tvalues := make([]float64, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%f\", &values[i])\n\t}\n\n\tsort.Sort(sort.Float64Slice(values))\n\tvar generated float64\n\n\tfor i := 0; i < N-1; i++ {\n\t\tgenerated = (values[i] + values[i+1]) / 2\n\t\tvalues[i+1] = generated\n\t}\n\n\tfmt.Println(generated)\n}\n", "test_IO": [ { "input": "2\n3 4\n", "output": "3.5\n" } ] }, { "id": "s385901297", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tns := make([]int, 4)\n\tscanner.Scan()\n\tfmt.Sscanf(scanner.Text(), \"%d %d %d %d\", &ns[0], &ns[1], &ns[2], &ns[3])\n\n\tsort.Sort(sort.IntSlice(ns))\n\tif ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "test_IO": [ { "input": "1 7 9 4\n", "output": "YES\n" } ] }, { "id": "s823623405", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tas := make([]int, n)\n\tps := make(map[int]int)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&as[i])\n\n\t\tns := primeFactorize(as[i])\n\t\tfor k, v := range ns {\n\t\t\tps[k] = max(ps[k], v)\n\t\t}\n\t}\n\n\tx := 1\n\tfor k, v := range ps {\n\t\tfor i := 1; i <= v; i++ {\n\t\t\tx = mul(x, k)\n\t\t}\n\t}\n\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tans = add(ans, div(x, as[i]))\n\t}\n\tfmt.Println(ans)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc primeFactorize(n int) map[int]int {\n\tres := make(map[int]int)\n\tfor i := 2; i*i <= n; i++ {\n\t\tfor n%i == 0 {\n\t\t\tn /= i\n\t\t\tres[i]++\n\t\t}\n\t}\n\tif n != 1 {\n\t\tres[n]++\n\t}\n\treturn res\n}\n\nconst mod int = 1000000007\n\nfunc pow(n, k int) int {\n\tif k == 0 {\n\t\treturn 1\n\t} else if k%2 == 1 {\n\t\treturn pow(n, k-1) * n % mod\n\t} else {\n\t\tt := pow(n, k/2)\n\t\treturn t * t % mod\n\t}\n}\n\nfunc add(a, b int) int {\n\treturn (a + b) % mod\n}\n\nfunc sub(a, b int) int {\n\treturn (a + mod - b) % mod\n}\n\nfunc mul(a, b int) int {\n\treturn a % mod * b % mod % mod\n}\n\nfunc div(a, b int) int {\n\treturn mul(a, pow(b, mod-2))\n}\n", "test_IO": [ { "input": "3\n2 3 4\n", "output": "13\n" } ] }, { "id": "s513492399", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(a int, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\nfunc main() {\n\tvar k, a, b, c int\n\tans := 0\n\tfmt.Scan(&k)\n\tfor a = 1; a <= k; a++ {\n\t\tfor b = 1; b <= k; b++ {\n\t\t\tfor c = 1; c <= k; c++ {\n\t\t\t\tans += gcd(a, gcd(b, c))\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "2\n", "output": "9\n" } ] }, { "id": "s430241485", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, t string\n\tfmt.Scan(&s, &t)\n\tfmt.Println(t + s)\n}\n", "test_IO": [ { "input": "oder atc\n", "output": "atcoder\n" } ] }, { "id": "s257493016", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(n ...int) int {\n\tif len(n) == 0 {\n\t\tpanic(\"len == 0\")\n\t}\n\tr := n[0]\n\tfor i := 1; i < len(n); i++ {\n\t\tif n[i] <= r {\n\t\t\tr = n[i]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc main() {\n\tvar H, N, A, B int\n\tfmt.Scan(&H, &N)\n\tdp := make([]int, H+10001)\n\tfor l := 1; l < H+10001; l++ {\n\t\tdp[l] = 2100000000\n\t}\n\tamax := 0\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scan(&A, &B)\n\t\tif A >= amax {\n\t\t\tamax = A\n\t\t}\n\t\tdp[A] = min(dp[A], B)\n\t\tfor j := A + 1; j <= H+A+1; j++ {\n\t\t\tdp[j] = min(dp[j], dp[j-A]+B)\n\t\t}\n\t}\n\tfmt.Println(min(dp[H : H+amax+1]...))\n}\n", "test_IO": [ { "input": "9 3\n8 3\n4 2\n2 1\n", "output": "4\n" } ] }, { "id": "s252511058", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc nextInt(sc *bufio.Scanner) int {\n\tsc.Scan()\n\tt, _ := strconv.Atoi(sc.Text())\n\treturn t\n}\n\ntype point struct {\n\tx, l, r int\n}\n\ntype ps []point\n\nfunc (p ps) Len() int {\n\treturn len(p)\n}\nfunc (p ps) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\nfunc (p ps) Less(i, j int) bool {\n\treturn p[i].r < p[j].r\n}\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tN := nextInt(sc)\n\tpoints := make([]point, N)\n\tfor i := 0; i < N; i++ {\n\t\tpoints[i].x = nextInt(sc)\n\t\tL := nextInt(sc)\n\t\tpoints[i].l = points[i].x - L\n\t\tpoints[i].r = points[i].x + L\n\t}\n\tsort.Sort(ps(points))\n\n\tstart := points[0].r\n\tans := 1\n\tfor i := 0; i < len(points); i++ {\n\t\tif points[i].l < start {\n\t\t\tcontinue\n\t\t}\n\t\tstart = points[i].r\n\t\tans++\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4\n2 4\n4 3\n9 3\n100 5\n", "output": "3\n" } ] }, { "id": "s129617956", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tn := nextInt()\n\trt := int(math.Sqrt(float64(n)))\n\tminf := 100\n\tfor i := 1; i < rt+1; i++ {\n\t\tif n%i == 0 {\n\t\t\tb := n / i\n\t\t\tndigit := 0\n\t\t\tfor b > 0 {\n\t\t\t\tb /= 10\n\t\t\t\tndigit++\n\t\t\t}\n\t\t\tminf = min(minf, ndigit)\n\t\t}\n\t}\n\tfmt.Println(minf)\n}\n\nconst size = 1000000\n\nvar reader = bufio.NewReaderSize(os.Stdin, size)\n\nfunc nextLine() string {\n\tvar line, buffer []byte\n\tisPrefix := true\n\tvar err error\n\tfor isPrefix {\n\t\tline, isPrefix, err = reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t}\n\treturn string(buffer)\n}\nfunc nextStringArray() []string {\n\treturn strings.Split(nextLine(), \" \")\n}\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(nextLine())\n\treturn n\n}\nfunc nextIntArray() []int {\n\ts := strings.Split(nextLine(), \" \")\n\tn := len(s)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i], _ = strconv.Atoi(s[i])\n\t}\n\treturn a\n}\n\nfunc min(i, j int) int {\n\tif i > j {\n\t\treturn j\n\t}\n\treturn i\n}\n", "test_IO": [ { "input": "10000\n", "output": "3\n" } ] }, { "id": "s030204253", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tfor i := 0; i+1 < n; i++ {\n\t\tsort.Sort(sort.Float64Slice(a))\n\t\tna := make([]float64, 0)\n\t\tfor j := 2; j < len(a); j++ {\n\t\t\tna = append(na, a[j])\n\t\t}\n\t\tna = append(na, (a[0]+a[1])/2)\n\t\ta = na\n\t}\n\tfmt.Println(a[0])\n}\n", "test_IO": [ { "input": "2\n3 4\n", "output": "3.5\n" } ] }, { "id": "s001472496", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tmax_tmp := 0\n\tmax := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tflag := false\n\t\tswitch string(s[i]) {\n\t\tcase \"A\", \"C\", \"T\", \"G\":\n\t\t\tmax_tmp++\n\t\tdefault:\n\t\t\tflag = true\n\t\t}\n\n\t\tif i == len(s)-1 {\n\t\t\tflag = true\n\t\t}\n\t\tif flag == true {\n\t\t\tif max < max_tmp {\n\t\t\t\tmax = max_tmp\n\t\t\t}\n\t\t\tmax_tmp = 0\n\t\t}\n\t}\n\tfmt.Println(max)\n}\n", "test_IO": [ { "input": "ATCODER\n", "output": "3\n" } ] }, { "id": "s940441641", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"container/heap\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst Inf = 1 << 60\n\nfunc main() {\n\tH, W, K := ReadInt(), ReadInt(), ReadInt()\n\tx1, y1, x2, y2 := ReadInt()-1, ReadInt()-1, ReadInt()-1, ReadInt()-1\n\tx1, y1 = y1, x1\n\tx2, y2 = y2, x2\n\tc := make([]string, H)\n\tfor y := 0; y < H; y++ {\n\t\tc[y] = ReadString()\n\t}\n\n\tvar dx = []int{1, 0, -1, 0}\n\tvar dy = []int{0, 1, 0, -1}\n\n\ttoID := func(x, y, dir int) int {\n\t\treturn 4*(W*y+x) + dir\n\t}\n\tsplatID := func(id int) (x, y, dir int) {\n\t\treturn id / 4 % W, id / 4 / W, id % 4\n\t}\n\n\tdist := make([]int, W*H*4)\n\tfor i := 0; i < W*H*4; i++ {\n\t\tdist[i] = Inf\n\t}\n\n\tq := Heap{}\n\tfor i := 0; i < 4; i++ {\n\t\tq = append(q, State{\n\t\t\tCost: 0,\n\t\t\tID: toID(x1, y1, i),\n\t\t})\n\t}\n\tfor len(q) > 0 {\n\t\tnow := q.pop()\n\t\tx, y, dir := splatID(now.ID)\n\t\tif c[y][x] == '@' {\n\t\t\tcontinue\n\t\t}\n\t\tif dist[now.ID] <= now.Cost {\n\t\t\tcontinue\n\t\t}\n\t\tdist[now.ID] = now.Cost\n\t\tif x == x2 && y == y2 {\n\t\t\tbreak\n\t\t}\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tnCost := (now.Cost + K - 1) / K * K\n\t\t\tnID := toID(x, y, i)\n\t\t\tif dist[nID] <= nCost {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tq.push(State{\n\t\t\t\tCost: nCost,\n\t\t\t\tID: nID,\n\t\t\t})\n\t\t}\n\t\tnx := x + dx[dir]\n\t\tny := y + dy[dir]\n\t\tif 0 <= nx && nx < W && 0 <= ny && ny < H {\n\t\t\tnCost := now.Cost + 1\n\t\t\tnID := toID(nx, ny, dir)\n\t\t\tif dist[nID] <= nCost {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tq.push(State{\n\t\t\t\tCost: nCost,\n\t\t\t\tID: nID,\n\t\t\t})\n\t\t}\n\t}\n\tans := Inf\n\tfor i := 0; i < 4; i++ {\n\t\tid := toID(x2, y2, i)\n\t\tif dist[id] < ans {\n\t\t\td2 := (dist[id] + K - 1) / K\n\t\t\tif d2 < ans {\n\t\t\t\tans = d2\n\t\t\t}\n\t\t}\n\t}\n\tif ans < Inf {\n\t\tfmt.Println(ans)\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n\ntype State struct {\n\tCost, ID int\n}\n\ntype HeapElement = State\ntype Heap []HeapElement\n\nfunc (h Heap) Less(i, j int) bool { return h[i].Cost < h[j].Cost }\nfunc (h Heap) Len() int { return len(h) }\nfunc (h Heap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }\nfunc (h *Heap) Push(x interface{}) { *h = append(*h, x.(HeapElement)) }\nfunc (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }\nfunc (h *Heap) push(v HeapElement) { heap.Push(h, v) }\nfunc (h *Heap) pop() HeapElement { return heap.Pop(h).(HeapElement) }\n\nvar reader = bufio.NewReader(os.Stdin)\n\nfunc Scan(a ...interface{}) {\n\tif _, err := fmt.Fscan(reader, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\nfunc ReadInt() (i int) { Scan(&i); return }\nfunc ReadString() (s string) { Scan(&s); return }\nfunc ReadInts(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tScan(&v[i])\n\t}\n\treturn v\n}\n", "test_IO": [ { "input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n", "output": "5\n" } ] }, { "id": "s865387202", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\ntype city struct {\n\tprefecture int\n\tposition int\n\tyear int\n}\n\ntype cities []*city\n\ntype cMap map[int]cities\n\nfunc main() {\n\tvar (\n\t\tn, m int\n\t)\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\th := make(cMap)\n\tfor i := 0; i < m; i++ {\n\t\tvar x, y int\n\t\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\t\t_, exists := h[x]\n\t\tif !exists {\n\t\t\th[x] = cities{{prefecture: x, year: y, position: i}}\n\t\t} else {\n\t\t\th[x] = append(h[x], &city{prefecture: x, year: y, position: i})\n\t\t}\n\t}\n\n\tresults := make([]string, m)\n\n\tfor _, v := range h {\n\t\tsort.Sort(v)\n\t\tfor idx, ci := range v {\n\t\t\tresults[ci.position] = fmt.Sprintf(\"%06d%06d\", ci.prefecture, idx+1)\n\t\t}\n\t}\n\tfmt.Println(strings.Join(results, \"\\n\"))\n}\n\nfunc (c cities) Len() int {\n\treturn len(c)\n}\n\nfunc (c cities) Swap(i, j int) {\n\tc[i], c[j] = c[j], c[i]\n}\n\nfunc (c cities) Less(i, j int) bool {\n\treturn c[i].year < c[j].year\n}\n", "test_IO": [ { "input": "2 3\n1 32\n2 63\n1 12\n", "output": "000001000002\n000002000001\n000001000001\n" } ] }, { "id": "s913685556", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tA, B := sc.NextInt(), sc.NextInt()\n\n\tmx := max(A+B, A-B)\n\tmx = max(mx, A*B)\n\tfmt.Println(mx)\n}\n\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextFloat() float64 {\n\tv, _ := strconv.ParseFloat(s.Next(), 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "-13 3\n", "output": "-10\n" } ] }, { "id": "s048939108", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tsc := newScanner()\n\tS := sc.next()\n\tif strings.HasPrefix(S, \"YAKI\") {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n\n}\n\nfunc min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc newScanner() *scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &scanner{r: rdr}\n}\nfunc (s *scanner) next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *scanner) nextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *scanner) nextInt() int {\n\tv, _ := strconv.Atoi(s.next())\n\treturn v\n}\nfunc (s *scanner) nextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\nfunc (s *scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "YAKINIKU\n", "output": "Yes\n" } ] }, { "id": "s512742019", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\ntype Scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc NewScanner() *Scanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 1024), int(1e+9))\n\treturn &Scanner{sc}\n}\n\nfunc (s *Scanner) nextStr() string {\n\ts.sc.Scan()\n\treturn s.sc.Text()\n}\n\nfunc (s *Scanner) nextInt() int {\n\ti, e := strconv.Atoi(s.nextStr())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (s *Scanner) nextFloat() float64 {\n\tf, e := strconv.ParseFloat(s.nextStr(), 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn f\n}\n\nfunc (s *Scanner) nextRuneSlice() []rune {\n\treturn []rune(s.nextStr())\n}\n\nfunc (s *Scanner) nextIntSlice(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextInt()\n\t}\n\treturn res\n}\n\nfunc (s *Scanner) nextFloatSlice(n int) []float64 {\n\tres := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextFloat()\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tm := nums[0]\n\tfor _, i := range nums {\n\t\tif m < i {\n\t\t\tm = i\n\t\t}\n\t}\n\treturn m\n}\n\nfunc min(nums ...int) int {\n\tm := nums[0]\n\tfor _, i := range nums {\n\t\tif m > i {\n\t\t\tm = i\n\t\t}\n\t}\n\treturn m\n}\n\nfunc abs(x int) int {\n\tif x > 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc pow(x, y int) int {\n\tres := 1\n\tfor i := 0; i < y; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\nfunc ceil(a, b int) int {\n\tif a%b == 0 {\n\t\treturn a / b\n\t} else {\n\t\treturn a/b + 1\n\t}\n}\n\ntype RuneSlice []rune\n\nfunc (a RuneSlice) Len() int { return len(a) }\nfunc (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }\nfunc (a RuneSlice) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\n\nconst MOD = int(1e+9) + 7\nconst INF = 1 << 60\n\ntype Mon struct {\n\tx, h int\n}\n\ntype Mons []Mon\n\nfunc (a Mons) Len() int { return len(a) }\nfunc (a Mons) Less(i, j int) bool { return a[i].x < a[j].x }\nfunc (a Mons) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\n\ntype Node struct {\n\tx, h int\n}\n\ntype Queue struct {\n\tarr []Node\n}\n\nfunc (q *Queue) push(v Node) {\n\tq.arr = append(q.arr, v)\n}\n\nfunc (q *Queue) first() Node {\n\treturn q.arr[0]\n}\n\nfunc (q *Queue) pop() Node {\n\tres := q.arr[0]\n\tq.arr = q.arr[1:]\n\treturn res\n}\n\nfunc (q *Queue) isEmpty() bool {\n\treturn len(q.arr) == 0\n}\n\nfunc main() {\n\tsc := NewScanner()\n\twtr := bufio.NewWriter(os.Stdout)\n\tN, D, A := sc.nextInt(), sc.nextInt(), sc.nextInt()\n\tM := make([]Mon, N)\n\tfor i := 0; i < N; i++ {\n\t\tM[i] = Mon{sc.nextInt(), sc.nextInt()}\n\t}\n\tsort.Sort(Mons(M))\n\tvar q Queue\n\tans := 0\n\ttotal := 0\n\tfor i := 0; i < N; i++ {\n\t\tm := M[i]\n\t\tfor !q.isEmpty() && q.first().x < m.x {\n\t\t\ttotal -= q.pop().h\n\t\t}\n\t\tif total < m.h {\n\t\t\tm.h -= total\n\t\t\tcount := ceil(m.h, A)\n\t\t\tans += count\n\t\t\tdamage := count * A\n\t\t\tq.push(Node{m.x + 2*D, damage})\n\t\t\ttotal += damage\n\t\t}\n\t}\n\n\tfmt.Fprintln(wtr, ans)\n\twtr.Flush()\n}\n", "test_IO": [ { "input": "3 3 2\n1 2\n5 4\n9 2\n", "output": "2\n" } ] }, { "id": "s102334995", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tfmt.Println(a*b, (a+b)*2)\n}\n", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s822496038", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tappleNum := nextInt()\n\tpieceNum := nextInt()\n\tpieceNumMadeFromApples := appleNum * 3\n\ttotalPiece := pieceNumMadeFromApples + pieceNum\n\tfmt.Println(totalPiece / 2)\n}\n", "test_IO": [ { "input": "1 3\n", "output": "3\n" } ] }, { "id": "s363337466", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc walkOnMultiplicationTable(num int) int {\n\n\tdiv := 0\n\tfor i := int(math.Sqrt(float64(num))); i > 1; i-- {\n\t\tif num%i == 0 {\n\t\t\tdiv = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif div == 0 {\n\t\treturn num - 1\n\t}\n\treturn div + num/div - 2\n\n}\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\tfmt.Println(walkOnMultiplicationTable(a))\n}\n", "test_IO": [ { "input": "10\n", "output": "5\n" } ] }, { "id": "s150867340", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tif product := a * b; product%2 == 0 {\n\t\tfmt.Println(\"Even\")\n\t} else {\n\t\tfmt.Println(\"Odd\")\n\t}\n}\n", "test_IO": [ { "input": "3 4\n", "output": "Even\n" } ] }, { "id": "s577481826", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc read() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\ta, _ := strconv.Atoi(read())\n\tb, _ := strconv.Atoi(read())\n\n\tret := a + b\n\n\tif ret < (a - b) {\n\t\tret = a - b\n\t}\n\tif ret < (a * b) {\n\t\tret = a * b\n\t}\n\n\tfmt.Println(ret)\n}\n", "test_IO": [ { "input": "3 1\n", "output": "4\n" } ] }, { "id": "s141943854", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc check(e error) {\n\tif e != nil {\n\t\tlog.Fatalf(\"error: %v\", e)\n\t}\n}\n\nfunc main() {\n\tstdin := bufio.NewScanner(os.Stdin)\n\tstdin.Scan()\n\tsage := stdin.Text()\n\n\tswitch sage {\n\tcase \"1\":\n\t\tfmt.Println(\"Hello World\")\n\tcase \"2\":\n\t\tvar sum int\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tstdin.Scan()\n\t\t\tnum, err := strconv.Atoi(stdin.Text())\n\t\t\tcheck(err)\n\t\t\tsum += num\n\t\t}\n\t\tfmt.Println(sum)\n\t}\n}\n", "test_IO": [ { "input": "1\n", "output": "Hello World\n" } ] }, { "id": "s870102598", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tif c >= a && c <= b {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "1 3 2\n", "output": "Yes\n" } ] }, { "id": "s050367086", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextUint64(scanner *bufio.Scanner) uint64 {\n\ti, _ := strconv.ParseUint(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextFloat64(scanner *bufio.Scanner) float64 {\n\ti, _ := strconv.ParseFloat(getNextString(scanner), 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\twfp := os.Stdout\n\n\tif os.Getenv(\"MASPY\") == \"\u307e\u3059\u30d4\" {\n\t\tfp, _ = os.Open(os.Getenv(\"BEET_THE_HARMONY_OF_PERFECT\"))\n\t}\n\tif os.Getenv(\"MASPYPY\") == \"\u307e\u3059\u30d4\u30c3\u30d4\" {\n\t\twfp, _ = os.Create(os.Getenv(\"NGTKANA_IS_GENIUS10\"))\n\t}\n\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(wfp)\n\n\ts := getNextString(scanner)\n\tt := getNextString(scanner)\n\n\tns := len(s)\n\tnt := len(t)\n\tss := make([]string, (nt-1)/ns+1)\n\n\tfor i := 0; i < len(ss); i++ {\n\t\tss[i] = s\n\t}\n\n\tsss := fmt.Sprintf(\"%s%s\", strings.Join(ss, \"\"), strings.Join(ss, \"\"))\n\n\tok := make([]bool, ns)\n\n\tuni := make([]int, ns)\n\tmp := MP{}\n\tmp.init(t)\n\tm := 0\n\tfor i := 0; i < ns; i++ {\n\t\tuni[i] = i\n\t}\n\tvar o bool\n\tfor i := 0; i < ns; i++ {\n\t\to = true\n\t\tfor m < nt {\n\t\t\tif t[m] != sss[i+m] {\n\t\t\t\to = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tm++\n\t\t}\n\t\tok[i] = o\n\t\tif o {\n\t\t\ti += nt - mp.table[m]\n\t\t\tm = mp.table[m]\n\t\t}\n\t\tfor m >= 0 && t[m] != sss[i+m] {\n\t\t\ti += m - mp.table[m]\n\t\t\tm = mp.table[m]\n\t\t}\n\t\ti--\n\t\tm++\n\t}\n\n\tans := 0\n\tvar r, rr int\n\tfor i := 0; i < ns; i++ {\n\t\tif ok[i] == false {\n\t\t\tcontinue\n\t\t}\n\t\tif ok[(i+nt)%ns] == false {\n\t\t\tcontinue\n\t\t}\n\t\tr = root(i, uni)\n\t\trr = root((i+nt)%ns, uni)\n\t\tif rr == r {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t\tuni[rr] = r\n\t}\n\n\tcounter := make([]int, ns)\n\tfor i := 0; i < ns; i++ {\n\t\tr = root(i, uni)\n\t\tif ok[r] == false {\n\t\t\tcontinue\n\t\t}\n\t\tcounter[r]++\n\t}\n\tfor i := 0; i < ns; i++ {\n\t\tif ans < counter[i] {\n\t\t\tans = counter[i]\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n\twriter.Flush()\n}\n\nfunc root(i int, uni []int) int {\n\tif i == uni[i] {\n\t\treturn i\n\t}\n\n\tuni[i] = root(uni[i], uni)\n\treturn uni[i]\n}\n\ntype MP struct {\n\ts string\n\ttable []int\n}\n\nfunc (mp *MP) init(s string) {\n\tmp.s = s\n\tn := len(s)\n\ttable := make([]int, n+1)\n\ttable[0] = -1\n\tj := -1\n\tfor i := 0; i < n; i++ {\n\t\tfor j >= 0 && s[i] != s[j] {\n\t\t\tj = table[j]\n\t\t}\n\t\tj++\n\t\ttable[i+1] = j\n\t}\n\tmp.table = table\n}\n", "test_IO": [ { "input": "abcabab\nab\n", "output": "3\n" } ] }, { "id": "s596502954", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, _ := strconv.Atoi(sc.Text())\n\treturn i\n}\n\nfunc nextFloat64() float64 {\n\tf, _ := strconv.ParseFloat(next(), 64)\n\treturn f\n}\n\nfunc nextInts(n int) []int {\n\tslice := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tslice[i] = nextInt()\n\t}\n\treturn slice\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tif nextInt()+nextInt() >= nextInt() {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "50 100 120\n", "output": "Yes\n" } ] }, { "id": "s192968897", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"unicode\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tl := len(s)\n\tans := \"AC\"\n\tif s[0] != 'A' {\n\t\tans = \"WA\"\n\t}\n\tcnt := 0\n\tfor i := 1; i < l; i++ {\n\t\tif unicode.IsUpper(rune(s[i])) {\n\t\t\tif i == 1 || i == l-1 || s[i] != 'C' {\n\t\t\t\tans = \"WA\"\n\t\t\t}\n\t\t\tcnt++\n\t\t}\n\t}\n\tif cnt != 1 {\n\t\tans = \"WA\"\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "AtCoder\n", "output": "AC\n" } ] }, { "id": "s255858499", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc nextLine() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tvar a, _ = strconv.Atoi(nextLine())\n\tvar b, _ = strconv.Atoi(nextLine())\n\n\tif a*b%2 != 0 {\n\t\tfmt.Println(\"Odd\")\n\t} else {\n\t\tfmt.Println(\"Even\")\n\t}\n}\n", "test_IO": [ { "input": "3 4\n", "output": "Even\n" } ] }, { "id": "s969060017", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\n\tif b%a == 0 {\n\t\tfmt.Println(a + b)\n\t} else {\n\t\tfmt.Println(b - a)\n\t}\n}\n", "test_IO": [ { "input": "4 12\n", "output": "16\n" } ] }, { "id": "s187065108", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc scanInt() int {\n\tnum, _ := strconv.Atoi(scanString())\n\treturn num\n}\n\nfunc scanString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc scanInts(n int) []int {\n\tsl := make([]int, n)\n\tfor i := range sl {\n\t\tsl[i] = scanInt()\n\t}\n\treturn sl\n}\n\nfunc scanStrings(n int) []string {\n\tsl := make([]string, n)\n\tfor i := range sl {\n\t\tsl[i] = scanString()\n\t}\n\treturn sl\n}\n\nfunc init() {\n\tsc.Split(bufio.ScanWords)\n}\n\nfunc main() {\n\tr, D, x := scanInt(), scanInt(), scanInt()\n\tfor i := 1; i <= 10; i++ {\n\t\tx = r*x - D\n\t\tfmt.Println(x)\n\t}\n}\n", "test_IO": [ { "input": "2 10 20\n", "output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n" } ] }, { "id": "s984400335", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(nums ...int) int {\n\tmin := nums[0]\n\tfor _, v := range nums {\n\t\tif v < min {\n\t\t\tmin = v\n\t\t}\n\t}\n\treturn min\n}\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scan(&n, &a, &b)\n\n\tfmt.Println(min(n*a, b))\n}\n", "test_IO": [ { "input": "7 17 120\n", "output": "119\n" } ] }, { "id": "s695527706", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n, &s)\n\tfmt.Println(strings.Count(s, \"ABC\"))\n}\n", "test_IO": [ { "input": "10\nZABCDBABCQ\n", "output": "2\n" } ] }, { "id": "s269502139", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype node struct {\n\tkey int32\n\tprev *node\n\tnext *node\n}\n\nfunc (n *node) rPrint(buf *bytes.Buffer) {\n\tbuf.WriteString(fmt.Sprint(n.key))\n\tif n.next != nil {\n\t\tbuf.WriteString(\" \")\n\t\tn.next.rPrint(buf)\n\t}\n\treturn\n}\n\nfunc (n *node) Delete(first, last *node) (*node, *node) {\n\tif n.prev != nil && n.next != nil {\n\n\t\tn.prev.next = n.next\n\t\tn.next.prev = n.prev\n\t\treturn first, last\n\t}\n\n\tif n.next == nil && n.prev == nil {\n\t\treturn nil, nil\n\t}\n\n\tif n.prev == nil {\n\t\tfirst = n.next\n\t\tn.next.prev = nil\n\t}\n\n\tif n.next == nil {\n\t\tlast = n.prev\n\t\tn.prev.next = nil\n\t}\n\n\treturn first, last\n}\n\nfunc initNode(key int32) *node {\n\treturn &node{\n\t\tkey: key,\n\t}\n}\n\nfunc main() {\n\tstdin := bufio.NewScanner(os.Stdin)\n\tvar first, last *node\n\tstdin.Scan()\n\n\tfor stdin.Scan() {\n\t\tcmd := stdin.Text()\n\t\tswitch cmd {\n\t\tcase \"deleteFirst\":\n\t\t\tfirst, last = first.Delete(first, last)\n\t\tcase \"deleteLast\":\n\t\t\tfirst, last = last.Delete(first, last)\n\t\tdefault:\n\t\t\txcmd := strings.Split(cmd, \" \")\n\t\t\tk, _ := strconv.Atoi(xcmd[1])\n\t\t\tk32 := int32(k)\n\t\t\tswitch xcmd[0] {\n\t\t\tcase \"delete\":\n\t\t\t\tfor a := first; a != nil; a = a.next {\n\t\t\t\t\tif a.key == k32 {\n\t\t\t\t\t\tfirst, last = a.Delete(first, last)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase \"insert\":\n\t\t\t\tn := initNode(k32)\n\t\t\t\tn.next = first\n\t\t\t\tif first != nil {\n\t\t\t\t\tfirst.prev = n\n\t\t\t\t}\n\n\t\t\t\tfirst = n\n\t\t\t\tif last == nil {\n\t\t\t\t\tlast = n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tvar buf bytes.Buffer\n\tfirst.rPrint(&buf)\n\tfmt.Println(buf.String())\n}\n", "test_IO": [ { "input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n", "output": "6 1 2\n" } ] }, { "id": "s447509781", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tinput := Input{bufio.NewReaderSize(os.Stdin, 1000000)}\n\tn := input.NextInt()\n\ts := input.NextIntArray()\n\tu := make([]bool, n)\n\tvar m, f int64\n\tfor c := 1; c < n-1; c++ {\n\t\tf = 0\n\t\tfor k := 0; c < n-1-k*c; k++ {\n\t\t\tu[k*c] = true\n\t\t\tif u[n-1-k*c] {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tf += s[n-1-k*c] + s[k*c]\n\t\t\tif m < f {\n\t\t\t\tm = f\n\t\t\t}\n\t\t}\n\t\tfor k := 0; k*c < n-1; k++ {\n\t\t\tu[k*c] = false\n\t\t}\n\t}\n\tfmt.Println(m)\n}\n\ntype Input struct {\n\treader *bufio.Reader\n}\n\nfunc (i *Input) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := i.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}\nfunc (i *Input) NextInt() int {\n\tn, _ := strconv.Atoi(i.NextLine())\n\treturn n\n}\nfunc (i *Input) NextIntArray() []int64 {\n\ts := strings.Split(i.NextLine(), \" \")\n\ta := make([]int64, len(s))\n\tfor i := 0; i < len(s); i++ {\n\t\ta[i], _ = strconv.ParseInt(s[i], 10, 64)\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "5\n0 2 5 1 0\n", "output": "3\n" } ] }, { "id": "s870655271", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar N, M int\n\tvar ans int\n\tfmt.Scan(&N, &M)\n\tif N == 1 && M == 1 {\n\t\tans += 1\n\t} else if 1 < N && 1 < M {\n\t\tans += (N - 2) * (M - 2)\n\t} else {\n\t\tans += (N * M) - 2\n\t}\n\n\tfmt.Println(ans)\n}\n\nfunc max(x ...int) int {\n\tvar res int = x[0]\n\tfor i := 1; i < len(x); i++ {\n\t\tres = int(math.Max(float64(x[i]), float64(res)))\n\t}\n\treturn res\n}\n\nfunc min(x ...int) int {\n\tvar res int = x[0]\n\tfor i := 1; i < len(x); i++ {\n\t\tres = int(math.Min(float64(x[i]), float64(res)))\n\t}\n\treturn res\n}\nfunc pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }\nfunc abs(x int) int { return int(math.Abs(float64(x))) }\nfunc floor(x int) int { return int(math.Floor(float64(x))) }\n\ntype SortBy []int\n\nfunc (a SortBy) Len() int { return len(a) }\nfunc (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }\n", "test_IO": [ { "input": "2 2\n", "output": "0\n" } ] }, { "id": "s323794848", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype deque struct {\n\tfront, back []byte\n}\n\nfunc (deq *deque) isEmptyFront() bool {\n\treturn len(deq.front) == 0\n}\nfunc (deq *deque) isEmptyBack() bool {\n\treturn len(deq.back) == 0\n}\n\nfunc (deq *deque) pushBack(v byte) {\n\tdeq.back = append(deq.back, v)\n}\nfunc (deq *deque) pushFront(v byte) {\n\tdeq.front = append(deq.front, v)\n}\nfunc (deq *deque) popBack(v *byte) bool {\n\tr := true\n\tif !deq.isEmptyBack() {\n\t\t*v = deq.back[len(deq.back)-1]\n\t\tdeq.back = deq.back[:len(deq.back)-1]\n\t} else if !deq.isEmptyFront() {\n\t\t*v = deq.front[0]\n\t\tdeq.front = deq.front[1:]\n\t} else {\n\t\tr = false\n\t}\n\treturn r\n}\nfunc (deq *deque) popFront(v *byte) bool {\n\tr := true\n\tif !deq.isEmptyFront() {\n\t\t*v = deq.front[len(deq.front)-1]\n\t\tdeq.front = deq.front[:len(deq.front)-1]\n\t} else if !deq.isEmptyBack() {\n\t\t*v = deq.back[0]\n\t\tdeq.back = deq.back[1:]\n\t} else {\n\t\tr = false\n\t}\n\treturn r\n}\n\nfunc (deq *deque) get(idx int) byte {\n\ttot := len(deq.front) + len(deq.back)\n\tvar v byte\n\tif idx < tot {\n\t\tif idx < len(deq.front) {\n\t\t\tv = deq.front[len(deq.front)-1-idx]\n\t\t} else {\n\t\t\tv = deq.back[idx-len(deq.front)]\n\t\t}\n\t}\n\treturn v\n}\n\ntype op struct {\n\trev, front bool\n\tc byte\n}\n\nfunc rev(s string) string {\n\tr := make([]byte, len(s))\n\ti, j := len(s)-1, 0\n\tfor i >= 0 {\n\t\tr[j] = s[i]\n\t\tj++\n\t\ti--\n\t}\n\treturn string(r)\n}\n\nfunc main() {\n\tvar S string\n\tfmt.Scan(&S)\n\tvar Q int\n\tfmt.Scan(&Q)\n\tops := make([]op, Q)\n\tfor i := 0; i < Q; i++ {\n\t\tvar q int\n\t\tfmt.Scan(&q)\n\t\tif q == 1 {\n\t\t\tops[i].rev = true\n\t\t} else {\n\t\t\tvar f int\n\t\t\tfmt.Scanf(\"%d %c\", &f, &ops[i].c)\n\t\t\tif f == 1 {\n\t\t\t\tops[i].front = true\n\t\t\t}\n\t\t}\n\t}\n\tsum := make([]int, Q+1)\n\tfor i := Q - 1; i >= 1; i-- {\n\t\tif ops[i].rev {\n\t\t\tsum[i-1] = sum[i] + 1\n\t\t} else {\n\t\t\tsum[i-1] = sum[i]\n\t\t}\n\t}\n\n\tif sum[0]%2 == 1 {\n\t\tS = rev(S)\n\t}\n\tvar deq deque\n\tfor i := 0; i < Q; i++ {\n\t\tif !ops[i].rev {\n\t\t\tif ops[i].front {\n\t\t\t\tif sum[i]%2 == 1 {\n\t\t\t\t\tdeq.pushBack(ops[i].c)\n\t\t\t\t} else {\n\t\t\t\t\tdeq.pushFront(ops[i].c)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif sum[i]%2 == 1 {\n\t\t\t\t\tdeq.pushFront(ops[i].c)\n\t\t\t\t} else {\n\t\t\t\t\tdeq.pushBack(ops[i].c)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\twtr := bufio.NewWriter(os.Stdout)\n\n\tfor i := len(deq.front) - 1; i >= 0; i-- {\n\t\tfmt.Fprint(wtr, string(deq.front[i]))\n\t}\n\tfor i := 0; i < len(S); i++ {\n\t\tfmt.Fprint(wtr, string(S[i]))\n\t}\n\tfor i := 0; i < len(deq.back); i++ {\n\t\tfmt.Fprint(wtr, string(deq.back[i]))\n\t}\n\tfmt.Fprintln(wtr)\n\twtr.Flush()\n}\n", "test_IO": [ { "input": "a\n4\n2 1 p\n1\n2 2 c\n1\n", "output": "cpa\n" } ] }, { "id": "s136583229", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar data int\n\tfmt.Scan(&data)\n\tvar result = data * data * data\n\tfmt.Printf(\"%d\\n\", result)\n}\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s589878052", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, h int\n\tfmt.Scan(&a, &b, &h)\n\n\tfmt.Println((a + b) * h / 2)\n}\n", "test_IO": [ { "input": "3\n4\n2\n", "output": "7\n" } ] }, { "id": "s546282715", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getNextWord(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextWord(scanner))\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t}\n\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\n\tn := getNextInt(scanner)\n\tm := getNextInt(scanner)\n\taa := make(map[int]int, 0)\n\tfor i := 0; i < m; i++ {\n\t\taa[getNextInt(scanner)] = 1\n\t}\n\n\tdp := make([]int, n+1)\n\tdp[0] = 1\n\tfor i := 0; i < n; i++ {\n\t\tfor ii := 1; ii <= 2 && i+ii <= n; ii++ {\n\t\t\t_, ok := aa[i+ii]\n\t\t\tif ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdp[i+ii] += dp[i]\n\t\t\tdp[i+ii] %= 1000000007\n\t\t}\n\t}\n\tfmt.Fprintln(writer, dp[n])\n\n\twriter.Flush()\n}\n", "test_IO": [ { "input": "6 1\n3\n", "output": "4\n" } ] }, { "id": "s774791701", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tprice := 700\n\tfor _, c := range s {\n\t\tif c == 'o' {\n\t\t\tprice += 100\n\t\t}\n\t}\n\tfmt.Println(price)\n}\n", "test_IO": [ { "input": "oxo\n", "output": "900\n" } ] }, { "id": "s464350089", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst mod = 1000000007\n\nconst ioBufferSize = 1 * 1024 * 1024\n\nvar sc = func() *bufio.Scanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Buffer(make([]byte, ioBufferSize), ioBufferSize)\n\tsc.Split(bufio.ScanWords)\n\treturn sc\n}()\n\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc main() {\n\th, n := nextInt(), nextInt()\n\ta := 0\n\n\tfor i := 0; i < n; i++ {\n\t\ta += nextInt()\n\t}\n\n\tif h > a {\n\t\tfmt.Println(\"No\")\n\t} else {\n\t\tfmt.Println(\"Yes\")\n\t}\n}\n", "test_IO": [ { "input": "10 3\n4 5 6\n", "output": "Yes\n" } ] }, { "id": "s584033358", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\n\tif k <= (n+n%2)/2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n", "test_IO": [ { "input": "3 2\n", "output": "YES\n" } ] }, { "id": "s693332680", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t_ \"bufio\"\n\t\"fmt\"\n\t_ \"os\"\n\t_ \"strconv\"\n)\n\nfunc main() {\n\tvar x, a, b int\n\tfmt.Scan(&x, &a, &b)\n\tswitch {\n\tcase b-a <= 0:\n\t\tfmt.Println(\"delicious\")\n\t\tbreak\n\tcase b-a <= x:\n\t\tfmt.Println(\"safe\")\n\t\tbreak\n\tdefault:\n\t\tfmt.Println(\"dangerous\")\n\t\tbreak\n\t}\n}\n", "test_IO": [ { "input": "4 3 6\n", "output": "safe\n" } ] }, { "id": "s506882149", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc comp(x, a int) int {\n\tif x < a {\n\t\treturn 0\n\t}\n\treturn 10\n}\n\nfunc main() {\n\tvar x, a int\n\tfmt.Scan(&x, &a)\n\n\tfmt.Println(comp(x, a))\n}\n", "test_IO": [ { "input": "3 5\n", "output": "0\n" } ] }, { "id": "s824350268", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tinitialBufSize = 10000\n\tmaxBufSize = 1000000\n\tmod = 1e9 + 7\n)\n\nvar (\n\tsc *bufio.Scanner = func() *bufio.Scanner {\n\t\tsc := bufio.NewScanner(os.Stdin)\n\t\tbuf := make([]byte, initialBufSize)\n\t\tsc.Buffer(buf, maxBufSize)\n\t\tsc.Split(bufio.ScanWords)\n\t\treturn sc\n\t}()\n)\n\nfunc main() {\n\tN := getInt()\n\tsqrtN := int(math.Sqrt(float64(N)))\n\n\tmin := N\n\tfor i := 1; i <= sqrtN; i++ {\n\t\tif N%i != 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tnum := i + (N / i) - 2\n\t\tif num < min {\n\t\t\tmin = num\n\t\t}\n\t}\n\n\tfmt.Println(min)\n}\n\ntype Graph struct {\n\tn int\n\tedges [][]int\n}\n\nfunc NewGraph(n int) *Graph {\n\tg := &Graph{\n\t\tn: n,\n\t\tedges: make([][]int, n),\n\t}\n\treturn g\n}\n\nfunc (g *Graph) AddEdge(u, v int) {\n\tg.edges[v] = append(g.edges[v], u)\n\tg.edges[u] = append(g.edges[u], v)\n}\n\nfunc dfs(c int, edges [][]int, visited map[int]struct{}) {\n\tvisited[c] = struct{}{}\n\n\tfor _, v := range edges[c] {\n\t\t_, flag := visited[v]\n\t\tif flag {\n\t\t\tcontinue\n\t\t}\n\t\tdfs(v, edges, visited)\n\t}\n}\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc abs(a int) int {\n\treturn int(math.Abs(float64(a)))\n}\n\nfunc pow(p, q int) int {\n\treturn int(math.Pow(float64(p), float64(q)))\n}\n\nfunc powMod(n, p int) int {\n\tif p == 0 {\n\t\treturn 1\n\t} else if p%2 == 0 {\n\t\tt := powMod(n, p/2)\n\t\treturn calcMod(t * t)\n\t} else {\n\t\treturn calcMod(n * powMod(n, p-1))\n\t}\n}\n\nfunc min(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton min() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Min(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton max() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Max(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc strSearch(a []string, b string) bool {\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] == b {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc printIntArray(array []int) {\n\tstrArray := fmt.Sprint(array)\n\tfmt.Println(strArray[1 : len(strArray)-1])\n}\n\nfunc calcMod(x int) int {\n\treturn x % mod\n}\n\nfunc reverse(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}\n\nfunc isPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t} else if n == 2 {\n\t\treturn true\n\t} else if n%2 == 0 {\n\t\treturn false\n\t}\n\n\tsqrtN := int(math.Sqrt(float64(n)))\n\tfor i := 3; i <= sqrtN; i += 2 {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n", "test_IO": [ { "input": "10\n", "output": "5\n" } ] }, { "id": "s633919449", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"container/heap\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tinitialBufSize = 10000\n\tmaxBufSize = 1000000\n\tmod = 1e9 + 7\n)\n\nvar (\n\tsc *bufio.Scanner = func() *bufio.Scanner {\n\t\tsc := bufio.NewScanner(os.Stdin)\n\t\tbuf := make([]byte, initialBufSize)\n\t\tsc.Buffer(buf, maxBufSize)\n\t\tsc.Split(bufio.ScanWords)\n\t\treturn sc\n\t}()\n)\n\nfunc main() {\n\tN := getInt()\n\n\tswitch N % 10 {\n\tcase 2, 4, 5, 7, 9:\n\t\tfmt.Println(\"hon\")\n\tcase 0, 1, 6, 8:\n\t\tfmt.Println(\"pon\")\n\tcase 3:\n\t\tfmt.Println(\"bon\")\n\t}\n}\n\ntype Graph struct {\n\tn int\n\tedges [][]int\n}\n\nfunc NewGraph(n int) *Graph {\n\tg := &Graph{\n\t\tn: n,\n\t\tedges: make([][]int, n),\n\t}\n\treturn g\n}\n\nfunc (g *Graph) AddEdge(u, v int) {\n\tg.edges[v] = append(g.edges[v], u)\n\tg.edges[u] = append(g.edges[u], v)\n}\n\nfunc dfs(c int, edges [][]int, visited map[int]struct{}) {\n\tvisited[c] = struct{}{}\n\n\tfor _, v := range edges[c] {\n\t\t_, flag := visited[v]\n\t\tif flag {\n\t\t\tcontinue\n\t\t}\n\t\tdfs(v, edges, visited)\n\t}\n}\n\nfunc bfs(c int, graph *Graph) {\n\tnext := make([]int, 0)\n\tnext = append(next, c)\n\tvisited := make(map[int]struct{})\n\n\tfor len(next) != 0 {\n\t\tu := next[0]\n\t\tnext = next[1:]\n\t\tvisited[u] = struct{}{}\n\n\t\tfor _, v := range graph.edges[u] {\n\t\t\t_, flag := visited[v]\n\t\t\tif flag {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tnext = append(next, v)\n\t\t}\n\t}\n}\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getIntArray(n int) []int {\n\tarray := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tarray[i] = getInt()\n\t}\n\treturn array\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc getStringArray(n int) []string {\n\tarray := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tarray[i] = getString()\n\t}\n\treturn array\n}\n\nfunc abs(a int) int {\n\treturn int(math.Abs(float64(a)))\n}\n\nfunc pow(p, q int) int {\n\treturn int(math.Pow(float64(p), float64(q)))\n}\n\nfunc powMod(n, p int) int {\n\tif p == 0 {\n\t\treturn 1\n\t} else if p%2 == 0 {\n\t\tt := powMod(n, p/2)\n\t\treturn calcMod(t * t)\n\t} else {\n\t\treturn calcMod(n * powMod(n, p-1))\n\t}\n}\n\nfunc min(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton min() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Min(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc max(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton max() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Max(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc strSearch(a []string, b string) bool {\n\tfor i := 0; i < len(a); i++ {\n\t\tif a[i] == b {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc printIntArray(array []int) {\n\tstrArray := fmt.Sprint(array)\n\tfmt.Println(strArray[1 : len(strArray)-1])\n}\n\nfunc calcMod(x int) int {\n\treturn x % mod\n}\n\nfunc reverse(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}\n\nfunc isPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t} else if n == 2 {\n\t\treturn true\n\t} else if n%2 == 0 {\n\t\treturn false\n\t}\n\n\tsqrtN := int(math.Sqrt(float64(n)))\n\tfor i := 3; i <= sqrtN; i += 2 {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc contains(s []int, e int) bool {\n\tfor _, v := range s {\n\t\tif e == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc makeRange(min, max int) []int {\n\ta := make([]int, max-min+1)\n\tfor i := range a {\n\t\ta[i] = min + i\n\t}\n\treturn a\n}\n\nfunc powerset2(nums []int) [][]int {\n\tlength := int(math.Pow(2, float64(len(nums))))\n\tresult := make([][]int, length)\n\n\tindex := 0\n\tresult[index] = []int{}\n\tindex++\n\n\tfor _, n := range nums {\n\t\tmax := index\n\t\tfor i := 0; i < max; i++ {\n\t\t\tresult[index] = copyAndAppend(result[i], n)\n\t\t\tindex++\n\t\t}\n\t}\n\n\treturn result\n}\n\nfunc copyAndAppend(nums []int, n int) []int {\n\tdst := make([]int, len(nums)+1)\n\tcopy(dst, nums)\n\tdst[len(nums)] = n\n\treturn dst\n}\n\nfunc calcGcd(x, y int) int {\n\tif y == 0 {\n\t\treturn x\n\t} else if x >= y {\n\t\treturn calcGcd(y, x%y)\n\t} else {\n\t\treturn calcGcd(x, y%x)\n\t}\n}\n\nfunc getDivisor(n int) []int {\n\tdivisor := make(map[int]struct{})\n\tdivisor[1] = struct{}{}\n\tif n != 1 {\n\t\tdivisor[n] = struct{}{}\n\t}\n\n\tsqrt := int(math.Sqrt(float64(n)))\n\tfor i := 2; i <= sqrt; i++ {\n\t\tif n%i == 0 {\n\t\t\tdivisor[i] = struct{}{}\n\t\t\tdivisor[n/i] = struct{}{}\n\t\t}\n\t}\n\n\tvar divisorArray []int\n\tfor d := range divisor {\n\t\tdivisorArray = append(divisorArray, d)\n\t}\n\treturn divisorArray\n}\n\ntype intHeap []int\n\nfunc (h intHeap) Len() int {\n\treturn len(h)\n}\n\nfunc (h intHeap) Less(i, j int) bool {\n\treturn h[i] > h[j]\n}\n\nfunc (h intHeap) Swap(i, j int) {\n\th[i], h[j] = h[j], h[i]\n}\n\nfunc (h *intHeap) Push(x interface{}) {\n\t*h = append(*h, x.(int))\n}\n\nfunc (h *intHeap) Pop() interface{} {\n\told := *h\n\tn := len(old)\n\tx := old[n-1]\n\t*h = old[0 : n-1]\n\treturn x\n}\n\nfunc initHeap() *intHeap {\n\tih := &intHeap{}\n\theap.Init(ih)\n\treturn ih\n}\n\nfunc (h *intHeap) pushHeap(n int) {\n\theap.Push(h, n)\n}\n\nfunc (h *intHeap) popHeap() int {\n\treturn heap.Pop(h).(int)\n}\n\nfunc factMod(n int) int {\n\tvalue := 1\n\tfor ; n > 1; n-- {\n\t\tvalue = calcMod(value * n)\n\t}\n\treturn value\n}\n\nfunc combinationMod(n, k int) int {\n\tfactN := factMod(n)\n\tfactK := factMod(k)\n\tfactNK := factMod(n - k)\n\tfactKR := powMod(factK, mod-2)\n\tfactNKR := powMod(factNK, mod-2)\n\treturn calcMod(factN * calcMod(factKR*factNKR))\n}\n\nfunc primeFactors(n int) []int {\n\tfactors := make([]int, 0)\n\ti := 2\n\tfor i*i <= n {\n\t\tr := n % i\n\t\tif r != 0 {\n\t\t\ti += 1\n\t\t} else if r == 0 {\n\t\t\tn /= i\n\t\t\tfactors = append(factors, i)\n\t\t}\n\t}\n\tif n > 1 {\n\t\tfactors = append(factors, n)\n\t}\n\treturn factors\n}\n", "test_IO": [ { "input": "16\n", "output": "pon\n" } ] }, { "id": "s601720340", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"flag\"\n\t\"runtime\"\n\t\"runtime/pprof\"\n)\n\nvar magic = 1000000007\n\nvar cpuprofile = flag.String(\"cpuprofile\", \"\", \"write cpu profile to file\")\nvar memprofile = flag.String(\"memprofile\", \"\", \"write mem profile to file\")\n\nvar N int\nvar p [200000]int\n\nfunc find(n int) int {\n\tfor i := 0; i < N; i++ {\n\t\tif n == p[i] {\n\t\t\treturn 0\n\t\t}\n\t}\n\treturn 1\n}\n\nfunc solve() {\n\tio := NewIo()\n\tdefer io.Flush()\n\n\tX := io.NextInt()\n\tLogf(\"%v\\n\", X)\n\tN = io.NextInt()\n\tLogf(\"%v\\n\", N)\n\tfor i := 0; i < N; i++ {\n\t\tp[i] = io.NextInt()\n\t}\n\tLogf(\"p %v\\n\", p[0:10])\n\n\tfor i := 0; i <= 100; i++ {\n\t\tif find(X-i) == 1 {\n\t\t\tfmt.Printf(\"%v\\n\", X-i)\n\t\t\tos.Exit(0)\n\t\t}\n\t\tif find(X+i) == 1 {\n\t\t\tfmt.Printf(\"%v\\n\", X+i)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n}\n\nfunc main() {\n\tflag.Parse()\n\tif *cpuprofile != \"\" {\n\t\tf, err := os.Create(*cpuprofile)\n\t\tif err != nil {\n\t\t\tLogf(\"%v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tpprof.StartCPUProfile(f)\n\t\tdefer pprof.StopCPUProfile()\n\t}\n\n\tsolve()\n\n\tif *memprofile != \"\" {\n\t\tf, err := os.Create(*memprofile)\n\t\tif err != nil {\n\t\t\tLogf(\"could not create memory profile: \", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tdefer f.Close()\n\t\truntime.GC()\n\t\tif err := pprof.WriteHeapProfile(f); err != nil {\n\t\t\tLogf(\"could not write memory profile: \", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}\n\ntype Io struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n\ttokens []string\n\tnextToken int\n}\n\nfunc NewIo() *Io {\n\treturn &Io{\n\t\treader: bufio.NewReader(os.Stdin),\n\t\twriter: bufio.NewWriter(os.Stdout),\n\t}\n}\n\nfunc (io *Io) Flush() {\n\terr := io.writer.Flush()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}\n\nfunc (io *Io) Next() string {\n\tfor io.nextToken >= len(io.tokens) {\n\t\tline := io.NextLine()\n\t\tio.tokens = strings.Fields(line)\n\t\tio.nextToken = 0\n\t}\n\tr := io.tokens[io.nextToken]\n\tio.nextToken++\n\treturn r\n}\n\nfunc (io *Io) NextInt() int {\n\ti, err := strconv.Atoi(io.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) NextFloat() float64 {\n\ti, err := strconv.ParseFloat(io.Next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) PrintLn(a ...interface{}) {\n\tfmt.Fprintln(io.writer, a...)\n}\n\nfunc (io *Io) Printf(format string, a ...interface{}) {\n\tfmt.Fprintf(io.writer, format, a...)\n}\n\nfunc (io *Io) PrintIntLn(a []int) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc (io *Io) PrintStringLn(a []string) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc Log(name string, value interface{}) {\n\tfmt.Fprintf(os.Stderr, \"%s=%+v\\n\", name, value)\n}\n\nfunc Logf(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\nfunc intMin(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc intMax(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc combination(n, m int) int {\n\tif m > n {\n\t\treturn 0\n\t} else if m == n || m == 0 {\n\t\treturn 1\n\t} else {\n\t\tres := 1\n\t\tfor i := 0; i < m; i++ {\n\t\t\tres *= (n - i)\n\t\t}\n\t\tfor i := 1; i <= m; i++ {\n\t\t\tres /= i\n\t\t}\n\t\treturn res\n\t}\n}\n\nfunc lucas(n, m, p int) int {\n\tntemp := n\n\tmtemp := m\n\tres := 1\n\tfor i := 0; i < 100; i++ {\n\n\t\tnreminder := ntemp % p\n\t\tntemp = ntemp / p\n\t\tmreminder := mtemp % p\n\t\tmtemp = mtemp / p\n\t\tres = res * (combination(nreminder, mreminder) % p)\n\t\tif ntemp == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res % p\n}\n\nfunc combMod(n, m, p int) int {\n\treturn lucas(n, m, p)\n}\n\nfunc bfs(start int, nodes map[int][]int, fn func(int)) {\n\tfrontier := []int{start}\n\tvisited := map[int]bool{}\n\n\tfor 0 < len(frontier) {\n\t\tnext := []int{}\n\t\tfor _, node := range frontier {\n\t\t\tvisited[node] = true\n\t\t\tfn(node)\n\t\t\tfor _, n := range bfsFrontier(node, nodes, visited) {\n\t\t\t\tnext = append(next, n)\n\t\t\t}\n\t\t}\n\t\tfrontier = next\n\t}\n}\n\nfunc bfsFrontier(node int, nodes map[int][]int, visited map[int]bool) []int {\n\tnext := []int{}\n\titer := func(n int) bool { _, ok := visited[n]; return !ok }\n\tfor _, n := range nodes[node] {\n\t\tif iter(n) {\n\t\t\tnext = append(next, n)\n\t\t}\n\t}\n\treturn next\n}\n\nfunc dfs(node int, nodes map[int][]int, fn func(int)) {\n\tdfsRecur(node, nodes, map[int]bool{}, fn)\n}\n\nfunc dfsRecur(node int, nodes map[int][]int, v map[int]bool, fn func(int)) {\n\tv[node] = true\n\tfn(node)\n\tfor _, n := range nodes[node] {\n\t\tif _, ok := v[n]; !ok {\n\t\t\tdfsRecur(n, nodes, v, fn)\n\t\t}\n\t}\n}\n\nfunc dfs2(node int, nodes map[int][]int, fn1, fn2 func(int, int)) {\n\tdfs2Recur(node, -1, nodes, map[int]bool{}, fn1, fn2)\n}\n\nfunc dfs2Recur(node, parent int, nodes map[int][]int, v map[int]bool, fn1, fn2 func(int, int)) {\n\tv[node] = true\n\tif fn1 != nil {\n\t\tfn1(node, parent)\n\t}\n\tfor _, n := range nodes[node] {\n\t\tif _, ok := v[n]; !ok {\n\t\t\tdfs2Recur(n, node, nodes, v, fn1, fn2)\n\t\t}\n\t}\n\tif fn2 != nil {\n\t\tfn2(node, parent)\n\t}\n}\n\ntype Stack struct {\n\ttop *Element\n\tsize int\n}\n\ntype Element struct {\n\tvalue interface{}\n\tnext *Element\n}\n\nfunc (s *Stack) Len() int {\n\treturn s.size\n}\n\nfunc (s *Stack) Push(value interface{}) {\n\ts.top = &Element{value, s.top}\n\ts.size++\n}\n\nfunc (s *Stack) Pop() (value interface{}) {\n\tif s.size > 0 {\n\t\tvalue, s.top = s.top.value, s.top.next\n\t\ts.size--\n\t\treturn\n\t}\n\treturn nil\n}\n\nfunc powerInt(n, p int) int {\n\ttmp := 1\n\tfor i := 0; i < n; i++ {\n\t\ttmp *= p\n\t}\n\treturn tmp\n}\n\nfunc findDivisors(n int, a *[]int) {\n\tif n == 1 {\n\t\treturn\n\t}\n\n\tsqrt := int(math.Sqrt(float64(n)))\n\tfor i := 2; i <= sqrt; i++ {\n\t\tif n%i == 0 {\n\t\t\t*a = append(*a, i)\n\t\t\t*a = append(*a, n/i)\n\t\t}\n\t}\n\t*a = append(*a, n)\n}\n\nfunc removeDuplicate(a []int) []int {\n\tm := make(map[int]bool)\n\tfor i := 0; i < len(a); i++ {\n\t\tm[a[i]] = true\n\t}\n\tres := []int{}\n\tfor i := range m {\n\t\tres = append(res, i)\n\t}\n\treturn res\n}\n\nfunc abs(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t}\n\treturn -a\n}\n\nfunc gcd(a, b int) int {\n\tfor a != 0 {\n\t\ta, b = b%a, a\n\t}\n\treturn b\n}\n\nfunc power2mod(n, mod int) int {\n\tres, x := 1, 2\n\tfor ; n > 0; n >>= 1 {\n\t\tif n&1 == 1 {\n\t\t\tres = res * x % mod\n\t\t}\n\t\tx = x * x % mod\n\t}\n\treturn res\n}\n\nfunc power2(n int) int {\n\treturn power2mod(n, magic)\n}\n", "test_IO": [ { "input": "6 5\n4 7 10 6 5\n", "output": "8\n" } ] }, { "id": "s558200435", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tb := make([]int, 0, n)\n\tfor _, v := range a {\n\t\tx := sort.Search(len(b), func(i int) bool {\n\t\t\treturn b[i] < v\n\t\t})\n\t\tif x == len(b) {\n\t\t\tb = append(b, v)\n\t\t} else {\n\t\t\tb[x] = v\n\t\t}\n\t}\n\n\tfmt.Println(len(b))\n}\n", "test_IO": [ { "input": "5\n2\n1\n4\n5\n3\n", "output": "2\n" } ] }, { "id": "s554832295", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x1, y1, x2, y2 int\n\tfmt.Scan(&x1, &y1, &x2, &y2)\n\n\ta := x2 - x1\n\tb := y2 - y1\n\n\tx3 := x2 - b\n\ty3 := y2 + a\n\tx4 := x1 - b\n\ty4 := y1 + a\n\n\tfmt.Println(x3, y3, x4, y4)\n}\n", "test_IO": [ { "input": "0 0 0 1\n", "output": "-1 1 -1 0\n" } ] }, { "id": "s789498198", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unsafe\"\n)\n\nfunc main() {\n\tAB := sc.nextInts()\n\tA := AB[0]\n\tB := AB[1]\n\n\tif (A+B)%2 == 0 {\n\t\tfmt.Println((A + B) / 2)\n\t\treturn\n\t}\n\tfmt.Println(\"IMPOSSIBLE\")\n}\n\nvar (\n\tsc scanner\n)\n\nfunc init() {\n\tsc = scanner{\n\t\tbuf: make([]string, 0, 0),\n\t\tcur: 0,\n\t\tr: bufio.NewReader(os.Stdin),\n\t}\n}\n\ntype scanner struct {\n\tbuf []string\n\tcur int\n\tr *bufio.Reader\n}\n\nfunc (s *scanner) readln() {\n\trbuf := make([]byte, 0, 0)\n\tfor {\n\t\tline, prefix, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trbuf = append(rbuf, line...)\n\t\tif prefix == false {\n\t\t\tbreak\n\t\t}\n\t}\n\ts.cur = 0\n\ts.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), \" \")\n}\nfunc (s *scanner) isFull() bool {\n\tif s.cur == len(s.buf) {\n\t\treturn true\n\t}\n\treturn false\n}\nfunc (s *scanner) resetCur() {\n\ts.cur = 0\n}\nfunc (s *scanner) next() string {\n\tif s.cur == 0 {\n\t\ts.readln()\n\t}\n\tres := s.buf[s.cur]\n\ts.cur++\n\tif s.isFull() {\n\t\ts.resetCur()\n\t}\n\treturn res\n}\nfunc (s *scanner) nexts() []string {\n\ts.readln()\n\ts.resetCur()\n\treturn s.buf\n}\nfunc (s *scanner) nextInt() int {\n\tif s.cur == 0 {\n\t\ts.readln()\n\t}\n\tres, _ := strconv.Atoi(s.buf[s.cur])\n\ts.cur++\n\tif s.isFull() {\n\t\ts.resetCur()\n\t}\n\treturn res\n}\nfunc (s *scanner) nextInts() []int {\n\ts.readln()\n\tres := make([]int, len(s.buf))\n\tfor i := range s.buf {\n\t\tres[i], _ = strconv.Atoi(s.buf[i])\n\t}\n\ts.resetCur()\n\treturn res\n}\nfunc (s *scanner) nextFloat() float64 {\n\tif s.cur == 0 {\n\t\ts.readln()\n\t}\n\tres, _ := strconv.ParseFloat(s.buf[s.cur],\n\t\t64)\n\ts.cur++\n\tif s.isFull() {\n\t\ts.resetCur()\n\t}\n\treturn res\n}\nfunc (s *scanner) nextFloats() []float64 {\n\ts.readln()\n\tres := make([]float64, len(s.buf))\n\tfor i := range s.buf {\n\t\tres[i], _ = strconv.ParseFloat(s.buf[i],\n\t\t\t64)\n\t}\n\ts.resetCur()\n\treturn res\n}\nfunc digits(x int) int {\n\treturn len(strconv.Itoa(x))\n}\nfunc powInt(x, p int) (result int) {\n\tresult = 1\n\tfor i := 0; i < p; i++ {\n\t\tresult *= x\n\t}\n\treturn\n}\nfunc max(x, y int) int {\n\treturn int(math.Max(float64(x), float64(y)))\n}\nfunc min(x, y int) int {\n\treturn int(math.Min(float64(x), float64(y)))\n}\nfunc abs(x int) int {\n\treturn int(math.Abs(float64(x)))\n}\nfunc varDump(value ...interface{}) {\n\tfor _, v := range value {\n\t\tfmt.Fprintf(os.Stderr, \"%#v\\n\", v)\n\t}\n}\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\ntype Pair struct {\n\tfirst int\n\tsecond int\n}\n\ntype Queue struct {\n\tv []Pair\n}\n\nfunc (q *Queue) Push(v Pair) {\n\tq.v = append(q.v, v)\n}\n\nfunc (q *Queue) Pop() Pair {\n\tr := q.v[0]\n\tq.v = q.v[1:]\n\treturn r\n}\n\nfunc (q Queue) Front() Pair {\n\treturn q.v[0]\n}\n\nfunc (q Queue) Empty() bool {\n\treturn len(q.v) == 0\n}\n", "test_IO": [ { "input": "2 16\n", "output": "9\n" } ] }, { "id": "s227655384", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc ReadLongLines(times int) ([]string, error) {\n\tresult := make([]string, times)\n\treader := bufio.NewReader(os.Stdin)\n\tbuffer := bytes.NewBuffer(make([]byte, 0))\n\treadBytes := int64(2)\n\tfor i := 0; i < times; i++ {\n\t\tfor {\n\t\t\treadBuf, isPrefix, err := reader.ReadLine()\n\n\t\t\treadBytes += int64(len(readBuf) + 1)\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tfmt.Println(\"EOF\")\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\treturn result, err\n\t\t\t\t}\n\t\t\t}\n\t\t\t_, err = buffer.Write(readBuf)\n\t\t\tif err != nil {\n\t\t\t\treturn result, err\n\t\t\t}\n\n\t\t\tif !isPrefix {\n\t\t\t\tresult[i] = buffer.String()\n\t\t\t\tbuffer.Reset()\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tos.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)\n\treturn result, nil\n}\n\ntype Console struct {\n\twriter *bufio.Writer\n}\n\nfunc NewConsole() Console {\n\treturn Console{bufio.NewWriter(os.Stdout)}\n}\nfunc (this *Console) Printf(format string, a ...interface{}) {\n\tfmt.Fprintf(this.writer, format, a...)\n}\nfunc (this *Console) Println(s string) {\n\tfmt.Fprintln(this.writer, s)\n}\nfunc (this *Console) Close() {\n\tthis.Flush()\n}\nfunc (this Console) Flush() {\n\tthis.writer.Flush()\n}\n\nfunc PrintList(list []int) {\n\tcon := NewConsole()\n\tdefer con.Flush()\n\tfor i := range list {\n\t\tif i == 0 {\n\t\t\tcon.Printf(\"%d\", list[i])\n\t\t} else {\n\t\t\tcon.Printf(\" %d\", list[i])\n\t\t}\n\t}\n\tcon.Println(\"\")\n}\n\nfunc main() {\n\tcon := NewConsole()\n\tdefer con.Flush()\n\n\tm := make(map[int]struct{})\n\tlines, _ := ReadLongLines(4)\n\ta := strings.Split(lines[1], \" \")\n\tfor i := range a {\n\t\tn, _ := strconv.Atoi(a[i])\n\t\tm[n] = struct{}{}\n\t}\n\n\tresult := make([]int, 0, 200000)\n\tb := strings.Split(lines[3], \" \")\n\tfor i := range b {\n\t\tn, _ := strconv.Atoi(b[i])\n\t\tif _, ok := m[n]; ok {\n\t\t\tdelete(m, n)\n\t\t} else {\n\t\t\tm[n] = struct{}{}\n\t\t}\n\t}\n\tfor k, _ := range m {\n\t\tresult = append(result, k)\n\t}\n\tsort.Slice(result, func(lhs, rhs int) bool {\n\t\treturn result[lhs] < result[rhs]\n\t})\n\tfor j := range result {\n\t\tcon.Printf(\"%d\\n\", result[j])\n\t}\n}\n", "test_IO": [ { "input": "7\n1 2 3 4 5 6 7\n4\n2 4 6 8\n", "output": "1\n3\n5\n7\n8\n" } ] }, { "id": "s240914668", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn := nextInt()\n\ta := nextInts(n)\n\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tl, r := i, i+1\n\t\tfor r+1 < n && (a[r]-a[l])*(a[r+1]-a[r]) >= 0 {\n\t\t\tr++\n\t\t}\n\t\tans++\n\t\ti = r\n\t}\n\tputs(ans)\n\twt.Flush()\n}\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\trdr = bufio.NewReaderSize(os.Stdin, 1000000)\n\twt = bufio.NewWriter(os.Stdout)\n)\n\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\ti, _ := strconv.Atoi(next())\n\treturn i\n}\n\nfunc nextFloat64() float64 {\n\tf, _ := strconv.ParseFloat(next(), 64)\n\treturn f\n}\n\nfunc nextInts(n int) []int {\n\tslice := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tslice[i] = nextInt()\n\t}\n\treturn slice\n}\n\nfunc nextFloat64s(n int) []float64 {\n\tslice := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tslice[i] = nextFloat64()\n\t}\n\treturn slice\n}\n\nfunc nextMega() string {\n\tbuf := make([]byte, 0, 1000000)\n\tfor {\n\t\tl, p, _ := rdr.ReadLine()\n\t\tbuf = append(buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buf)\n}\n\nfunc putf(format string, a ...interface{}) {\n\tfmt.Fprintf(wt, format, a...)\n}\n\nfunc puts(a ...interface{}) {\n\tfmt.Fprintln(wt, a...)\n}\n", "test_IO": [ { "input": "6\n1 2 3 2 2 1\n", "output": "2\n" } ] }, { "id": "s097554686", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nconst size = 100001\n\nfunc main() {\n\tvar n, t int\n\tvar l, r int\n\tvar mem [size]int\n\tfmt.Scan(&n)\n\tfmt.Scan(&t)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&l)\n\t\tfmt.Scan(&r)\n\t\tmem[l] += 1\n\t\tmem[r] -= 1\n\t}\n\tans := mem[0]\n\tfor i := 1; i < t+1; i++ {\n\t\tmem[i] += mem[i-1]\n\t\tif ans < mem[i] {\n\t\t\tans = mem[i]\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "6 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10\n", "output": "4\n" } ] }, { "id": "s225883945", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, _ := strconv.Atoi(sc.Text())\n\treturn i\n}\n\nfunc nextFloat64() float64 {\n\tf, _ := strconv.ParseFloat(next(), 64)\n\treturn f\n}\n\nfunc nextInts(n int) []int {\n\tslice := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tslice[i] = nextInt()\n\t}\n\treturn slice\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn, k := nextInt(), nextInt()\n\ta := nextInts(n)\n\n\ta[0] = 0\n\n\tsum := k\n\tans := 1\n\tfor sum < n {\n\t\tsum = sum - 1 + k\n\t\tans++\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4 3\n2 3 1 4\n", "output": "2\n" } ] }, { "id": "s502485201", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar r, d, x int\n\tfmt.Scanf(\"%d %d %d\", &r, &d, &x)\n\n\tfor i := 0; i < 10; i++ {\n\t\tx = r*x - d\n\t\tfmt.Println(x)\n\t}\n}\n", "test_IO": [ { "input": "2 10 20\n", "output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n" } ] }, { "id": "s982630782", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\tm := make(map[int]int)\n\tN, M := ReadInt(), ReadInt()\n\tfor i := 0; i < N; i++ {\n\t\tm[ReadInt()]++\n\t}\n\tfor i := 0; i < M; i++ {\n\t\tB, C := ReadInt(), ReadInt()\n\t\tm[C] += B\n\t}\n\tints := make([]int, len(m))\n\tfor i, _ := range m {\n\t\tints = append(ints, i)\n\t}\n\tsort.Sort(sort.Reverse(sort.IntSlice(ints)))\n\trest := N\n\tsum := 0\n\tfor _, i := range ints {\n\t\tnum := m[i]\n\t\tif num >= rest {\n\t\t\tsum += rest * i\n\t\t\tbreak\n\t\t}\n\t\tsum += num * i\n\t\trest -= num\n\t}\n\tfmt.Println(sum)\n}\n\nvar reader = bufio.NewReader(os.Stdin)\n\nfunc Scan(a ...interface{}) {\n\tif _, err := fmt.Fscan(reader, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\nfunc ReadInt() (i int) { Scan(&i); return }\n", "test_IO": [ { "input": "3 2\n5 1 4\n2 3\n1 5\n", "output": "14\n" } ] }, { "id": "s724499011", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s []byte\n\tfmt.Scan(&s)\n\tns := make([]int, n)\n\tfor i := range s {\n\t\tswitch s[i] {\n\t\tcase 'R':\n\t\t\tns[i] = 0\n\t\tcase 'G':\n\t\t\tns[i] = 1\n\t\tcase 'B':\n\t\t\tns[i] = 2\n\t\t}\n\t}\n\n\trgb := make([][]int, n+1)\n\trgb[0] = make([]int, 3)\n\tfor i := 1; i <= n; i++ {\n\t\trgb[i] = make([]int, 3)\n\t\tfor j := 0; j < 3; j++ {\n\t\t\trgb[i][j] = rgb[i-1][j]\n\t\t}\n\t\trgb[i][ns[i-1]]++\n\t}\n\tvar sum int\n\tfor i := 0; i < n-2; i++ {\n\t\tfor j := i + 1; j < n-1; j++ {\n\t\t\tif ns[i] != ns[j] {\n\t\t\t\ttn := 3 - ns[i] - ns[j]\n\t\t\t\tsum += rgb[n][tn] - rgb[j+1][tn]\n\t\t\t\tk := 2*j - i\n\t\t\t\tif k < n && ns[k] == tn {\n\t\t\t\t\tsum--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n", "test_IO": [ { "input": "4\nRRGB\n", "output": "1\n" } ] }, { "id": "s846000843", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tio := NewIo()\n\tdefer io.Flush()\n\n\tn := io.Int()\n\n\taa := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\taa[i] = io.Int()\n\t}\n\n\tcumsum := CumSum(aa)\n\n\tans := 2020202020\n\tfor i := 1; i < len(cumsum)-1; i++ {\n\t\tans = Min(ans, Abs(cumsum[len(cumsum)-1]-cumsum[i]-(cumsum[i]-cumsum[0])))\n\t}\n\n\tfmt.Println(ans)\n\n}\n\ntype Io struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n\ttokens []string\n\tnextToken int\n}\n\nfunc NewIo() *Io {\n\treturn &Io{\n\t\treader: bufio.NewReader(os.Stdin),\n\t\twriter: bufio.NewWriter(os.Stdout),\n\t}\n}\n\nfunc (io *Io) Flush() {\n\terr := io.writer.Flush()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}\n\nfunc (io *Io) Next() string {\n\tfor io.nextToken >= len(io.tokens) {\n\t\tline := io.NextLine()\n\t\tio.tokens = strings.Fields(line)\n\t\tio.nextToken = 0\n\t}\n\tr := io.tokens[io.nextToken]\n\tio.nextToken++\n\treturn r\n}\n\nfunc (io *Io) Int() int {\n\ti, err := strconv.Atoi(io.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) Float() float64 {\n\ti, err := strconv.ParseFloat(io.Next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc (io *Io) PrintLn(a ...interface{}) {\n\tfmt.Fprintln(io.writer, a...)\n}\n\nfunc (io *Io) Printf(format string, a ...interface{}) {\n\tfmt.Fprintf(io.writer, format, a...)\n}\n\nfunc (io *Io) PrintIntLn(a []int) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc (io *Io) PrintStringLn(a []string) {\n\tb := []interface{}{}\n\tfor _, x := range a {\n\t\tb = append(b, x)\n\t}\n\tio.PrintLn(b...)\n}\n\nfunc Log(name string, value interface{}) {\n\tfmt.Fprintf(os.Stderr, \"%s=%+v\\n\", name, value)\n}\n\nfunc Abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc Pow(p, q int) int {\n\treturn int(math.Pow(float64(p), float64(q)))\n}\n\nfunc Min(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton min() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Min(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc Max(nums ...int) int {\n\tif len(nums) == 0 {\n\t\tpanic(\"funciton max() requires at least one argument.\")\n\t}\n\tres := nums[0]\n\tfor i := 0; i < len(nums); i++ {\n\t\tres = int(math.Max(float64(res), float64(nums[i])))\n\t}\n\treturn res\n}\n\nfunc SortAsc(a []int) []int {\n\tsort.Ints(a)\n\treturn a\n}\n\nfunc SortDesc(a []int) []int {\n\tsort.Sort(sort.Reverse(sort.IntSlice(a)))\n\treturn a\n}\n\nfunc GCD(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn GCD(b, a%b)\n}\n\nfunc LCM(a, b int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 0\n\t}\n\treturn a * b / GCD(a, b)\n}\n\nfunc CumSum(nums []int) []int {\n\tsums := []int{0}\n\n\tfor i := 0; i < len(nums); i++ {\n\t\tsums = append(sums, sums[i]+nums[i])\n\t}\n\treturn sums\n}\n\nfunc BisectLeft(nums []int, left, right int, target int) int {\n\tif left == right {\n\t\tif nums[left] == target {\n\t\t\treturn left\n\t\t} else if nums[left] < target {\n\t\t\treturn left + 1\n\t\t} else {\n\t\t\treturn left\n\t\t}\n\t}\n\n\tmid := (left + right) / 2\n\tif nums[mid] == target {\n\t\treturn mid\n\t}\n\n\tif nums[mid] > target {\n\t\treturn BisectLeft(nums, left, mid, target)\n\t} else if nums[mid] < target {\n\t\treturn BisectLeft(nums, mid+1, right, target)\n\t}\n\treturn 0\n}\n\nfunc Permutations(nums []int) [][]int {\n\tn := len(nums)\n\tif n == 0 {\n\t\treturn [][]int{}\n\t}\n\tans := [][]int{}\n\n\tfor _, n := range nums {\n\t\trest := remove(nums, n)\n\t\tlists := Permutations(rest)\n\t\tif len(lists) == 0 {\n\t\t\tlists = [][]int{nil}\n\t\t}\n\n\t\tfor i := 0; i < len(lists); i++ {\n\t\t\tlists[i] = append(lists[i], n)\n\t\t\tans = append(ans, lists[i])\n\t\t}\n\t}\n\treturn ans\n}\n\nfunc remove(nums []int, target int) []int {\n\tresult := []int{}\n\tfor i := 0; i < len(nums); i++ {\n\t\tif nums[i] != target {\n\t\t\tresult = append(result, nums[i])\n\t\t}\n\t}\n\treturn result\n}\n\nfunc PowerSet(nums []int) [][]int {\n\tsize := Pow(2, len(nums))\n\tresult := make([][]int, size)\n\n\tidx := 0\n\tresult[idx] = []int{}\n\tidx++\n\n\tfor _, n := range nums {\n\t\tmax := idx\n\t\tfor i := 0; i < max; i++ {\n\t\t\tresult[idx] = copyAndAppend(result[i], n)\n\t\t\tidx++\n\t\t}\n\t}\n\n\treturn result\n}\n\nfunc copyAndAppend(nums []int, n int) []int {\n\tdst := make([]int, len(nums)+1)\n\tcopy(dst, nums)\n\tdst[len(nums)] = n\n\treturn dst\n}\n\nfunc Combination(nums []int, k int) [][]int {\n\tsize := len(nums)\n\tresult := make([][]int, CombinationCount(int64(len(nums)), int64(k), 10e10))\n\tbi := (1 << uint(k)) - 1\n\tmax := 1 << uint(size)\n\tidx := 0\n\n\tfor bi < max {\n\t\tflags := bi\n\t\ts := []int{}\n\t\tfor _, n := range nums {\n\t\t\tif flags%2 != 0 {\n\t\t\t\ts = append(s, n)\n\t\t\t}\n\t\t\tflags /= 2\n\t\t}\n\t\tresult[idx] = s\n\t\tidx++\n\t\tbi = Combination2NextIndex(bi)\n\t}\n\treturn result\n}\n\nfunc Combination2NextIndex(n int) int {\n\tsmallest := n & -n\n\tripple := n + smallest\n\tnewSmallest := ripple & -ripple\n\tones := ((newSmallest / smallest) >> 1) - 1\n\treturn ripple | ones\n}\n\nfunc CombinationCount(n, m, maxInput int64) int64 {\n\tmemo := map[int64]map[int64]int64{}\n\tfor i := int64(1); i <= maxInput*maxInput; i++ {\n\t\tmemo[int64(i)] = map[int64]int64{}\n\t}\n\treturn combinationCount(n, m, memo)\n}\nfunc combinationCount(n, m int64, memo map[int64]map[int64]int64) int64 {\n\tif n == m || m == 0 {\n\t\treturn 1\n\t}\n\n\tleft, lOK := memo[n-1][m-1]\n\tright, rOK := memo[n-1][m]\n\n\tif lOK && rOK {\n\t\treturn left + right\n\t}\n\n\tif lOK {\n\t\tright = combinationCount(n-1, m, memo)\n\t\tmemo[n-1][m] = right\n\t\treturn left + right\n\t}\n\n\tif rOK {\n\t\tleft = combinationCount(n-1, m-1, memo)\n\t\tmemo[n-1][m-1] = left\n\t\treturn left + right\n\t}\n\n\tleft = combinationCount(n-1, m-1, memo)\n\tright = combinationCount(n-1, m, memo)\n\tmemo[n-1][m-1] = left\n\tmemo[n-1][m] = right\n\treturn left + right\n}\n\nfunc Fact(n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\treturn n * Fact(n-1)\n\t}\n}\n\nfunc Divisors(n int) []int {\n\tdivisors := map[int]bool{}\n\tfor i := 1; i < int(math.Sqrt(float64(n)))+1; i++ {\n\t\tif n%i == 0 {\n\t\t\tdivisors[i] = true\n\n\t\t\tif i != n {\n\t\t\t\tdivisors[n/i] = true\n\n\t\t\t}\n\t\t}\n\n\t}\n\tans := []int{}\n\tfor k := range divisors {\n\t\tans = append(ans, k)\n\t}\n\treturn ans\n}\n", "test_IO": [ { "input": "3\n2 4 3\n", "output": "3\n" } ] }, { "id": "s040219730", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nconst (\n\tMOD = 1000000000 + 7\n\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, q int\n\tC []int\n\tQ []Query\n\n\tP [500000 + 50]int\n\tAnswers [500000 + 50]int\n)\n\ntype Query struct {\n\tidx, l, r int\n}\n\nfunc main() {\n\tn, q = ReadInt2()\n\tC = ReadIntSlice(n)\n\n\tfor i := 1; i <= n; i++ {\n\t\tP[i] = -1\n\t}\n\n\tfor i := 0; i < q; i++ {\n\t\tl, r := ReadInt2()\n\t\tquery := Query{idx: i, l: l, r: r}\n\t\tQ = append(Q, query)\n\t}\n\n\tsort.SliceStable(Q, func(i, j int) bool { return Q[i].r < Q[j].r })\n\tft := NewFenwickTree(500000 + 50)\n\n\tk := 0\n\tfor _, query := range Q {\n\t\tfor k < query.r {\n\t\t\tif P[C[k]] != -1 {\n\t\t\t\tft.Add(P[C[k]]+1, -1)\n\t\t\t}\n\t\t\tP[C[k]] = k\n\t\t\tft.Add(k+1, 1)\n\n\t\t\tk++\n\t\t}\n\n\t\tAnswers[query.idx] = ft.Sum(query.r) - ft.Sum(query.l-1)\n\t}\n\n\tfor i := 0; i < q; i++ {\n\n\t\tPrintfBufStdout(\"%d\\n\", Answers[i])\n\t}\n\tstdout.Flush()\n}\n\ntype FenwickTree struct {\n\tdat []int\n\tn int\n\tminPow2 int\n}\n\nfunc NewFenwickTree(n int) *FenwickTree {\n\tft := new(FenwickTree)\n\n\tft.dat = make([]int, n+1)\n\tft.n = n\n\n\tft.minPow2 = 1\n\tfor {\n\t\tif (ft.minPow2 << 1) > n {\n\t\t\tbreak\n\t\t}\n\t\tft.minPow2 <<= 1\n\t}\n\n\treturn ft\n}\n\nfunc (ft *FenwickTree) Sum(i int) int {\n\ts := 0\n\n\tfor i > 0 {\n\t\ts += ft.dat[i]\n\t\ti -= i & (-i)\n\t}\n\n\treturn s\n}\n\nfunc (ft *FenwickTree) Add(i, x int) {\n\tfor i <= ft.n {\n\t\tft.dat[i] += x\n\t\ti += i & (-i)\n\t}\n}\n\nfunc (ft *FenwickTree) LowerBound(w int) int {\n\tif w <= 0 {\n\t\treturn 0\n\t}\n\n\tx := 0\n\tfor k := ft.minPow2; k > 0; k /= 2 {\n\t\tif x+k <= ft.n && ft.dat[x+k] < w {\n\t\t\tw -= ft.dat[x+k]\n\t\t\tx += k\n\t\t}\n\t}\n\n\treturn x + 1\n}\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10)\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "test_IO": [ { "input": "4 3\n1 2 1 3\n1 3\n2 4\n3 3\n", "output": "2\n3\n1\n" } ] }, { "id": "s141561537", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, x, sum int\n\tfmt.Scan(&a, &b, &c, &x)\n\tfor i := 0; i <= a; i++ {\n\t\tfor j := 0; j <= b; j++ {\n\t\t\tfor k := 0; k <= c; k++ {\n\t\t\t\tif 500*i+100*j+50*k == x {\n\t\t\t\t\tsum++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n", "test_IO": [ { "input": "2\n2\n2\n100\n", "output": "2\n" } ] }, { "id": "s617271364", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\nvar wtr = bufio.NewWriter(os.Stdout)\nvar N, ss, ans, A, B, C int\n\nfunc main() {\n\n\tX := strings.Split(nextLine(), \" \")\n\n\tN, _ = strconv.Atoi(X[0])\n\tA, _ = strconv.Atoi(X[1])\n\tB, _ = strconv.Atoi(X[2])\n\tC, _ = strconv.Atoi(X[3])\n\n\tarr := make([]int, N)\n\tdp := make([]int, N)\n\tans = 10000\n\tss = A + B + C\n\n\tfor i := 0; i < N; i++ {\n\t\tY := strings.Split(nextLine(), \" \")\n\n\t\ta, _ := strconv.Atoi(Y[0])\n\t\tarr[i] = a\n\n\t}\n\tdfs(dp, 0, arr)\n\n\tfmt.Fprintln(wtr, ans)\n\n\t_ = wtr.Flush()\n}\n\nfunc dfs(dp []int, times int, arr []int) {\n\tif times >= N {\n\t\tans = min(ans, calc(dp, arr))\n\t\treturn\n\t}\n\n\tfor i := 0; i < 4; i++ {\n\t\tdp[times] = i\n\t\tdfs(dp, times+1, arr)\n\t}\n}\n\nfunc calc(dp, arr []int) int {\n\tvar cost, AA, BB, CC int\n\n\tmemo := make([]int, 4)\n\tfor i := 0; i < len(dp); i++ {\n\t\tmemo[dp[i]]++\n\t\tif dp[i] == 1 {\n\t\t\tAA += arr[i]\n\t\t} else if dp[i] == 2 {\n\t\t\tBB += arr[i]\n\t\t} else if dp[i] == 3 {\n\t\t\tCC += arr[i]\n\t\t}\n\t}\n\tcost += abs(A-AA) + abs(B-BB) + abs(C-CC)\n\n\tfor i := 1; i < 4; i++ {\n\t\ta := memo[i]\n\t\tif a < 1 {\n\t\t\tcost += 10000\n\t\t} else {\n\t\t\tcost += (a - 1) * 10\n\t\t}\n\t}\n\n\treturn cost\n}\n\ntype otosidama struct {\n\tx float64\n\tv string\n}\n\nfunc chmax(a *string, b string) {\n\tif len(*a) < len(b) {\n\t\t*a = b\n\t} else if len(*a) == len(b) && *a < b {\n\t\t*a = b\n\t}\n}\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc nextLine() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc com(a, b int) int {\n\n\tif a > b {\n\t\treturn 0\n\t}\n\treturn 0\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn a * -1\n\t}\n\treturn a\n}\nfunc sum(a []int) (sum int) {\n\tfor _, num := range a {\n\t\tsum += num\n\t}\n\treturn\n}\n\ntype item struct {\n\tx int\n}\n\ntype que []item\n\nfunc (p que) Len() int {\n\treturn len(p)\n}\n\nfunc (p que) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p que) Less(i, j int) bool {\n\n\treturn p[i].x < p[j].x\n}\n\nfunc (p que) Push(in int) {\n\tp = append(p, item{x: in})\n\tsort.Sort(p)\n}\n\nfunc (p que) Pop() int {\n\tres := p[0].x\n\tp = p[1:]\n\treturn res\n}\n\nfunc (p que) Peek() int {\n\treturn p[0].x\n}\n", "test_IO": [ { "input": "5 100 90 80\n98\n40\n30\n21\n80\n", "output": "23\n" } ] }, { "id": "s984936225", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar N, M int\n\tfmt.Scan(&N, &M)\n\tInf := 1 << 62\n\n\ta := make([]int, M)\n\tb := make([]int, M)\n\tc := make([]int, M)\n\tfor i := 0; i < M; i++ {\n\t\tfmt.Scan(&a[i], &b[i], &c[i])\n\t\tc[i] = -c[i]\n\t}\n\n\tdist := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tdist[i] = Inf\n\t}\n\tdist[0] = 0\n\tfor loop := 0; loop < N; loop++ {\n\t\tfor i := 0; i < M; i++ {\n\t\t\tif dist[a[i]-1] == Inf {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif dist[b[i]-1] > dist[a[i]-1]+c[i] {\n\n\t\t\t\tdist[b[i]-1] = dist[a[i]-1] + c[i]\n\t\t\t}\n\t\t}\n\t}\n\tans := dist[N-1]\n\tnavigate := make([]bool, N)\n\tfor loop := 0; loop < N; loop++ {\n\t\tfor i := 0; i < M; i++ {\n\t\t\tif dist[a[i]-1] == Inf {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif dist[b[i]-1] > dist[a[i]-1]+c[i] {\n\t\t\t\tdist[b[i]-1] = dist[a[i]-1] + c[i]\n\t\t\t\tnavigate[b[i]-1] = true\n\t\t\t}\n\t\t\tif navigate[a[i]-1] == true {\n\t\t\t\tnavigate[b[i]-1] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tif navigate[N-1] {\n\t\tfmt.Println(\"inf\")\n\t} else {\n\t\tfmt.Println(-ans)\n\t}\n\n}\n", "test_IO": [ { "input": "3 3\n1 2 4\n2 3 3\n1 3 5\n", "output": "7\n" } ] }, { "id": "s494300734", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\tans := \"No\"\n\tif strings.Index(s, \"C\") < strings.LastIndex(s, \"F\") {\n\t\tans = \"Yes\"\n\t}\n\tif strings.Index(s, \"C\") < 0 {\n\t\tans = \"No\"\n\t}\n\n\tfmt.Printf(\"%s\\n\", ans)\n}\n", "test_IO": [ { "input": "CODEFESTIVAL\n", "output": "Yes\n" } ] }, { "id": "s452291224", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar A, B, C int\n\tfmt.Scanf(\"%d %d %d\", &A, &B, &C)\n\tif C-A+B < 0 {\n\t\tfmt.Println(\"0\")\n\t} else {\n\t\tfmt.Printf(\"%d\\n\", C-A+B)\n\t}\n}\n", "test_IO": [ { "input": "6 4 3\n", "output": "1\n" } ] }, { "id": "s940795037", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\n\tn := sc.NextInt()\n\tans := 0.0\n\tfor i := 0; i < n; i++ {\n\t\ttmp := 1 / float64(sc.NextInt())\n\t\tans += tmp\n\t}\n\tfmt.Printf(\"%v\\n\", 1/ans)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tresult = append(result, v)\n\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "2\n10 30\n", "output": "7.5\n" } ] }, { "id": "s436101574", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanString() string { sc.Scan(); return sc.Text() }\nfunc scanRunes() []rune { return []rune(scanString()) }\nfunc scanInt() int { a, _ := strconv.Atoi(scanString()); return a }\nfunc scanInt64() int64 { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }\nfunc scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = scanInt()\n\t}\n\treturn res\n}\n\nfunc debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer wr.Flush()\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1001001)\n\n\ts := scanRunes()\n\tt := scanRunes()\n\n\tans := []string{}\n\tfor i := 0; i < len(s)-len(t)+1; i++ {\n\t\tf := true\n\t\tss := make([]rune, len(s))\n\t\tcopy(ss, s)\n\n\t\tfor j := 0; j < len(t); j++ {\n\t\t\tif s[i+j] != t[j] && s[i+j] != '?' {\n\t\t\t\tf = false\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tss[i+j] = t[j]\n\t\t\t}\n\t\t}\n\t\tif f {\n\t\t\tans = append(ans, strings.Replace(string(ss), \"?\", \"a\", -1))\n\t\t}\n\t}\n\tsort.Strings(ans)\n\tif len(ans) == 0 {\n\t\tfmt.Fprintln(wr, \"UNRESTORABLE\")\n\t} else {\n\t\tfmt.Fprintln(wr, ans[0])\n\t}\n}\n", "test_IO": [ { "input": "?tc????\ncoder\n", "output": "atcoder\n" } ] }, { "id": "s225932846", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar S string\n\tfmt.Scan(&S)\n\tfor i := 2; i <= len(S); i = i + 2 {\n\t\tif S[0:(len(S)-i)/2] == S[(len(S)-i)/2:len(S)-i] {\n\t\t\tfmt.Println((len(S) - i))\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "abaababaab\n", "output": "6\n" } ] }, { "id": "s731620136", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype Scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc NewScanner() *Scanner {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10240), int(1e+9))\n\treturn &Scanner{sc}\n}\n\nfunc (s *Scanner) nextStr() string {\n\ts.sc.Scan()\n\treturn s.sc.Text()\n}\n\nfunc (s *Scanner) nextInt() int {\n\ti, e := strconv.Atoi(s.nextStr())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc (s *Scanner) nextFloat() float64 {\n\tf, e := strconv.ParseFloat(s.nextStr(), 64)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn f\n}\n\nfunc (s *Scanner) nextRuneSlice() []byte {\n\treturn []byte(s.nextStr())\n}\n\nfunc (s *Scanner) nextIntSlice(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextInt()\n\t}\n\treturn res\n}\n\nfunc (s *Scanner) nextFloatSlice(n int) []float64 {\n\tres := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = s.nextFloat()\n\t}\n\treturn res\n}\n\nfunc run(input io.Reader, output io.Writer) int {\n\tsc := NewScanner()\n\tN := sc.nextInt()\n\tS := sc.nextStr()\n\n\tif N == 0 {\n\t}\n\n\tif N < 4 {\n\t\tfmt.Println(0)\n\t\treturn 0\n\t}\n\n\tvar nr, nb, ng int\n\tfor _, c := range S {\n\t\tif c == 'R' {\n\t\t\tnr++\n\t\t}\n\n\t\tif c == 'B' {\n\t\t\tnb++\n\t\t}\n\n\t\tif c == 'G' {\n\t\t\tng++\n\t\t}\n\t}\n\n\tsame := 0\n\n\tfor a := 1; a < N; a++ {\n\t\ti := 0\n\t\tj := 1 * a\n\t\tk := 2 * a\n\t\tif k >= N {\n\t\t\tbreak\n\t\t}\n\t\tfor k < N {\n\n\t\t\tif S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {\n\t\t\t\tsame++\n\n\t\t\t}\n\n\t\t\ti += 1\n\t\t\tj += 1\n\t\t\tk += 1\n\t\t}\n\t}\n\n\ttot := nr * nb * ng\n\n\tfmt.Println(tot - same)\n\n\treturn 0\n}\n\nfunc main() {\n\tos.Exit(run(os.Stdin, os.Stdout))\n}\n", "test_IO": [ { "input": "4\nRRGB\n", "output": "1\n" } ] }, { "id": "s861455616", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif len(s) >= 4 && s[0:4] == \"YAKI\" {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n", "test_IO": [ { "input": "YAKINIKU\n", "output": "Yes\n" } ] }, { "id": "s521372598", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := getInt()\n\tas := getIntSlice(n)\n\n\txs := make([]int, n)\n\tfor i, a := range as {\n\t\txs[i] = a - i + 1\n\t}\n\tsort.Ints(xs)\n\n\tb := xs[n/2]\n\tans := 0\n\tfor _, x := range xs {\n\t\tans += abs(x - b)\n\t}\n\tfmt.Fprintln(wr, ans)\n}\n\nfunc abs(n int) int {\n\tif n < 0 {\n\t\treturn -n\n\t}\n\treturn n\n}\n\nconst (\n\tinf = 1 << 60\n)\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tmaxBufSize := int(1e8)\n\tsc.Buffer(make([]byte, 4096), maxBufSize)\n\tsc.Split(bufio.ScanWords)\n\tsolve()\n\twr.Flush()\n}\n\nfunc getInt() (ret int) {\n\tsc.Scan()\n\tret, err := strconv.Atoi(sc.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}\n\nfunc getIntSlice(n int) (ret []int) {\n\tret = make([]int, n)\n\tfor i := range ret {\n\t\tret[i] = getInt()\n\t}\n\treturn\n}\n\nfunc getString() (ret string) {\n\tsc.Scan()\n\tret = sc.Text()\n\treturn\n}\n\nfunc getRunes() (ret []rune) {\n\tret = []rune(getString())\n\treturn\n}\n", "test_IO": [ { "input": "5\n2 2 3 5 5\n", "output": "2\n" } ] }, { "id": "s069675863", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst (\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tS []rune\n\tx, y int\n\n\tdpx, dpy [8000][20000]bool\n)\n\nfunc main() {\n\tS = ReadRuneSlice()\n\tx, y = ReadInt2()\n\n\tF := []int{}\n\n\tcur := 0\n\tfor i := 0; i < len(S); i++ {\n\t\tif S[i] == 'F' {\n\t\t\tcur++\n\t\t} else {\n\t\t\tF = append(F, cur)\n\t\t\tcur = 0\n\t\t}\n\t}\n\tF = append(F, cur)\n\tPrintfDebug(\"%v\\n\", F)\n\n\tevens, odds := []int{}, []int{}\n\tfor i := 0; i < len(F); i++ {\n\t\tif i%2 == 0 {\n\t\t\tevens = append(evens, F[i])\n\t\t} else {\n\t\t\todds = append(odds, F[i])\n\t\t}\n\t}\n\n\tdpx[0][10000], dpy[0][10000] = true, true\n\tfor i := 0; i < len(evens); i++ {\n\t\tval := evens[i]\n\t\tfor j := 2000; j <= 18000; j++ {\n\t\t\tif j+val <= 18000 {\n\t\t\t\tdpx[i+1][j+val] = dpx[i+1][j+val] || dpx[i][j]\n\t\t\t}\n\t\t\tif j-val >= 2000 && i != 0 {\n\t\t\t\tdpx[i+1][j-val] = dpx[i+1][j-val] || dpx[i][j]\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < len(odds); i++ {\n\t\tval := odds[i]\n\t\tfor j := 2000; j <= 18000; j++ {\n\t\t\tif j+val <= 18000 {\n\t\t\t\tdpy[i+1][j+val] = dpy[i+1][j+val] || dpy[i][j]\n\t\t\t}\n\t\t\tif j-val >= 2000 {\n\t\t\t\tdpy[i+1][j-val] = dpy[i+1][j-val] || dpy[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tif dpx[len(evens)][x+10000] && dpy[len(odds)][y+10000] {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n\nvar (\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10)\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n", "test_IO": [ { "input": "FTFFTFFF\n4 2\n", "output": "Yes\n" } ] }, { "id": "s794438584", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc max(lhs, rhs int) int {\n\treturn int(math.Max(float64(lhs), float64(rhs)))\n}\n\nfunc main() {\n\tvar (\n\t\tN, M int\n\t)\n\tfmt.Scanf(\"%d %d\", &N, &M)\n\tvalues := make([]int, N)\n\tweights := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%d %d\", &weights[i], &values[i])\n\t}\n\n\tdp := make([][]int, N+1)\n\tfor i := 0; i < N+1; i++ {\n\t\tdp[i] = make([]int, M+1)\n\t}\n\tfor i := 1; i <= N; i++ {\n\t\tfor j := 0; j <= M; j++ {\n\t\t\tdp[i][j] = dp[i-1][j]\n\t\t\tif j >= weights[i-1] {\n\t\t\t\tdp[i][j] = max(dp[i][j], dp[i-1][j-weights[i-1]]+values[i-1])\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(dp[N][M])\n}\n", "test_IO": [ { "input": "3 8\n3 30\n4 50\n5 60\n", "output": "90\n" } ] }, { "id": "s458415155", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype scanner struct{ *bufio.Scanner }\n\nfunc newScanner(r io.Reader) *scanner {\n\ts := bufio.NewScanner(r)\n\ts.Split(bufio.ScanWords)\n\ts.Buffer(nil, 100000000)\n\treturn &scanner{s}\n}\n\nfunc (s *scanner) Int() int {\n\ts.Scan()\n\tn, _ := strconv.Atoi(s.Text())\n\treturn n\n}\n\nfunc (s *scanner) IntSlice(l int) []int {\n\tif l == 0 {\n\t\treturn []int{}\n\t}\n\tsl := make([]int, l, l)\n\tfor i := range sl {\n\t\tsl[i] = s.Int()\n\t}\n\treturn sl\n}\n\nfunc iabs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc solve(n int, heights []int) int {\n\tt := make([]int, n+1, n+1)\n\tfor i := range t {\n\t\tt[i] = math.MaxInt64\n\t}\n\n\tt[0] = 0\n\tfor i := 1; i < n; i++ {\n\t\tif v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {\n\t\t\tt[i] = v\n\t\t}\n\t\tif 1 < i {\n\t\t\tif v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {\n\t\t\t\tt[i] = v\n\t\t\t}\n\t\t}\n\t}\n\n\treturn t[n-1]\n}\n\nfunc main() {\n\tsc := newScanner(os.Stdin)\n\tn := sc.Int()\n\theights := sc.IntSlice(n)\n\tans := solve(n, heights)\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "4\n10 30 40 20\n", "output": "30\n" } ] }, { "id": "s617302278", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc NextLine() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc NextIntsLine() []int {\n\tints := []int{}\n\tintsStr := NextLine()\n\ttmp := strings.Split(intsStr, \" \")\n\tfor _, s := range tmp {\n\t\tinteger, _ := strconv.Atoi(s)\n\t\tints = append(ints, integer)\n\t}\n\treturn ints\n}\n\nfunc NextStringsLine() []string {\n\tstrs := []string{}\n\tstringsStr := NextLine()\n\ttmp := strings.Split(stringsStr, \" \")\n\tfor _, s := range tmp {\n\t\tstrs = append(strs, s)\n\t}\n\treturn strs\n}\n\nfunc NextRunesLine() []rune {\n\treturn []rune(NextLine())\n}\n\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\tfa := float64(a)\n\tfe := float64(e)\n\tfanswer := math.Pow(fa, fe)\n\treturn int(fanswer)\n}\n\nfunc AbsInt(a int) int {\n\tfa := float64(a)\n\tfanswer := math.Abs(fa)\n\treturn int(fanswer)\n}\n\nfunc DeleteElement(s []int, i int) []int {\n\tif i < 0 || len(s) <= i {\n\t\tpanic(errors.New(\"[index error]\"))\n\t}\n\n\tn := make([]int, 0, len(s)-1)\n\tn = append(n, s[:i]...)\n\tn = append(n, s[i+1:]...)\n\treturn n\n}\n\nfunc Concat(s, t []rune) []rune {\n\tn := make([]rune, 0, len(s)+len(t))\n\tn = append(n, s...)\n\tn = append(n, t...)\n\treturn n\n}\n\nvar x int\n\nfunc main() {\n\ttmp := NextIntsLine()\n\tx = tmp[0]\n\ti := 1\n\tsum := 0\n\tfor {\n\t\tsum += i\n\t\tif sum >= x {\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t}\n\tfmt.Println(i)\n}\n", "test_IO": [ { "input": "6\n", "output": "3\n" } ] }, { "id": "s566920420", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\tfmt.Println(a + a*a + a*a*a)\n}\n", "test_IO": [ { "input": "2\n", "output": "14\n" } ] }, { "id": "s940603045", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n\t\"math/rand\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n)\n\nvar dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}\nvar dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}\n\nvar inf = math.MaxInt64\n\nvar next = newScanner()\n\nfunc init() {\n\tlog.SetFlags(log.Lshortfile)\n\trand.Seed(time.Now().UnixNano())\n}\n\nfunc main() {\n\tN := next.String()\n\tb := []byte(N)\n\tn := 0\n\n\tfor i := 0; i < len(b); i++ {\n\t\tn += int(b[i] - '0')\n\t}\n\tm, _ := strconv.Atoi(N)\n\tif m%n == 0 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n\ntype Pair struct {\n\ta, b int\n}\n\ntype Pairs []Pair\n\nfunc (p Pairs) Len() int {\n\treturn len(p)\n}\nfunc (p Pairs) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p Pairs) Less(i, j int) bool {\n\treturn p[i].b < p[i].b\n}\n\nfunc in(c, a, z int) bool {\n\treturn c >= a && c < z\n}\nfunc out(c, a, z int) bool {\n\treturn !in(c, a, z)\n}\nfunc btoi(b bool) int {\n\tif b {\n\t\treturn 1\n\t}\n\treturn 0\n}\nfunc itob(a int) bool {\n\treturn a != 0\n}\nfunc max(a ...int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r < a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\nfunc min(a ...int) int {\n\tr := a[0]\n\tfor i := 0; i < len(a); i++ {\n\t\tif r > a[i] {\n\t\t\tr = a[i]\n\t\t}\n\t}\n\treturn r\n}\nfunc sum(a []int) (r int) {\n\tfor i := range a {\n\t\tr += a[i]\n\t}\n\treturn r\n}\nfunc pro(a []int) int {\n\tr := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tr *= a[i]\n\t}\n\treturn r\n}\n\nfunc fill(a []int, n int) []int {\n\tfor i := range a {\n\t\ta[i] = n\n\t}\n\treturn a\n}\nfunc minmax(a, b int) (int, int) {\n\tif a > b {\n\t\treturn b, a\n\t}\n\treturn a, b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc ceil(a, b int) int {\n\tif a%b != 0 {\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc printStrings(out []string) {\n\tfor i := range out {\n\t\tfmt.Print(out[i])\n\t\tif i != len(out)-1 {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n\tfmt.Print(\"\\n\")\n}\nfunc printInts(out []int) {\n\tfor i := range out {\n\t\tfmt.Print(out[i])\n\t\tif i != len(out)-1 {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n\tfmt.Print(\"\\n\")\n}\n\ntype scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc newScanner() *scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 10000)\n\treturn &scanner{r: rdr}\n}\nfunc (s *scanner) next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *scanner) Line() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *scanner) String() string {\n\treturn s.next()\n}\nfunc (s *scanner) Int() int {\n\tv, err := strconv.Atoi(s.next())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn v\n}\nfunc (s *scanner) Ints(n int) []int {\n\tr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tr[i] = s.Int()\n\t}\n\treturn r\n}\nfunc (s *scanner) Int64() int64 {\n\tv, err := strconv.ParseInt(s.next(), 10, 64)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn v\n}\nfunc (s *scanner) Uint64() uint64 {\n\tv, err := strconv.ParseUint(s.next(), 10, 64)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn v\n}\nfunc (s *scanner) Float64() float64 {\n\tv, err := strconv.ParseFloat(s.next(), 64)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn v\n}\nfunc (s *scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "12\n", "output": "Yes\n" } ] }, { "id": "s058450440", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\ta []int\n\tans = 0\n)\n\nfunc dfs(left, i, res int) {\n\tif left == 0 {\n\t\tans += res\n\t\treturn\n\t}\n\tfor j := i; j < len(a); j++ {\n\t\tdfs(left-1, j+1, res*a[j])\n\t}\n}\n\nfunc main() {\n\tio := newIo()\n\tn := io.nextInt()\n\tdic := map[rune]int{}\n\n\tfor range make([]struct{}, n) {\n\t\tc := io.nextString()[0]\n\t\tswitch c {\n\t\tcase 'M', 'A', 'R', 'C', 'H':\n\t\t\tdic[rune(c)]++\n\t\t}\n\t}\n\n\tfor _, v := range dic {\n\t\ta = append(a, v)\n\t}\n\n\tdfs(3, 0, 1)\n\tfmt.Println(ans)\n}\n\ntype io struct {\n\treader *bufio.Reader\n\ttokens []string\n\tnextToken int\n}\n\nfunc newIo() *io {\n\treturn &io{reader: bufio.NewReader(os.Stdin)}\n}\n\nfunc (io *io) nextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, _ := io.reader.ReadLine()\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}\n\nfunc (io *io) nextString() string {\n\tfor io.nextToken >= len(io.tokens) {\n\t\tline := io.nextLine()\n\t\tio.tokens = strings.Fields(line)\n\t\tio.nextToken = 0\n\t}\n\tr := io.tokens[io.nextToken]\n\tio.nextToken++\n\treturn r\n}\n\nfunc (io *io) nextInt() int {\n\ti, _ := strconv.Atoi(io.nextString())\n\treturn i\n}\n", "test_IO": [ { "input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n", "output": "2\n" } ] }, { "id": "s144285625", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn := nextInt()\n\tar := make([]int, 3*n)\n\tfor i := range ar {\n\t\tar[i] = nextInt()\n\t}\n\tsort.Ints(ar)\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tsum += ar[3*n-(i+1)*2]\n\t}\n\tfmt.Println(sum)\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, _ := strconv.Atoi(sc.Text())\n\treturn i\n}\n", "test_IO": [ { "input": "2\n5 2 8 5 1 5\n", "output": "10\n" } ] }, { "id": "s143950643", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\n\tfmt.Println(3 * a * a)\n}\n", "test_IO": [ { "input": "4\n", "output": "48\n" } ] }, { "id": "s682653189", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tfor i := 0; i < len(s); i++ {\n\t\tfmt.Print(\"x\")\n\t}\n\tfmt.Println(\"\")\n}\n", "test_IO": [ { "input": "sardine\n", "output": "xxxxxxx\n" } ] }, { "id": "s525290130", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc nextInt(sc *bufio.Scanner) int {\n\tsc.Scan()\n\tt, _ := strconv.Atoi(sc.Text())\n\treturn t\n}\n\nfunc reva(b []int) {\n\tfor i := 0; i < len(b)/2; i++ {\n\t\tb[i], b[len(b)-1-i] = b[len(b)-1-i], b[i]\n\t}\n}\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Split(bufio.ScanWords)\n\tn := nextInt(sc)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = nextInt(sc)\n\t}\n\tq := nextInt(sc)\n\tfor i := 0; i < q; i++ {\n\t\tb := nextInt(sc)\n\t\te := nextInt(sc)\n\t\treva(a[b:e])\n\t}\n\twtr := bufio.NewWriter(os.Stdout)\n\tfor i := 0; i < n; i++ {\n\t\tif i > 0 {\n\t\t\tfmt.Fprint(wtr, \" \")\n\t\t}\n\t\tfmt.Fprint(wtr, a[i])\n\t}\n\tfmt.Fprintln(wtr)\n\twtr.Flush()\n}\n", "test_IO": [ { "input": "8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8\n", "output": "1 6 5 8 7 2 3 4\n" } ] }, { "id": "s863302171", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n string\n\tfmt.Scan(&n)\n\n\tfor i := 0; i < 3; i++ {\n\t\tif n[i] == '7' {\n\t\t\tfmt.Println(\"Yes\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"No\")\n}\n", "test_IO": [ { "input": "117\n", "output": "Yes\n" } ] }, { "id": "s725956217", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc out(x ...interface{}) {\n\tfmt.Println(x...)\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc asub(a, b int) int {\n\tif a > b {\n\t\treturn a - b\n\t}\n\treturn b - a\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\treturn -a\n}\n\nfunc lowerBound(a []int, x int) int {\n\tidx := sort.Search(len(a), func(i int) bool {\n\t\treturn a[i] >= x\n\t})\n\treturn idx\n}\n\nfunc upperBound(a []int, x int) int {\n\tidx := sort.Search(len(a), func(i int) bool {\n\t\treturn a[i] > x\n\t})\n\treturn idx\n}\n\ntype shop struct {\n\ta, b int\n}\n\ntype Datas []shop\n\nfunc (p Datas) Len() int {\n\treturn len(p)\n}\n\nfunc (p Datas) Swap(i, j int) {\n\tp[i], p[j] = p[j], p[i]\n}\n\nfunc (p Datas) Less(i, j int) bool {\n\treturn p[i].a < p[j].a\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\n\tN, M := getInt(), getInt()\n\ts := make(Datas, N)\n\tfor i := 0; i < N; i++ {\n\t\ta, b := getInt(), getInt()\n\t\ts[i] = shop{a, b}\n\t}\n\tsort.Sort(s)\n\n\ttotal := 0\n\tfor _, e := range s {\n\t\tn := min(e.b, M)\n\t\ttotal += n * e.a\n\t\tM -= n\n\t\tif M == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tout(total)\n}\n", "test_IO": [ { "input": "2 5\n4 9\n2 4\n", "output": "12\n" } ] }, { "id": "s851255999", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\n\tvar n int\n\tfmt.Scan(&n)\n\tvar ws works = make([]work, n)\n\tfor i := 0; i < n; i++ {\n\t\tvar a, n int\n\t\tfmt.Scan(&a, &n)\n\t\tws[i] = work{a, n}\n\t}\n\tsort.Sort(ws)\n\n\tsum := int64(0)\n\tfor _, w := range ws {\n\t\tsum += int64(w.time)\n\t\tif sum > int64(w.limit) {\n\t\t\tfmt.Println(\"No\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"Yes\")\n}\n\ntype work struct{ time, limit int }\ntype works []work\n\nfunc (w works) Len() int { return len(w) }\nfunc (w works) Swap(i, j int) { w[i], w[j] = w[j], w[i] }\nfunc (w works) Less(i, j int) bool { return w[i].limit < w[j].limit }\n", "test_IO": [ { "input": "5\n2 4\n1 9\n1 8\n4 9\n3 12\n", "output": "Yes\n" } ] }, { "id": "s129530281", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextUint64(scanner *bufio.Scanner) uint64 {\n\ti, _ := strconv.ParseUint(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextFloat64(scanner *bufio.Scanner) float64 {\n\ti, _ := strconv.ParseFloat(getNextString(scanner), 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t}\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(os.Stdout)\n\n\tn := getNextInt(scanner)\n\tm := getNextInt(scanner)\n\tseg := Segment{}\n\tseg.init(n)\n\tfor i := 0; i < n; i++ {\n\t\tseg.maximize(i, getNextInt(scanner))\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tseg.maximize(seg.top(), seg.bucket[seg.h-1][0]>>1)\n\t}\n\n\tvar ans int64\n\tfor i := 0; i < n; i++ {\n\t\tans += int64(seg.bucket[0][i])\n\t}\n\n\tfmt.Fprintln(writer, ans)\n\twriter.Flush()\n}\n\ntype Segment struct {\n\tn, h, i, chunk int\n\tunit []int\n\tbucket [][]int\n}\n\nfunc (seg *Segment) init(n int) {\n\tseg.n = n\n\tseg.unit = make([]int, 1)\n\tseg.unit[0] = 1\n\tseg.bucket = make([][]int, 1)\n\tseg.bucket[0] = make([]int, n)\n\n\tchunk := 8\n\tfor i := 0; n > 1; i++ {\n\t\tn = (n-1)/chunk + 1\n\t\tseg.bucket = append(seg.bucket, make([]int, n))\n\t\tseg.unit = append(seg.unit, seg.unit[i]*chunk)\n\t}\n\tseg.h = len(seg.unit)\n\tseg.chunk = chunk\n}\n\nfunc (seg *Segment) maximize(index, value int) {\n\tseg.bucket[0][index] = value\n\tfor seg.i = 0; seg.i < seg.h-1; seg.i++ {\n\t\ts := index - index%seg.chunk\n\t\tt := s + seg.chunk\n\t\tif t > len(seg.bucket[seg.i]) {\n\t\t\tt = len(seg.bucket[seg.i])\n\t\t}\n\t\tparent := index / seg.chunk\n\t\tmax := 0\n\t\tfor i := s; i < t; i++ {\n\t\t\tif max < seg.bucket[seg.i][i] {\n\t\t\t\tmax = seg.bucket[seg.i][i]\n\t\t\t}\n\t\t}\n\t\tseg.bucket[seg.i+1][parent] = max\n\t\tindex /= seg.chunk\n\t}\n}\n\nfunc (seg *Segment) top() int {\n\tindex := 0\n\tfor seg.i = seg.h - 2; seg.i >= 0; seg.i-- {\n\t\ts := index * seg.chunk\n\t\tt := s + seg.chunk\n\t\tif t > len(seg.bucket[seg.i]) {\n\t\t\tt = len(seg.bucket[seg.i])\n\t\t}\n\t\tfor i := s; i < t; i++ {\n\t\t\tif seg.bucket[seg.i][i] == seg.bucket[seg.i+1][index] {\n\t\t\t\tindex = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn index\n}\n", "test_IO": [ { "input": "3 3\n2 13 8\n", "output": "9\n" } ] }, { "id": "s118500787", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tS, T := ReadString(), ReadString()\n\tmax := 0\n\tfor i := 0; i <= len(S)-len(T); i++ {\n\t\tc := 0\n\t\tfor j := 0; j < len(T); j++ {\n\t\t\tif S[i+j] == T[j] {\n\t\t\t\tc++\n\t\t\t}\n\t\t}\n\t\tif max < c {\n\t\t\tmax = c\n\t\t}\n\t}\n\tfmt.Println(len(T) - max)\n}\n\nvar reader = bufio.NewReader(os.Stdin)\n\nfunc Scan(a ...interface{}) {\n\tif _, err := fmt.Fscan(reader, a...); err != nil {\n\t\tpanic(err)\n\t}\n}\nfunc ReadInt() (i int) { Scan(&i); return }\nfunc ReadString() (s string) { Scan(&s); return }\nfunc ReadInts(n int) []int {\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tScan(&v[i])\n\t}\n\treturn v\n}\n", "test_IO": [ { "input": "cabacc\nabc\n", "output": "1\n" } ] }, { "id": "s692569558", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Scan()\n\ts.Scan()\n\tds := s.Text()\n\n\tdd := strings.Split(ds, \" \")\n\tdn := make([]int, len(dd))\n\tfor i, d := range dd {\n\t\tdn[i], _ = strconv.Atoi(d)\n\t}\n\n\tsum := 0\n\tfor i := 0; i < len(dn); i++ {\n\t\tfor j := i + 1; j < len(dn); j++ {\n\t\t\tsum += dn[i] * dn[j]\n\t\t}\n\t}\n\n\tfmt.Println(sum)\n}\n", "test_IO": [ { "input": "3\n3 1 2\n", "output": "11\n" } ] }, { "id": "s803744887", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tconst MX = 10000\n\tsieve := make([]int, MX)\n\tprimes := make([]int, 0, MX)\n\tfor i := 2; i < MX; i++ {\n\t\tif sieve[i] != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tprimes = append(primes, i)\n\t\tfor j := i + i; j < MX; j += i {\n\t\t\tsieve[j] = i\n\t\t}\n\t}\n\n\tvar n int\n\tfmt.Scan(&n)\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Scan(&x)\n\t\tans++\n\t\tfor j := 0; j < len(primes); j++ {\n\t\t\tif x > primes[j] && x%primes[j] == 0 {\n\t\t\t\tans--\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "5\n2\n3\n4\n5\n6\n", "output": "3\n" } ] }, { "id": "s554024899", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tlog.SetFlags(log.Lshortfile)\n\tsc := newScanner()\n\tx := sc.nextInt()\n\ty := sc.nextInt()\n\tvar xt, yt int\n\ta := [3][]int{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}}\n\tfor i, t := range a {\n\t\tfor _, n := range t {\n\n\t\t\tif x == n {\n\t\t\t\txt = i\n\t\t\t}\n\t\t\tif y == n {\n\t\t\t\tyt = i\n\t\t\t}\n\t\t}\n\t}\n\tif xt == yt {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\ntype scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc newScanner() *scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &scanner{r: rdr}\n}\nfunc (s *scanner) next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *scanner) nextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *scanner) nextInt() int {\n\tv, _ := strconv.Atoi(s.next())\n\treturn v\n}\n\nfunc (s *scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "1 3\n", "output": "Yes\n" } ] }, { "id": "s918723842", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tH, W, N := sc.NextInt(), sc.NextInt(), sc.NextInt()\n\n\tA := max(H, W)\n\n\tfmt.Println((N + A - 1) / A)\n\n}\n\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextFloat() float64 {\n\tv, _ := strconv.ParseFloat(s.Next(), 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n", "test_IO": [ { "input": "3\n7\n10\n", "output": "2\n" } ] }, { "id": "s382986061", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nvar N, K int\nvar d, a int\n\nfunc main() {\n\tfmt.Scan(&N, &K)\n\tas := make(map[int]int)\n\tfor i := 1; i <= N; i++ {\n\t\tas[i] = 0\n\t}\n\tfor i := 0; i < K; i++ {\n\t\tfmt.Scan(&d)\n\t\tfor j := 0; j < d; j++ {\n\t\t\tfmt.Scan(&a)\n\t\t\tas[a]++\n\t\t}\n\t}\n\tans := 0\n\tfor _, v := range as {\n\t\tif v == 0 {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n", "test_IO": [ { "input": "3 2\n2\n1 3\n1\n3\n", "output": "1\n" } ] }, { "id": "s541050824", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype bufReader struct {\n\tr *bufio.Reader\n\tbuf []byte\n\ti int\n}\n\nvar reader = &bufReader{\n\tbufio.NewReader(os.Stdin),\n\tmake([]byte, 0),\n\t0,\n}\n\nfunc (r *bufReader) readLine() {\n\tif r.i < len(r.buf) {\n\t\treturn\n\t}\n\tr.buf = make([]byte, 0)\n\tr.i = 0\n\tfor {\n\t\tline, isPrefix, err := r.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tr.buf = append(r.buf, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunc (r *bufReader) next() string {\n\tr.readLine()\n\tfrom := r.i\n\tfor ; r.i < len(r.buf); r.i++ {\n\t\tif r.buf[r.i] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\ts := string(r.buf[from:r.i])\n\tr.i++\n\treturn s\n}\n\nfunc (r *bufReader) nextLine() string {\n\tr.readLine()\n\ts := string(r.buf[r.i:])\n\tr.i = len(r.buf)\n\treturn s\n}\n\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n\treturn reader.next()\n}\n\nfunc nextInt() int64 {\n\ti, err := strconv.ParseInt(reader.next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc nextLine() string {\n\treturn reader.nextLine()\n}\n\nfunc out(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc joinInts(a []int64, sep string) string {\n\tb := make([]string, len(a))\n\tfor i, v := range a {\n\t\tb[i] = strconv.FormatInt(v, 10)\n\t}\n\treturn strings.Join(b, sep)\n}\n\nfunc divUp(x, y int64) int64 {\n\treturn (x + y - 1) / y\n}\n\nfunc main() {\n\tsolve()\n\twriter.Flush()\n}\n\nfunc solve() {\n\tN := nextInt()\n\tT, A := make([]int64, N), make([]int64, N)\n\tfor i := 0; i < int(N); i++ {\n\t\tT[i], A[i] = nextInt(), nextInt()\n\t}\n\tt, a := T[0], A[0]\n\tfor i := 1; i < int(N); i++ {\n\t\tr := max(divUp(t, T[i]), divUp(a, A[i]))\n\t\tt, a = T[i]*r, A[i]*r\n\t}\n\tout(t + a)\n}\n", "test_IO": [ { "input": "3\n2 3\n1 1\n3 2\n", "output": "10\n" } ] }, { "id": "s784695632", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scan(&x, &y)\n\n\tfmt.Println(x + y/2)\n}\n", "test_IO": [ { "input": "81 58\n", "output": "110\n" } ] }, { "id": "s168401731", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextUint64(scanner *bufio.Scanner) uint64 {\n\ti, _ := strconv.ParseUint(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc getNextFloat64(scanner *bufio.Scanner) float64 {\n\ti, _ := strconv.ParseFloat(getNextString(scanner), 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\twfp := os.Stdout\n\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t\tif len(os.Args) > 2 {\n\t\t\twfp, _ = os.Create(os.Args[2])\n\t\t}\n\t}\n\n\tscanner := getScanner(fp)\n\twriter := bufio.NewWriter(wfp)\n\n\tn := getNextInt(scanner)\n\n\tans := \"second\"\n\tfor i := 0; i < n; i++ {\n\t\ta := getNextInt(scanner)\n\t\tif a%2 == 1 {\n\t\t\tans = \"first\"\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Fprintln(writer, ans)\n\twriter.Flush()\n}\n", "test_IO": [ { "input": "2\n1\n2\n", "output": "first\n" } ] }, { "id": "s294436820", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar DEBUG = false\n\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\nvar OutputBuffer *bufio.Writer\n\nvar OutputWriter io.Writer\n\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbufferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\nfunc SetUnbufferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\nfunc reads() string {\n\treturn string(readb())\n}\n\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\nfunc readsln() string {\n\treturn string(readbln())\n}\n\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\nfunc readi() int {\n\treturn int(readll())\n}\n\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\nfunc debugf(f string, args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc debug(args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintln(os.Stderr, args...)\n}\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\nconst (\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minf(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxf(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absf(a float64) float64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\nfunc init() {\n\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\tSetInteractive(os.Stdout, os.Stdin)\n}\n\nfunc main() {\n\tdefer Flush()\n\th, w, k := readi(), readi(), readi()\n\tm := make([][]int, h)\n\tfor i := 0; i < h; i++ {\n\t\tm[i] = make([]int, w)\n\t\ts := reads()\n\t\tfor j := 0; j < w; j++ {\n\t\t\tm[i][j] = int(s[j])\n\t\t}\n\t}\n\n\tanswer := solve(h, w, k, m)\n\tprintln(answer)\n}\n\nconst Black int = 35\n\nfunc countBlack(h, w int, m [][]int) int {\n\tcount := 0\n\tdebug(\"new table\")\n\tfor i := 0; i < h; i++ {\n\t\tfor j := 0; j < w; j++ {\n\t\t\tif m[i][j] == Black {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t\tdebug(m[i])\n\t}\n\tdebug(\"result : \", count)\n\treturn count\n}\n\nfunc solve(h, w, a int, m [][]int) int {\n\tresult := 0\n\tfor i := 0; i < 1< 0 {\n\t\t\t\t\tdebug(\"painted \", j, 1< 0 {\n\t\t\t\t\tfor l := 0; l < h; l++ {\n\t\t\t\t\t\ttmp[l][j] = 1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tdebug(\"i\", strconv.FormatInt(int64(i), 2))\n\t\t\tdebug(\"k\", strconv.FormatInt(int64(k), 2))\n\t\t\tif countBlack(h, w, tmp) == a {\n\t\t\t\tresult++\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}\n", "test_IO": [ { "input": "2 3 2\n..#\n###\n", "output": "5\n" } ] }, { "id": "s497500962", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tR := nextInt()\n\tG := nextInt()\n\tB := nextInt()\n\tN := nextInt()\n\n\tvar ans int\n\tfor x := 0; x <= N; x++ {\n\t\tfor y := 0; y <= N; y++ {\n\t\t\ttmp := N - R*x - G*y\n\t\t\tif tmp >= 0 && tmp%B == 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tsc.Buffer([]byte{}, math.MaxInt64)\n\tsc.Split(bufio.ScanWords)\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, err := strconv.Atoi(sc.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn i\n}\n\nfunc nextFloat() float64 {\n\tsc.Scan()\n\tf64, err := strconv.ParseFloat(sc.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn f64\n}\n\nfunc nextString() string {\n\tsc.Scan()\n\tif err := sc.Err(); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn sc.Text()\n}\n\nfunc abs(x int) int {\n\treturn int(math.Abs(float64(x)))\n}\n\nfunc min(x, y int) int {\n\treturn int(math.Min(float64(x), float64(y)))\n}\n\nfunc max(x, y int) int {\n\treturn int(math.Max(float64(x), float64(y)))\n}\n", "test_IO": [ { "input": "1 2 3 4\n", "output": "4\n" } ] }, { "id": "s057401371", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Scan()\n\ts := sc.Text()\n\n\td := 'a' - 'A'\n\tfor _, r := range s {\n\t\trr := r\n\t\tif 'A' <= r && r <= 'Z' {\n\t\t\trr = r + d\n\t\t} else if 'a' <= r && r <= 'z' {\n\t\t\trr = r - d\n\t\t}\n\t\tfmt.Printf(\"%c\", rr)\n\t}\n\tfmt.Println()\n}\n", "test_IO": [ { "input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n", "output": "Fair, later, occasionally cloudy.\n" } ] }, { "id": "s236040683", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc out(x ...interface{}) {\n\tfmt.Println(x...)\n}\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc getInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\nfunc getString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\ntype Node struct {\n\tto []int\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\n\tN, M := getInt(), getInt()\n\tn := make([]Node, N)\n\tfor i := 0; i < M; i++ {\n\t\tfrom, to := getInt()-1, getInt()-1\n\t\tn[from].to = append(n[from].to, to)\n\t\tn[to].to = append(n[to].to, from)\n\t}\n\n\tfor i := 0; i < N; i++ {\n\t\tout(len(n[i].to))\n\t}\n\n}\n", "test_IO": [ { "input": "4 3\n1 2\n2 3\n1 4\n", "output": "2\n2\n1\n1\n" } ] }, { "id": "s197768810", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\n\nfunc readInt() int {\n\tsc.Scan()\n\ti, err := strconv.Atoi(sc.Text())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc readFloat64() float64 {\n\tsc.Scan()\n\tf, err := strconv.ParseFloat(sc.Text(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn f\n}\n\nfunc readString() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tn, m := readInt(), readInt()\n\ta := make([]int, n)\n\tsum := 0\n\tfor i := 0; i < m; i++ {\n\t\ta[i] = readInt()\n\t\tsum += a[i]\n\t}\n\tif sum > n {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t}\n\n\tfmt.Println(n - sum)\n}\n", "test_IO": [ { "input": "41 2\n5 6\n", "output": "30\n" } ] }, { "id": "s953070177", "dataset": "codenet", "language": "Go", "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc getScanner(fp *os.File) *bufio.Scanner {\n\tscanner := bufio.NewScanner(fp)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 500001), 500000)\n\treturn scanner\n}\n\nfunc getNextString(scanner *bufio.Scanner) string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc getNextInt(scanner *bufio.Scanner) int {\n\ti, _ := strconv.Atoi(getNextString(scanner))\n\treturn i\n}\n\nfunc getNextInt64(scanner *bufio.Scanner) int64 {\n\ti, _ := strconv.ParseInt(getNextString(scanner), 10, 64)\n\treturn i\n}\n\nfunc main() {\n\tfp := os.Stdin\n\tif len(os.Args) > 1 {\n\t\tfp, _ = os.Open(os.Args[1])\n\t}\n\n\tscanner := getScanner(fp)\n\n\twriter := bufio.NewWriter(os.Stdout)\n\n\tn := getNextInt(scanner)\n\n\taa := make([]int, n+2)\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\taa[i+1] = getNextInt(scanner)\n\t\tsum += absint(aa[i+1] - aa[i])\n\t}\n\tsum += absint(aa[n+1] - aa[n])\n\n\tfor i := 1; i < n+1; i++ {\n\t\tans := sum - absint(aa[i+1]-aa[i]) - absint(aa[i]-aa[i-1]) + absint(aa[i+1]-aa[i-1])\n\t\tfmt.Fprintln(writer, ans)\n\t}\n\n\twriter.Flush()\n}\n\nfunc absint(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n", "test_IO": [ { "input": "3\n3 5 -1\n", "output": "12\n8\n10\n" } ] }, { "id": "s752993784", "dataset": "codenet", "language": "Python", "code": "s = list(input())\nmods = [0]*(len(s))\ncountRemainder = [0] * 2019\ncnt = 0\n\n\nm = 1\nmod = 0\nfor i in range(len(s)):\n mod += int(s[len(s) - i - 1]) * m\n\n mod %= 2019\n m *= 10\n m %= 2019\n\n countRemainder[mod] += 1\n\ncountRemainder[0] += 1\n\nfor i in range(2019):\n cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)\n\nprint(cnt)\n", "test_IO": [ { "input": "1817181712114\n", "output": "3\n" } ] }, { "id": "s199418121", "dataset": "codenet", "language": "Python", "code": "A, B = input().split()\nA = int(A)\nB = int(B.replace(\".\", \"\"))\nprint(A * B // 100)\n", "test_IO": [ { "input": "198 1.10\n", "output": "217\n" } ] }, { "id": "s537584449", "dataset": "codenet", "language": "Python", "code": "a = int(input())\n\n\ndef func(a):\n digits = []\n temp = a\n while temp != 0:\n digits.append(temp % 10)\n temp = int(temp/10)\n result = sum(digits)\n if result == 1:\n print('10')\n else:\n print(result)\n\n\nfunc(a)\n", "test_IO": [ { "input": "15\n", "output": "6\n" } ] }, { "id": "s043545989", "dataset": "codenet", "language": "Python", "code": "import collections\nN = int(input())\na = list(map(int, input().split()))\nB = collections.Counter(a)\nk = list(B.keys())\nv = list(B.values())\n\nif len(B) == 3 and k[0] ^ k[1] ^ k[2] == 0 and v[0] == v[1] == v[2]:\n print(\"Yes\")\nelif len(B) == 2 and 0 in k and (v[0] == 2*v[1] or v[1] == 2*v[0]):\n print(\"Yes\")\nelif len(B) == 1 and 0 in k:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "test_IO": [ { "input": "3\n1 2 3\n", "output": "Yes\n" } ] }, { "id": "s609392609", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n s = 0\n for j in range(len(t)):\n if j == p-1:\n s += x\n else:\n s += t[j]\n print(s)\n", "test_IO": [ { "input": "3\n2 1 4\n2\n1 1\n2 3\n", "output": "6\n9\n" } ] }, { "id": "s310981504", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\n\nif a <= b:\n print(a)\nelse:\n print(a-1)\n", "test_IO": [ { "input": "5 5\n", "output": "5\n" } ] }, { "id": "s419623944", "dataset": "codenet", "language": "Python", "code": "N, R = map(int, input().split())\nif N >= 10:\n print(R)\nelse:\n print(R+100*(10-N))\n", "test_IO": [ { "input": "2 2919\n", "output": "3719\n" } ] }, { "id": "s546174362", "dataset": "codenet", "language": "Python", "code": "N, M = map(int, input().split())\n*A, = map(int, input().split())\nA = sorted(A)\n\nwhile M:\n A[-1] //= 2\n M -= 1\n i = -2\n while M and (-N <= i and A[i] >= A[-1]):\n A[i] //= 2\n M -= 1\n i -= 1\n A.sort()\n\nprint(sum(A))\n", "test_IO": [ { "input": "3 3\n2 13 8\n", "output": "9\n" } ] }, { "id": "s908812767", "dataset": "codenet", "language": "Python", "code": "import sys\nsys.setrecursionlimit(100000)\n\n\ndef dfs(i):\n for v, w in V.get(i, []):\n if (w % 2) == 0:\n if color[v] == -1:\n color[v] = color[i]\n elif color[v] == color[i]:\n continue\n elif color[v] != color[i]:\n return False\n else:\n if color[v] == -1:\n color[v] = 0 if color[i] else 1\n elif color[v] == color[i]:\n return False\n elif color[v] != color[i]:\n continue\n dfs(v)\n return True\n\n\nif __name__ == '__main__':\n n = int(input())\n V = {}\n color = {}\n for i in range(1, n):\n u, v, w = map(int, input().split())\n if not V.get(u, False):\n V[u] = [[v, w]]\n else:\n V[u].append([v, w])\n\n if not V.get(v, False):\n V[v] = [[u, w]]\n else:\n V[v].append([u, w])\n\n for i in range(1, n+1):\n color[i] = -1\n\n while True:\n i = 0\n for j in range(1, n+1):\n if color[j] == -1:\n i = j\n color[i] = 0\n break\n if i == 0:\n for j in range(1, n+1):\n print(color[j])\n break\n else:\n if not dfs(i):\n print('No')\n break\n", "test_IO": [ { "input": "3\n1 2 2\n2 3 1\n", "output": "0\n0\n1\n" } ] }, { "id": "s251858505", "dataset": "codenet", "language": "Python", "code": "print(sum(map(lambda x, y: x == y, input(), input())))\n", "test_IO": [ { "input": "CSS\nCSR\n", "output": "2\n" } ] }, { "id": "s504709360", "dataset": "codenet", "language": "Python", "code": "s = input()\nif len(s) < 26:\n for i in range(26):\n c = chr(ord(\"a\")+i)\n if c not in s:\n print(s+c)\n exit()\nelse:\n for i in reversed(range(1, 26)):\n if s[i-1] < s[i]:\n s1 = s[0:i-1]\n for j in range(26):\n c = chr(ord(\"a\")+j)\n if c > s[i-1] and c not in s1:\n print(s1+c)\n exit()\n print(-1)\n", "test_IO": [ { "input": "atcoder\n", "output": "atcoderb\n" } ] }, { "id": "s785944322", "dataset": "codenet", "language": "Python", "code": "import sys\ninput = sys.stdin.readline\n\na, b = map(int, input().split())\n\nif a >= 13:\n print(b)\nelif a >= 6:\n print(int(b/2))\nelse:\n print(0)\n", "test_IO": [ { "input": "30 100\n", "output": "100\n" } ] }, { "id": "s170274782", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = []\nfor _ in range(2):\n s = list(map(int, input().split()))\n A.append(s)\n\n\nans = []\n\ncount = 0\nfor i in range(N):\n baselis = A[0]\n groundlis = A[1]\n count = 0\n count = count + sum(baselis[0:i+1]) + sum(groundlis[i:N+1])\n ans.append(count)\n\nprint(max(ans))\n", "test_IO": [ { "input": "5\n3 2 2 4 1\n1 2 2 2 1\n", "output": "14\n" } ] }, { "id": "s662673721", "dataset": "codenet", "language": "Python", "code": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\n\nans = 10 ** 18\n\nfor i in range(1, int(n ** (1 / 2)) + 2):\n if n % i != 0:\n continue\n j = n // i\n ans = min(ans, i + j - 2)\n\nprint(ans)\n", "test_IO": [ { "input": "10\n", "output": "5\n" } ] }, { "id": "s539244923", "dataset": "codenet", "language": "Python", "code": "n, k = map(int, input().split())\nprint(n+k if k % n == 0 else k-n)\n", "test_IO": [ { "input": "4 12\n", "output": "16\n" } ] }, { "id": "s790754864", "dataset": "codenet", "language": "Python", "code": "import math\nN, K = (int(x) for x in input().split())\nR = N - K\nmod = 10**9 + 7\n\n\ndef fact(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nfor i in range(1, K+1):\n if N - K + 1 < i:\n ans = 0\n else:\n ans = fact(R+1, i)*fact(K-1, i-1)\n print(int(ans) % mod)\n", "test_IO": [ { "input": "5 3\n", "output": "3\n6\n1\n" } ] }, { "id": "s636719275", "dataset": "codenet", "language": "Python", "code": "s = input()\nt = input()\n\n\ndef check(a, b):\n s = 0\n for i, j in zip(a, b):\n s += i != j\n return s\n\n\nans = 10**6\nfor i in range(len(s)):\n a = s[i:]\n if len(a) >= len(t):\n ans = min(ans, check(t, a[:len(t)]))\nprint(ans)\n", "test_IO": [ { "input": "cabacc\nabc\n", "output": "1\n" } ] }, { "id": "s240532461", "dataset": "codenet", "language": "Python", "code": "N, L = map(int, input().split())\naji = []\nfor i in range(1, N+1):\n aji.append(L+i-1)\nif min(aji) >= 0:\n aji.pop(aji.index(min(aji)))\nelif max(aji) <= 0:\n aji.pop(aji.index(max(aji)))\nelse:\n aji.pop(aji.index(min(aji, key=abs)))\nprint(sum(aji))\n", "test_IO": [ { "input": "5 2\n", "output": "18\n" } ] }, { "id": "s828550015", "dataset": "codenet", "language": "Python", "code": "x, y, a, b, c = map(int, input().split())\np = sorted([int(i) for i in input().split()], reverse=True)[:x]\nq = sorted([int(i) for i in input().split()], reverse=True)[:y]\nr = sorted([int(i) for i in input().split()], reverse=True)\npq = sorted(p+q)\nfor i in range(min(x+y, a+b, c)):\n if pq[i] < r[i]:\n pq[i] = r[i]\nprint(sum(pq))\n", "test_IO": [ { "input": "1 2 2 2 1\n2 4\n5 1\n3\n", "output": "12\n" } ] }, { "id": "s225615697", "dataset": "codenet", "language": "Python", "code": "n = int(input())\na = list(map(int, input().split()))\n\nm1 = int(sum([a[i] * ((-1)**i) for i in range(n)]) / 2)\n\nresult = str(m1)\n\nm = [None] * n\nm[0] = m1\nfor i in range(1, n):\n m[i] = a[i-1] - m[i-1]\n\nprint(' '.join([str(x*2) for x in m]))\n", "test_IO": [ { "input": "3\n2 2 4\n", "output": "4 0 4\n" } ] }, { "id": "s846046431", "dataset": "codenet", "language": "Python", "code": "import sys\nN, M = map(int, sys.stdin.readline().split())\nA = list(map(int, sys.stdin.readline().split()))\nA.sort(reverse=True)\nS = sum(A)\nfor a in A[:M]:\n if a/S - 1/(4*M) < 0:\n print('No')\n break\nelse:\n print('Yes')\n", "test_IO": [ { "input": "4 1\n5 4 2 1\n", "output": "Yes\n" } ] }, { "id": "s462546732", "dataset": "codenet", "language": "Python", "code": "a, b = input().split(\" \")\na = int(a)\nb = int(b)\nif a <= b:\n print(a)\nelse:\n print(a-1)\n", "test_IO": [ { "input": "5 5\n", "output": "5\n" } ] }, { "id": "s131946120", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nprint(len(set([input() for _ in range(n)])))\n", "test_IO": [ { "input": "4\n10\n8\n8\n6\n", "output": "3\n" } ] }, { "id": "s016605598", "dataset": "codenet", "language": "Python", "code": "import heapq\nconst = 0\nleft = []\nright = []\n\nq = int(input())\ncnt = 0\nleft_sum = 0\nright_sum = 0\nfor _ in range(q):\n t = list(map(int, input().split()))\n if t[0] == 1:\n\n a, b = t[1:]\n const += b\n if cnt % 2 == 0:\n if not right:\n heapq.heappush(left, -a)\n left_sum += a\n cnt += 1\n\n continue\n\n c = heapq.heappop(right)\n right_sum -= c\n if a <= c:\n heapq.heappush(left, -a)\n heapq.heappush(right, c)\n left_sum += a\n right_sum += c\n else:\n heapq.heappush(left, -c)\n heapq.heappush(right, a)\n left_sum += c\n right_sum += a\n else:\n c = heapq.heappop(left)\n left_sum += c\n if a <= -c:\n heapq.heappush(left, -a)\n heapq.heappush(right, -c)\n left_sum += a\n right_sum -= c\n else:\n heapq.heappush(left, c)\n heapq.heappush(right, a)\n left_sum -= c\n right_sum += a\n cnt += 1\n\n else:\n tmp = -left[0]\n print(tmp, const - left_sum + right_sum + tmp * (cnt % 2))\n", "test_IO": [ { "input": "4\n1 4 2\n2\n1 1 -8\n2\n", "output": "4 2\n1 -3\n" } ] }, { "id": "s441028271", "dataset": "codenet", "language": "Python", "code": "(a, b, c, k) = list(map(int, input().split()))\nif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)\n", "test_IO": [ { "input": "1 2 3 1\n", "output": "1\n" } ] }, { "id": "s269975433", "dataset": "codenet", "language": "Python", "code": "from itertools import combinations_with_replacement\nimport sys\n\n\ndef LI(): return map(int, sys.stdin.readline().rstrip().split())\n\n\nN, M, Q = LI()\n\nQ_groups = []\nfor _ in range(Q):\n Q_groups.append([*LI()])\n\nmax_score = 0\nfor p in combinations_with_replacement(range(1, M + 1), r=N):\n temp_score = 0\n for q in Q_groups:\n if p[q[1] - 1] - p[q[0] - 1] == q[2]:\n temp_score += q[3]\n max_score = max(max_score, temp_score)\n\nprint(max_score)\n", "test_IO": [ { "input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n", "output": "110\n" } ] }, { "id": "s949655009", "dataset": "codenet", "language": "Python", "code": "strn = input()\nn = int(strn)\nshichigolist = [\"3\", \"5\", \"7\"]\nshichigo = [[] for _ in range(len(strn))]\nfor i in range(len(strn)):\n if i == 0:\n for j in shichigolist:\n shichigo[i].append(j)\n else:\n for j in shichigo[i-1]:\n for k in shichigolist:\n shichigo[i].append(j+k)\ntarget = len(strn)-1\nfor i in range(len(strn)):\n for j in shichigo[i][:]:\n if i == target:\n if int(j) > n:\n shichigo[target].remove(j)\n elif j.count(\"3\") == 0 or j.count(\"5\") == 0 or j.count(\"7\") == 0:\n shichigo[target].remove(j)\n else:\n if j.count(\"3\") == 0 or j.count(\"5\") == 0 or j.count(\"7\") == 0:\n shichigo[i].remove(j)\n\nprint(sum([len(shichigo[i]) for i in range(len(strn))]))\n", "test_IO": [ { "input": "575\n", "output": "4\n" } ] }, { "id": "s316832655", "dataset": "codenet", "language": "Python", "code": "a, b, c = map(int, input().split())\nprint(int((a*b)/2))\n", "test_IO": [ { "input": "3 4 5\n", "output": "6\n" } ] }, { "id": "s103029464", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = list(map(int, input().split()))\nB = [0] * N\n\nfor i in range(N - 1, -1, -1):\n tmp_sum = 0\n for j in range((i + 1) * 2 - 1, N, i + 1):\n tmp_sum += B[j]\n tmp_sum %= 2\n B[i] = tmp_sum ^ A[i]\n\nprint(sum(B))\nprint(*[i + 1 for i, b in enumerate(B) if b == 1])\n", "test_IO": [ { "input": "3\n1 0 0\n", "output": "1\n1\n" } ] }, { "id": "s759547301", "dataset": "codenet", "language": "Python", "code": "S = input()\n\nif S == 'Sunny':\n print('Cloudy')\n\nif S == 'Cloudy':\n print('Rainy')\n\nif S == 'Rainy':\n print('Sunny')\n", "test_IO": [ { "input": "Sunny\n", "output": "Cloudy\n" } ] }, { "id": "s961772658", "dataset": "codenet", "language": "Python", "code": "s = input()\nalphabets = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\",\n \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\nfor i in range(len(alphabets)):\n if alphabets[i] == s:\n print(alphabets[i+1])\n", "test_IO": [ { "input": "a\n", "output": "b\n" } ] }, { "id": "s018260659", "dataset": "codenet", "language": "Python", "code": "N = int(input())\ncnt = 1\nwhile cnt <= 9:\n if N % cnt == 0 and 1 <= N/cnt <= 9:\n print('Yes')\n break\n else:\n cnt += 1\nelse:\n print('No')\n", "test_IO": [ { "input": "10\n", "output": "Yes\n" } ] }, { "id": "s826716211", "dataset": "codenet", "language": "Python", "code": "import copy\n\n\ndef solve():\n S_d = list(input())\n T = list(input())\n\n end = len(S_d) - 1\n first = end - len(T) + 1\n while first >= 0:\n t_i = 0\n for s_i in range(first, end+1):\n if T[t_i] != S_d[s_i] and S_d[s_i] != '?':\n break\n t_i += 1\n else:\n break\n\n first -= 1\n end -= 1\n\n else:\n print('UNRESTORABLE')\n exit(0)\n\n ans = copy.deepcopy(S_d)\n t_i = 0\n for i in range(first, end+1):\n ans[i] = T[t_i]\n t_i += 1\n\n ans = ''.join(ans).replace('?', 'a')\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "test_IO": [ { "input": "?tc????\ncoder\n", "output": "atcoder\n" } ] }, { "id": "s353603279", "dataset": "codenet", "language": "Python", "code": "X = int(input())\nh = X // 500\na = (X % 500) // 5\ny = h * 1000 + a * 5\nprint(y)\n", "test_IO": [ { "input": "1024\n", "output": "2020\n" } ] }, { "id": "s663509070", "dataset": "codenet", "language": "Python", "code": "import math\nN, D = map(int, input().split())\nmat = []\nfor d in range(N):\n mat.append([int(x) for x in input().split()])\n\nc = 0\nfor i in range(len(mat)-1):\n for j in range(i+1, len(mat)):\n dist = math.sqrt(sum([(x-y)**2 for x, y in zip(mat[i], mat[j])]))\n if int(dist) == dist:\n c += 1\nprint(c)\n", "test_IO": [ { "input": "3 2\n1 2\n5 5\n-2 8\n", "output": "1\n" } ] }, { "id": "s000375264", "dataset": "codenet", "language": "Python", "code": "X, t = map(int, input().split())\n\nif X > t:\n answer = X - t\nelif X <= t:\n answer = 0\n\nprint(answer)\n", "test_IO": [ { "input": "100 17\n", "output": "83\n" } ] }, { "id": "s522872163", "dataset": "codenet", "language": "Python", "code": "X, A = list(map(int, input().split()))\nif X < A:\n print(0)\nelse:\n print(10)\n", "test_IO": [ { "input": "3 5\n", "output": "0\n" } ] }, { "id": "s997947249", "dataset": "codenet", "language": "Python", "code": "N, K = map(int, input().split())\nif N % K == 0:\n print(0)\nelse:\n print(1)\n", "test_IO": [ { "input": "7 3\n", "output": "1\n" } ] }, { "id": "s451465602", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nh = int(n / 3600)\nn %= 3600\nm = int(n / 60)\nn %= 60\ns = int(n)\nprint(str(h) + \":\" + str(m) + \":\" + str(s))\n", "test_IO": [ { "input": "46979\n", "output": "13:2:59\n" } ] }, { "id": "s760938927", "dataset": "codenet", "language": "Python", "code": "h, w, ka = map(int, input().split())\nmat = [list(input()) for i in range(h)]\nans = 0\nfor i in range(2**(h+w)):\n b = bin(i)[2:].zfill(h+w)\n rs = b[:h]\n cs = b[h:]\n ct = 0\n for l in range(h):\n for k in range(w):\n if mat[l][k] == '#' and rs[l] == '0' and cs[k] == '0':\n ct += 1\n if ct == ka:\n ans += 1\nprint(ans)\n", "test_IO": [ { "input": "2 3 2\n..#\n###\n", "output": "5\n" } ] }, { "id": "s621701371", "dataset": "codenet", "language": "Python", "code": "s = input()\nq = int(input())\nqs = [input().split() for i in range(q)]\nn = False\nleft = right = \"\"\nfor operation in qs:\n if operation[0] == '1':\n n = not n\n if operation[0] == '2':\n t, f, c = operation\n f = int(f)\n if n:\n f = 1 if f != 1 else 2\n if f == 1:\n left = c+left\n elif f == 2:\n right += c\ns = left+s+right\nprint(s[::-1] if n else s)\n", "test_IO": [ { "input": "a\n4\n2 1 p\n1\n2 2 c\n1\n", "output": "cpa\n" } ] }, { "id": "s875904659", "dataset": "codenet", "language": "Python", "code": "def bubbleSort(cards):\n n = len(cards)\n for i in range(0, n):\n for j in range(n-1, i, -1):\n if int(cards[j][1]) < int(cards[j-1][1]):\n cards[j], cards[j-1] = cards[j-1], cards[j]\n\n print(\" \".join(map(str, cards)))\n\n\ndef selectionSort(cards):\n n = len(cards)\n for i in range(0, n):\n mini = i\n for j in range(i, n):\n if int(cards[j][1]) < int(cards[mini][1]):\n mini = j\n if mini != i:\n cards[i], cards[mini] = cards[mini], cards[i]\n\n print(\" \".join(map(str, cards)))\n\n\nn = int(input())\ncards = input().split(\" \")\ncards2 = list(cards)\nbubbleSort(cards)\nprint(\"Stable\")\nselectionSort(cards2)\nif \" \".join(map(str, cards2)) == \" \".join(map(str, cards)):\n print(\"Stable\")\nelse:\n print(\"Not stable\")\n", "test_IO": [ { "input": "5\nH4 C9 S4 D2 C3\n", "output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n" } ] }, { "id": "s706119740", "dataset": "codenet", "language": "Python", "code": "candy = sorted(map(int, input().split()))\nprint(\"Yes\" if candy[0]+candy[1] == candy[2] else \"No\")\n", "test_IO": [ { "input": "10 30 20\n", "output": "Yes\n" } ] }, { "id": "s636592395", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = list(map(int, input().split()))\n\n\ndef main():\n A.sort()\n ans = A[-1] - A[0]\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "test_IO": [ { "input": "4\n1 4 6 3\n", "output": "5\n" } ] }, { "id": "s137613418", "dataset": "codenet", "language": "Python", "code": "import sys\nimport math\n\nfrom collections import defaultdict\nfrom collections import deque\n\n\ndef load(vtype=int):\n return vtype(input().strip())\n\n\ndef load_list(seplator=\" \", vtype=int):\n return [vtype(v) for v in input().strip().split(seplator)]\n\n\ndef exit():\n import sys\n sys.exit(0)\n\n\ndef perm_sub(li, used):\n if len(li) == len(used):\n return [deque()]\n k = []\n for i in range(len(li)):\n if i in used:\n continue\n used.add(i)\n sub_list = perm_sub(li, used)\n for sub in sub_list:\n sub.appendleft(li[i])\n k.extend(sub_list)\n used.discard(i)\n return k\n\n\ndef perm_li(li):\n return perm_sub(li, set())\n\n\ndef perm_n(n):\n return perm_sub(list(range(n)), set())\n\n\ndef join_i(li, sep=\"\"):\n return sep.join([str(e) for e in li])\n\n\ndef li2n(li):\n n, base = 0, 1\n for i in range(len(li)-1, -1, -1):\n n += li[i] * base\n base *= 10\n return n\n\n\ndef sli2ili(li):\n return [int(s) for s in li]\n\n\ndef prime_list(n):\n li = [i for i in range(2, n+1)]\n for i in range(len(li)):\n if li[i] >= int(math.sqrt(n)):\n break\n if li[i] == -1:\n continue\n for j in range(i+1, len(li)):\n if li[j] % li[i] == 0:\n li[j] = -1\n return [n for n in li if n != -1]\n\n\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n while True:\n r = a % b\n if r == 0:\n return b\n a, b = b, r\n\n\ndef lcm(a, b):\n return int(a * b / gcd(a, b))\n\n\ndef all_subset(li):\n s = []\n n = len(li)\n for bit in range(0, (1 << (n+1))):\n ss = set()\n for i in range(0, n):\n if (bit & (1 << i)):\n ss.add(li[i])\n s.append(ss)\n return s\n\n\ndef factorial(n):\n if n == 1:\n return 1\n return n * factorial(n-1)\n\n\ndef mCn(m, n):\n def factorial_ntimes(m, n):\n r = 1\n while n:\n r *= m\n m -= 1\n n -= 1\n return r\n return int(factorial_ntimes(m, n) / factorial(n))\n\n\nn = load()\nA = load_list()\n\nif n == len(set(A)):\n print('YES')\nelse:\n print('NO')\n", "test_IO": [ { "input": "5\n2 6 1 4 5\n", "output": "YES\n" } ] }, { "id": "s028530838", "dataset": "codenet", "language": "Python", "code": "x = input()\nif x.islower():\n print(\"a\")\nelse:\n print(\"A\")\n", "test_IO": [ { "input": "B\n", "output": "A\n" } ] }, { "id": "s273727373", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = list(map(int, input().split()))\nB = list(A)\ncount = 1\nfor i in A:\n B[i-1] = count\n count += 1\n\n\nprint(*B)\n", "test_IO": [ { "input": "3\n2 3 1\n", "output": "3 1 2\n" } ] }, { "id": "s404600540", "dataset": "codenet", "language": "Python", "code": "def main():\n q, h, s, d = map(int, input().split())\n n = int(input())\n min_1 = min(q*4, h*2, q*2+h, s)\n min_2 = min(min_1*2, d)\n\n print((n % 2)*min_1 + (n // 2)*min_2)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "20 30 70 90\n3\n", "output": "150\n" } ] }, { "id": "s922746568", "dataset": "codenet", "language": "Python", "code": "n = int(input())\ns = input()\n\nr_cnt = s.count('R')\ng_cnt = s.count('G')\nb_cnt = s.count('B')\n\nans = r_cnt * g_cnt * b_cnt\n\nfor i in range(n):\n for d in range(n):\n j = i + d\n k = j + d\n if k >= n:\n break\n\n if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:\n\n ans -= 1\nprint(ans)\n", "test_IO": [ { "input": "4\nRRGB\n", "output": "1\n" } ] }, { "id": "s267172486", "dataset": "codenet", "language": "Python", "code": "h, a = map(int, input().strip().split())\n\nans = h // a\nama = h % a\n\nif ama != 0:\n ans += 1\nprint(ans)\n", "test_IO": [ { "input": "10 4\n", "output": "3\n" } ] }, { "id": "s616346400", "dataset": "codenet", "language": "Python", "code": "def atc_079a(input_value: str) -> str:\n n = 3\n for i in range(0, len(input_value) + 1 - n):\n for j in range(1, n):\n if input_value[i] != input_value[i + j]:\n break\n if j == n - 1:\n return \"Yes\"\n return \"No\"\n\n\ninput_value = input()\nprint(atc_079a(input_value))\n", "test_IO": [ { "input": "1118\n", "output": "Yes\n" } ] }, { "id": "s430322735", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nlst = []\npair = 0\nfor i in range(n):\n st = ''.join(sorted(list(input())))\n lst.append(st)\nlst = sorted(lst)\nlst += ['end']\npre = ''\ntmp_cnt = 0\ncnt = 0\nfor i in lst:\n if i == pre:\n tmp_cnt += 1\n else:\n cnt += sum([j for j in range(tmp_cnt + 1)])\n tmp_cnt = 0\n pre = i\nprint(cnt)\n", "test_IO": [ { "input": "3\nacornistnt\npeanutbomb\nconstraint\n", "output": "1\n" } ] }, { "id": "s761121328", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = list(map(int, input().split()))\ns = A[0] ^ A[1]\nfor i in range(2, N):\n s = s ^ A[i]\n\nB = [0]*N\nfor i in range(N):\n B[i] = s ^ A[i]\n\nL = [str(a) for a in B]\nL = \" \".join(L)\nprint(L)\n", "test_IO": [ { "input": "4\n20 11 9 24\n", "output": "26 5 7 22\n" } ] }, { "id": "s031917494", "dataset": "codenet", "language": "Python", "code": "print('Christmas'+' Eve'*abs(int(input())-25))\n", "test_IO": [ { "input": "25\n", "output": "Christmas\n" } ] }, { "id": "s952264435", "dataset": "codenet", "language": "Python", "code": "N, M = map(int, input().split())\nA = map(int, input().split())\nA_sum = sum(A)\n\nprint(N - A_sum if N - A_sum >= 0 else \"-1\")\n", "test_IO": [ { "input": "41 2\n5 6\n", "output": "30\n" } ] }, { "id": "s986062252", "dataset": "codenet", "language": "Python", "code": "from sys import stdin\ndef il(func=int): return list(map(func, stdin.readline().rstrip().split()))\n\n\nils = lambda n, s=\"int(input())\": [eval(s) for _ in range(n)]\n\n\ndef gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\nn, m = il()\ns = input()\nt = input()\naa = gcd(n, m)\nbb = lcm(n, m)\ncc = aa // bb\nfor i in range(aa):\n if s[n//aa*i] != t[m//aa*i]:\n print(-1)\n exit()\nprint(bb)\n", "test_IO": [ { "input": "3 2\nacp\nae\n", "output": "6\n" } ] }, { "id": "s923405856", "dataset": "codenet", "language": "Python", "code": "while True:\n n = int(input())\n\n if n == 0:\n break\n\n res = -1111111111\n s = 0\n for i in range(n):\n a = int(input())\n s = max(s + a, a)\n res = max(s, res)\n\n print(res)\n", "test_IO": [ { "input": "7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n", "output": "19\n14\n1001\n" } ] }, { "id": "s534639230", "dataset": "codenet", "language": "Python", "code": "from collections import Counter\n\n\ndef solve():\n N = int(input())\n D = list(map(int, input().split()))\n\n mod = 998244353\n\n if D[0] != 0:\n print(0)\n return\n\n cnt = Counter(D)\n\n if cnt[0] > 1:\n print(0)\n return\n\n res = 1\n\n for i in range(1, max(D)+1):\n if cnt[i-1] == 1:\n continue\n res *= cnt[i-1]**cnt[i] % mod\n res %= mod\n\n print(res)\n\n\nsolve()\n", "test_IO": [ { "input": "4\n0 1 1 2\n", "output": "2\n" } ] }, { "id": "s817205687", "dataset": "codenet", "language": "Python", "code": "from functools import reduce\nimport math\n\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\n\n\nA = [a // 2 for a in A]\n\n\ncount_div_2 = None\nfor a in A:\n cnt = 0\n while a % 2 == 0:\n a //= 2\n cnt += 1\n\n if count_div_2 is None:\n count_div_2 = cnt\n\n elif cnt != count_div_2:\n print(0)\n exit()\n\n\nmy_lcm = lcm_list(A)\nif my_lcm > M:\n print(0)\n exit()\n\ntmp = M // my_lcm\n\n\nans = (tmp + 1) // 2\nprint(ans)\n", "test_IO": [ { "input": "2 50\n6 10\n", "output": "2\n" } ] }, { "id": "s287369394", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\nans = 0\nfor i in range(N):\n d = min(A[i], B[i])\n ans += d\n A[i] -= d\n B[i] -= d\n d = min(A[i + 1], B[i])\n ans += d\n A[i + 1] -= d\n B[i] -= d\n\nprint(ans)\n", "test_IO": [ { "input": "2\n3 5 2\n4 5\n", "output": "9\n" } ] }, { "id": "s058944700", "dataset": "codenet", "language": "Python", "code": "import numpy as np\n\nn, k = map(int, input().split())\n\nif n > k:\n tmp = n % k\n if tmp >= k - tmp:\n ans = k - tmp\n else:\n ans = tmp\nelif n < k:\n if n >= k - n:\n ans = k - n\n else:\n ans = n\nelse:\n ans = 0\n\nprint(ans)\n", "test_IO": [ { "input": "7 4\n", "output": "1\n" } ] }, { "id": "s185068963", "dataset": "codenet", "language": "Python", "code": "a, b, c = map(int, input().split())\nprint(\"Yes\" if a + b >= c else \"No\")\n", "test_IO": [ { "input": "50 100 120\n", "output": "Yes\n" } ] }, { "id": "s764169243", "dataset": "codenet", "language": "Python", "code": "import sys\ninput = sys.stdin.buffer.readline\n\n\ndef main():\n\n class SegmentTree:\n\n def __init__(self, size, default):\n self.size = 2**(size-1).bit_length()\n self.default = default\n self.seg = [default]*(2*self.size-1)\n\n def segfunc(self, x, y):\n return max(x, y)\n\n def update(self, k, x):\n k += self.size-1\n self.seg[k] = x\n while k:\n k = (k-1)//2\n self.seg[k] = self.segfunc(self.seg[2*k+1], self.seg[2*k+2])\n\n def query(self, p, q):\n if q <= p:\n return self.default\n p += self.size-1\n q += self.size-2\n ret = self.default\n while q-p > 1:\n if p & 1 == 0:\n ret = self.segfunc(ret, self.seg[p])\n if q & 1 == 1:\n ret = self.segfunc(ret, self.seg[q])\n q -= 1\n p = p//2\n q = (q-1)//2\n ret = self.segfunc(self.segfunc(ret, self.seg[p]), self.seg[q])\n return ret\n\n def seg_print(self):\n print(self.seg)\n\n N = int(input())\n a = list(map(int, input().split()))\n ans = [i+1 for i in range(N)]\n left_seg = SegmentTree(N, 0)\n for i, num in enumerate(a):\n ans[num-1] *= i + 1 - left_seg.query(0, num)\n left_seg.update(num-1, i+1)\n right_seg = SegmentTree(N, 0)\n for i, num in enumerate(a[::-1]):\n ans[num-1] *= i + 1 - right_seg.query(0, num)\n right_seg.update(num-1, i+1)\n\n print(sum(ans))\n\n\nif __name__ == \"__main__\":\n main()\n", "test_IO": [ { "input": "3\n2 1 3\n", "output": "9\n" } ] }, { "id": "s768331281", "dataset": "codenet", "language": "Python", "code": "N, L = map(int, input().split())\nS = [input().rstrip() for _ in range(N)]\nprint(''.join(sorted(S)))\n", "test_IO": [ { "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n" } ] }, { "id": "s993625131", "dataset": "codenet", "language": "Python", "code": "S = list(input())\n\ncount = 0\nrecord = 0\nfor i in range(len(S)):\n if S[i] == \"A\" or S[i] == \"C\" or S[i] == \"G\" or S[i] == \"T\":\n count += 1\n else:\n if count > record:\n record = count\n count = 0\nif count > record:\n record = count\n\nprint(record)\n", "test_IO": [ { "input": "ATCODER\n", "output": "3\n" } ] }, { "id": "s315467749", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nS = list(map(int, input().split()))\nq = int(input())\nT = list(map(int, input().split()))\n\nans = 0\nfor i in T:\n if i == S[-1] or i == S[0]:\n ans += 1\n else:\n left = 0\n right = n-1\n while right-left > 1:\n mid = (left+right)//2\n if S[mid] == i:\n ans += 1\n break\n elif S[mid] < i:\n left = mid\n else:\n right = mid\n\nprint(ans)\n", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s060838372", "dataset": "codenet", "language": "Python", "code": "N, K = map(int, input().split())\nS = list(input())\nif S[K-1] == \"A\":\n S[K-1] = \"a\"\nelif S[K-1] == \"B\":\n S[K-1] = \"b\"\nelse:\n S[K-1] = \"c\"\nans = \"\".join(S)\nprint(ans)\n", "test_IO": [ { "input": "3 1\nABC\n", "output": "aBC\n" } ] }, { "id": "s695100304", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nx = list(map(int, input().split()))\nx.reverse()\nprint(*x)\n", "test_IO": [ { "input": "5\n1 2 3 4 5\n", "output": "5 4 3 2 1\n" } ] }, { "id": "s831456551", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\nprint(A*B)\n", "test_IO": [ { "input": "2 5\n", "output": "10\n" } ] }, { "id": "s951065247", "dataset": "codenet", "language": "Python", "code": "N, A, B, C = map(int, input().split())\nl = [int(input()) for i in range(N)]\n\n\ndef dfs(cur, a, b, c):\n if cur == N:\n return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else 10 ** 9\n no_add = dfs(cur + 1, a, b, c)\n add_a = dfs(cur + 1, a + l[cur], b, c) + 10\n add_b = dfs(cur + 1, a, b + l[cur], c) + 10\n add_c = dfs(cur + 1, a, b, c + l[cur]) + 10\n\n return min(no_add, add_a, add_b, add_c)\n\n\nprint(dfs(0, 0, 0, 0))\n", "test_IO": [ { "input": "5 100 90 80\n98\n40\n30\n21\n80\n", "output": "23\n" } ] }, { "id": "s542358243", "dataset": "codenet", "language": "Python", "code": "N = int(input())\n\nif N % 9 == 0:\n print('Yes')\nelse:\n print('No')\n", "test_IO": [ { "input": "123456789\n", "output": "Yes\n" } ] }, { "id": "s031459110", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nc = input()\n\nnum_w = c.count(\"W\")\nnum_r = N - num_w\n\ncomp = \"R\"*num_r + \"W\"*num_w\nans = 0\nfor i in range(num_r):\n if c[i] != comp[i]:\n ans += 1\n\nans = min(num_w, num_r, ans)\nprint(ans)\n", "test_IO": [ { "input": "4\nWWRR\n", "output": "2\n" } ] }, { "id": "s681105182", "dataset": "codenet", "language": "Python", "code": "import sys\nsys.setrecursionlimit(10**7)\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return sys.stdin.readline().strip()\n\n\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = II()\n a_li = LI()\n\n a_li.sort()\n\n n = a_li[-1]\n\n dif = INF\n prev_dif = dif\n for a in a_li[:-1]:\n dif = min(abs(n/2 - a), dif)\n if dif != prev_dif:\n r = a\n prev_dif = dif\n\n print(n, r)\n\n\nmain()\n", "test_IO": [ { "input": "5\n6 9 4 2 11\n", "output": "11 6\n" } ] }, { "id": "s838619850", "dataset": "codenet", "language": "Python", "code": "S = input()\nT = input()\n\nN = len(S)\nM = len(T)\nans = M\nfor i in range(N-M+1):\n S_2 = S[i:i+M]\n cnt = 0\n for j in range(M):\n if T[j] != S_2[j]:\n cnt += 1\n ans = min(ans, cnt)\n\nprint(ans)\n", "test_IO": [ { "input": "cabacc\nabc\n", "output": "1\n" } ] }, { "id": "s087080706", "dataset": "codenet", "language": "Python", "code": "from bisect import bisect\nn, m, x = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\nans = 0\ni = bisect(a, x)\nprint(min(len(a[:i]), len(a[i:])))\n", "test_IO": [ { "input": "5 3 3\n1 2 4\n", "output": "1\n" } ] }, { "id": "s733189960", "dataset": "codenet", "language": "Python", "code": "def main():\n n = int(input())\n sdic = {}\n for _ in range(n):\n s = [_s for _s in sorted(input().strip())]\n s = ''.join(s)\n if s in sdic:\n sdic[s] += 1\n else:\n sdic[s] = 1\n ans = 0\n for k, v in sdic.items():\n ans += v*(v-1)//2\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "3\nacornistnt\npeanutbomb\nconstraint\n", "output": "1\n" } ] }, { "id": "s855969677", "dataset": "codenet", "language": "Python", "code": "s = input()\n\nif s == 'RRR':\n print(3)\nelif s == 'SSS':\n print(0)\nelif s == 'RRS' or s == 'SRR':\n print(2)\nelse:\n print(1)\n", "test_IO": [ { "input": "RRS\n", "output": "2\n" } ] }, { "id": "s238775098", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nres = 0\nfor _ in range(n):\n x, u = list(input().split())\n if u == \"BTC\":\n res += float(x) * 380000\n else:\n res += int(x)\nprint(res)\n", "test_IO": [ { "input": "2\n10000 JPY\n0.10000000 BTC\n", "output": "48000.0\n" } ] }, { "id": "s101447419", "dataset": "codenet", "language": "Python", "code": "import collections\n\n\ndef main():\n n = int(input())\n v = list(map(int, input().split()))\n ve = []\n vo = []\n for i in range(n//2):\n ve.append(v[2*i])\n vo.append(v[2*i+1])\n ce = collections.Counter(ve)\n co = collections.Counter(vo)\n ans = n\n if ce.most_common()[0][0] != co.most_common()[0][0]:\n ans = n-ce.most_common()[0][1]-co.most_common()[0][1]\n elif len(ce) == 1 and len(co) == 1:\n ans = n-ce.most_common()[0][1]\n elif len(ce) == 1:\n ans = n-ce.most_common()[0][1]-co.most_common()[1][1]\n elif len(co) == 1:\n ans = n-ce.most_common()[1][1]-co.most_common()[0][1]\n else:\n ans = min(n-ce.most_common()[0][1]-co.most_common()[1]\n [1], n-ce.most_common()[1][1]-co.most_common()[0][1])\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "test_IO": [ { "input": "4\n3 1 3 2\n", "output": "1\n" } ] }, { "id": "s060251920", "dataset": "codenet", "language": "Python", "code": "def main():\n a, b = map(int, input().split())\n print(a*b)\n\n\nmain()\n", "test_IO": [ { "input": "2 5\n", "output": "10\n" } ] }, { "id": "s960572618", "dataset": "codenet", "language": "Python", "code": "a, b, c = input().strip().split()\n\nif a == b and b == c:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "test_IO": [ { "input": "2 2 2\n", "output": "Yes\n" } ] }, { "id": "s091400419", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\nlst = [a+b, a-b, a*b]\nprint(max(lst))\n", "test_IO": [ { "input": "-13 3\n", "output": "-10\n" } ] }, { "id": "s764356857", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\n\nmin = B * 10\nmax = (B+1) * 10 - 1\n\nans = -1\nfor i in range(min, max+1):\n if int(i * 0.08) == A:\n ans = i\n break\n\nprint(ans)\n", "test_IO": [ { "input": "2 2\n", "output": "25\n" } ] }, { "id": "s280552889", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nif N % 2 == 0:\n print(N//2)\nelse:\n print(N//2+1)\n", "test_IO": [ { "input": "5\n", "output": "3\n" } ] }, { "id": "s827462150", "dataset": "codenet", "language": "Python", "code": "import numpy as np\nn = int(input())\nA = np.zeros(n)\n\nx, y, z = 1, 1, 1\n\nwhile x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:\n while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:\n while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:\n i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x\n A[i - 1] += 1\n z += 1\n z = 1\n y += 1\n y, z = 1, 1\n x += 1\nfor i in range(n):\n print(int(A[i]))\n", "test_IO": [ { "input": "20\n", "output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n" } ] }, { "id": "s225521100", "dataset": "codenet", "language": "Python", "code": "N, K = map(int, input().split())\nA = []\n\nfor i in range(N):\n A.append(0)\n\nfor i in range(K):\n d = int(input())\n AA = list(map(int, input().split()))\n for j in range(d):\n A[AA[j] - 1] = 1\n\nn = 0\nfor i in range(N):\n if A[i] == 0:\n n += 1\nprint(n)\n", "test_IO": [ { "input": "3 2\n2\n1 3\n1\n3\n", "output": "1\n" } ] }, { "id": "s683277023", "dataset": "codenet", "language": "Python", "code": "n, k = map(int, input().split())\nli = list(map(int, input().split()))\nli.sort()\ntmp = li[:k]\nprint(sum(tmp))\n", "test_IO": [ { "input": "5 3\n50 100 80 120 80\n", "output": "210\n" } ] }, { "id": "s208095748", "dataset": "codenet", "language": "Python", "code": "A, B, C = map(int, input().split())\nif B < C:\n print(0)\nelif A * C < B:\n print(C)\nelse:\n print(B//A)\n", "test_IO": [ { "input": "2 11 4\n", "output": "4\n" } ] }, { "id": "s500828884", "dataset": "codenet", "language": "Python", "code": "n, a, b = map(int, input().split())\nprint(min(n * a, b))\n", "test_IO": [ { "input": "7 17 120\n", "output": "119\n" } ] }, { "id": "s975943078", "dataset": "codenet", "language": "Python", "code": "import sys\nfrom bisect import bisect_left\n\n\ndef solve():\n input = sys.stdin.readline\n N, K = map(int, input().split())\n A = [(int(a) % K) - 1 for a in input().split()]\n sum_A = [0 for _ in range(N + 1)]\n\n count = 0\n modK = dict()\n modK[0] = [0]\n for i in range(N):\n sum_A[i + 1] = (sum_A[i] + A[i]) % K\n if sum_A[i+1] not in modK:\n modK[sum_A[i+1]] = [i + 1]\n else:\n modK[sum_A[i+1]].append(i+1)\n\n for key in modK:\n lenK = len(modK[key])\n for i, a in enumerate(modK[key]):\n count += bisect_left(modK[key], a + K, i, lenK) - i - 1\n\n print(count)\n return 0\n\n\nif __name__ == \"__main__\":\n solve()\n", "test_IO": [ { "input": "5 4\n1 4 2 3 5\n", "output": "4\n" } ] }, { "id": "s205112814", "dataset": "codenet", "language": "Python", "code": "n, m = map(int, input().split())\n\ngate_cond = [[int(x) for x in input().split()] for _ in range(m)]\nmax_under_th = max([l[0] for l in gate_cond])\nmin_upper_th = min([l[1] for l in gate_cond])\nif min_upper_th - max_under_th >= 0:\n print(min_upper_th - max_under_th + 1)\nelse:\n print(0)\n", "test_IO": [ { "input": "4 2\n1 3\n2 4\n", "output": "2\n" } ] }, { "id": "s214672212", "dataset": "codenet", "language": "Python", "code": "nums = list(map(int, input().split(\" \")))\nnums.sort(reverse=True)\nprint(nums[0]*10+nums[1]+nums[2])\n", "test_IO": [ { "input": "1 5 2\n", "output": "53\n" } ] }, { "id": "s197514717", "dataset": "codenet", "language": "Python", "code": "ABC = list(map(int, input().split()))\n\nA = ABC[0]\nB = ABC[1]\nC = ABC[2]\n\nprint(max([10*A+B+C, 10*B+C+A, 10*C+A+B]))\n", "test_IO": [ { "input": "1 5 2\n", "output": "53\n" } ] }, { "id": "s267613210", "dataset": "codenet", "language": "Python", "code": "import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef input_nums(): return list(map(int, input().split()))\n\n\ndef main():\n K, N = input_nums()\n A = input_nums()\n dist = []\n for i in range(len(A)-1):\n dist.append(A[i+1]-A[i])\n dist.append(K+A[0]-A[-1])\n maxv = max(dist)\n print(sum(dist) - maxv)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "20 3\n5 10 15\n", "output": "10\n" } ] }, { "id": "s813548165", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nS, T = input().split()\n\nchar_lists = []\n\nfor i, char in enumerate(S):\n char_lists.append(char)\n char_lists.append(T[i])\n\nprint(\"\".join(char_lists))\n", "test_IO": [ { "input": "2\nip cc\n", "output": "icpc\n" } ] }, { "id": "s869207096", "dataset": "codenet", "language": "Python", "code": "n = int(input())\ns = input()\ncnt = 1\nfor i in range(n-1):\n if s[i] == s[i+1]:\n continue\n\n else:\n cnt += 1\n\nprint(cnt)\n", "test_IO": [ { "input": "10\naabbbbaaca\n", "output": "5\n" } ] }, { "id": "s025428739", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\nlst = []\nlst.append(A+B)\nlst.append(A-B)\nlst.append(A*B)\nprint(max(lst))\n", "test_IO": [ { "input": "-13 3\n", "output": "-10\n" } ] }, { "id": "s491954463", "dataset": "codenet", "language": "Python", "code": "n, m = list(map(int, input().split()))\na = []\nb = []\nfor i in range(m):\n a1, b1 = list(map(int, input().split()))\n a.append(a1)\n b.append(b1)\n\nfor i in range(1, n+1):\n print(a.count(i)+b.count(i))\n", "test_IO": [ { "input": "4 3\n1 2\n2 3\n1 4\n", "output": "2\n2\n1\n1\n" } ] }, { "id": "s575946485", "dataset": "codenet", "language": "Python", "code": "a = [int(input()) for i in range(5)]\n\ndic = {}\n\nfor i in range(5):\n if str(a[i])[-1] == \"0\":\n dic.update({i: 0})\n else:\n dic.update({i: int(str(a[i])[-1]) - 10})\n\n\nmin_num = [i for i in dic if dic[i] == min(dic.values())][0]\na_sum = sum(a)\ndic.pop(min_num)\nprint(abs(sum(dic.values())) + a_sum)\n", "test_IO": [ { "input": "29\n20\n7\n35\n120\n", "output": "215\n" } ] }, { "id": "s747093551", "dataset": "codenet", "language": "Python", "code": "N, M, X, Y = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nprint('No War' if max(max(x), X) < min(min(y), Y) else 'War')\n", "test_IO": [ { "input": "3 2 10 20\n8 15 13\n16 22\n", "output": "No War\n" } ] }, { "id": "s814885508", "dataset": "codenet", "language": "Python", "code": "def main():\n X, K, D = map(int, input().split())\n\n r = X // D\n if abs(r) > K:\n print(abs(X) - K * D)\n exit()\n a = X - r * D\n if (K - r) % 2 == 0:\n print(a)\n else:\n print(abs(D - a))\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "6 2 4\n", "output": "2\n" } ] }, { "id": "s704354119", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nl = input().split()\nmax = -1e9\nmin = 1e9\nsum = 0\nfor i in range(n):\n sum += int(l[i])\n if max < int(l[i]):\n max = int(l[i])\n if min > int(l[i]):\n min = int(l[i])\nprint(min, max, sum)\n", "test_IO": [ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ] }, { "id": "s043174379", "dataset": "codenet", "language": "Python", "code": "H, W = map(int, input().split())\nh, w = map(int, input().split())\nans = H * W - (h * W + w * H - h * w)\nprint(ans)\n", "test_IO": [ { "input": "3 2\n2 1\n", "output": "1\n" } ] }, { "id": "s246930871", "dataset": "codenet", "language": "Python", "code": "N, A, B = map(int, input().split())\nans = A * (N//(A+B)) + min(A, N % (A+B))\nprint(ans)\n", "test_IO": [ { "input": "8 3 4\n", "output": "4\n" } ] }, { "id": "s357377130", "dataset": "codenet", "language": "Python", "code": "A, B, K = map(int, input().split())\nif A+K-1 >= B-K+1:\n while A <= B:\n print(A)\n A += 1\nelse:\n i = 0\n while i <= K-1:\n print(A+i)\n i += 1\n while B-K+1 <= B:\n print(B-K+1)\n K -= 1\n", "test_IO": [ { "input": "3 8 2\n", "output": "3\n4\n7\n8\n" } ] }, { "id": "s708549466", "dataset": "codenet", "language": "Python", "code": "N, x = map(int, input().split())\na = list(map(int, input().split()))\ncnt = 0\nfor i in range(1, N):\n tmp = a[i - 1] + a[i]\n if tmp > x:\n if tmp - x > a[i]:\n a[i - 1] = tmp - a[i] - x\n a[i] = 0\n else:\n a[i] = a[i] - (tmp - x)\n cnt += tmp - x\n\nprint(cnt)\n", "test_IO": [ { "input": "3 3\n2 2 2\n", "output": "1\n" } ] }, { "id": "s122565091", "dataset": "codenet", "language": "Python", "code": "a, v = map(int, input().split())\nb, w = map(int, input().split())\nt = int(input())\nif a == b:\n print('YES')\nelif v <= w:\n print('NO')\nelse:\n if t < abs(a - b) / (v - w):\n print('NO')\n else:\n print('YES')\n", "test_IO": [ { "input": "1 2\n3 1\n3\n", "output": "YES\n" } ] }, { "id": "s735480710", "dataset": "codenet", "language": "Python", "code": "from collections import deque\nn = int(input())\na = list(map(str, input().split()))\nb = []\n\nb = a[1::2][::-1]+a[::2]\nif len(a) % 2 == 0:\n print(' '.join(b))\nelse:\n print(' '.join(b[::-1]))\n", "test_IO": [ { "input": "4\n1 2 3 4\n", "output": "4 2 1 3\n" } ] }, { "id": "s622795537", "dataset": "codenet", "language": "Python", "code": "n = int(input())\narr = {}\n\nfor i in range(n):\n s = input()\n if not s in arr:\n arr[s] = 1\n else:\n arr[s] += 1\n\nmax_count = max(arr.values())\ndic = [key[0] for key in arr.items() if key[1] == max_count]\n\nout_sort = sorted(dic)\nfor i in out_sort:\n print(i)\n", "test_IO": [ { "input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n", "output": "beet\nvet\n" } ] }, { "id": "s232279435", "dataset": "codenet", "language": "Python", "code": "n = int(input())\ns = str(input())\n\nans = 0\n\nfor i in range(n):\n x = set(s[:i+1])\n y = set(s[i+1:])\n\n z = 0\n for w in x:\n if w in y:\n z += 1\n if z > ans:\n ans = z\nprint(ans)\n", "test_IO": [ { "input": "6\naabbca\n", "output": "2\n" } ] }, { "id": "s195311365", "dataset": "codenet", "language": "Python", "code": "s = input()\n\nif len(s) == 2:\n print(s)\nelse:\n print(s[::-1])\n", "test_IO": [ { "input": "abc\n", "output": "cba\n" } ] }, { "id": "s840967243", "dataset": "codenet", "language": "Python", "code": "import math\nMOD = 10**9+7\nf = math.factorial\nn, m = sorted(map(int, input().split()))\nprint(max(2 - m + n, 0)*f(n)*f(m) % MOD)\n", "test_IO": [ { "input": "2 2\n", "output": "8\n" } ] }, { "id": "s067092519", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nm = []\nline = ''\nm = [[[0 for k in range(10)] for j in range(3)] for i in range(10)]\nfor i in range(N):\n n = input().split()\n b = int(n[0])\n f = int(n[1])\n r = int(n[2])\n v = int(n[3])\n m[b-1][f-1][r-1] += v\n\nfor i in range(4):\n for j in range(3):\n for k in range(10):\n line += ' {0}'.format(m[i][j][k])\n print(line)\n line = ''\n if i < 3:\n print('#'*20)\n", "test_IO": [ { "input": "3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n", "output": " 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0\n" } ] }, { "id": "s485638370", "dataset": "codenet", "language": "Python", "code": "a = input()\nprint(\"Yes\" if '9' in a else \"No\")\n", "test_IO": [ { "input": "29\n", "output": "Yes\n" } ] }, { "id": "s642705424", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nS = input()\nx = 1\nfor i in range(N-1):\n if S[i] != S[i+1]:\n x = x+1\nprint(x)\n", "test_IO": [ { "input": "10\naabbbbaaca\n", "output": "5\n" } ] }, { "id": "s048491063", "dataset": "codenet", "language": "Python", "code": "def main():\n\n N, M, Q = map(int, input().split())\n train = [[0 for _ in range(N)] for _ in range(N)]\n for _ in range(M):\n l, r = map(int, input().split())\n train[l-1][r-1] += 1\n\n accum = [[0 for _ in range(N+1)]]\n for i in range(N):\n temp = [0]\n v = 0\n for j in range(N):\n v += train[i][j]\n temp.append(accum[-1][j+1]+v)\n accum.append(temp)\n\n for _ in range(Q):\n p, q = map(int, input().split())\n v = accum[q][q] - accum[p-1][q] - accum[q][p-1] + accum[p-1][p-1]\n print(v)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n", "output": "3\n" } ] }, { "id": "s040517919", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\nif A == B:\n print(\"Draw\")\nelif A == 1:\n print(\"Alice\")\nelif B == 1:\n print(\"Bob\")\nelif A > B:\n print(\"Alice\")\nelse:\n print(\"Bob\")\n", "test_IO": [ { "input": "8 6\n", "output": "Alice\n" } ] }, { "id": "s147181072", "dataset": "codenet", "language": "Python", "code": "print(input().swapcase())\n", "test_IO": [ { "input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n", "output": "Fair, later, occasionally cloudy.\n" } ] }, { "id": "s086522214", "dataset": "codenet", "language": "Python", "code": "import collections\nimport scipy.misc\nimport sys\nimport numpy as np\nimport math\nfrom operator import itemgetter\nimport itertools\nimport copy\n\n\ndef prime_decomposition(n):\n i = 2\n table = []\n while i * i <= n:\n while n % i == 0:\n n /= i\n table.append(int(i))\n i += 1\n if n > 1:\n table.append(int(n))\n return table\n\n\ndef digit(i):\n if i > 0:\n return digit(i//10) + [i % 10]\n else:\n return []\n\n\ndef getNearestValueIndex(list, num):\n\n idx = np.abs(np.asarray(list) - num).argmin()\n return idx\n\n\nS = input()\nT = S.split('/')\n\ndate = int(T[1]+T[2])\nif date <= 430:\n print('Heisei')\nelse:\n print('TBD')\n", "test_IO": [ { "input": "2019/04/30\n", "output": "Heisei\n" } ] }, { "id": "s977408144", "dataset": "codenet", "language": "Python", "code": "import re\nimport math\nfrom collections import defaultdict\nimport itertools\nfrom copy import deepcopy\nimport random\nfrom heapq import heappop, heappush\nimport time\nimport os\nimport queue\nimport sys\nimport datetime\nfrom functools import lru_cache\n\nreadline = sys.stdin.readline\nsys.setrecursionlimit(2000000)\n\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\nmod = int(10**9+7)\ninf = int(10**20)\n\n\ndef yn(b):\n if b:\n print(\"yes\")\n else:\n print(\"no\")\n\n\ndef Yn(b):\n if b:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef YN(b):\n if b:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nclass union_find():\n def __init__(self, n):\n self.n = n\n self.P = [a for a in range(N)]\n self.rank = [0]*n\n\n def find(self, x):\n if (x != self.P[x]):\n self.P[x] = self.find(self.P[x])\n return self.P[x]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def link(self, x, y):\n if self.rank[x] < self.rank[y]:\n self.P[x] = y\n elif self.rank[y] < self.rank[x]:\n self.P[y] = x\n else:\n self.P[x] = y\n self.rank[y] += 1\n\n def unite(self, x, y):\n self.link(self.find(x), self.find(y))\n\n def size(self):\n S = set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\n\n\ndef is_power(a, b):\n now = b\n while now < a:\n now *= b\n if now == a:\n return True\n else:\n return False\n\n\ndef bin_(num, size):\n A = [0]*size\n for a in range(size):\n if (num >> (size-a-1)) & 1 == 1:\n A[a] = 1\n else:\n A[a] = 0\n return A\n\n\ndef get_facs(n, mod_=0):\n A = [1]*(n+1)\n for a in range(2, len(A)):\n A[a] = A[a-1]*a\n if (mod > 0):\n A[a] %= mod_\n return A\n\n\ndef comb(n, r, mod, fac):\n if (n-r < 0):\n return 0\n return (fac[n]*pow(fac[n-r], mod-2, mod)*pow(fac[r], mod-2, mod)) % mod\n\n\ndef next_comb(num, size):\n x = num & (-num)\n y = num+x\n z = num & (~y)\n z //= x\n z = z >> 1\n num = (y | z)\n if (num >= (1 << size)):\n return False\n else:\n return num\n\n\ndef get_primes(n, type=\"int\"):\n A = [True]*(n+1)\n A[0] = False\n A[1] = False\n for a in range(2, n+1):\n if A[a]:\n for b in range(a*2, n+1, a):\n A[b] = False\n if (type == \"bool\"):\n return A\n B = []\n for a in range(n+1):\n if (A[a]):\n B.append(a)\n return B\n\n\ndef is_prime(num):\n if (num <= 2):\n return False\n i = 2\n while i*i <= num:\n if (num % i == 0):\n return False\n i += 1\n return True\n\n\ndef ifelse(a, b, c):\n if a:\n return b\n else:\n return c\n\n\ndef join(A, c=\" \"):\n n = len(A)\n A = list(map(str, A))\n s = \"\"\n for a in range(n):\n s += A[a]\n if (a < n-1):\n s += c\n return s\n\n\ndef factorize(n, type_=\"dict\"):\n b = 2\n list_ = []\n while b * b <= n:\n while n % b == 0:\n n //= b\n list_.append(b)\n b += 1\n if n > 1:\n list_.append(n)\n if type_ == \"dict\":\n dic = {}\n for a in list_:\n if a in dic:\n dic[a] += 1\n else:\n dic[a] = 1\n return dic\n elif type_ == \"list\":\n return list_\n else:\n return None\n\n\ndef floor_(n, x=1):\n return x*(n//x)\n\n\ndef ceil_(n, x=1):\n return x*((n+x-1)//x)\n\n\ndef hani(x, min_, max_):\n ret = x\n if x < min_:\n ret = min_\n if x > max_:\n ret = max_\n return ret\n\n\ndef seifu(x):\n return x//abs(x)\n\n\ndef main():\n n, l = map(int, input().split())\n S = []\n for a in range(n):\n S.append(input())\n S.sort()\n print(\"\".join(S))\n\n\nmain()\n", "test_IO": [ { "input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n" } ] }, { "id": "s797394058", "dataset": "codenet", "language": "Python", "code": "from itertools import *\n\nN = int(input())\nx = 1\n\nN_list = [x+1 for x in range(N)]\n\nn = list(product(N_list, repeat=3))\n\nm = len(n)\n\nprint(m)\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s934308496", "dataset": "codenet", "language": "Python", "code": "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nm.sort()\nprint(n + (x - sum(m)) // m[0])\n", "test_IO": [ { "input": "3 1000\n120\n100\n140\n", "output": "9\n" } ] }, { "id": "s411244720", "dataset": "codenet", "language": "Python", "code": "N, K = [int(_) for _ in input().split()]\nS = set()\nfor i in range(K):\n d = int(input())\n A = [int(_) for _ in input().split()]\n S = S | set(A)\nprint(N - len(S))\n", "test_IO": [ { "input": "3 2\n2\n1 3\n1\n3\n", "output": "1\n" } ] }, { "id": "s200092246", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nans = []\n\nfor i in range(1, N+1):\n if sum(range(1, i + 1)) < N:\n continue\n else:\n ans = [i - 1, sum(range(1, i + 1)) - N]\n break\nfor i in range(ans[0]+1):\n if i + 1 != ans[1]:\n print(i + 1)\n", "test_IO": [ { "input": "4\n", "output": "1\n3\n" } ] }, { "id": "s453478465", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\nif a <= 8 and b <= 8:\n print(\"Yay!\")\nelse:\n print(\":(\")\n", "test_IO": [ { "input": "5 4\n", "output": "Yay!\n" } ] }, { "id": "s668439281", "dataset": "codenet", "language": "Python", "code": "import collections\n\nn = int(input())\nls = [input() for i in range(n)]\nc = collections.Counter(ls)\n\ncount = c.most_common()[0][1]\nans = []\np = c.most_common()\nfor i in range(len(c)):\n if p[i][1] == count:\n ans.append(p[i][0])\n else:\n break\nans = sorted(ans)\nfor i in ans:\n print(i)\n", "test_IO": [ { "input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n", "output": "beet\nvet\n" } ] }, { "id": "s615966179", "dataset": "codenet", "language": "Python", "code": "n, a, b = map(int, input().split())\nans = n//(a+b)*a\nr = min(n % (a+b), a)\nans += r\nprint(ans)\n", "test_IO": [ { "input": "8 3 4\n", "output": "4\n" } ] }, { "id": "s951169509", "dataset": "codenet", "language": "Python", "code": "from collections import deque\nH, W = map(int, input().split())\nG = []\nfor i in range(H+2):\n if i == 0 or i == H+1:\n G.append('#'*(W+2))\n else:\n G.append('#' + input() + '#')\n\nans = 0\nfor sx in range(W+2):\n for sy in range(H+2):\n if G[sy][sx] == '.':\n dist = [[-float('inf') for i in range(W+2)] for i in range(H+2)]\n visited = [[-1 for i in range(W+2)] for i in range(H+2)]\n q = deque([])\n q.append((sx, sy))\n dist[sy][sx] = 0\n visited[sy][sx] = 1\n while q:\n x, y = q.popleft()\n\n if G[y][x+1] == '.' and visited[y][x+1] == -1:\n q.append((x+1, y))\n dist[y][x+1] = dist[y][x] + 1\n visited[y][x+1] = 1\n\n if G[y][x-1] == '.' and visited[y][x-1] == -1:\n q.append((x-1, y))\n dist[y][x-1] = dist[y][x] + 1\n visited[y][x-1] = 1\n\n if G[y+1][x] == '.' and visited[y+1][x] == -1:\n q.append((x, y+1))\n dist[y+1][x] = dist[y][x] + 1\n visited[y+1][x] = 1\n\n if G[y-1][x] == '.' and visited[y-1][x] == -1:\n q.append((x, y-1))\n dist[y-1][x] = dist[y][x] + 1\n visited[y-1][x] = 1\n for i in range(W+2):\n for j in range(H+2):\n ans = max(ans, dist[j][i])\nprint(ans)\n", "test_IO": [ { "input": "3 3\n...\n...\n...\n", "output": "4\n" } ] }, { "id": "s676839884", "dataset": "codenet", "language": "Python", "code": "s = input()\nt = input()\n\nif t[:-1] == s:\n print('Yes')\nelse:\n print('No')\n", "test_IO": [ { "input": "chokudai\nchokudaiz\n", "output": "Yes\n" } ] }, { "id": "s554393427", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nmo = []\nfor _ in range(N):\n x, u = input().split()\n x = float(x)\n mo.append([x, u])\nokz = 0\nfor i in mo:\n if i[1] == \"JPY\":\n okz += i[0]\n else:\n okz += i[0]*380000\n\nprint(okz)\n", "test_IO": [ { "input": "2\n10000 JPY\n0.10000000 BTC\n", "output": "48000.0\n" } ] }, { "id": "s441329208", "dataset": "codenet", "language": "Python", "code": "import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 7)\ns = sorted(readline().rstrip())\nt = sorted(readline().rstrip())[::-1]\nprint(\"Yes\" if s < t else \"No\")\n", "test_IO": [ { "input": "yx\naxy\n", "output": "Yes\n" } ] }, { "id": "s897879131", "dataset": "codenet", "language": "Python", "code": "R, G, B, N = map(int, input().split())\n\nscore = 0\nfor i in range(N // R + 1):\n for j in range((N-i * R) // G + 1):\n if N - i * R - j * G >= 0 and (N - i * R - j * G) % B == 0:\n score += 1\n\nprint(score)\n", "test_IO": [ { "input": "1 2 3 4\n", "output": "4\n" } ] }, { "id": "s344468705", "dataset": "codenet", "language": "Python", "code": "import sys\n\n\nfrom bisect import bisect_left, bisect_right\n\n\ninput = sys.stdin.readline\n\n\ndef getS(): return input().strip()\ndef getN(): return int(input())\ndef getList(): return list(map(int, input().split()))\ndef getZList(): return [int(x) - 1 for x in input().split()]\n\n\nINF = 10 ** 20\nMOD = 1000000007\n\n\ndef solve():\n n = getN()\n dp = [-INF]\n for i in range(n):\n num = getN()\n num = -num\n if num >= dp[-1]:\n dp.append(num)\n else:\n idx = bisect_right(dp, num)\n dp[idx] = num\n\n print(len(dp) - 1)\n return\n\n\ndef main():\n n = getN()\n for _ in range(n):\n solve()\n\n\nif __name__ == \"__main__\":\n\n solve()\n", "test_IO": [ { "input": "5\n2\n1\n4\n5\n3\n", "output": "2\n" } ] }, { "id": "s233116196", "dataset": "codenet", "language": "Python", "code": "from collections import deque\nN, M = map(int, input().split())\nG = {i: [] for i in range(1, N+1)}\nfor _ in range(M):\n a, b = map(int, input().split())\n G[a].append(b)\n G[b].append(a)\ncol = [-1 for _ in range(N+1)]\ncnt = 0\nfor i in range(1, N+1):\n if col[i] < 0:\n col[i] = cnt\n que = deque([i])\n while que:\n x = que.popleft()\n for y in G[x]:\n if col[y] < 0:\n col[y] = cnt\n que.append(y)\n cnt += 1\ncmax = max(col)\nprint(cmax)\n", "test_IO": [ { "input": "3 1\n1 2\n", "output": "1\n" } ] }, { "id": "s062747389", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\nprint(a+b if a == b else max(a, b)*2-1)\n", "test_IO": [ { "input": "5 3\n", "output": "9\n" } ] }, { "id": "s964794058", "dataset": "codenet", "language": "Python", "code": "memTime = int(input())\nmemLate = input().split()\nmemLate = [int(i) for i in memLate]\ncolorList = []\nmemColor = 0\nhighLate = 0\nfor color in range(memTime):\n member = memLate[color]\n if member // 400 >= 8:\n highLate += 1\n elif ((member // 400) in colorList) == False:\n colorList.append(member // 400)\nmaxColor = len(colorList) + highLate\nminColor = len(colorList)\nif minColor == 0:\n minColor = 1\nprint(str(minColor) + \" \" + str(maxColor))\n", "test_IO": [ { "input": "4\n2100 2500 2700 2700\n", "output": "2 2\n" } ] }, { "id": "s724326345", "dataset": "codenet", "language": "Python", "code": "def main():\n A, B, C, X, Y = map(int, input().split())\n ans = 10 ** 10\n\n for k in range(max(X, Y) + 1):\n total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)\n if total < ans:\n ans = total\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "test_IO": [ { "input": "1500 2000 1600 3 2\n", "output": "7900\n" } ] }, { "id": "s878873709", "dataset": "codenet", "language": "Python", "code": "import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n N = int(readline())\n s = {1, 2, 4, 8, 16, 32, 64}\n ans = 0\n\n for i in range(1, N + 1):\n if i in s:\n ans = i\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "7\n", "output": "4\n" } ] }, { "id": "s652791025", "dataset": "codenet", "language": "Python", "code": "n = input()\nn = int(n[-1])\n\nif n == 2 or n == 4 or n == 5 or n == 7 or n == 9:\n print(\"hon\")\nelif n == 0 or n == 1 or n == 6 or n == 8:\n print(\"pon\")\nelse:\n print(\"bon\")\n", "test_IO": [ { "input": "16\n", "output": "pon\n" } ] }, { "id": "s039768540", "dataset": "codenet", "language": "Python", "code": "x = int(input())\nprint(\"ai1333{}\".format(\"3\"*(x // 100)))\n", "test_IO": [ { "input": "0\n", "output": "ai1333\n" } ] }, { "id": "s174910557", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nS = input()\n\nans = 1\ntmp = S[0]\nfor s in S:\n if s != tmp:\n ans += 1\n tmp = s\n\nprint(ans)\n", "test_IO": [ { "input": "10\naabbbbaaca\n", "output": "5\n" } ] }, { "id": "s893778513", "dataset": "codenet", "language": "Python", "code": "n = input()\nl = list(map(int, input().split()))\n\nb = max(l)\ns = sum(l)\n\nif b < s - b:\n print('Yes')\nelse:\n print('No')\n", "test_IO": [ { "input": "4\n3 8 5 1\n", "output": "Yes\n" } ] }, { "id": "s592421258", "dataset": "codenet", "language": "Python", "code": "I = input\ns = I()*2\nprint(['No', 'Yes'][I() in s])\n", "test_IO": [ { "input": "vanceknowledgetoad\nadvance\n", "output": "Yes\n" } ] }, { "id": "s182651529", "dataset": "codenet", "language": "Python", "code": "N, K = map(int, input().split())\nscore = list(map(int, input().split()))\nmae = 0\nusiro = K\nfor i in range(N-K):\n if score[mae] < score[usiro]:\n print('Yes')\n else:\n print('No')\n mae += 1\n usiro += 1\n", "test_IO": [ { "input": "5 3\n96 98 95 100 20\n", "output": "Yes\nNo\n" } ] }, { "id": "s681170949", "dataset": "codenet", "language": "Python", "code": "N = str(input())\n\nprint(\"ABC\"+N)\n", "test_IO": [ { "input": "100\n", "output": "ABC100\n" } ] }, { "id": "s486032847", "dataset": "codenet", "language": "Python", "code": "import math\n\n\ndef keta(s):\n if len(s) < 2:\n return int(s)\n n = sum(map(int, s))\n return keta(str(n))\n\n\ndef main():\n N = input()\n\n if keta(N) % 9 == 0:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nif __name__ == \"__main__\":\n main()\n", "test_IO": [ { "input": "123456789\n", "output": "Yes\n" } ] }, { "id": "s694958625", "dataset": "codenet", "language": "Python", "code": "x = int(input())\na = int(input())\nb = int(input())\n\nprint((x-a) % b)\n", "test_IO": [ { "input": "1234\n150\n100\n", "output": "84\n" } ] }, { "id": "s702834515", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nr = 0\nfor ii in range(n):\n if (ii+1) % 3 != 0 and (ii+1) % 5 != 0:\n r += (ii+1)\nprint(r)\n", "test_IO": [ { "input": "15\n", "output": "60\n" } ] }, { "id": "s664563518", "dataset": "codenet", "language": "Python", "code": "from heapq import heappush, heappop, heapify\nfrom collections import deque, defaultdict, Counter\nimport itertools\nfrom itertools import permutations, combinations, accumulate\nimport sys\nimport bisect\nimport string\nimport math\nimport time\n\n\ndef I(): return int(input())\n\n\ndef MI(): return map(int, input().split())\n\n\ndef LI(): return [int(i) for i in input().split()]\n\n\ndef LI_(): return [int(i)-1 for i in input().split()]\n\n\ndef StoI(): return [ord(i)-97 for i in input()]\n\n\ndef ItoS(nn): return chr(nn+97)\n\n\ndef input(): return sys.stdin.readline().rstrip()\n\n\ndef show(*inp, end='\\n'):\n if show_flg:\n print(*inp, end=end)\n\n\nYN = ['No', 'Yes']\nMOD = 10**9+7\ninf = float('inf')\nIINF = 10**10\nl_alp = string.ascii_lowercase\nu_alp = string.ascii_uppercase\nts = time.time()\nsys.setrecursionlimit(10**6)\nnums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']\n\nshow_flg = False\n\n\ndef main():\n N = I()\n s = [0] * N\n t = [0] * N\n\n for i in range(N):\n s[i], t[i] = map(str, input().split())\n t[i] = int(t[i])\n\n X = input()\n xi = 0\n\n for i in range(N):\n if s[i] == X:\n xi = i\n break\n\n ans = 0\n\n for i in range(N):\n if xi < i:\n ans += t[i]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "test_IO": [ { "input": "3\ndwango 2\nsixth 5\nprelims 25\ndwango\n", "output": "30\n" } ] }, { "id": "s870744379", "dataset": "codenet", "language": "Python", "code": "n = int(input())\n\nif n >= 1000:\n print('ABD')\nelse:\n print('ABC')\n", "test_IO": [ { "input": "999\n", "output": "ABC\n" } ] }, { "id": "s103354654", "dataset": "codenet", "language": "Python", "code": "W, H, x, y, r = map(int, input().split())\n\nif x >= r and (W - r) >= x:\n if y >= r and (H - r) >= y:\n print('Yes')\n else:\n print('No')\nelse:\n print('No')\n", "test_IO": [ { "input": "5 4 2 2 1\n", "output": "Yes\n" } ] }, { "id": "s895229833", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nH = list(map(int, list(input().split())))\n\ncount_best, count_tmp = 0, 0\n\nfor i in range(N-1):\n if H[i] >= H[i+1]:\n count_tmp += 1\n else:\n if count_tmp > count_best:\n count_best = count_tmp\n\n count_tmp = 0\n\nif count_tmp > count_best:\n count_best = count_tmp\n\nprint(count_best)\n", "test_IO": [ { "input": "5\n10 4 8 7 3\n", "output": "2\n" } ] }, { "id": "s749244504", "dataset": "codenet", "language": "Python", "code": "from itertools import chain\nimport numpy as np\nimport networkx as nx\n\nX = iter(open(0).readlines())\nh, w = map(int, next(X).split())\nC = np.zeros((10, 10), dtype=int)\nfor i in range(10):\n for j, c in enumerate(map(int, next(X).split())):\n C[i, j] = c\nA = np.zeros((h, w), dtype=int)\nfor i in range(h):\n for j, a in enumerate(map(int, next(X).split())):\n A[i, j] = a\n\nG = nx.DiGraph(C)\nd = {}\nfor i in range(10):\n if i == 1:\n continue\n d[i] = nx.shortest_path_length(G, i, 1, weight='weight')\n\ns = 0\nfor a in chain.from_iterable(A):\n if a == -1 or a == 1:\n continue\n s += d[a]\nprint(s)\n", "test_IO": [ { "input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n", "output": "12\n" } ] }, { "id": "s759499751", "dataset": "codenet", "language": "Python", "code": "n, k = map(int, input().split())\na = [i for i in input()]\nc = [0]*n\nfor i in range(1, n):\n if a[i] == \"C\" and a[i-1] == \"A\":\n c[i] = c[i-1]+1\n else:\n c[i] = c[i-1]\nfor w in range(k):\n l, r = map(int, input().split())\n print(c[r-1]-c[l-1])\n", "test_IO": [ { "input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n", "output": "2\n0\n3\n" } ] }, { "id": "s124725275", "dataset": "codenet", "language": "Python", "code": "from collections import deque\nfrom itertools import product, permutations, combinations\nimport sys\nsys.setrecursionlimit(1 << 25)\nreadline = sys.stdin.buffer.readline\nread = sys.stdin.readline\nra = range\nenu = enumerate\n\n\ndef exit(*argv, **kwarg):\n print(*argv, **kwarg)\n sys.exit()\n\n\ndef mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))\n\n\ndef a_int(): return int(readline())\n\n\ndef ints(): return list(map(int, readline().split()))\n\n\ndef read_col(H):\n\n ret = []\n for _ in range(H):\n ret.append(list(map(int, readline().split())))\n return tuple(map(list, zip(*ret)))\n\n\ndef read_map_as(H, replace={'#': 1, '.': 0}, pad=None):\n\n if pad is None:\n ret = []\n for _ in range(H):\n ret.append([replace[s] for s in read()[:-1]])\n\n else:\n ret = [[pad] * (W + 2)]\n for _ in range(H):\n ret.append([pad] + [replace[s] for s in read()[:-1]] + [pad])\n ret.append([pad] * (W + 2))\n\n return ret\n\n\ndef grid_dijkstra(grid, si: int, sj: int):\n\n from heapq import heappop, heappush\n H = len(grid)\n W = len(grid[0])\n D = [[-1] * W for _ in [0] * H]\n que = [(0, si, sj)]\n while que:\n c, i, j = heappop(que)\n if D[i][j] != -1:\n continue\n D[i][j] = c\n for di, dj in product([-2, -1, 0, 1, 2], repeat=2):\n ni, nj = i + di, j + dj\n if not (0 <= ni < H and 0 <= nj < W) or D[ni][nj] != -1 or ni == nj == 0 or grid[ni][nj] == 1:\n continue\n if (di == 0 and abs(dj) == 1) or (dj == 0 and abs(di) == 1):\n nc = c\n else:\n nc = c + 1\n heappush(que, (nc, ni, nj))\n return D\n\n\nMOD = 10**9 + 7\nINF = 2**31\n\n\nH, W = ints()\nsi, sj = mina(*ints())\nti, tj = mina(*ints())\n\nS = read_map_as(H)\nD = [[-1] * W for _ in [0] * H]\nque = deque([(0, si, sj)])\nwhile que:\n c, i, j = que.popleft()\n if D[i][j] != -1:\n continue\n D[i][j] = c\n for di, dj in product([-2, -1, 0, 1, 2], repeat=2):\n ni, nj = i + di, j + dj\n if not (0 <= ni < H and 0 <= nj < W) or D[ni][nj] != -1 or ni == nj == 0 or S[ni][nj] == 1:\n continue\n if (di == 0 and abs(dj) == 1) or (dj == 0 and abs(di) == 1):\n que.appendleft((c, ni, nj))\n else:\n que.append((c + 1, ni, nj))\n\nprint(D[ti][tj])\n", "test_IO": [ { "input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n", "output": "1\n" } ] }, { "id": "s777789287", "dataset": "codenet", "language": "Python", "code": "n, m = map(int, input().split())\na = list(map(int, input().split()))\na.sort(reverse=True)\ns = sum(a)/(4*m)\nif a[m-1] >= s:\n print('Yes')\nelse:\n print('No')\n", "test_IO": [ { "input": "4 1\n5 4 2 1\n", "output": "Yes\n" } ] }, { "id": "s858647829", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "test_IO": [ { "input": "4 5\n", "output": "Possible\n" } ] }, { "id": "s763097776", "dataset": "codenet", "language": "Python", "code": "n = int(input())\np = [int(x) for x in input().split()]\np_copy = p[:]\n\np.sort()\n\ncount = 0\nfor i in range(n):\n if p[i] != p_copy[i]:\n count += 1\n\nif count == 0 or count == 2:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "test_IO": [ { "input": "5\n5 2 3 4 1\n", "output": "YES\n" } ] }, { "id": "s582886163", "dataset": "codenet", "language": "Python", "code": "N = int(input())\ncapacity_list = [int(input()) for _ in range(5)]\ncapacity_list.sort()\nbottle_neck = capacity_list[0]\nprint(4+int((N+bottle_neck-1)/bottle_neck))\n", "test_IO": [ { "input": "5\n3\n2\n4\n3\n5\n", "output": "7\n" } ] }, { "id": "s787811177", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nls = [list(map(int, input().split())) for i in range(n)]\nls = sorted(ls, key=lambda x: sum(x), reverse=True)\ntaka = sum([ls[i][0] for i in range(0, len(ls), 2)])\naoki = sum([ls[i][1] for i in range(1, len(ls), 2)])\n\nprint(taka-aoki)\n", "test_IO": [ { "input": "3\n10 10\n20 20\n30 30\n", "output": "20\n" } ] }, { "id": "s906994739", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nF = [tuple(map(int, input().split())) for _ in range(n)]\nP = [tuple(map(int, input().split())) for _ in range(n)]\nans = -10 ** 18\n\nfor i in range(1, 2**10):\n tmp = 0\n lst = [0]*n\n for j in range(10):\n if (i >> j) & 1:\n for k in range(n):\n lst[k] += F[k][j]\n for k in range(n):\n tmp += P[k][lst[k]]\n ans = max(ans, tmp)\n\n\nprint(ans)\n", "test_IO": [ { "input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n", "output": "8\n" } ] }, { "id": "s957164965", "dataset": "codenet", "language": "Python", "code": "X, N = list(map(int, input().split()))\np = list(map(int, input().split()))\n\np.sort()\n\ncandidates = {}\nfor i in range(-1, 102):\n\n if i in p:\n continue\n\n if not (abs(X-i) in candidates.keys()):\n candidates[abs(X-i)] = [i]\n else:\n candidates[abs(X-i)].append(i)\n\nsmallest = min(candidates.keys())\n\nminNum = min(candidates[smallest])\n\nprint(minNum)\n", "test_IO": [ { "input": "6 5\n4 7 10 6 5\n", "output": "8\n" } ] }, { "id": "s259116349", "dataset": "codenet", "language": "Python", "code": "from math import factorial as f\n\nN = int(input())\n\nprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\ndivs = []\nfor i in range(1, 101):\n tmp = [0 for _ in range(len(primes))]\n for j in range(len(primes)):\n p = primes[j]\n tmp[j] = 0\n while (i//p == i/p):\n i = i//p\n tmp[j] += 1\n divs.append(tmp)\n\n\ndivsum = [0 for _ in range(len(primes))]\nfor i in range(1, N+1):\n for j in range(len(primes)):\n divsum[j] += divs[i-1][j]\n\n\ndef num(n):\n return len(list(filter(lambda x: x >= n-1, divsum)))\n\n\nans = 0\n\n\nans += num(75)\n\n\nans += num(15)*(num(5)-1)\n\n\nans += num(25)*(num(3)-1)\n\n\nans += num(5) * (num(5)-1) * (num(3)-2) // 2\nprint(int(ans))\n", "test_IO": [ { "input": "9\n", "output": "0\n" } ] }, { "id": "s191853417", "dataset": "codenet", "language": "Python", "code": "a, b, c, d, e = map(int, input().split())\nprint(15-a-b-c-d-e)\n", "test_IO": [ { "input": "0 2 3 4 5\n", "output": "1\n" } ] }, { "id": "s557080041", "dataset": "codenet", "language": "Python", "code": "N = input()\nif N == 0:\n print('Yes')\nelse:\n N = str(N)\n L = list(N)\n L = [int(s) for s in L]\n X = sum(L)\n if X % 9 == 0:\n print('Yes')\n else:\n print('No')\n", "test_IO": [ { "input": "123456789\n", "output": "Yes\n" } ] }, { "id": "s763208424", "dataset": "codenet", "language": "Python", "code": "from math import floor\nfrom heapq import heappush, heappop\nn, m = map(int, input().split())\na = []\nfor i in map(int, input().split()):\n heappush(a, -i)\n\n\ndef dis(x, y): return x // 2**y\n\n\nfor _ in range(m):\n heappush(a, -dis(-heappop(a), 1))\nprint(-sum(a))\n", "test_IO": [ { "input": "3 3\n2 13 8\n", "output": "9\n" } ] }, { "id": "s880494034", "dataset": "codenet", "language": "Python", "code": "import math\n\nN = input()\nXS = [int(i) for i in input().split()]\n\nm = 9999999999\nfor i in range(1, 101):\n c = sum([(x - i) ** 2 for x in XS])\n if m > c:\n m = c\n\nprint(m)\n", "test_IO": [ { "input": "2\n1 4\n", "output": "5\n" } ] }, { "id": "s770408311", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nres = []\nfor i in range(n):\n a = input()\n res.append(a)\nprint(len(set(res)))\n", "test_IO": [ { "input": "3\napple\norange\napple\n", "output": "2\n" } ] }, { "id": "s167793578", "dataset": "codenet", "language": "Python", "code": "N, M = map(int, input().split())\n\na = N * (N - 1) // 2\nb = M * (M - 1) // 2\n\nprint(a + b)\n", "test_IO": [ { "input": "2 1\n", "output": "1\n" } ] }, { "id": "s591424993", "dataset": "codenet", "language": "Python", "code": "d, g = list(map(int, input().split()))\npc = [list(map(int, input().split())) for _ in range(d)]\n\nans = float(\"inf\")\n\nfor bit in range(1 << d):\n count = 0\n sum = 0\n nokori = set(range(1, d + 1))\n\n for i in range(d):\n if bit & (1 << i):\n sum += pc[i][0] * (i + 1) * 100 + pc[i][1]\n count += pc[i][0]\n nokori.discard(i + 1)\n\n if sum < g:\n use = max(nokori)\n n = min(pc[use-1][0], -(-(g - sum) // (use * 100)))\n count += n\n sum += n * use * 100\n\n if sum >= g:\n ans = min(ans, count)\nprint(ans)\n", "test_IO": [ { "input": "2 700\n3 500\n5 800\n", "output": "3\n" } ] }, { "id": "s142939923", "dataset": "codenet", "language": "Python", "code": "a, b = map(int, input().split())\n\n\nx = [a + b]\n\nx.append(a - b)\n\nx.append(a * b)\nprint(max(x))\n", "test_IO": [ { "input": "3 1\n", "output": "4\n" } ] }, { "id": "s666154520", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nfor i in range(1, 10 ** 5):\n if i * i > n:\n print((i-1) * (i-1))\n exit()\n", "test_IO": [ { "input": "10\n", "output": "9\n" } ] }, { "id": "s952876397", "dataset": "codenet", "language": "Python", "code": "n = int(input())\ns = input()\n\nleft = 0\nfor i in s:\n if i == \")\":\n left += 1\n else:\n break\n\nleft1 = 0\nright1 = 0\n\nfor i in range(left, n):\n if s[i] == \"(\":\n right1 += 1\n elif right1 > 0:\n right1 -= 1\n else:\n left1 += 1\n\nleft1 += left\nfor i in range(right1):\n s += \")\"\nfor i in range(left1):\n s = \"(\" + s\n\nprint(s)\n", "test_IO": [ { "input": "3\n())\n", "output": "(())\n" } ] }, { "id": "s151217193", "dataset": "codenet", "language": "Python", "code": "R = int(input())\nG = int(input())\nprint(G*2-R)\n", "test_IO": [ { "input": "2002\n2017\n", "output": "2032\n" } ] }, { "id": "s052231578", "dataset": "codenet", "language": "Python", "code": "import bisect\n\nN = int(input())\narr = [111, 222, 333, 444, 555, 666, 777, 888, 999]\nans_idx = bisect.bisect_left(arr, N)\nprint(arr[ans_idx])\n", "test_IO": [ { "input": "111\n", "output": "111\n" } ] }, { "id": "s146553386", "dataset": "codenet", "language": "Python", "code": "import numpy\nn = int(input())\na = []\nfor i in range(2):\n a.append(list(map(int, input().split())))\na[1] = a[1][::-1]\nres_0 = numpy.cumsum(a[0])\nres_1 = numpy.cumsum(a[1])\nans = 0\nfor i in range(n):\n check = res_0[i] + res_1[n-1-i]\n ans = max(ans, check)\nprint(ans)\n", "test_IO": [ { "input": "5\n3 2 2 4 1\n1 2 2 2 1\n", "output": "14\n" } ] }, { "id": "s913338871", "dataset": "codenet", "language": "Python", "code": "N = int(input())\na = list(map(int, input().split()))\na.sort()\n\ns = [ai for ai in a[N::2]]\nprint(sum(s))\n", "test_IO": [ { "input": "2\n5 2 8 5 1 5\n", "output": "10\n" } ] }, { "id": "s454986054", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nprint(n**3)\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s793709854", "dataset": "codenet", "language": "Python", "code": "N, T = map(int, input().split())\nL = [[int(l) for l in input().split()] for _ in range(N)]\n\ndp = [[0]*T for _ in range(N+1)]\n\nfor i in range(N):\n for j in range(T):\n if j < L[i][0]:\n dp[i+1][j] = dp[i][j]\n else:\n dp[i+1][j] = max(dp[i][j], dp[i][j-L[i][0]]+L[i][1])\n\nused = []\nB = dp[N][T-1]\nj = T-1\nfor i in range(N-1, -1, -1):\n if B == dp[i][j]:\n continue\n B -= L[i][1]\n used.append(i)\n j -= L[i][0]\n\nans = dp[N][T-1]\nc = 0\nfor i in range(N):\n if i in used:\n continue\n c = max(c, L[i][1])\n\nprint(ans+c)\n", "test_IO": [ { "input": "2 60\n10 10\n100 100\n", "output": "110\n" } ] }, { "id": "s246280701", "dataset": "codenet", "language": "Python", "code": "n = int(input())\nx = list(map(int, input().split()))\nans = 10**10\nfor i in range(101):\n tmp = [abs(i - x[j])**2 for j in range(n)]\n if sum(tmp) < ans:\n ans = sum(tmp)\n\nprint(ans)\n", "test_IO": [ { "input": "2\n1 4\n", "output": "5\n" } ] }, { "id": "s590045523", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nL = list(map(int, input().split()))\n\nans = 0\nfor i in range(N-2):\n for j in range(i+1, N-1):\n for k in range(j+1, N):\n a = L[i]\n b = L[j]\n c = L[k]\n if a == b or b == c or c == a:\n continue\n if a+b > c and b+c > a and c+a > b:\n ans += 1\n\nprint(ans)\n", "test_IO": [ { "input": "5\n4 4 9 7 5\n", "output": "5\n" } ] }, { "id": "s007458552", "dataset": "codenet", "language": "Python", "code": "import sys\nfrom collections import Counter, defaultdict\n\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\n\ndef main():\n n = II()\n S = SI()\n C = Counter(S)\n\n return 'Yes' if C['R'] > n - C['R'] else 'No'\n\n\nprint(main())\n", "test_IO": [ { "input": "4\nRRBR\n", "output": "Yes\n" } ] }, { "id": "s554858080", "dataset": "codenet", "language": "Python", "code": "input = list(map(str, input().split()))\nnum = ''.join(input)\n\nif (int(num) % 4 == 0):\n print('YES')\nelse:\n print('NO')\n", "test_IO": [ { "input": "4 3 2\n", "output": "YES\n" } ] }, { "id": "s110149598", "dataset": "codenet", "language": "Python", "code": "a, b = input().split()\nif a < b:\n print(\"<\")\nelif a > b:\n print(\">\")\nelse:\n print(\"=\")\n", "test_IO": [ { "input": "A B\n", "output": "<\n" } ] }, { "id": "s538657784", "dataset": "codenet", "language": "Python", "code": "import math\nN = int(input())\nsqN = int(math.sqrt(N))\nfor i in range(sqN):\n if N % (sqN-i) == 0:\n print(int(N/(sqN-i)+sqN-i)-2)\n break\n", "test_IO": [ { "input": "10\n", "output": "5\n" } ] }, { "id": "s001486412", "dataset": "codenet", "language": "Python", "code": "n = int(input())\na = list(map(int, input().split()))\nbelow = 0\nfor i in range(n):\n below += 1/a[i]\nprint(1/below)\n", "test_IO": [ { "input": "2\n10 30\n", "output": "7.5\n" } ] }, { "id": "s242961129", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nA = [int(x) for x in input().split()]\nans = abs(A[-1])\nA = [0]+A+[0]\ndiff = [0 for x in range(N)]\nfor i in range(1, N+1):\n dif = abs(A[i]-A[i-1])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1])\n ans += abs(A[i]-A[i-1])\n diff[i-1] = dif\n\nfor i in range(N):\n print(ans-diff[i])\n", "test_IO": [ { "input": "3\n3 5 -1\n", "output": "12\n8\n10\n" } ] }, { "id": "s896397037", "dataset": "codenet", "language": "Python", "code": "s = list(str(input()))\ns.sort()\nif s[0] == s[1] and s[0] != s[2] and s[2] == s[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "test_IO": [ { "input": "ASSA\n", "output": "Yes\n" } ] }, { "id": "s423256012", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\n\nif (A+B) % 2 == 1:\n print('IMPOSSIBLE')\nelse:\n print((A+B)//2)\n", "test_IO": [ { "input": "2 16\n", "output": "9\n" } ] }, { "id": "s002779582", "dataset": "codenet", "language": "Python", "code": "N = int(input())\nHs = list(map(int, input().split()))\n\nans = 0\nmaxH = 0\nfor H in Hs:\n if maxH <= H:\n ans += 1\n maxH = H\n\nprint(ans)\n", "test_IO": [ { "input": "4\n6 5 6 8\n", "output": "3\n" } ] }, { "id": "s331817031", "dataset": "codenet", "language": "Python", "code": "h, w = map(int, input().split())\nl = []\nfor _ in range(h):\n a = list(map(str, input()))\n l.append(a)\n\ntmp = 0\n\nfor i in range(h):\n for j in range(w):\n if l[i][j] == \"#\":\n if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j\n\n\nprint(\"Possible\")\n", "test_IO": [ { "input": "4 5\n##...\n.##..\n..##.\n...##\n", "output": "Possible\n" } ] }, { "id": "s355314304", "dataset": "codenet", "language": "Python", "code": "n = int(input())\n\nif n % 1000 == 0:\n print(0)\nelse:\n print(1000 - n % 1000)\n", "test_IO": [ { "input": "1900\n", "output": "100\n" } ] }, { "id": "s210889193", "dataset": "codenet", "language": "Python", "code": "def solver():\n N = int(input())\n action = []\n for i in range(N):\n action.append(list(map(int, input().split())))\n\n dp = [[0 for _ in range(3)] for _ in range(N)]\n\n for i in range(3):\n dp[0][i] = action[0][i]\n\n for i in range(1, N):\n dp[i][0] = max(dp[i-1][1] + action[i][0], dp[i-1][2] + action[i][0])\n dp[i][1] = max(dp[i-1][0] + action[i][1], dp[i-1][2] + action[i][1])\n dp[i][2] = max(dp[i-1][0] + action[i][2], dp[i-1][1] + action[i][2])\n print(max(dp[N-1]))\n\n\nsolver()\n", "test_IO": [ { "input": "3\n10 40 70\n20 50 80\n30 60 90\n", "output": "210\n" } ] }, { "id": "s289483518", "dataset": "codenet", "language": "Python", "code": "n, m = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nope = [list(map(int, input().split())) for _ in range(m)]\nope = sorted(ope, key=lambda x: x[1], reverse=True)\nj = 0\nfor i in range(n):\n if a[i] < ope[j][1]:\n a[i] = ope[j][1]\n ope[j][0] -= 1\n if ope[j][0] == 0:\n j += 1\n if j == len(ope):\n break\n else:\n break\nprint(sum(a))\n", "test_IO": [ { "input": "3 2\n5 1 4\n2 3\n1 5\n", "output": "14\n" } ] }, { "id": "s607161467", "dataset": "codenet", "language": "Python", "code": "R = int(input())\n\nif R < 1200:\n print(\"ABC\")\nelif R < 2800:\n print(\"ARC\")\nelse:\n print(\"AGC\")\n", "test_IO": [ { "input": "1199\n", "output": "ABC\n" } ] }, { "id": "s179314665", "dataset": "codenet", "language": "Python", "code": "A, B = [int(x) for x in input().split()]\nif A < 10 and B < 10:\n print(A*B)\nelse:\n print(-1)\n", "test_IO": [ { "input": "2 5\n", "output": "10\n" } ] }, { "id": "s804484425", "dataset": "codenet", "language": "Python", "code": "from operator import itemgetter\n\n\nn, k = map(int, input().split())\ninfo = [list(map(int, input().split())) for i in range(n)]\n\ninfo = sorted(info, key=itemgetter(1), reverse=True)\n\nselected = info[0:k]\nselected_only = []\nselected_chohuku = []\nunselected_only = []\nmemo = {}\nfor t, d in selected:\n if t not in memo:\n memo[t] = 1\n selected_only.append(d)\n else:\n selected_chohuku.append(d)\n\ncnt_type = len(memo)\nfor t, d in info[k:]:\n if t not in memo:\n memo[t] = 1\n unselected_only.append(d)\n\n\nsum_select = sum(selected_chohuku) + sum(selected_only)\nans = cnt_type*cnt_type + sum_select\n\nunselected_only = unselected_only[::-1]\nfor i in range(min(len(selected_chohuku), len(unselected_only))):\n cnt_type += 1\n sum_select += unselected_only[-1]\n sum_select -= selected_chohuku[-1]\n del unselected_only[-1]\n del selected_chohuku[-1]\n tmp = cnt_type*cnt_type + sum_select\n ans = max(ans, tmp)\nprint(ans)\n", "test_IO": [ { "input": "5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n", "output": "26\n" } ] }, { "id": "s661542483", "dataset": "codenet", "language": "Python", "code": "H = int(input())\n\ncount = 0\n\n\ndef dfs(h):\n if h == 1:\n return 1\n\n return dfs(h // 2) * 2 + 1\n\n\nprint(dfs(H))\n", "test_IO": [ { "input": "2\n", "output": "3\n" } ] }, { "id": "s013976107", "dataset": "codenet", "language": "Python", "code": "A, B = map(int, input().split())\nS = list(input())\nif S[A] == '-' and S.count('-') == 1:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "test_IO": [ { "input": "3 4\n269-6650\n", "output": "Yes\n" } ] }, { "id": "s398580870", "dataset": "codenet", "language": "Python", "code": "n, k = map(int, input().split())\nif k % 2 == 1:\n print((n//k)**3)\nelse:\n print((n//k)**3+((n+k//2)//k)**3)\n", "test_IO": [ { "input": "3 2\n", "output": "9\n" } ] }, { "id": "s780275612", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s780275612 {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int intA = sc.nextInt();\n\n double dbAncer = Math.pow(intA, 3);\n int intAncer = (int) dbAncer;\n System.out.println(intAncer);\n }\n}\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s175590171", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s175590171 {\n public static void main(String[] args) {\n FastScanner fs = new FastScanner();\n int n = fs.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = fs.nextInt();\n }\n Arrays.sort(a);\n long sum = 0;\n int count = 0;\n for (int i = 0; i < n - 1; i++) {\n sum += a[i];\n if (a[i + 1] <= 2 * sum) {\n count++;\n } else {\n count = 0;\n }\n }\n System.out.println(count + 1);\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "test_IO": [ { "input": "3\n3 1 4\n", "output": "2\n" } ] }, { "id": "s500433274", "dataset": "codenet", "language": "Java", "code": "import java.math.*;\nimport java.util.Scanner;\n\npublic class s500433274 {\n\n public static void main(String[] args) {\n BigInteger a, b, c;\n Scanner cin = new Scanner(System.in);\n while (cin.hasNext()) {\n a = cin.nextBigInteger();\n b = cin.nextBigInteger();\n c = a.max(b);\n if (a.equals(c) && !b.equals(c)) System.out.println(\"GREATER\");\n else if (b.equals(c) && !a.equals(c)) System.out.println(\"LESS\");\n else System.out.println(\"EQUAL\");\n }\n cin.close();\n }\n}\n", "test_IO": [ { "input": "36\n24\n", "output": "GREATER\n" } ] }, { "id": "s314813282", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s314813282 {\n public static void main(String[] args) throws Exception {\n Scanner scan = new Scanner(System.in);\n int m = scan.nextInt();\n int n = scan.nextInt();\n int x = scan.nextInt();\n int y = scan.nextInt();\n int[] a = new int[m];\n for (int i = 0; i < a.length; i++) {\n a[i] = scan.nextInt();\n }\n int[] b = new int[n];\n for (int i = 0; i < b.length; i++) {\n b[i] = scan.nextInt();\n }\n int x_max = MaxInt(x, a);\n int y_min = MinInt(y, b);\n CheckWar(x_max, y_min);\n }\n\n static int MaxInt(int x, int[] a) {\n int bignum = x;\n for (int i = 0; i < a.length; i++) {\n bignum = Math.max(bignum, a[i]);\n }\n return bignum;\n }\n\n static int MinInt(int y, int[] b) {\n int smallnum = y;\n for (int i = 0; i < b.length; i++) {\n smallnum = Math.min(smallnum, b[i]);\n }\n return smallnum;\n }\n\n static void CheckWar(int a, int b) {\n if (a >= b) {\n System.out.println(\"War\");\n } else {\n System.out.println(\"No War\");\n }\n }\n}\n", "test_IO": [ { "input": "3 2 10 20\n8 15 13\n16 22\n", "output": "No War\n" } ] }, { "id": "s173032907", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s173032907 implements Runnable {\n\n private static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) {\n new Thread(null, new s173032907(), \"\", 128 * 1024 * 1024).start();\n }\n\n public void run() {\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n long cost1 = 0;\n long cost2 = 0;\n int current1 = 0;\n int current2 = 0;\n long[] dp1 = new long[n];\n long[] dp2 = new long[n];\n for (int i = 0, j = n - 1; i < n; i++, j--) {\n cost1 += Math.abs(a[i] - current1);\n current1 = a[i];\n dp1[i] = cost1;\n cost2 += Math.abs(a[j] - current2);\n current2 = a[j];\n dp2[j] = cost2;\n }\n\n for (int i = 0; i < n; i++) {\n if (i == 0) {\n System.out.println(dp2[i + 1] + Math.abs(a[1]));\n } else if (i == n - 1) {\n System.out.println(dp1[i - 1] + Math.abs(a[i - 1]));\n } else {\n System.out.println(dp1[i - 1] + dp2[i + 1] + Math.abs(a[i - 1] - a[i + 1]));\n }\n }\n }\n}\n", "test_IO": [ { "input": "3\n3 5 -1\n", "output": "12\n8\n10\n" } ] }, { "id": "s898738430", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s898738430 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n int ans = 0;\n for (int i = 1; i < n - 1; i++) {\n if (a[i] != Math.min(a[i - 1], Math.min(a[i], a[i + 1]))\n && a[i] != Math.max(a[i - 1], Math.max(a[i], a[i + 1]))) {\n ans++;\n }\n }\n System.out.println(ans);\n sc.close();\n }\n}\n", "test_IO": [ { "input": "5\n1 3 5 4 2\n", "output": "2\n" } ] }, { "id": "s527301188", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class s527301188 {\n\n public static void main(String[] args) throws NumberFormatException, IOException {\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\n String[] strs = reader.readLine().split(\" \");\n int[] nums = new int[strs.length];\n int top = 0;\n for (int i = 0; i < strs.length; i++) {\n switch (strs[i].charAt(0)) {\n case '+':\n top--;\n nums[top - 1] = nums[top - 1] + nums[top];\n break;\n case '-':\n top--;\n nums[top - 1] = nums[top - 1] - nums[top];\n break;\n case '*':\n top--;\n nums[top - 1] = nums[top - 1] * nums[top];\n break;\n default:\n nums[top] = Integer.parseInt(strs[i]);\n top++;\n break;\n }\n }\n System.out.println(nums[0]);\n }\n}\n", "test_IO": [ { "input": "1 2 +\n", "output": "3\n" } ] }, { "id": "s356471394", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s356471394 {\n\n static Scanner sc = new Scanner(System.in);\n static String[] nums = sc.nextLine().split(\" \");\n\n static int N = Integer.parseInt(nums[0]);\n static int M = Integer.parseInt(nums[1]);\n static char[][] room = new char[N][M];\n static int D = Integer.parseInt(nums[2]);\n static int num = 0;\n\n public static void main(String[] args) {\n inputRoom();\n\n if (M >= D) {\n setWE();\n }\n\n if (N >= D) {\n setNS();\n }\n\n System.out.println(num);\n sc.close();\n }\n\n private static void setWE() {\n boolean canPut = true;\n\n for (int i = 0; i < N; i++) {\n for (int j = 0; j < M - D + 1; j++) {\n canPut = true;\n\n for (int k = 0; k < D; k++) {\n if (s356471394.room[i][j + k] == '#') {\n canPut = false;\n break;\n }\n }\n\n if (canPut == true) {\n num++;\n }\n }\n }\n }\n\n private static void setNS() {\n boolean canPut = true;\n\n for (int i = 0; i < M; i++) {\n for (int j = 0; j < N - D + 1; j++) {\n canPut = true;\n\n for (int k = 0; k < D; k++) {\n if (s356471394.room[j + k][i] == '#') {\n canPut = false;\n break;\n }\n }\n\n if (canPut == true) {\n num++;\n }\n }\n }\n }\n\n private static void inputRoom() {\n String str_room = \"\";\n\n for (int i = 0; i < N; i++) {\n str_room = sc.nextLine();\n s356471394.room[i] = str_room.toCharArray();\n }\n }\n}\n", "test_IO": [ { "input": "3 5 2\n...#.\n#...#\n....#\n", "output": "12\n" } ] }, { "id": "s275359315", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s275359315 {\n public static void main(String... args) {\n Scanner scan = new Scanner(System.in);\n int r = scan.nextInt();\n int res = (int) Math.pow(r, 2);\n System.out.println(res);\n }\n}\n", "test_IO": [ { "input": "2\n", "output": "4\n" } ] }, { "id": "s640163137", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class s640163137 {\n\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int n = Integer.parseInt(br.readLine());\n int[] a = new int[n];\n String[] elements = br.readLine().split(\" \");\n\n for (int i = 0; i < n; i++) {\n a[i] = Integer.parseInt(elements[i]);\n }\n\n int swapCount = 0;\n\n for (int i = 0; i < a.length; i++) {\n int mini = i;\n\n for (int j = i; j < a.length; j++) {\n if (a[j] < a[mini]) {\n mini = j;\n }\n }\n\n if (mini != i) {\n int v = a[mini];\n a[mini] = a[i];\n a[i] = v;\n\n swapCount++;\n }\n }\n\n String ans = String.valueOf(a[0]);\n for (int i = 1; i < a.length; i++) {\n ans += \" \" + a[i];\n }\n\n System.out.println(ans);\n System.out.println(swapCount);\n }\n}\n", "test_IO": [ { "input": "6\n5 6 4 2 1 3\n", "output": "1 2 3 4 5 6\n4\n" } ] }, { "id": "s077706488", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s077706488 {\n\n public static void main(String[] args) {\n Scanner stdIn = new Scanner(System.in);\n int N = stdIn.nextInt();\n int X = stdIn.nextInt();\n int[] m = new int[N];\n m[0] = stdIn.nextInt();\n X -= m[0];\n int min = m[0];\n for (int i = 1; i < N; i++) {\n m[i] = stdIn.nextInt();\n X -= m[i];\n if (m[i] < min) {\n min = m[i];\n }\n }\n System.out.println(N + X / min);\n }\n}\n", "test_IO": [ { "input": "3 1000\n120\n100\n140\n", "output": "9\n" } ] }, { "id": "s476581255", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s476581255 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n int count = bubbleSort(a, n);\n for (int i = 0; i < n; i++) {\n if (i < n - 1) {\n System.out.print(a[i] + \" \");\n } else {\n System.out.println(a[i]);\n }\n }\n System.out.println(count);\n }\n\n public static int bubbleSort(int[] a, int n) {\n boolean flag = true;\n int count = 0;\n while (flag == true) {\n flag = false;\n for (int j = n - 1; j > 0; j--) {\n if (a[j] < a[j - 1]) {\n int free = a[j];\n a[j] = a[j - 1];\n a[j - 1] = free;\n count++;\n flag = true;\n }\n }\n }\n return count;\n }\n}\n", "test_IO": [ { "input": "5\n5 3 2 4 1\n", "output": "1 2 3 4 5\n8\n" } ] }, { "id": "s490798303", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s490798303 {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int n = scanner.nextInt();\n int k = scanner.nextInt();\n\n Map> map = new HashMap<>();\n\n for (int i = 0; i < k; i++) {\n int d = scanner.nextInt();\n for (int j = 0; j < d; j++) {\n int person = scanner.nextInt();\n\n if (!map.containsKey(person)) {\n map.put(person, new ArrayList<>());\n }\n map.get(person).add(d);\n }\n }\n\n int count = 0;\n for (int i = 1; i <= n; i++) {\n if (!map.containsKey(i)) {\n count++;\n }\n }\n\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "3 2\n2\n1 3\n1\n3\n", "output": "1\n" } ] }, { "id": "s307170605", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s307170605 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n for (int i = 0; i < 5; i++) {\n if (sc.nextInt() == 0) {\n System.out.println(i + 1);\n break;\n }\n }\n }\n}\n", "test_IO": [ { "input": "0 2 3 4 5\n", "output": "1\n" } ] }, { "id": "s100570405", "dataset": "codenet", "language": "Java", "code": "import static java.lang.System.out;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.NoSuchElementException;\n\npublic class s100570405 {\n public static void main(String args[]) {\n new s100570405().run();\n }\n\n MyInput in = new MyInput();\n\n public void run() {\n String Sd = in.next();\n String T = in.next();\n int count = 0;\n char c;\n boolean ok = false;\n int first = -1;\n int end = -1;\n for (int j = 0; j < Sd.length(); j++) {\n count = 0;\n for (int i = 0; i + j < Sd.length(); i++) {\n c = Sd.charAt(i + j);\n if (c == '?' || c == T.charAt(count)) {\n count++;\n if (count == T.length()) {\n first = i + j - T.length() + 1;\n end = i + j;\n ok = true;\n break;\n }\n } else count = 0;\n }\n }\n if (ok) {\n for (int i = 0; i < Sd.length(); i++) {\n if (first <= i && i <= end) {\n out.print(T.charAt(i - first));\n } else {\n if (Sd.charAt(i) == '?') out.print(\"a\");\n else out.print(Sd.charAt(i));\n }\n }\n out.println();\n } else {\n out.println(\"UNRESTORABLE\");\n }\n }\n}\n\nclass MyInput {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n public int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n private void skipUnprintable() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n }\n\n public boolean hasNext() {\n skipUnprintable();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "test_IO": [ { "input": "?tc????\ncoder\n", "output": "atcoder\n" } ] }, { "id": "s399184958", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s399184958 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n int C = sc.nextInt();\n if (A == B && B == C && C == A) System.out.println(\"Yes\");\n else System.out.println(\"No\");\n }\n}\n", "test_IO": [ { "input": "2 2 2\n", "output": "Yes\n" } ] }, { "id": "s888667117", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\nimport java.util.stream.*;\n\npublic class s888667117 {\n public static final Scanner in =\n new Scanner(new BufferedReader(new InputStreamReader(System.in)));\n public static final PrintStream out = System.out;\n public static final PrintStream err = System.err;\n\n public static void main(String[] args) {\n String Si = in.next();\n char[] S = new StringBuilder(Si).reverse().toString().toCharArray();\n\n long[] dp = new long[13];\n dp[0] = 1;\n\n for (int i = 0, d = 1; i < S.length; i++, d = d * 10 % 13) {\n long[] nd = new long[13];\n\n err.println(\"d: \" + d + \", i: \" + i + \", S[i]: \" + S[i]);\n char c = S[i];\n\n if (Character.isDigit(c)) {\n int x = (c - '0') * d;\n\n for (int j = 0; j < 13; j++) {\n nd[(j + x) % 13] = dp[j];\n }\n } else {\n for (int xi = 0; xi < 10; xi++) {\n int x = xi * d;\n\n for (int j = 0; j < 13; j++) {\n int ni = (j + x) % 13;\n nd[ni] = (nd[ni] + dp[j]) % 1000000007;\n }\n }\n }\n\n err.println(Arrays.toString(nd));\n dp = nd;\n }\n\n out.println(dp[5]);\n }\n}\n", "test_IO": [ { "input": "??2??5\n", "output": "768\n" } ] }, { "id": "s684030429", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class s684030429 {\n Scanner sc;\n int max = 0, cur = 0;\n\n void solve() {\n int a = ni();\n int b = ni();\n\n System.out.println(Math.max(0, a - 2 * b));\n }\n\n s684030429() {\n try {\n sc = new Scanner(System.in);\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) {\n new s684030429().solve();\n }\n\n int ni() {\n int a = sc.nextInt();\n return a;\n }\n\n long nl() {\n return sc.nextLong();\n }\n\n float nf() {\n float a = sc.nextFloat();\n return a;\n }\n\n double nd() {\n double a = sc.nextDouble();\n return a;\n }\n\n String ns() {\n return sc.nextLine();\n }\n\n StringTokenizer nst(String s) {\n return new StringTokenizer(s);\n }\n\n void ia(int a[]) {\n for (int i = 0; i < a.length; i++) a[i] = sc.nextInt();\n }\n\n void la(long a[]) {\n for (int i = 0; i < a.length; i++) a[i] = sc.nextLong();\n }\n\n void fa(float a[]) {\n for (int i = 0; i < a.length; i++) a[i] = sc.nextFloat();\n }\n\n void da(double a[]) {\n for (int i = 0; i < a.length; i++) a[i] = sc.nextDouble();\n }\n\n void sa(String a[], boolean empty) {\n if (empty) {\n for (int i = 0; i < a.length; i++) {\n a[i] = \"\";\n }\n } else {\n for (int i = 0; i < a.length; i++) {\n a[i] = ns();\n }\n }\n }\n\n void ida(int a[][], int n, int m) {\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n a[i][j] = ni();\n }\n }\n }\n\n void lda(long a[][], int n, int m) {\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n a[i][j] = nl();\n }\n }\n }\n\n void dda(double a[][], int n, int m) {\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n a[i][j] = nd();\n }\n }\n }\n\n int stoi(String s) {\n return Integer.parseInt(s);\n }\n\n double stod(String s) {\n return Double.parseDouble(s);\n }\n\n long lmin(long a[]) {\n long min = Long.MAX_VALUE;\n for (int i = 0; i < a.length; i++) {\n if (min > a[i]) min = a[i];\n }\n return min;\n }\n\n int imin(int a[]) {\n int min = Integer.MAX_VALUE;\n for (int i = 0; i < a.length; i++) {\n if (min > a[i]) min = a[i];\n }\n return min;\n }\n\n long lmax(long a[]) {\n long max = Long.MIN_VALUE;\n for (int i = 0; i < a.length; i++) {\n if (max < a[i]) max = a[i];\n }\n return max;\n }\n\n int imax(int a[]) {\n int max = Integer.MIN_VALUE;\n for (int i = 0; i < a.length; i++) {\n if (max < a[i]) max = a[i];\n }\n return max;\n }\n\n boolean ibs(int a[], int toFind) {\n Arrays.sort(a);\n int min = 0;\n int max = a.length - 1;\n boolean found = false;\n\n while (min <= max && !found) {\n int mid = min + (max - min) / 2;\n if (a[mid] == toFind) {\n found = true;\n } else if (toFind > a[mid]) {\n min = mid + 1;\n } else {\n max = mid - 1;\n }\n }\n return found;\n }\n\n boolean lbs(long a[], long toFind) {\n Arrays.sort(a);\n int min = 0;\n int max = a.length - 1;\n boolean found = false;\n\n while (min <= max && !found) {\n int mid = min + (max - min) / 2;\n if (a[mid] == toFind) {\n found = true;\n } else if (toFind > a[mid]) {\n min = mid + 1;\n } else {\n max = mid - 1;\n }\n }\n return found;\n }\n\n int stb(String s) {\n int sum = 0;\n int k = 0;\n for (int i = s.length() - 1; i >= 0; i--) {\n sum += stoi(s.charAt(i) + \"\") * Math.pow(2, k++);\n }\n return sum;\n }\n}\n", "test_IO": [ { "input": "12 4\n", "output": "4\n" } ] }, { "id": "s799002881", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.nio.charset.StandardCharsets;\n\npublic class s799002881 {\n public static void main(String[] args) throws IOException {\n InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);\n BufferedReader in = new BufferedReader(reader);\n String[] str = in.readLine().split(\" \");\n int n = Integer.parseInt(str[0]);\n double d = Integer.parseInt(str[1]);\n int cnt = 0;\n\n for (int i = 0; i < n; i++) {\n str = in.readLine().split(\" \");\n double x = Integer.parseInt(str[0]);\n double y = Integer.parseInt(str[1]);\n if (Math.sqrt(x * x + y * y) <= d) {\n cnt++;\n }\n }\n System.out.println(cnt);\n }\n}\n", "test_IO": [ { "input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n", "output": "3\n" } ] }, { "id": "s514557145", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\npublic class s514557145 {\n static final long MOD1 = 1000000007;\n static final long MOD2 = 998244353;\n static long[] tenmod;\n static final long inv9 = modInv(9);\n\n public static void main(String[] args) {\n PrintWriter out = new PrintWriter(System.out);\n InputReader sc = new InputReader(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n tenmod = new long[N + 1];\n tenmod[0] = 1;\n for (int j = 1; j <= N; j++) {\n tenmod[j] = (tenmod[j - 1] * 10L) % MOD2;\n }\n S[] dat = new S[N];\n Arrays.setAll(dat, i -> new S(tenmod[N - i - 1], i, i));\n LazySegTree lazySegTree =\n new LazySegTree(dat, S::op, S.E, S::map, F::composite, F.I);\n for (int j = 0; j < Q; j++) {\n int l = sc.nextInt() - 1;\n int r = sc.nextInt() - 1;\n long D = sc.nextLong();\n lazySegTree.apply(l, r + 1, new F(D, N));\n out.println(lazySegTree.allProd().sum);\n }\n out.flush();\n }\n\n static class S {\n static final S E = new S(0, Integer.MAX_VALUE / 2, Integer.MIN_VALUE / 2);\n long sum;\n int l;\n int r;\n\n public S(long sum, int l, int r) {\n super();\n this.sum = sum;\n this.l = l;\n this.r = r;\n }\n\n public static S op(S s1, S s2) {\n long sum = s1.sum + s2.sum;\n if (sum >= MOD2) {\n sum -= MOD2;\n }\n return new S(sum, Math.min(s1.l, s2.l), Math.max(s1.r, s2.r));\n }\n\n static S map(F f, S s) {\n long c = (tenmod[(f.N - s.l)] - tenmod[(f.N - s.r - 1)]);\n if (c < 0) {\n c += MOD2;\n }\n return new S(((f.D * c) % MOD2 * inv9) % MOD2, s.l, s.r);\n }\n }\n\n static class F {\n static final F I = new F(0, 0);\n long D;\n int N;\n\n public F(long D, int N) {\n super();\n this.D = D;\n this.N = N;\n }\n\n public static F composite(F f, F g) {\n return new F(f.D, f.N);\n }\n }\n\n static long modInv(long x) {\n return modPow(x, MOD2 - 2);\n }\n\n static long modPow(long x, long y) {\n long z = 1;\n while (y > 0) {\n if (y % 2 == 0) {\n x = (x * x) % MOD2;\n y /= 2;\n } else {\n z = (z * x) % MOD2;\n y--;\n }\n }\n return z;\n }\n\n static class LazySegTree {\n final int MAX;\n\n final int N;\n final int Log;\n final java.util.function.BinaryOperator Op;\n final S E;\n final java.util.function.BiFunction Mapping;\n final java.util.function.BinaryOperator Composition;\n final F Id;\n\n final S[] Dat;\n final F[] Laz;\n\n @SuppressWarnings(\"unchecked\")\n public LazySegTree(\n int n,\n java.util.function.BinaryOperator op,\n S e,\n java.util.function.BiFunction mapping,\n java.util.function.BinaryOperator composition,\n F id) {\n this.MAX = n;\n int k = 1;\n while (k < n) k <<= 1;\n this.N = k;\n this.Log = Integer.numberOfTrailingZeros(N);\n this.Op = op;\n this.E = e;\n this.Mapping = mapping;\n this.Composition = composition;\n this.Id = id;\n this.Dat = (S[]) new Object[N << 1];\n this.Laz = (F[]) new Object[N];\n java.util.Arrays.fill(Dat, E);\n java.util.Arrays.fill(Laz, Id);\n }\n\n public LazySegTree(\n S[] dat,\n java.util.function.BinaryOperator op,\n S e,\n java.util.function.BiFunction mapping,\n java.util.function.BinaryOperator composition,\n F id) {\n this(dat.length, op, e, mapping, composition, id);\n build(dat);\n }\n\n private void build(S[] dat) {\n int l = dat.length;\n System.arraycopy(dat, 0, Dat, N, l);\n for (int i = N - 1; i > 0; i--) {\n Dat[i] = Op.apply(Dat[i << 1 | 0], Dat[i << 1 | 1]);\n }\n }\n\n private void push(int k) {\n if (Laz[k] == Id) return;\n int lk = k << 1 | 0, rk = k << 1 | 1;\n Dat[lk] = Mapping.apply(Laz[k], Dat[lk]);\n Dat[rk] = Mapping.apply(Laz[k], Dat[rk]);\n if (lk < N) Laz[lk] = Composition.apply(Laz[k], Laz[lk]);\n if (rk < N) Laz[rk] = Composition.apply(Laz[k], Laz[rk]);\n Laz[k] = Id;\n }\n\n private void pushTo(int k) {\n for (int i = Log; i > 0; i--) push(k >> i);\n }\n\n private void pushTo(int lk, int rk) {\n for (int i = Log; i > 0; i--) {\n if (((lk >> i) << i) != lk) push(lk >> i);\n if (((rk >> i) << i) != rk) push(rk >> i);\n }\n }\n\n private void updateFrom(int k) {\n k >>= 1;\n while (k > 0) {\n Dat[k] = Op.apply(Dat[k << 1 | 0], Dat[k << 1 | 1]);\n k >>= 1;\n }\n }\n\n private void updateFrom(int lk, int rk) {\n for (int i = 1; i <= Log; i++) {\n if (((lk >> i) << i) != lk) {\n int lki = lk >> i;\n Dat[lki] = Op.apply(Dat[lki << 1 | 0], Dat[lki << 1 | 1]);\n }\n if (((rk >> i) << i) != rk) {\n int rki = (rk - 1) >> i;\n Dat[rki] = Op.apply(Dat[rki << 1 | 0], Dat[rki << 1 | 1]);\n }\n }\n }\n\n public void set(int p, S x) {\n exclusiveRangeCheck(p);\n p += N;\n pushTo(p);\n Dat[p] = x;\n updateFrom(p);\n }\n\n public S get(int p) {\n exclusiveRangeCheck(p);\n p += N;\n pushTo(p);\n return Dat[p];\n }\n\n public S allProd() {\n return Dat[1];\n }\n\n public void apply(int p, F f) {\n exclusiveRangeCheck(p);\n p += N;\n pushTo(p);\n Dat[p] = Mapping.apply(f, Dat[p]);\n updateFrom(p);\n }\n\n public void apply(int l, int r, F f) {\n if (l > r) {\n throw new IllegalArgumentException(String.format(\"Invalid range: [%d, %d)\", l, r));\n }\n inclusiveRangeCheck(l);\n inclusiveRangeCheck(r);\n if (l == r) return;\n l += N;\n r += N;\n pushTo(l, r);\n for (int l2 = l, r2 = r; l2 < r2; ) {\n if ((l2 & 1) == 1) {\n Dat[l2] = Mapping.apply(f, Dat[l2]);\n if (l2 < N) Laz[l2] = Composition.apply(f, Laz[l2]);\n l2++;\n }\n if ((r2 & 1) == 1) {\n r2--;\n Dat[r2] = Mapping.apply(f, Dat[r2]);\n if (r2 < N) Laz[r2] = Composition.apply(f, Laz[r2]);\n }\n l2 >>= 1;\n r2 >>= 1;\n }\n updateFrom(l, r);\n }\n\n public int maxRight(int l, java.util.function.Predicate g) {\n inclusiveRangeCheck(l);\n if (!g.test(E)) {\n throw new IllegalArgumentException(\"Identity element must satisfy the condition.\");\n }\n if (l == MAX) return MAX;\n l += N;\n pushTo(l);\n S sum = E;\n do {\n l >>= Integer.numberOfTrailingZeros(l);\n if (!g.test(Op.apply(sum, Dat[l]))) {\n while (l < N) {\n push(l);\n l = l << 1;\n if (g.test(Op.apply(sum, Dat[l]))) {\n sum = Op.apply(sum, Dat[l]);\n l++;\n }\n }\n return l - N;\n }\n sum = Op.apply(sum, Dat[l]);\n l++;\n } while ((l & -l) != l);\n return MAX;\n }\n\n public int minLeft(int r, java.util.function.Predicate g) {\n inclusiveRangeCheck(r);\n if (!g.test(E)) {\n throw new IllegalArgumentException(\"Identity element must satisfy the condition.\");\n }\n if (r == 0) return 0;\n r += N;\n pushTo(r - 1);\n S sum = E;\n do {\n r--;\n while (r > 1 && (r & 1) == 1) r >>= 1;\n if (!g.test(Op.apply(Dat[r], sum))) {\n while (r < N) {\n push(r);\n r = r << 1 | 1;\n if (g.test(Op.apply(Dat[r], sum))) {\n sum = Op.apply(Dat[r], sum);\n r--;\n }\n }\n return r + 1 - N;\n }\n sum = Op.apply(Dat[r], sum);\n } while ((r & -r) != r);\n return 0;\n }\n\n private void exclusiveRangeCheck(int p) {\n if (p < 0 || p >= MAX) {\n throw new IndexOutOfBoundsException(\n String.format(\"Index %d is not in [%d, %d).\", p, 0, MAX));\n }\n }\n\n private void inclusiveRangeCheck(int p) {\n if (p < 0 || p > MAX) {\n throw new IndexOutOfBoundsException(\n String.format(\"Index %d is not in [%d, %d].\", p, 0, MAX));\n }\n }\n\n private int indent = 6;\n\n public void setIndent(int newIndent) {\n this.indent = newIndent;\n }\n\n @Override\n public String toString() {\n return toString(1, 0);\n }\n\n private String toString(int k, int sp) {\n if (k >= N) return indent(sp) + Dat[k];\n String s = \"\";\n s += toString(k << 1 | 1, sp + indent);\n s += \"\\n\";\n s += indent(sp) + Dat[k] + \"/\" + Laz[k];\n s += \"\\n\";\n s += toString(k << 1 | 0, sp + indent);\n return s;\n }\n\n private static String indent(int n) {\n StringBuilder sb = new StringBuilder();\n while (n-- > 0) sb.append(' ');\n return sb.toString();\n }\n }\n\n static class InputReader {\n private InputStream in;\n private byte[] buffer = new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {\n this.in = in;\n this.curbuf = this.lenbuf = 0;\n }\n\n public boolean hasNextByte() {\n if (curbuf >= lenbuf) {\n curbuf = 0;\n try {\n lenbuf = in.read(buffer);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return false;\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[curbuf++];\n else return -1;\n }\n\n private boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private void skip() {\n while (hasNextByte() && isSpaceChar(buffer[curbuf])) curbuf++;\n }\n\n public boolean hasNext() {\n skip();\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (!isSpaceChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public int nextInt() {\n if (!hasNext()) throw new NoSuchElementException();\n int c = readByte();\n while (isSpaceChar(c)) c = readByte();\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') throw new InputMismatchException();\n res = res * 10 + c - '0';\n c = readByte();\n } while (!isSpaceChar(c));\n return (minus) ? -res : res;\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n int c = readByte();\n while (isSpaceChar(c)) c = readByte();\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long res = 0;\n do {\n if (c < '0' || c > '9') throw new InputMismatchException();\n res = res * 10 + c - '0';\n c = readByte();\n } while (!isSpaceChar(c));\n return (minus) ? -res : res;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nextLong();\n return a;\n }\n\n public char[][] nextCharMap(int n, int m) {\n char[][] map = new char[n][m];\n for (int i = 0; i < n; i++) map[i] = next().toCharArray();\n return map;\n }\n }\n}\n", "test_IO": [ { "input": "8 5\n3 6 2\n1 4 7\n3 8 3\n2 2 2\n4 5 1\n", "output": "11222211\n77772211\n77333333\n72333333\n72311333\n" } ] }, { "id": "s629237879", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.Arrays;\n\npublic class s629237879 {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String sc = br.readLine();\n int n = Integer.parseInt(sc);\n String[] str = new String[n];\n for (int i = 0; i < n; i++) {\n str[i] = br.readLine();\n }\n String[] mark = {\"S\", \"H\", \"C\", \"D\"};\n for (String ma : mark) {\n for (int i = 1; i <= 13; i++) {\n String s = Integer.toString(i);\n String st = ma + \" \" + s;\n if (Arrays.asList(str).contains(st)) {\n continue;\n } else {\n System.out.println(st);\n }\n }\n }\n }\n}\n", "test_IO": [ { "input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n", "output": "S 1\nH 3\nH 7\nC 12\nD 8\n" } ] }, { "id": "s749703010", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s749703010 {\n\n static class Pair {\n int l, r;\n\n Pair(int a, int b) {\n l = a;\n r = b;\n }\n\n @Override\n public String toString() {\n return l + \" \" + r;\n }\n }\n\n static int[][][] memo;\n static int[][] a;\n static int n;\n\n static int dp(int fliped, int idx, int msk) {\n if (msk == (1 << n) - 1) return 0;\n if (memo[fliped][idx][msk] != -1) return memo[fliped][idx][msk];\n int x = Integer.bitCount(msk);\n int ff = 0;\n int ans = (int) 1e9;\n for (int i = 0; i < n; i++) {\n if ((msk & (1 << i)) == 0) {\n int nf = x % 2;\n if (idx == n || a[fliped][idx] <= a[(nf + (ff % 2)) % 2][i]) {\n ans = Math.min(ans, ff + dp((nf + (ff % 2)) % 2, i, msk | 1 << i));\n }\n ff++;\n } else x--;\n }\n return memo[fliped][idx][msk] = ans;\n }\n\n public static void main(String[] args) throws IOException, InterruptedException {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n n = sc.nextInt();\n a = new int[2][n];\n for (int i = 0; i < n; i++) a[0][i] = sc.nextInt();\n for (int i = 0; i < n; i++) a[1][i] = sc.nextInt();\n memo = new int[2][n + 1][1 << n];\n for (int[][] z : memo) for (int[] x : z) Arrays.fill(x, -1);\n int ans = dp(0, n, 0);\n pw.println(ans >= 1e8 ? -1 : ans);\n pw.flush();\n }\n\n static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(FileReader r) {\n br = new BufferedReader(r);\n }\n\n public Scanner(InputStream s) {\n br = new BufferedReader(new InputStreamReader(s));\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n String x = next();\n StringBuilder sb = new StringBuilder(\"0\");\n double res = 0, f = 1;\n boolean dec = false, neg = false;\n int start = 0;\n if (x.charAt(0) == '-') {\n neg = true;\n start++;\n }\n for (int i = start; i < x.length(); i++)\n if (x.charAt(i) == '.') {\n res = Long.parseLong(sb.toString());\n sb = new StringBuilder(\"0\");\n dec = true;\n } else {\n sb.append(x.charAt(i));\n if (dec) f *= 10;\n }\n res += Long.parseLong(sb.toString()) / f;\n return res * (neg ? -1 : 1);\n }\n\n public boolean ready() throws IOException {\n return br.ready();\n }\n }\n}\n", "test_IO": [ { "input": "3\n3 4 3\n3 2 3\n", "output": "1\n" } ] }, { "id": "s301480578", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s301480578 {\n\n public static void main(String[] args) {\n @SuppressWarnings(\"resource\")\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] h = new int[n];\n for (int i = 0; i < n; i++) {\n h[i] = sc.nextInt();\n }\n int max = 0;\n for (int l = 0; l < n - 1; l++) {\n int count = 0;\n while (l < n - 1 && h[l] >= h[l + 1]) {\n l++;\n count++;\n }\n max = Math.max(max, count);\n }\n System.out.println(max);\n }\n}\n", "test_IO": [ { "input": "5\n10 4 8 7 3\n", "output": "2\n" } ] }, { "id": "s196249385", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s196249385 {\n\n private static Scanner sc;\n private static Printer pr;\n\n private static void solve() {\n int n = sc.nextInt();\n int k = sc.nextInt();\n\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n\n long[] cumsum = new long[n + 1];\n for (int i = 0; i < n; i++) {\n cumsum[i + 1] = cumsum[i] + a[i];\n }\n\n List b = new ArrayList<>(n * (n + 1) / 2);\n long max = 0;\n for (int i = 0; i < n; i++) {\n for (int j = i; j < n; j++) {\n b.add(cumsum[j + 1] - cumsum[i]);\n max = Math.max(max, cumsum[j + 1] - cumsum[i]);\n }\n }\n\n long mask = Long.highestOneBit(max);\n while (mask > 0) {\n List tmp = new ArrayList<>();\n for (long e : b) {\n if ((e & mask) != 0) {\n tmp.add(e);\n }\n }\n\n if (tmp.size() >= k) {\n b = tmp;\n }\n\n mask >>= 1;\n }\n\n if (b.size() < k) {\n pr.println(0);\n } else {\n long ans = -1L;\n for (long e : b) {\n ans &= e;\n }\n\n pr.println(ans);\n }\n }\n\n public static void main(String[] args) {\n sc = new Scanner(System.in);\n pr = new Printer(System.out);\n\n solve();\n\n pr.close();\n sc.close();\n }\n\n static class Printer extends PrintWriter {\n Printer(OutputStream out) {\n super(out);\n }\n }\n}\n", "test_IO": [ { "input": "4 2\n2 5 2 5\n", "output": "12\n" } ] }, { "id": "s918182055", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s918182055 {\n\n public static void main(String[] args) {\n MyWriter out = new MyWriter(System.out);\n\n MyScanner sc = new MyScanner(System.in);\n int N = sc.nextInt();\n int M = sc.nextInt();\n LinkedList[] list = new LinkedList[100001];\n\n for (int i = 0; i < N; i++) {\n int a = sc.nextInt();\n int b = sc.nextInt();\n if (list[a] == null) {\n list[a] = new LinkedList();\n }\n list[a].add(b);\n }\n\n int res = 0;\n PriorityQueue pqueue = new PriorityQueue(Collections.reverseOrder());\n for (int i = 1; i <= M; i++) {\n if (list[i] != null) {\n pqueue.addAll(list[i]);\n }\n if (!pqueue.isEmpty()) res += pqueue.poll();\n }\n\n out.println(res);\n out.flush();\n }\n\n static final class MyScanner {\n static final int BUFFER_SIZE = 8192;\n private final InputStream in;\n private final byte[] buffer = new byte[BUFFER_SIZE];\n private int point;\n private int readLength;\n\n MyScanner(InputStream in) {\n this.in = in;\n }\n\n private int readByte() {\n if (point < readLength) {\n int result = buffer[point];\n point += 1;\n return result;\n }\n try {\n readLength = in.read(buffer);\n } catch (IOException e) {\n throw new AssertionError(null, e);\n }\n if (readLength == -1) {\n return -1;\n }\n point = 1;\n return buffer[0];\n }\n\n private static boolean isPrintableCharExceptSpace(int c) {\n return 33 <= c && c <= 126;\n }\n\n String next() {\n int c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n StringBuilder b = new StringBuilder();\n do {\n b.appendCodePoint(c);\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return b.toString();\n }\n\n long nextLong() {\n int c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long result = 0L;\n do {\n if (c < '0' || c > '9') {\n throw new InputMismatchException();\n }\n result = result * 10L + (c - '0');\n c = readByte();\n } while (c != -1 && isPrintableCharExceptSpace(c));\n return minus ? -result : result;\n }\n\n int nextInt() {\n long n = nextLong();\n if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {\n throw new InputMismatchException();\n }\n return (int) n;\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n int[] nextIntArray(int n) {\n int[] result = new int[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextInt();\n }\n return result;\n }\n\n private static boolean allSameLength(int[] a, int[] b, int[]... c) {\n if (a.length != b.length) {\n return false;\n }\n for (int[] element : c) {\n if (a.length != element.length) {\n return false;\n }\n }\n return true;\n }\n\n private static boolean allSameLength(char[] a, char[] b, char[]... c) {\n if (a.length != b.length) {\n return false;\n }\n for (char[] element : c) {\n if (a.length != element.length) {\n return false;\n }\n }\n return true;\n }\n\n void nextVerticalIntArrays(int[] a, int[] b, int[]... c) {\n if (!allSameLength(a, b, c)) {\n throw new IllegalArgumentException();\n }\n for (int i = 0; i < a.length; i++) {\n a[i] = nextInt();\n b[i] = nextInt();\n for (int[] d : c) {\n d[i] = nextInt();\n }\n }\n }\n\n long[] nextLongArray(int n) {\n long[] result = new long[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextLong();\n }\n return result;\n }\n\n char nextChar() {\n int c = readByte();\n while (!(c == -1 || isPrintableCharExceptSpace(c))) {\n c = readByte();\n }\n if (c == -1) {\n throw new NoSuchElementException();\n }\n return (char) c;\n }\n\n char[] nextCharArray(int n) {\n char[] result = new char[n];\n for (int i = 0; i < n; i++) {\n result[i] = nextChar();\n }\n return result;\n }\n\n char[][] next2dCharArray(int n, int m) {\n char[][] result = new char[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n result[i][j] = nextChar();\n }\n }\n return result;\n }\n\n void nextVerticalCharArrays(char[] a, char[] b, char[]... c) {\n if (!allSameLength(a, b, c)) {\n throw new IllegalArgumentException();\n }\n for (int i = 0; i < a.length; i++) {\n a[i] = nextChar();\n b[i] = nextChar();\n for (char[] d : c) {\n d[i] = nextChar();\n }\n }\n }\n }\n\n static final class MyWriter extends PrintWriter {\n MyWriter(OutputStream out) {\n super(out);\n }\n\n void joinAndPrintln(int[] x) {\n joinAndPrintln(x, \" \");\n }\n\n void joinAndPrintln(int[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n\n void joinAndPrintln(long[] x) {\n joinAndPrintln(x, \" \");\n }\n\n void joinAndPrintln(long[] x, String delimiter) {\n StringBuilder b = new StringBuilder();\n if (x.length > 0) {\n b.append(x[0]);\n for (int i = 1; i < x.length; i++) {\n b.append(delimiter).append(x[i]);\n }\n }\n println(b.toString());\n }\n\n void joinAndPrintln(Iterable iterable) {\n joinAndPrintln(iterable, \" \");\n }\n\n void joinAndPrintln(Iterable iterable, String delimiter) {\n StringBuilder b = new StringBuilder();\n for (Iterator i = iterable.iterator(); i.hasNext(); ) {\n b.append(i.next());\n while (i.hasNext()) {\n b.append(delimiter).append(i.next());\n }\n }\n println(b.toString());\n }\n }\n}\n", "test_IO": [ { "input": "3 4\n4 3\n4 1\n2 2\n", "output": "5\n" } ] }, { "id": "s192812966", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s192812966 {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int w = scanner.nextInt(), h = scanner.nextInt(), n = scanner.nextInt();\n int[] x = new int[n];\n int[] y = new int[n];\n int[] a = new int[n];\n int xmax = w, xmin = 0;\n int ymax = h, ymin = 0;\n for (int i = 0; i < n; i++) {\n x[i] = scanner.nextInt();\n y[i] = scanner.nextInt();\n a[i] = scanner.nextInt();\n switch (a[i]) {\n case 1:\n xmin = Math.max(xmin, x[i]);\n break;\n case 2:\n xmax = Math.min(xmax, x[i]);\n break;\n case 3:\n ymin = Math.max(ymin, y[i]);\n break;\n case 4:\n ymax = Math.min(ymax, y[i]);\n break;\n }\n }\n w = Math.max(xmax - xmin, 0);\n h = Math.max(ymax - ymin, 0);\n\n System.out.println(w * h);\n }\n}\n", "test_IO": [ { "input": "5 4 2\n2 1 1\n3 3 4\n", "output": "9\n" } ] }, { "id": "s561914763", "dataset": "codenet", "language": "Java", "code": "import java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\n\npublic class s561914763 {\n\n static Set ODD = new HashSet<>();\n static Set EVE = new HashSet<>();\n\n static {\n ODD.add(\"R\");\n ODD.add(\"U\");\n ODD.add(\"D\");\n EVE.add(\"L\");\n EVE.add(\"U\");\n EVE.add(\"D\");\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String N = sc.nextLine();\n char[] tap = N.toCharArray();\n\n boolean isGood = true;\n for (int i = 0; i < N.length(); i++) {\n if ((i + 1) % 2 == 0) {\n if (!isMatch(EVE, tap[i])) {\n isGood = false;\n break;\n }\n } else {\n if (!isMatch(ODD, tap[i])) {\n isGood = false;\n break;\n }\n }\n }\n\n System.out.println(isGood ? \"Yes\" : \"No\");\n }\n\n private static boolean isMatch(Set set, char c) {\n return set.contains(String.valueOf(c));\n }\n}\n", "test_IO": [ { "input": "RUDLUDR\n", "output": "Yes\n" } ] }, { "id": "s442273167", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s442273167 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] l = new int[n];\n int[] r = new int[n];\n for (int i = 0; i < n; i++) {\n l[i] = sc.nextInt();\n r[i] = sc.nextInt();\n }\n int sum = 0;\n for (int i = 0; i < n; i++) {\n sum += r[i] - l[i] + 1;\n }\n System.out.println(sum);\n }\n}\n", "test_IO": [ { "input": "1\n24 30\n", "output": "7\n" } ] }, { "id": "s440824480", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s440824480 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int c = 0;\n int flg = 0;\n while (n-- > 0) {\n int x = sc.nextInt();\n int y = sc.nextInt();\n\n if (x == y) {\n c++;\n if (c >= 3) {\n flg = 1;\n }\n } else {\n c = 0;\n }\n }\n if (flg == 0) {\n System.out.println(\"No\");\n } else {\n System.out.println(\"Yes\");\n }\n }\n}\n", "test_IO": [ { "input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n", "output": "Yes\n" } ] }, { "id": "s481865042", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s481865042 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n long k = sc.nextLong();\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < s.length(); i++) {\n if ((26 - (s.charAt(i) - 'a')) <= k && s.charAt(i) != 'a') {\n k -= 26 - (s.charAt(i) - 'a');\n sb.append('a');\n } else {\n sb.append(s.charAt(i));\n }\n }\n if (k > 0) {\n char t = sb.charAt(s.length() - 1);\n sb.delete(s.length() - 1, s.length());\n sb.append((char) ('a' + (t - 'a' + k) % 26));\n }\n System.out.println(sb);\n }\n}\n", "test_IO": [ { "input": "xyz\n4\n", "output": "aya\n" } ] }, { "id": "s443066739", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\nimport java.util.concurrent.*;\n\nclass s443066739 {\n static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n static FastScanner sc = new FastScanner(br);\n static PrintWriter out = new PrintWriter(System.out);\n static Random rnd = new Random();\n\n public static void main(String args[]) throws Exception {\n int n = sc.nextInt();\n long[] pre = new long[n + 1];\n\n for (int i = 1; i <= n; i++) {\n pre[i] = pre[i - 1] + sc.nextLong();\n }\n\n long min = Long.MAX_VALUE;\n\n for (int i = 1; i < n; i++) {\n long val1 = pre[i], val2 = pre[n] - pre[i];\n\n min = Math.min(min, Math.abs(val1 - val2));\n }\n\n out.println(min);\n out.close();\n }\n}\n\nclass FastScanner {\n BufferedReader in;\n StringTokenizer st;\n\n public FastScanner(BufferedReader in) {\n this.in = in;\n }\n\n public String nextToken() throws Exception {\n while (st == null || !st.hasMoreTokens()) {\n st = new StringTokenizer(in.readLine());\n }\n return st.nextToken();\n }\n\n public String next() throws Exception {\n return nextToken().toString();\n }\n\n public int nextInt() throws Exception {\n return Integer.parseInt(nextToken());\n }\n\n public long nextLong() throws Exception {\n return Long.parseLong(nextToken());\n }\n\n public double nextDouble() throws Exception {\n return Double.parseDouble(nextToken());\n }\n}\n", "test_IO": [ { "input": "6\n1 2 3 4 5 6\n", "output": "1\n" } ] }, { "id": "s960387817", "dataset": "codenet", "language": "Java", "code": "import java.util.HashSet;\nimport java.util.Scanner;\nimport java.util.Set;\nimport java.util.stream.IntStream;\n\npublic class s960387817 {\n\n public static void main(String[] args) {\n try (Scanner scanner = new Scanner(System.in)) {\n int n = scanner.nextInt();\n Set set = new HashSet<>();\n IntStream.range(0, n).forEach(i -> set.add(scanner.nextInt()));\n System.out.println(set.size());\n }\n }\n}\n", "test_IO": [ { "input": "4\n10\n8\n8\n6\n", "output": "3\n" } ] }, { "id": "s832608243", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s832608243 {\n public static void main(final String[] args) {\n Scanner scanner = new Scanner(System.in);\n int a = scanner.nextInt(), b = scanner.nextInt();\n boolean flag = false;\n for (int i = 1; i <= 100000; i++) {\n if (Math.floor(1. * i * .08) == a && b == Math.floor(.1 * i)) {\n System.out.println(i);\n flag = true;\n break;\n }\n }\n if (!flag) {\n System.out.println(-1);\n }\n }\n}\n", "test_IO": [ { "input": "2 2\n", "output": "25\n" } ] }, { "id": "s336166208", "dataset": "codenet", "language": "Java", "code": "public class s336166208 {\n public static void main(String[] args) {\n\n int[][][] info = new int[4][3][10];\n for (int i = 0; i < 4; i++) {\n for (int j = 0; j < 3; j++) {\n for (int k = 0; k < 10; k++) {\n info[i][j][k] = 0;\n }\n }\n }\n\n java.util.Scanner sc = new java.util.Scanner(System.in);\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n int built = sc.nextInt();\n int floor = sc.nextInt();\n int room = sc.nextInt();\n int num = sc.nextInt();\n info[built - 1][floor - 1][room - 1] += num;\n }\n\n for (int i = 0; i < 4; i++) {\n for (int j = 0; j < 3; j++) {\n for (int k = 0; k < 10; k++) {\n System.out.print(\" \" + info[i][j][k]);\n }\n System.out.print(\"\\n\");\n }\n if (i != 4 - 1) {\n System.out.print(\"####################\\n\");\n }\n }\n }\n}\n", "test_IO": [ { "input": "3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n", "output": " 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0\n" } ] }, { "id": "s416486483", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s416486483 {\n private static long split(long n, long k) {\n long sum = 0;\n while (n > 0) {\n sum += n % k;\n n /= k;\n }\n return sum;\n }\n\n private static long solve(long n, long s) {\n long k;\n for (k = 2; k * k <= n || k < 100; k++) {\n if (split(n, k) == s) {\n return k;\n }\n }\n while (k <= n) {\n long a = n / k;\n long b = n % k;\n if ((a + b - s) % a == 0) {\n long dk = (a + b - s) / a;\n if (dk >= 0 && b - dk * a >= 0) {\n return k + dk;\n }\n }\n k = n / a + 1;\n }\n if (n == s) {\n return n + 1;\n }\n return -1;\n }\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n long nl = s.nextLong();\n long sl = s.nextLong();\n System.out.println(solve(nl, sl));\n }\n}\n", "test_IO": [ { "input": "87654\n30\n", "output": "10\n" } ] }, { "id": "s821112618", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s821112618 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n String[] s = \".,!? :abc:def:ghi:jkl:mno:pqrs:tuv:wxyz\".split(\":\");\n char[][] k = new char[9][];\n for (int i = 0; i < 9; i++) {\n k[i] = s[i].toCharArray();\n }\n while (n-- > 0) {\n char[] c = sc.next().toCharArray();\n int l = -1, a = 0;\n for (int i = 0; i < c.length; i++) {\n if (c[i] != '0') {\n a = c[i] - '1';\n l = (l + 1) % k[a].length;\n } else if (l >= 0) {\n System.out.print(k[a][l]);\n l = -1;\n }\n }\n System.out.println();\n }\n }\n}\n", "test_IO": [ { "input": "5\n20\n220\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000\n", "output": "a\nb\nb\nhello, world!\nkeitai\n" } ] }, { "id": "s452855095", "dataset": "codenet", "language": "Java", "code": "import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class s452855095 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int n = sc.nextInt();\n int arr[] = new int[n];\n for (int i = 0; i < n; i++) arr[i] = sc.nextInt();\n int cnt = 0;\n boolean flag = true;\n while (true) {\n for (int i = 0; i < n; i++) {\n if (arr[i] % 2 != 0) {\n flag = false;\n break;\n } else arr[i] = arr[i] / 2;\n }\n if (flag == true) cnt++;\n else break;\n }\n out.println(cnt);\n out.flush();\n }\n}\n", "test_IO": [ { "input": "3\n8 12 40\n", "output": "2\n" } ] }, { "id": "s916993080", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s916993080 {\n public static void main(String[] args) throws IOException {\n int n = sc.nextInt();\n int[][] arr = new int[n][3];\n for (int i = 0; i < n; ++i) for (int j = 0; j <= 2; ++j) arr[i][j] = sc.nextInt();\n int[][] dp = new int[n][3];\n dp[0][0] = arr[0][0];\n dp[0][1] = arr[0][1];\n dp[0][2] = arr[0][2];\n for (int i = 1; i < n; ++i) {\n for (int j = 0; j < 3; ++j) {\n if (j == 0) dp[i][j] = Math.max(arr[i][0] + dp[i - 1][1], arr[i][0] + dp[i - 1][2]);\n if (j == 1) dp[i][j] = Math.max(arr[i][1] + dp[i - 1][0], arr[i][1] + dp[i - 1][2]);\n if (j == 2) dp[i][j] = Math.max(arr[i][2] + dp[i - 1][1], arr[i][2] + dp[i - 1][0]);\n }\n }\n int max = -1;\n for (int i = 0; i < 3; ++i) if (dp[n - 1][i] > max) max = dp[n - 1][i];\n System.out.println(max);\n }\n}\n\nclass sc {\n static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n static StringTokenizer tokenizer = new StringTokenizer(\"\");\n\n static String next() throws IOException {\n while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());\n return tokenizer.nextToken();\n }\n\n static int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n static double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n static long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n static float nextFloat() throws IOException {\n return Float.parseFloat(next());\n }\n}\n", "test_IO": [ { "input": "3\n10 40 70\n20 50 80\n30 60 90\n", "output": "210\n" } ] }, { "id": "s577060895", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s577060895 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n long n = Long.parseLong(sc.nextLine());\n\n double sqrt = Math.sqrt(n);\n double nearNum = Math.floor(sqrt);\n\n long ans = (long) Math.pow(nearNum, 2);\n\n System.out.println(ans);\n\n sc.close();\n }\n}\n", "test_IO": [ { "input": "10\n", "output": "9\n" } ] }, { "id": "s681118763", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s681118763 {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n String c = in.next();\n Character letter = c.charAt(0);\n letter++;\n\n System.out.println(letter);\n }\n}\n", "test_IO": [ { "input": "a\n", "output": "b\n" } ] }, { "id": "s321983475", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s321983475 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int w = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n int answer = Math.max(a, b) - Math.min(a, b) - w;\n if (answer < 0) {\n System.out.println(0);\n } else {\n System.out.println(answer);\n }\n }\n}\n", "test_IO": [ { "input": "3 2 6\n", "output": "1\n" } ] }, { "id": "s933313035", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s933313035 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int m = sc.nextInt();\n\n Node tree = null;\n for (int i = 0; i < m; i++) {\n String command = sc.next();\n\n if (command.equals(\"insert\")) {\n long key = sc.nextLong();\n if (tree == null) {\n tree = new Node();\n tree.value = key;\n } else {\n tree.insert(key);\n }\n } else {\n if (tree != null) {\n tree.printInOrder();\n System.out.println();\n tree.printPreOrder();\n System.out.println();\n }\n }\n }\n }\n\n static class Node {\n long value;\n Node left;\n Node right;\n\n void insert(long newValue) {\n if (newValue < this.value) {\n if (left == null) {\n left = new Node();\n left.value = newValue;\n } else {\n left.insert(newValue);\n }\n } else {\n if (right == null) {\n right = new Node();\n right.value = newValue;\n } else {\n right.insert(newValue);\n }\n }\n }\n\n void printInOrder() {\n if (left != null) {\n left.printInOrder();\n }\n System.out.print(\" \" + value);\n if (right != null) {\n right.printInOrder();\n }\n }\n\n void printPreOrder() {\n System.out.print(\" \" + value);\n if (left != null) {\n left.printPreOrder();\n }\n if (right != null) {\n right.printPreOrder();\n }\n }\n }\n}\n", "test_IO": [ { "input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n", "output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n" } ] }, { "id": "s257593977", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s257593977 {\n\n private static final int BASE = 3;\n\n public static void main(String[] args) {\n System.out.println((int) Math.pow(new Scanner(System.in).nextInt(), BASE));\n }\n}\n", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s081988820", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.*;\nimport java.util.stream.IntStream;\n\npublic class s081988820 {\n public static void main(String[] args) {\n s081988820 main = new s081988820();\n main.solve();\n }\n\n private void solve() {\n Scanner sc = new Scanner(System.in);\n int H = sc.nextInt();\n int W = sc.nextInt();\n int[][] c = new int[10][10];\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n c[i][j] = sc.nextInt();\n }\n }\n int[] min = new int[10];\n for (int i = 0; i < 10; i++) {\n min[i] = c[i][1];\n }\n for (int tc = 0; tc < 10; tc++) {\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n min[i] = Math.min(min[i], c[i][j] + min[j]);\n }\n }\n }\n int ans = 0;\n for (int h = 1; h <= H; h++) {\n for (int w = 1; w <= W; w++) {\n int A = sc.nextInt();\n if (A >= 0) {\n ans += min[A];\n }\n }\n }\n System.out.println(ans);\n }\n\n class Scanner {\n private InputStream in;\n private byte[] buffer = new byte[1024];\n private int index;\n private int length;\n\n public Scanner(InputStream in) {\n this.in = in;\n }\n\n private boolean isPrintableChar(int c) {\n return '!' <= c && c <= '~';\n }\n\n private boolean isDigit(int c) {\n return '0' <= c && c <= '9';\n }\n\n private boolean hasNextByte() {\n if (index < length) {\n return true;\n } else {\n try {\n length = in.read(buffer);\n index = 0;\n } catch (IOException e) {\n e.printStackTrace();\n }\n return length > 0;\n }\n }\n\n private boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[index])) {\n index++;\n }\n return hasNextByte();\n }\n\n private int readByte() {\n return hasNextByte() ? buffer[index++] : -1;\n }\n\n public String next() {\n if (!hasNext()) {\n throw new RuntimeException(\"no input\");\n }\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) {\n throw new RuntimeException(\"no input\");\n }\n long value = 0L;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n while (isPrintableChar(b)) {\n if (isDigit(b)) {\n value = value * 10 + (b - '0');\n }\n b = readByte();\n }\n return minus ? -value : value;\n }\n\n public int nextInt() {\n return (int) nextLong();\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n\n interface CombCalculator {\n long comb(int n, int m);\n }\n\n interface MobiusFunction {\n int get(int n);\n }\n\n class SieveMobiusFunction implements MobiusFunction {\n int size;\n int[] mobiusFunctionValues;\n\n public SieveMobiusFunction(int size) {\n this.size = size;\n mobiusFunctionValues = new int[size];\n\n mobiusFunctionValues[0] = 0;\n mobiusFunctionValues[1] = 1;\n for (int i = 2; i < size; i++) {\n mobiusFunctionValues[i] = 1;\n }\n for (int i = 2; i * i < size; i++) {\n for (int k = 1; i * i * k < size; k++) {\n mobiusFunctionValues[i * i * k] *= 0;\n }\n }\n\n for (int i = 2; i < size; i++) {\n if (mobiusFunctionValues[i] == 1) {\n for (int k = 1; i * k < size; k++) {\n mobiusFunctionValues[i * k] *= -2;\n }\n }\n if (mobiusFunctionValues[i] > 1) {\n mobiusFunctionValues[i] = 1;\n }\n if (mobiusFunctionValues[i] < -1) {\n mobiusFunctionValues[i] = -1;\n }\n }\n }\n\n @Override\n public int get(int n) {\n if (n > size) {\n throw new RuntimeException(\"n is greater than size.\");\n }\n if (n < 0) {\n return 0;\n }\n return mobiusFunctionValues[n];\n }\n }\n\n class PrimeFactorizationMobiusFunction implements MobiusFunction {\n @Override\n public int get(int n) {\n if (n <= 0) {\n return 0;\n }\n if (n == 1) {\n return 1;\n }\n int num = 0;\n for (int i = 2; i < n; i++) {\n if (n % i == 0) {\n n /= i;\n num++;\n if (n % i == 0) {\n return 0;\n }\n }\n }\n return num % 2 == 0 ? -1 : 1;\n }\n }\n\n class FactorialTableCombCalculator implements CombCalculator {\n int size;\n long[] factorialTable;\n long[] inverseFactorialTable;\n long mod;\n\n public FactorialTableCombCalculator(int size, long mod) {\n this.size = size;\n factorialTable = new long[size + 1];\n inverseFactorialTable = new long[size + 1];\n this.mod = mod;\n\n factorialTable[0] = 1L;\n for (int i = 1; i <= size; i++) {\n factorialTable[i] = (factorialTable[i - 1] * i) % mod;\n }\n inverseFactorialTable[size] = inverse(factorialTable[size], mod);\n for (int i = size - 1; i >= 0; i--) {\n inverseFactorialTable[i] = (inverseFactorialTable[i + 1] * (i + 1)) % mod;\n }\n }\n\n private long inverse(long n, long mod) {\n return pow(n, mod - 2, mod);\n }\n\n private long pow(long n, long p, long mod) {\n if (p == 0) {\n return 1L;\n }\n long half = pow(n, p / 2, mod);\n long ret = (half * half) % mod;\n if (p % 2 == 1) {\n ret = (ret * n) % mod;\n }\n return ret;\n }\n\n @Override\n public long comb(int n, int m) {\n if (n > size) {\n throw new RuntimeException(\"n is greater than size.\");\n }\n if (n < 0 || m < 0 || n < m) {\n return 0L;\n }\n return (((factorialTable[n] * inverseFactorialTable[m]) % mod)\n * inverseFactorialTable[n - m])\n % mod;\n }\n }\n\n class TableCombCalculator implements CombCalculator {\n long[][] table;\n int size;\n\n public TableCombCalculator(int size, long mod) {\n this.size = size;\n table = new long[size + 1][];\n\n table[0] = new long[1];\n table[0][0] = 1L;\n for (int n = 1; n <= size; n++) {\n table[n] = new long[n + 1];\n table[n][0] = 1L;\n for (int m = 1; m < n; m++) {\n table[n][m] = (table[n - 1][m - 1] + table[n - 1][m]) % mod;\n }\n table[n][n] = 1L;\n }\n }\n\n @Override\n public long comb(int n, int m) {\n if (n > size) {\n throw new RuntimeException(\"n is greater than size.\");\n }\n if (n < 0 || m < 0 || n < m) {\n return 0L;\n }\n return table[n][m];\n }\n }\n\n interface Graph {\n void link(int from, int to, long cost);\n\n Optional getCost(int from, int to);\n\n int getVertexNum();\n }\n\n interface FlowResolver {\n long maxFlow(int from, int to);\n }\n\n class ArrayGraph implements Graph {\n private Long[][] costArray;\n private int vertexNum;\n\n public ArrayGraph(int n) {\n costArray = new Long[n][];\n for (int i = 0; i < n; i++) {\n costArray[i] = new Long[n];\n }\n vertexNum = n;\n }\n\n @Override\n public void link(int from, int to, long cost) {\n costArray[from][to] = new Long(cost);\n }\n\n @Override\n public Optional getCost(int from, int to) {\n return Optional.ofNullable(costArray[from][to]);\n }\n\n @Override\n public int getVertexNum() {\n return vertexNum;\n }\n }\n\n class DfsFlowResolver implements FlowResolver {\n private Graph graph;\n\n public DfsFlowResolver(Graph graph) {\n this.graph = graph;\n }\n\n public long maxFlow(int from, int to) {\n long sum = 0L;\n long currentFlow;\n do {\n currentFlow = flow(from, to, Long.MAX_VALUE / 3, new boolean[graph.getVertexNum()]);\n sum += currentFlow;\n } while (currentFlow > 0);\n return sum;\n }\n\n private long flow(int from, int to, long current_flow, boolean[] passed) {\n passed[from] = true;\n if (from == to) {\n return current_flow;\n }\n for (int id = 0; id < graph.getVertexNum(); id++) {\n if (passed[id]) {\n continue;\n }\n Optional cost = graph.getCost(from, id);\n if (cost.orElse(0L) > 0) {\n long nextFlow = current_flow < cost.get() ? current_flow : cost.get();\n long returnFlow = flow(id, to, nextFlow, passed);\n if (returnFlow > 0) {\n graph.link(from, id, cost.get() - returnFlow);\n graph.link(id, from, graph.getCost(id, from).orElse(0L) + returnFlow);\n return returnFlow;\n }\n }\n }\n return 0L;\n }\n }\n\n class BinaryIndexedTree {\n private long[] array;\n\n public BinaryIndexedTree(int size) {\n this.array = new long[size + 1];\n }\n\n public void add(int index, long value) {\n for (int i = index; i < array.length; i += (i & -i)) {\n array[i] += value;\n }\n }\n\n public long getSum(int index) {\n long sum = 0L;\n for (int i = index; i > 0; i -= (i & -i)) {\n sum += array[i];\n }\n return sum;\n }\n }\n\n class BinaryIndexedTree2D {\n private long[][] array;\n\n public BinaryIndexedTree2D(int size1, int size2) {\n this.array = new long[size1 + 1][];\n for (int i = 1; i <= size1; i++) {\n this.array[i] = new long[size2 + 1];\n }\n }\n\n public void add(int index1, int index2, long value) {\n for (int i1 = index1; i1 < array.length; i1 += (i1 & -i1)) {\n for (int i2 = index2; i2 < array.length; i2 += (i2 & -i2)) {\n array[i1][i2] += value;\n }\n }\n }\n\n public long getSum(int index1, int index2) {\n long sum = 0L;\n for (int i1 = index1; i1 > 0; i1 -= (i1 & -i1)) {\n for (int i2 = index2; i2 > 0; i2 -= (i2 & -i2)) {\n sum += array[i1][i2];\n }\n }\n return sum;\n }\n }\n\n interface UnionFind {\n void union(int A, int B);\n\n boolean judge(int A, int B);\n\n Set getSet(int id);\n }\n\n class SetUnionFind extends ArrayUnionFind {\n Map> map;\n\n public SetUnionFind(int size) {\n super(size);\n map = new HashMap<>();\n for (int i = 0; i < size; i++) {\n map.put(i, new HashSet<>());\n map.get(i).add(i);\n }\n }\n\n @Override\n protected void unionTo(int source, int dest) {\n super.unionTo(source, dest);\n map.get(dest).addAll(map.get(source));\n }\n\n @Override\n public Set getSet(int id) {\n return map.get(root(id));\n }\n }\n\n class ArrayUnionFind implements UnionFind {\n int[] parent;\n int[] rank;\n int size;\n\n public ArrayUnionFind(int size) {\n parent = new int[size];\n for (int i = 0; i < size; i++) {\n parent[i] = i;\n }\n rank = new int[size];\n this.size = size;\n }\n\n @Override\n public void union(int A, int B) {\n int rootA = root(A);\n int rootB = root(B);\n if (rootA != rootB) {\n if (rank[rootA] < rank[rootB]) {\n unionTo(rootA, rootB);\n } else {\n unionTo(rootB, rootA);\n if (rank[rootA] == rank[rootB]) {\n rank[rootA]++;\n }\n }\n }\n }\n\n protected void unionTo(int source, int dest) {\n parent[source] = dest;\n }\n\n @Override\n public boolean judge(int A, int B) {\n return root(A) == root(B);\n }\n\n @Override\n public Set getSet(int id) {\n Set set = new HashSet<>();\n IntStream.range(0, size).filter(i -> judge(i, id)).forEach(set::add);\n return set;\n }\n\n protected int root(int id) {\n if (parent[id] == id) {\n return id;\n }\n parent[id] = root(parent[id]);\n return parent[id];\n }\n }\n\n class PrimeNumberUtils {\n boolean[] isPrimeArray;\n List primes;\n\n public PrimeNumberUtils(int limit) {\n if (limit > 10000000) {\n System.err.println(\"\u4e0a\u9650\u306e\u5024\u304c\u9ad8\u3059\u304e\u308b\u305f\u3081\u7d20\u6570\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u306e\u521d\u671f\u5316\u3067TLE\u3059\u308b\u53ef\u80fd\u6027\u304c\u5927\u5909\u9ad8\u3044\u3067\u3059\");\n }\n primes = new ArrayList<>();\n isPrimeArray = new boolean[limit];\n if (limit > 2) {\n primes.add(2);\n isPrimeArray[2] = true;\n }\n\n for (int i = 3; i < limit; i += 2) {\n if (isPrime(i, primes)) {\n primes.add(i);\n isPrimeArray[i] = true;\n }\n }\n }\n\n public List getPrimeNumberList() {\n return primes;\n }\n\n public boolean isPrime(int n) {\n return isPrimeArray[n];\n }\n\n private boolean isPrime(int n, List primes) {\n for (int prime : primes) {\n if (n % prime == 0) {\n return false;\n }\n if (prime > Math.sqrt(n)) {\n break;\n }\n }\n return true;\n }\n }\n\n interface BitSet {\n void set(int index, boolean bit);\n\n boolean get(int index);\n\n void shiftRight(int num);\n\n void shiftLeft(int num);\n\n void or(BitSet bitset);\n\n void and(BitSet bitset);\n }\n\n class LongBit implements BitSet {\n long[] bitArray;\n\n public LongBit(int size) {\n bitArray = new long[((size + 63) / 64)];\n }\n\n @Override\n public void set(int index, boolean bit) {\n int segment = index / 64;\n int inIndex = index % 64;\n if (bit) {\n bitArray[segment] |= 1L << inIndex;\n } else {\n bitArray[segment] &= ~(1L << inIndex);\n }\n }\n\n @Override\n public boolean get(int index) {\n int segment = index / 64;\n int inIndex = index % 64;\n return (bitArray[segment] & (1L << inIndex)) != 0L;\n }\n\n @Override\n public void shiftRight(int num) {\n int shiftSeg = num / 64;\n int shiftInI = num % 64;\n for (int segment = 0; segment < bitArray.length; segment++) {\n int sourceSeg = segment + shiftSeg;\n if (sourceSeg < bitArray.length) {\n bitArray[segment] = bitArray[sourceSeg] >>> shiftInI;\n if (shiftInI > 0 && sourceSeg + 1 < bitArray.length) {\n bitArray[segment] |= bitArray[sourceSeg + 1] << (64 - shiftInI);\n }\n } else {\n bitArray[segment] = 0L;\n }\n }\n }\n\n @Override\n public void shiftLeft(int num) {\n int shiftSeg = num / 64;\n int shiftInI = num % 64;\n for (int segment = bitArray.length - 1; segment >= 0; segment--) {\n int sourceSeg = segment - shiftSeg;\n if (sourceSeg >= 0) {\n bitArray[segment] = bitArray[sourceSeg] << shiftInI;\n if (shiftInI > 0 && sourceSeg > 0) {\n bitArray[segment] |= bitArray[sourceSeg - 1] >>> (64 - shiftInI);\n }\n } else {\n bitArray[segment] = 0L;\n }\n }\n }\n\n public long getLong(int segment) {\n return bitArray[segment];\n }\n\n @Override\n public void or(BitSet bitset) {\n if (!(bitset instanceof LongBit)) {\n return;\n }\n for (int segment = 0; segment < bitArray.length; segment++) {\n bitArray[segment] |= ((LongBit) bitset).getLong(segment);\n }\n }\n\n @Override\n public void and(BitSet bitset) {\n if (!(bitset instanceof LongBit)) {\n return;\n }\n for (int segment = 0; segment < bitArray.length; segment++) {\n bitArray[segment] &= ((LongBit) bitset).getLong(segment);\n }\n }\n }\n}\n", "test_IO": [ { "input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n", "output": "12\n" } ] }, { "id": "s063482767", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s063482767 {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n PriorityQueue queue = new PriorityQueue<>();\n for (int i = 0; i < n; i++) {\n queue.add(sc.nextInt());\n }\n int sum = 0;\n for (int i = 0; i < n - 1; i++) {\n sum += queue.poll();\n }\n\n System.out.println(queue.poll() < sum ? \"Yes\" : \"No\");\n }\n}\n", "test_IO": [ { "input": "4\n3 8 5 1\n", "output": "Yes\n" } ] }, { "id": "s321216487", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s321216487 {\n public static void main(String[] args) throws Exception {\n\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n\n String begin;\n String end;\n String answer;\n\n for (int i = 0; i < S.length(); i++) {\n\n for (int j = 0; j < S.length(); j++) {\n\n begin = S.substring(0, i);\n end = S.substring(j, S.length());\n answer = begin + end;\n\n if (answer.equals(\"keyence\")) {\n System.out.println(\"YES\");\n return;\n\n } else if (begin.equals(\"keyence\")) {\n System.out.println(\"YES\");\n return;\n\n } else if (end.equals(\"keyence\")) {\n System.out.println(\"YES\");\n return;\n }\n }\n }\n System.out.println(\"NO\");\n }\n}\n", "test_IO": [ { "input": "keyofscience\n", "output": "YES\n" } ] }, { "id": "s125837071", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s125837071 {\n\n @SuppressWarnings(\"resource\")\n public static void main(String args[]) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n long ans = 1;\n int mod = (int) Math.pow(10, 9) + 7;\n for (int i = 2; i <= n; i++) {\n for (int j = 2; (i % j != 0 && j < i) || j == i; j++) {\n if (j == i) {\n int s = 0;\n for (int k = 1; k <= n; k++) {\n s += findS(k, i);\n }\n\n ans = (ans * (s + 1)) % mod;\n }\n }\n }\n System.out.println(ans);\n }\n\n private static int findS(int k, int i) {\n int s = 0;\n for (int j = k; j % i == 0; j /= i) {\n\n s++;\n }\n return s;\n }\n}\n", "test_IO": [ { "input": "3\n", "output": "4\n" } ] }, { "id": "s937747608", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s937747608 {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int d = sc.nextInt();\n if (a * b >= c * d) {\n System.out.println(a * b);\n } else if (a * b <= c * d) {\n System.out.println(c * d);\n }\n }\n}\n", "test_IO": [ { "input": "3 5 2 7\n", "output": "15\n" } ] }, { "id": "s221078931", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\npublic class s221078931 {\n\n public static void main(String[] args) throws IOException {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n IntegralRect rects[] = new IntegralRect[40000];\n for (int i = 0; i < 200; i++) {\n for (int j = 0; j < 200; j++) {\n rects[i * 200 + j] = new IntegralRect(i + 1, j + 1);\n }\n }\n Arrays.sort(rects);\n\n while (true) {\n String[] tmpArray = br.readLine().split(\" \");\n\n int h = Integer.parseInt(tmpArray[0]);\n int w = Integer.parseInt(tmpArray[1]);\n\n if (h == 0 && w == 0) {\n break;\n }\n\n IntegralRect tmpRect = new IntegralRect(h, w);\n int diag = tmpRect.diagonal();\n\n for (int i = 0; i < rects.length; i++) {\n\n if (rects[i].compareTo(tmpRect) > 0) {\n System.out.println(rects[i].height + \" \" + rects[i].width);\n break;\n }\n }\n }\n }\n}\n\nclass IntegralRect implements Comparable {\n int height;\n int width;\n\n public IntegralRect(int h, int w) {\n this.height = h;\n this.width = w;\n }\n\n public int diagonal() {\n if (height >= width) {\n return Integer.MAX_VALUE;\n }\n return this.height * this.height + this.width * this.width;\n }\n\n @Override\n public int compareTo(IntegralRect o) {\n\n int d1 = this.diagonal();\n int d2 = o.diagonal();\n\n return d1 == d2 ? this.height - o.height : d1 - d2;\n }\n}\n", "test_IO": [ { "input": "1 2\n1 3\n2 3\n1 4\n2 4\n5 6\n1 8\n4 7\n98 100\n99 100\n0 0\n", "output": "1 3\n2 3\n1 4\n2 4\n3 4\n1 8\n4 7\n2 8\n3 140\n89 109\n" } ] }, { "id": "s847387793", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.NoSuchElementException;\n\nclass s847387793 {\n\n static class Solver {\n final FastScanner sc;\n final PrintWriter writer;\n\n Solver(final FastScanner sc, final PrintWriter writer) {\n this.sc = sc;\n this.writer = writer;\n }\n\n int n, m, q;\n int max = 0;\n int[] a, b, c, d;\n\n void run() {\n n = sc.nextInt();\n m = sc.nextInt();\n q = sc.nextInt();\n a = new int[q];\n b = new int[q];\n c = new int[q];\n d = new int[q];\n for (int i = 0; i < q; i++) {\n a[i] = sc.nextInt();\n b[i] = sc.nextInt();\n c[i] = sc.nextInt();\n d[i] = sc.nextInt();\n }\n dfs(new int[] {1});\n writer.println(max);\n }\n\n private void dfs(int[] array) {\n if (array.length > n) {\n int score = 0;\n for (int i = 0; i < q; i++) {\n if (array[b[i]] - array[a[i]] == c[i]) {\n score += d[i];\n }\n }\n max = Math.max(max, score);\n return;\n }\n\n int[] newArray = new int[array.length + 1];\n System.arraycopy(array, 0, newArray, 0, array.length);\n System.arraycopy(new int[] {array[array.length - 1]}, 0, newArray, array.length, 1);\n\n while (newArray[newArray.length - 1] <= m) {\n dfs(newArray);\n newArray[newArray.length - 1] += 1;\n }\n }\n }\n\n public static void main(final String[] args) {\n final FastScanner sc = new FastScanner();\n try (final PrintWriter w = new PrintWriter(System.out)) {\n new Solver(sc, w).run();\n w.flush();\n }\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n public FastScanner() {}\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (final IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private boolean isPrintableChar(final int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n final StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n final long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(final int n) {\n final int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(final int n) {\n final long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nextLong();\n return a;\n }\n }\n}\n", "test_IO": [ { "input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n", "output": "110\n" } ] }, { "id": "s962361667", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s962361667 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int w = sc.nextInt();\n int n = sc.nextInt();\n int[] values = new int[w];\n for (int i = 0; i < values.length; i++) {\n values[i] = i + 1;\n }\n for (int i = 0; i < n; i++) {\n int x = 0;\n String str = sc.next();\n String[] ab = str.split(\",\");\n int a = Integer.parseInt(ab[0]) - 1;\n int b = Integer.parseInt(ab[1]) - 1;\n x = values[a];\n values[a] = values[b];\n values[b] = x;\n }\n for (int i = 0; i < w; i++) {\n System.out.println(values[i]);\n }\n }\n}\n", "test_IO": [ { "input": "5\n4\n2,4\n3,5\n1,2\n3,4\n", "output": "4\n1\n2\n5\n3\n" } ] }, { "id": "s432314829", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s432314829 {\n public static void main(String[] args) {\n Scanner stdIn = new Scanner(System.in);\n\n int n = stdIn.nextInt();\n int m = stdIn.nextInt();\n int dp[] = new int[n + 2];\n dp[n + 1] = 0;\n dp[n] = 1;\n for (int i = 0; i < m; i++) dp[stdIn.nextInt()] = -1;\n for (int i = n - 1; i >= 0; i--) {\n if (dp[i] == -1) dp[i] = 0;\n else dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;\n }\n System.out.println(dp[0]);\n }\n}\n", "test_IO": [ { "input": "6 1\n3\n", "output": "4\n" } ] }, { "id": "s505375619", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s505375619 {\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int n = Integer.parseInt(s.next());\n int[] v = new int[n];\n int[] c = new int[n];\n int[] dp = new int[n];\n\n for (int i = 0; i < n; i++) {\n dp[i] = 0;\n }\n for (int i = 0; i < n; i++) {\n v[i] = Integer.parseInt(s.next());\n }\n for (int i = 0; i < n; i++) {\n c[i] = Integer.parseInt(s.next());\n }\n\n dp[0] = 0;\n\n for (int i = 1; i < n; i++) {\n int tmp = dp[i - 1] + (v[i - 1] - c[i - 1]);\n dp[i] = tmp > dp[i - 1] ? tmp : dp[i - 1];\n }\n\n int tmp = dp[n - 1] + (v[n - 1] - c[n - 1]);\n dp[n - 1] = tmp > dp[n - 1] ? tmp : dp[n - 1];\n\n System.out.println(dp[n - 1]);\n }\n}\n", "test_IO": [ { "input": "3\n10 2 5\n6 3 4\n", "output": "5\n" } ] }, { "id": "s000087391", "dataset": "codenet", "language": "Java", "code": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class s000087391 {\n public static void main(String[] args) {\n ArrayList result = new ArrayList();\n Scanner insert = new Scanner(System.in);\n int n = -1;\n while (true) {\n String line = insert.nextLine();\n n = Integer.parseInt(line);\n if (n == 0) {\n break;\n }\n for (int i = 0; i < n; i++) {}\n\n line = insert.nextLine();\n String array2[] = line.split(\" \");\n int[] input = new int[n];\n int sum = 0;\n for (int i = 0; i < n; i++) {\n input[i] = (Integer.parseInt(array2[i]));\n sum += input[i];\n }\n double avg = (double) sum / (double) n;\n int num = 0;\n for (int i = 0; i < n; i++) {\n if (input[i] <= avg) {\n num++;\n }\n }\n result.add(num);\n }\n for (int i = 0; i < (result.size()); i++) {\n if (result.get(i) == -1) {\n System.out.println(\"NONE\");\n } else {\n System.out.println(result.get(i));\n }\n }\n }\n}\n", "test_IO": [ { "input": "7\n15 15 15 15 15 15 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 8 4\n0\n", "output": "7\n3\n9\n1\n4\n" } ] }, { "id": "s380356166", "dataset": "codenet", "language": "Java", "code": "import static java.util.Comparator.*;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractMap;\n\npublic class s380356166 {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n\n Solver solver = new Solver();\n solver.solve(1, in, out);\n\n out.close();\n }\n\n static class Solver {\n\n public void solve(int testNumber, MyInput in, PrintWriter out) {\n int ans = 0;\n int K = in.nextInt();\n int S = in.nextInt();\n int wk = 0;\n for (int x = 0; x <= K; x++) {\n for (int y = 0; y <= K; y++) {\n wk = S - x - y;\n if (wk >= 0 && wk <= K) {\n ans++;\n }\n }\n }\n out.println(ans);\n }\n }\n\n static class Pair extends AbstractMap.SimpleEntry {\n\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n\n public String getString() {\n return \"[\" + getKey() + \"] [\" + getValue() + \"]\";\n }\n }\n\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public String nextString() {\n String ret = new String(nextDChar()).trim();\n return ret;\n }\n\n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i = 0; i < len; i++) ret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {}\n }\n}\n", "test_IO": [ { "input": "2 2\n", "output": "6\n" } ] }, { "id": "s682242794", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s682242794 {\n int high;\n int low;\n int sa;\n\n public void solve() {\n Scanner sc = new Scanner(System.in);\n for (int i = 0; i < 7; i++) {\n high = sc.nextInt();\n low = sc.nextInt();\n sa = high - low;\n System.out.println(sa);\n }\n }\n\n public static void main(String[] args) {\n s682242794 obj = new s682242794();\n obj.solve();\n }\n}\n", "test_IO": [ { "input": "30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n", "output": "11\n19\n1\n5\n1\n13\n20\n" } ] }, { "id": "s936984238", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s936984238 {\n static Scanner sc = new Scanner(System.in);\n\n static int[] score;\n\n static int number;\n\n public static void main(String[] args) {\n\n while (read()) {\n slove();\n }\n }\n\n static boolean read() {\n number = sc.nextInt();\n if (number == 0) return false;\n\n score = new int[number];\n for (int i = 0; i < number; i++) {\n score[i] = sc.nextInt();\n }\n return true;\n }\n\n static void slove() {\n java.util.Arrays.sort(score);\n int sum = 0;\n for (int i = 1; i < number - 1; i++) {\n sum = sum + score[i];\n }\n System.out.println(sum / (number - 2));\n }\n}\n", "test_IO": [ { "input": "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n", "output": "342\n7\n300\n326\n" } ] }, { "id": "s650785519", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s650785519 {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n sc.close();\n\n int ans = (2199 - x) / 200;\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "725\n", "output": "7\n" } ] }, { "id": "s851323333", "dataset": "codenet", "language": "Java", "code": "import java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class s851323333 {\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n LinkedList list = new LinkedList();\n\n while (scan.hasNextInt() == true) {\n int a = scan.nextInt();\n if (a == 0) {\n System.out.println(list.pop());\n } else {\n list.push(a);\n }\n }\n }\n}\n", "test_IO": [ { "input": "1\n6\n0\n8\n10\n0\n0\n0\n", "output": "6\n10\n8\n1\n" } ] }, { "id": "s606985261", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s606985261 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n int total = 0;\n\n for (int i = 0; i < s.length(); i++) {\n for (int j = i + 1; j < s.length(); j++) {\n if (s.charAt(i) == s.charAt(j)) {\n total++;\n }\n }\n }\n\n System.out.println(total == 2 ? \"Yes\" : \"No\");\n }\n}\n", "test_IO": [ { "input": "ASSA\n", "output": "Yes\n" } ] }, { "id": "s295587559", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\npublic class s295587559 {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int[] num = new int[in.nextInt()];\n for (int i = 0; i < num.length; i++) {\n num[i] = i + 1;\n }\n int count = in.nextInt();\n Pattern pt = Pattern.compile(\"(\\\\d+),(\\\\d+)\");\n int line[] = new int[2];\n for (int i = 0; i < count; i++) {\n String next = in.next(pt);\n for (int j = 0; j < line.length; j++) {\n Matcher matcher = pt.matcher(next);\n matcher.matches();\n line[j] = Integer.parseInt(matcher.group(j + 1)) - 1;\n }\n int change = num[line[0]];\n num[line[0]] = num[line[1]];\n num[line[1]] = change;\n }\n for (int i = 0; i < num.length; i++) {\n System.out.println(num[i]);\n }\n }\n}\n", "test_IO": [ { "input": "5\n4\n2,4\n3,5\n1,2\n3,4\n", "output": "4\n1\n2\n5\n3\n" } ] }, { "id": "s720527488", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\npublic class s720527488 {\n\n static final InputStream in = System.in;\n static final PrintWriter out = new PrintWriter(System.out);\n static final int INF = Integer.MAX_VALUE / 2;\n static final long LINF = Long.MAX_VALUE / 2;\n\n public static void main(String[] args) throws IOException {\n InputReader ir = new InputReader(in);\n int m = ir.nextInt();\n int n = ir.nextInt();\n int[] manju = ir.toIntArray(m);\n int[] boxlen = new int[n];\n int[] boxcost = new int[n];\n for (int i = 0; i < n; i++) {\n boxlen[i] = ir.nextInt();\n boxcost[i] = ir.nextInt();\n }\n sort(manju);\n int[][] dp = new int[m + 1][n + 1];\n for (int i = m - 1; i >= 0; i--) {\n for (int j = n - 1; j >= 0; j--) {\n int len = i + boxlen[j] >= m ? m : i + boxlen[j];\n int cnt = 0;\n for (int k = i; k < len; k++) cnt += manju[m - 1 - k];\n dp[i][j] = Math.max(dp[i][j], dp[len][j + 1] + cnt - boxcost[j]);\n dp[i][j] = Math.max(dp[i][j], dp[i][j + 1]);\n }\n }\n out.println(dp[0][0]);\n out.flush();\n }\n\n public static void sort(int[] a) {\n for (int i = a.length - 1; i >= 1; i--) {\n int t = (int) Math.random() * i;\n int temp = a[i];\n a[i] = a[t];\n a[t] = temp;\n }\n Arrays.sort(a);\n }\n\n static class InputReader {\n private InputStream in;\n private byte[] buffer = new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {\n this.in = in;\n }\n\n public int readByte() {\n if (lenbuf == -1) throw new InputMismatchException();\n if (curbuf >= lenbuf) {\n curbuf = 0;\n try {\n lenbuf = in.read(buffer);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return -1;\n }\n return buffer[curbuf++];\n }\n\n public boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private int skip() {\n int b;\n while ((b = readByte()) != -1 && isSpaceChar(b))\n ;\n return b;\n }\n\n public String next() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while (!isSpaceChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public int nextInt() {\n int c = readByte();\n while (isSpaceChar(c)) c = readByte();\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9') throw new InputMismatchException();\n res = res * 10 + c - '0';\n c = readByte();\n } while (!isSpaceChar(c));\n return (minus) ? -res : res;\n }\n\n public long nextLong() {\n int c = readByte();\n while (isSpaceChar(c)) c = readByte();\n boolean minus = false;\n if (c == '-') {\n minus = true;\n c = readByte();\n }\n long res = 0;\n do {\n if (c < '0' || c > '9') throw new InputMismatchException();\n res = res * 10 + c - '0';\n c = readByte();\n } while (!isSpaceChar(c));\n return (minus) ? -res : res;\n }\n\n public int[] toIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = nextInt();\n return a;\n }\n }\n}\n", "test_IO": [ { "input": "4 3\n180\n160\n170\n190\n2 100\n3 120\n4 250\n", "output": "480\n" } ] }, { "id": "s022285498", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.Arrays;\nimport java.util.StringTokenizer;\n\npublic class s022285498 {\n\n static class Task {\n\n public void solve(int testNumber, InputReader in, PrintWriter out) {\n int n = in.nextInt();\n int[] countArr = new int[n + 1];\n for (int x = 1; x <= 100; x++) {\n for (int y = 1; y <= 100; y++) {\n for (int z = 1; z <= 100; z++) {\n int value = x * x + y * y + z * z + x * y + x * z + y * z;\n if (value > n) {\n break;\n }\n countArr[value]++;\n }\n }\n }\n\n for (int i = 1; i <= n; i++) {\n out.println(countArr[i]);\n }\n }\n }\n\n private static void sort(double[] arr) {\n Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);\n Arrays.sort(objArr);\n for (int i = 0; i < arr.length; i++) {\n arr[i] = objArr[i];\n }\n }\n\n private static void sort(int[] arr) {\n Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);\n Arrays.sort(objArr);\n for (int i = 0; i < arr.length; i++) {\n arr[i] = objArr[i];\n }\n }\n\n private static void sort(long[] arr) {\n Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);\n Arrays.sort(objArr);\n for (int i = 0; i < arr.length; i++) {\n arr[i] = objArr[i];\n }\n }\n\n private static void solve() {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n Task task = new Task();\n task.solve(1, in, out);\n out.close();\n }\n\n public static void main(String[] args) {\n new Thread(null, () -> solve(), \"1\", 1 << 26).start();\n }\n\n static class InputReader {\n\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "test_IO": [ { "input": "20\n", "output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n" } ] }, { "id": "s162740530", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s162740530 {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int m = sc.nextInt();\n int[] a = new int[m + 1];\n int[] cnt = new int[n + 1];\n cnt[0] = 1;\n final int MOD = 1000000007;\n\n for (int i = 1; i < a.length; i++) {\n a[i] = sc.nextInt();\n }\n\n int num = 1;\n if (m > 0) {\n if (a[1] == 1) {\n cnt[1] = 0;\n if (num < m) {\n num++;\n }\n } else {\n cnt[1] = 1;\n }\n } else {\n cnt[1] = 1;\n }\n\n for (int i = 2; i < cnt.length; i++) {\n\n cnt[i] = cnt[i - 2] + cnt[i - 1];\n cnt[i] %= MOD;\n if (m > 0) {\n if (i == a[num]) {\n cnt[i] = 0;\n if (num < m) {\n num++;\n }\n }\n }\n }\n\n System.out.println(cnt[n]);\n sc.close();\n }\n}\n", "test_IO": [ { "input": "6 1\n3\n", "output": "4\n" } ] }, { "id": "s863488345", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s863488345 {\n static int mapNum;\n static int h;\n static int w;\n static char[][] battleTown;\n static int bomberActNum;\n static char[] bomberAct;\n\n static int[] tank = new int[2];\n static int xOfTank;\n static int yOfTank;\n static int xOfBomber;\n static int yOfBomber;\n static int s;\n static int k;\n static int a;\n static int b;\n static int x;\n static int y;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n mapNum = sc.nextInt();\n\n for (int i = 0; i < mapNum; i++) {\n if (1 <= i && i < mapNum) {\n System.out.println(\"\");\n }\n h = sc.nextInt();\n w = sc.nextInt();\n\n battleTown = new char[h][w];\n\n for (int j = 0; j < h; j++) {\n char[] c = sc.next().toCharArray();\n for (int k = 0; k < w; k++) {\n battleTown[j][k] = c[k];\n\n if ('^' == battleTown[j][k]\n || 'v' == battleTown[j][k]\n || '<' == battleTown[j][k]\n || '>' == battleTown[j][k]) {\n\n x = j;\n y = k;\n }\n }\n }\n\n bomberActNum = sc.nextInt();\n bomberAct = sc.next().toCharArray();\n\n if (0 <= x && x <= h && 0 <= y && y <= w) {\n for (int l = 0; l < bomberActNum; l++) {\n\n if (bomberAct[l] == 'U') {\n\n battleTown[x][y] = '^';\n if (x - 1 >= 0 && battleTown[x - 1][y] == '.') {\n\n battleTown[x - 1][y] = '^';\n battleTown[x][y] = '.';\n x--;\n }\n }\n if (bomberAct[l] == 'D') {\n\n battleTown[x][y] = 'v';\n if (x + 1 < h && battleTown[x + 1][y] == '.') {\n\n battleTown[x + 1][y] = 'v';\n battleTown[x][y] = '.';\n x++;\n }\n }\n if (bomberAct[l] == 'L') {\n\n battleTown[x][y] = '<';\n if (y - 1 >= 0 && battleTown[x][y - 1] == '.') {\n\n battleTown[x][y - 1] = '<';\n battleTown[x][y] = '.';\n y--;\n }\n }\n if (bomberAct[l] == 'R') {\n\n battleTown[x][y] = '>';\n if (y + 1 < w && battleTown[x][y + 1] == '.') {\n\n battleTown[x][y + 1] = '>';\n battleTown[x][y] = '.';\n y++;\n }\n }\n\n if (bomberAct[l] == 'S') {\n\n xOfBomber = x;\n yOfBomber = y;\n moveBomber(xOfBomber, yOfBomber);\n }\n }\n for (s = 0; s < h; s++) {\n for (k = 0; k < w; k++) {\n System.out.print(battleTown[s][k]);\n }\n System.out.println();\n }\n }\n }\n }\n\n public static void moveBomber(int a, int b) {\n\n if (0 <= a && a <= h && 0 <= b && b <= w) {\n\n if ('^' == battleTown[a][b]) {\n\n for (int i = a - 1; i >= 0; i--) {\n if (a <= 0) {\n return;\n } else if (battleTown[a - 1][b] == '*') {\n\n battleTown[a - 1][b] = '.';\n\n return;\n } else if (battleTown[a - 1][b] == '#') {\n\n return;\n } else {\n\n a--;\n\n if (a == 0) {\n return;\n }\n }\n }\n }\n\n if ('v' == battleTown[a][b]) {\n for (int i = a + 1; i < h; i++) {\n\n if (battleTown[a + 1][b] == '*') {\n battleTown[a + 1][b] = '.';\n\n return;\n } else if (battleTown[a + 1][b] == '#') {\n\n return;\n } else {\n a++;\n if (a == h) {\n return;\n }\n }\n }\n }\n if ('<' == battleTown[a][b]) {\n for (int i = b - 1; i >= 0; i--) {\n\n if (battleTown[a][b - 1] == '*') {\n battleTown[a][b - 1] = '.';\n\n return;\n } else if (battleTown[a][b - 1] == '#') {\n\n return;\n } else {\n b--;\n if (b == 0) {\n return;\n }\n }\n }\n }\n if ('>' == battleTown[a][b]) {\n for (int i = b + 1; i < w; i++) {\n\n if (battleTown[a][b + 1] == '*') {\n battleTown[a][b + 1] = '.';\n\n return;\n } else if (battleTown[a][b + 1] == '#') {\n\n return;\n } else {\n b++;\n if (b == w) {\n return;\n }\n }\n }\n }\n }\n }\n}\n", "test_IO": [ { "input": "4\n4 6\n*.*..*\n*.....\n..-...\n^.*#..\n10\nSRSSRRUSSR\n2 2\n<.\n..\n12\nDDSRRSUUSLLS\n3 5\n>-#**\n.-*#*\n.-**#\n15\nSSSDRSSSDRSSSUU\n5 5\nv****\n*****\n*****\n*****\n*****\n44\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD\n", "output": "*....*\n......\n..-...\n..>#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n.....\n.***.\n..*..\n..*..\n....v\n" } ] }, { "id": "s853705214", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s853705214 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] nums = new int[n];\n\n for (int i = 0; i < n; i++) {\n nums[i] = sc.nextInt();\n }\n\n int min = Integer.MAX_VALUE;\n int countNegatives = 0;\n long sum = 0;\n for (int num : nums) {\n int abs = Math.abs(num);\n sum += abs;\n min = Math.min(min, abs);\n if (num < 0) {\n countNegatives++;\n }\n }\n\n System.out.println(countNegatives % 2 == 0 ? sum : sum - (min * 2));\n }\n}\n", "test_IO": [ { "input": "3\n-10 5 -4\n", "output": "19\n" } ] }, { "id": "s545439898", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s545439898 {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int count = Integer.parseInt(sc.next());\n int[] givingNumbers = new int[count];\n\n for (int i = 0; i < count; i++) {\n\n givingNumbers[i] = Integer.parseInt(sc.next());\n }\n\n for (int i = count - 1; 0 <= i; i--) {\n\n System.out.print(givingNumbers[i]);\n\n if (i > 0) {\n System.out.print(\" \");\n }\n }\n\n System.out.println();\n\n sc.close();\n }\n}\n", "test_IO": [ { "input": "5\n1 2 3 4 5\n", "output": "5 4 3 2 1\n" } ] }, { "id": "s059841225", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s059841225 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n while (sc.hasNext()) {\n String str = sc.next();\n String[] strArr = str.split(\",\");\n int[] l = new int[10];\n int d = 0;\n for (int i = 0; i < 10; i++) {\n l[i] = Integer.parseInt(strArr[i]);\n d += l[i];\n }\n int[] v = {Integer.parseInt(strArr[10]), Integer.parseInt(strArr[11])};\n double t = (double) d / (v[0] + v[1]);\n d = 0;\n for (int i = 0; i < 11; i++) {\n if (v[0] * t <= d) {\n System.out.println(i);\n break;\n } else {\n d += l[i];\n }\n }\n }\n }\n}\n", "test_IO": [ { "input": "1,1,1,1,1,1,1,1,1,1,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49\n", "output": "4\n7\n6\n" } ] }, { "id": "s318252319", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s318252319 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n String s = sc.next();\n int n = Integer.parseInt(s.substring(s.length() - 1, s.length()));\n if (n == 3) System.out.println(\"bon\");\n else if (n == 0 || n == 1 || n == 6 || n == 8) System.out.println(\"pon\");\n else System.out.println(\"hon\");\n sc.close();\n }\n}\n", "test_IO": [ { "input": "16\n", "output": "pon\n" } ] }, { "id": "s773621585", "dataset": "codenet", "language": "Java", "code": "import java.util.HashMap;\nimport java.util.Scanner;\n\npublic class s773621585 {\n public static void main(String[] args) {\n HashMap map = new HashMap();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n String str = sc.nextLine();\n for (int i = 0; i < n; i++) {\n map.put(sc.nextLine(), \"\");\n }\n sc.close();\n\n System.out.println(map.size());\n }\n}\n", "test_IO": [ { "input": "3\napple\norange\napple\n", "output": "2\n" } ] }, { "id": "s609591310", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s609591310 {\n public static void main(String[] args) {\n int ans = 0;\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int list[] = new int[n];\n for (int i = 0; i < n; i++) {\n list[i] = sc.nextInt();\n }\n\n int numlist1[] = new int[100000];\n int numlist2[] = new int[100000];\n for (int i = 0; i < 100000; i++) {\n numlist1[i] = 0;\n numlist2[i] = 0;\n }\n\n for (int i = 0; i < n; i += 2) {\n numlist1[list[i] - 1] += 1;\n numlist2[list[i + 1] - 1] += 1;\n }\n\n int max11 = 0, max12 = 0, max21 = 0, max22 = 0;\n int val1 = 0, val2 = 0;\n for (int i = 0; i < 100000; i++) {\n if (numlist1[i] >= max11) {\n max12 = max11;\n max11 = numlist1[i];\n val1 = i;\n } else if (numlist1[i] >= max12) {\n max12 = numlist1[i];\n }\n if (numlist2[i] >= max21) {\n max22 = max21;\n max21 = numlist2[i];\n val2 = i;\n } else if (numlist2[i] >= max22) {\n max22 = numlist2[i];\n }\n }\n\n if (val1 != val2) {\n ans = n - max11 - max21;\n } else {\n ans = n - Math.max(max12 + max21, max11 + max22);\n }\n\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "4\n3 1 3 2\n", "output": "1\n" } ] }, { "id": "s283652523", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\n@SuppressWarnings(\"unused\")\npublic class s283652523 {\n FastScanner in;\n PrintWriter out;\n static final int MOD = (int) 1e9 + 7;\n\n void solve() {\n int N = in.nextInt();\n int[] A = in.nextIntArray(N);\n\n long ans = 0, sum = A[N - 1];\n for (int i = N - 2; i >= 0; i--) {\n ans += (sum * A[i]) % MOD;\n ans %= MOD;\n sum += A[i];\n sum %= MOD;\n }\n out.println(ans);\n }\n\n public static void main(String[] args) {\n new s283652523().m();\n }\n\n private void m() {\n in = new FastScanner(System.in);\n out = new PrintWriter(System.out);\n\n solve();\n out.flush();\n in.close();\n out.close();\n }\n\n static class FastScanner {\n private Reader input;\n\n public FastScanner() {\n this(System.in);\n }\n\n public FastScanner(InputStream stream) {\n this.input = new BufferedReader(new InputStreamReader(stream));\n }\n\n public void close() {\n try {\n this.input.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public long nextLong() {\n try {\n int sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n long ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) return ret * sign;\n ret *= 10;\n ret += b - '0';\n }\n } catch (IOException e) {\n e.printStackTrace();\n return -1;\n }\n }\n\n public double nextDouble() {\n try {\n double sign = 1;\n int b = input.read();\n while ((b < '0' || '9' < b) && b != '-' && b != '+') {\n b = input.read();\n }\n if (b == '-') {\n sign = -1;\n b = input.read();\n } else if (b == '+') {\n b = input.read();\n }\n double ret = b - '0';\n while (true) {\n b = input.read();\n if (b < '0' || '9' < b) break;\n ret *= 10;\n ret += b - '0';\n }\n if (b != '.') return sign * ret;\n double div = 1;\n b = input.read();\n while ('0' <= b && b <= '9') {\n ret *= 10;\n ret += b - '0';\n div *= 10;\n b = input.read();\n }\n return sign * ret / div;\n } catch (IOException e) {\n e.printStackTrace();\n return Double.NaN;\n }\n }\n\n public char nextChar() {\n try {\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n return (char) b;\n } catch (IOException e) {\n e.printStackTrace();\n return 0;\n }\n }\n\n public String nextStr() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (Character.isWhitespace(b)) {\n b = input.read();\n }\n while (b != -1 && !Character.isWhitespace(b)) {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public String nextLine() {\n try {\n StringBuilder sb = new StringBuilder();\n int b = input.read();\n while (b != -1 && b != '\\n') {\n sb.append((char) b);\n b = input.read();\n }\n return sb.toString();\n } catch (IOException e) {\n e.printStackTrace();\n return \"\";\n }\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt();\n }\n return res;\n }\n\n public int[] nextIntArrayDec(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextInt() - 1;\n }\n return res;\n }\n\n public int[] nextIntArray1Index(int n) {\n int[] res = new int[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextInt();\n }\n return res;\n }\n\n public long[] nextLongArray(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong();\n }\n return res;\n }\n\n public long[] nextLongArrayDec(int n) {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextLong() - 1;\n }\n return res;\n }\n\n public long[] nextLongArray1Index(int n) {\n long[] res = new long[n + 1];\n for (int i = 0; i < n; i++) {\n res[i + 1] = nextLong();\n }\n return res;\n }\n\n public double[] nextDoubleArray(int n) {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) {\n res[i] = nextDouble();\n }\n return res;\n }\n }\n}\n", "test_IO": [ { "input": "3\n1 2 3\n", "output": "11\n" } ] }, { "id": "s393796709", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s393796709 {\n long MOD = 1000000007;\n\n void solve(BufferedReader in) throws Exception {\n int[] xx = toInts(in.readLine());\n int min = Math.min(xx[0], xx[1]);\n int max = Math.max(xx[0], xx[1]);\n long res;\n if (min == max) {\n long f = f(min);\n res = (2 * f * f) % MOD;\n } else if (min + 1 == max) {\n long f = f(min);\n res = (f * ((f * max) % MOD)) % MOD;\n } else {\n res = 0;\n }\n System.out.println(res);\n }\n\n long f(int n) {\n long res = 1;\n for (int i = 2; i <= n; i++) res = (res * i) % MOD;\n return res;\n }\n\n int toInt(String s) {\n return Integer.parseInt(s);\n }\n\n int[] toInts(String s) {\n String[] a = s.split(\" \");\n int[] o = new int[a.length];\n for (int i = 0; i < a.length; i++) o[i] = toInt(a[i]);\n return o;\n }\n\n void e(Object o) {\n System.err.println(o);\n }\n\n public static void main(String[] args) throws Exception {\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n (new s393796709()).solve(in);\n }\n}\n", "test_IO": [ { "input": "2 2\n", "output": "8\n" } ] }, { "id": "s998094687", "dataset": "codenet", "language": "Java", "code": "import java.lang.Math.*;\nimport java.util.Arrays;\nimport java.util.Scanner;\n\nclass s998094687 {\n public static void main(String[] args) {\n final Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[3];\n for (int i = 0; i < n; i++) {\n a[0] = sc.nextInt();\n a[1] = sc.nextInt();\n a[2] = sc.nextInt();\n Arrays.sort(a);\n if (Math.pow(a[2], 2) == Math.pow(a[0], 2) + Math.pow(a[1], 2))\n System.out.println(\"YES\");\n else System.out.println(\"NO\");\n }\n }\n}\n", "test_IO": [ { "input": "3\n4 3 5\n4 3 6\n8 8 8\n", "output": "YES\nNO\nNO\n" } ] }, { "id": "s409580149", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s409580149 {\n static int n, a[];\n static double dp[][][];\n\n static void solve() {\n n = ni();\n a = na(n);\n dp = new double[n + 1][n + 1][n + 1];\n for (int i = 0; i < n + 1; i++) fill(dp[i], -1);\n dp[0][0][0] = 0;\n int cnt[] = new int[3];\n for (int i = 0; i < n; i++) {\n cnt[a[i] - 1]++;\n }\n double ans = rec(cnt[0], cnt[1], cnt[2]);\n out.println(ans);\n }\n\n static double rec(int i, int j, int k) {\n if (dp[i][j][k] != -1) return dp[i][j][k];\n double ret = 0;\n double p = ((double) i + j + k) / n;\n double pi = (double) i / n;\n double pj = (double) j / n;\n double pk = (double) k / n;\n ret += 1 / p;\n if (i > 0) ret += pi / p * rec(i - 1, j, k);\n if (j > 0) ret += pj / p * rec(i + 1, j - 1, k);\n if (k > 0) ret += pk / p * rec(i, j + 1, k - 1);\n return dp[i][j][k] = ret;\n }\n\n static final long mod = (long) 1e9 + 7;\n static final int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};\n static final int[] dx8 = {-1, -1, -1, 0, 0, 1, 1, 1}, dy8 = {-1, 0, 1, -1, 1, -1, 0, 1};\n static final int inf = Integer.MAX_VALUE / 2;\n static final long linf = Long.MAX_VALUE / 3;\n static final double dinf = Double.MAX_VALUE / 3;\n static final double eps = 1e-10;\n static final double pi = Math.PI;\n static StringBuilder sb = new StringBuilder();\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n static void reverse(int ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n int t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(long ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n long t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(double ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n double t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(char ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n char t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static String getReverse(String s) {\n char c[] = s.toCharArray();\n reverse(c);\n s = String.valueOf(c);\n return s;\n }\n\n static void reverse(List ls) {\n int sz = ls.size();\n for (int i = 0; i < sz / 2; i++) {\n T t = ls.get(i);\n ls.set(i, ls.get(sz - 1 - i));\n ls.set(sz - 1 - i, t);\n }\n }\n\n static void reverse(T[] ar) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n T t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void sbnl() {\n sb.append(\"\\n\");\n }\n\n static int lowerBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int upperBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int rupperBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int rlowerBound(List ls, T x) {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int[] concat(int x, int arr[]) {\n int ret[] = new int[arr.length + 1];\n System.arraycopy(arr, 0, ret, 1, ret.length - 1);\n ret[0] = x;\n return ret;\n }\n\n static int[] concat(int arr[], int x) {\n int ret[] = new int[arr.length + 1];\n System.arraycopy(arr, 0, ret, 0, ret.length - 1);\n ret[ret.length - 1] = x;\n return ret;\n }\n\n static long[] concat(long x, long arr[]) {\n long ret[] = new long[arr.length + 1];\n System.arraycopy(arr, 0, ret, 1, ret.length - 1);\n ret[0] = x;\n return ret;\n }\n\n static long[] concat(long arr[], long x) {\n long ret[] = new long[arr.length + 1];\n System.arraycopy(arr, 0, ret, 0, ret.length - 1);\n ret[ret.length - 1] = x;\n return ret;\n }\n\n static int max(int x, int y) {\n return Math.max(x, y);\n }\n\n static int min(int x, int y) {\n return Math.min(x, y);\n }\n\n static int max(int x, int y, int z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static int min(int x, int y, int z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static long max(long x, long y) {\n return Math.max(x, y);\n }\n\n static long min(long x, long y) {\n return Math.min(x, y);\n }\n\n static long max(long x, long y, long z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static long min(long x, long y, long z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static double max(double x, double y) {\n return Math.max(x, y);\n }\n\n static double min(double x, double y) {\n return Math.min(x, y);\n }\n\n static double max(double x, double y, double z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static double min(double x, double y, double z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static void sort(int[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(long[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(double[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(char[] ar) {\n Arrays.sort(ar);\n }\n\n static void rsort(int[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n int tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(long[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n long tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(double[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n double tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(char[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n char tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void fill(int arr[], int x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(long arr[], long x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(boolean arr[], boolean x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(double arr[], double x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(int arr[][], int x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(long arr[][], long x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(double arr[][], double x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(boolean arr[][], boolean x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static long plus(long x, long y) {\n long res = (x + y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long sub(long x, long y) {\n long res = (x - y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long mul(long x, long y) {\n long res = (x * y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long div(long x, long y) {\n long res = x * pow(y, mod - 2) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long pow(long x, long y) {\n if (y < 0) return 0;\n if (y == 0) return 1;\n if (y % 2 == 1) return (x * pow(x, y - 1)) % mod;\n long root = pow(x, y / 2);\n return root * root % mod;\n }\n\n public static void main(String[] args) throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n solve();\n out.flush();\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if (lenbuf == -1) throw new InputMismatchException();\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0;\n try {\n lenbuf = is.read(inbuf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private static int skip() {\n int b;\n while ((b = readByte()) != -1 && isSpaceChar(b))\n ;\n return b;\n }\n\n @SuppressWarnings(\"unused\")\n private static double nd() {\n return Double.parseDouble(ns());\n }\n\n @SuppressWarnings(\"unused\")\n private static char nc() {\n return (char) skip();\n }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while (!(isSpaceChar(b))) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while (p < n && !(isSpaceChar(b))) {\n buf[p++] = (char) b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n @SuppressWarnings(\"unused\")\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for (int i = 0; i < n; i++) map[i] = ns(m);\n return map;\n }\n\n @SuppressWarnings(\"unused\")\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = ni();\n return a;\n }\n\n @SuppressWarnings(\"unused\")\n private static long[] nla(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nl();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n @SuppressWarnings(\"unused\")\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n}\n", "test_IO": [ { "input": "3\n1 1 1\n", "output": "5.5\n" } ] }, { "id": "s656827329", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s656827329 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) {\n a[i] = sc.nextInt();\n }\n int count = 1;\n int now = 0;\n int bef = 0;\n for (int i = 1; i < n; i++) {\n if (a[i - 1] < a[i]) {\n now = 1;\n } else if (a[i - 1] > a[i]) {\n now = -1;\n } else {\n continue;\n }\n if (bef == 0) {\n bef = now;\n }\n if (bef != now) {\n count++;\n bef = 0;\n }\n }\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "6\n1 2 3 2 2 1\n", "output": "2\n" } ] }, { "id": "s965025950", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s965025950 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int y = sc.nextInt();\n int z = sc.nextInt();\n System.out.println(z + \" \" + x + \" \" + y);\n sc.close();\n }\n}\n", "test_IO": [ { "input": "1 2 3\n", "output": "3 1 2\n" } ] }, { "id": "s214067324", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s214067324 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = Integer.parseInt(sc.next());\n System.out.println(x < 1200 ? \"ABC\" : \"ARC\");\n }\n}\n", "test_IO": [ { "input": "1000\n", "output": "ABC\n" } ] }, { "id": "s685734377", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\n\npublic class s685734377 {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n FastScanner in = new FastScanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n TaskB solver = new TaskB();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class TaskB {\n public void solve(int testNumber, FastScanner in, PrintWriter out) {\n int n = in.nextInt();\n char[][] a = new char[n][n];\n long P = 37, Q = 47;\n long[] powP = new long[n + 1], powQ = new long[n + 1];\n powP[0] = powQ[0] = 1;\n for (int i = 1; i <= n; i++) {\n powP[i] = powP[i - 1] * P;\n powQ[i] = powQ[i - 1] * Q;\n }\n for (int i = 0; i < n; i++) {\n a[i] = in.next().toCharArray();\n }\n\n long[][] hashRow = new long[n][n];\n long[][] hashCol = new long[n][n];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) {\n for (int k = 0; k < n; k++) {\n hashRow[i][k] += a[i][j] * powP[(j - k + n) % n];\n hashCol[j][k] += a[i][j] * powP[(i - k + n) % n];\n }\n }\n }\n\n int ans = 0;\n for (int A = 0; A < n; A++) {\n for (int B = 0; B < n; B++) {\n boolean ok = true;\n for (int i = 0; i < n; i++) {\n ok &= hashRow[(i + A) % n][B] == hashCol[(i + B) % n][A];\n }\n ans += ok ? 1 : 0;\n }\n }\n out.println(ans);\n }\n }\n\n static class FastScanner {\n BufferedReader br;\n StringTokenizer st;\n\n public FastScanner(InputStream in) {\n br = new BufferedReader(new InputStreamReader(in));\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public String next() {\n while (st == null || !st.hasMoreElements()) {\n String line = null;\n try {\n line = br.readLine();\n } catch (IOException e) {\n }\n st = new StringTokenizer(line);\n }\n return st.nextToken();\n }\n }\n}\n", "test_IO": [ { "input": "2\nab\nca\n", "output": "2\n" } ] }, { "id": "s989561778", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.util.Scanner;\n\nclass s989561778 {\n public static void main(String[] args) throws IOException {\n Scanner sc = new Scanner(System.in);\n StringBuilder sb = new StringBuilder(\"\");\n int a, b, digit;\n while (sc.hasNextInt()) {\n a = sc.nextInt();\n b = sc.nextInt();\n digit = (int) Math.log10(a + b) + 1;\n sb.append(digit);\n sb.append('\\n');\n }\n System.out.print(sb);\n }\n}\n", "test_IO": [ { "input": "5 7\n1 99\n1000 999\n", "output": "2\n3\n4\n" } ] }, { "id": "s151517960", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s151517960 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n HashMap map = new HashMap();\n for (int i = 0; i < n; i++) {\n int a = sc.nextInt();\n if (map.containsKey(a)) {\n map.put(a, map.get(a) + 1);\n } else {\n map.put(a, 1);\n }\n }\n int ans = 0;\n for (int key : map.keySet()) {\n if ((map.get(key) % 2) == 1) ans++;\n }\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "3\n6\n2\n6\n", "output": "1\n" } ] }, { "id": "s466963472", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s466963472 {\n\n static Scanner sc = new Scanner(System.in);\n static int d;\n\n static boolean read() {\n if (!sc.hasNextInt()) return false;\n d = sc.nextInt();\n return true;\n }\n\n static int solve() {\n int ans, n;\n\n ans = 0;\n for (int i = 1; i * d < 600; i++) {\n int x = i * d;\n int y = x * x;\n ans += y * d;\n }\n return ans;\n }\n\n public static void main(String[] args) {\n while (read()) {\n System.out.println(solve());\n }\n }\n}\n", "test_IO": [ { "input": "20\n10\n", "output": "68440000\n70210000\n" } ] }, { "id": "s393629232", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s393629232 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int maxv = Integer.MIN_VALUE;\n int minv = sc.nextInt();\n for (int i = 1; i < n; i++) {\n int ri = sc.nextInt();\n maxv = Math.max(maxv, ri - minv);\n minv = Math.min(minv, ri);\n }\n System.out.println(maxv);\n sc.close();\n }\n}\n", "test_IO": [ { "input": "6\n5\n3\n1\n3\n4\n3\n", "output": "3\n" } ] }, { "id": "s016010007", "dataset": "codenet", "language": "Java", "code": "import static java.lang.Integer.parseInt;\n\nimport java.awt.geom.Point2D.Double;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class s016010007 {\n\n public static void main(String[] args) {\n new s016010007().run();\n }\n\n public void run() {\n\n try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n Point2D p0, p1, p2;\n String[] line = br.readLine().split(\" \");\n p0 = new Point2D(parseInt(line[0]), parseInt(line[1]));\n p1 = new Point2D(parseInt(line[2]), parseInt(line[3]));\n int q = parseInt(br.readLine());\n\n StringBuilder buf = new StringBuilder();\n for (int i = 0; i < q; i++) {\n line = br.readLine().split(\" \");\n p2 = new Point2D(parseInt(line[0]), parseInt(line[1]));\n buf.append(jadgeClockwise(p0, p1, p2)).append(\"\\n\");\n }\n\n System.out.print(buf);\n\n } catch (IOException e) {\n System.out.println(e);\n }\n }\n\n public String jadgeClockwise(Point2D p0, Point2D p1, Point2D p2) {\n Vector v = new Vector();\n Point2D a = p1.diff(p0);\n Point2D b = p2.diff(p0);\n\n if (v.cross(a, b) > v.EPS) {\n return \"COUNTER_CLOCKWISE\";\n }\n if (v.cross(a, b) < -v.EPS) {\n return \"CLOCKWISE\";\n }\n if (v.dot(a, b) < -v.EPS) {\n return \"ONLINE_BACK\";\n }\n if (a.norm() < b.norm()) {\n return \"ONLINE_FRONT\";\n }\n\n return \"ON_SEGMENT\";\n }\n\n private class Point2D extends Double {\n private static final long serialVersionUID = 1L;\n double EPS = 1e-10;\n\n public Point2D() {\n super();\n }\n\n public Point2D(double x, double y) {\n super(x, y);\n }\n\n public boolean equals(double a, double b) {\n return Math.abs(a - b) < EPS;\n }\n\n public Point2D sum(Point2D b) {\n return new Point2D(x + b.x, y + b.y);\n }\n\n public Point2D diff(Point2D b) {\n return new Point2D(x - b.x, y - b.y);\n }\n\n public Point2D multiple(double k) {\n return new Point2D(x * k, y * k);\n }\n\n public double norm() {\n return x * x + y * y;\n }\n\n public double abs(Point2D a) {\n return Math.sqrt(a.norm());\n }\n\n @Override\n public String toString() {\n return String.format(\"%.10f %.10f\", x, y);\n }\n }\n\n private class Vector extends Point2D {\n\n private static final long serialVersionUID = 1L;\n\n public Vector() {\n super();\n }\n\n public Vector(double x, double y) {\n super(x, y);\n }\n\n public Vector(Point2D p) {\n super(p.x, p.y);\n }\n\n public double dot(Point2D a, Point2D b) {\n return a.x * b.x + a.y * b.y;\n }\n\n public double cross(Point2D a, Point2D b) {\n return a.x * b.y - a.y * b.x;\n }\n\n public boolean isOrthogonal(Point2D a, Point2D b) {\n return equals(dot(a, b), 0.0);\n }\n\n public boolean isOrthogonal(Point2D a1, Point2D a2, Point2D b1, Point2D b2) {\n return isOrthogonal(a1.diff(a2), b1.diff(b2));\n }\n\n public boolean isParallel(Point2D a, Point2D b) {\n return equals(cross(a, b), 0.0);\n }\n\n public boolean isParallel(Point2D a1, Point2D a2, Point2D b1, Point2D b2) {\n return isParallel(a1.diff(a2), b1.diff(b2));\n }\n\n public Point2D project(Point2D sp1, Point2D sp2, Point2D p) {\n Vector base = new Vector(sp2.diff(sp1));\n double r = dot(p.diff(sp1), base) / base.norm();\n\n return sp1.sum(base.multiple(r));\n }\n\n public Point2D reflect(Point2D sp1, Point2D sp2, Point2D p) {\n return p.sum(project(sp1, sp2, p).diff(p).multiple(2.0));\n }\n }\n}\n", "test_IO": [ { "input": "0 0 2 0\n2\n-1 1\n-1 -1\n", "output": "COUNTER_CLOCKWISE\nCLOCKWISE\n" } ] }, { "id": "s196451707", "dataset": "codenet", "language": "Java", "code": "import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class s196451707 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n\n int[][] g = new int[n + 1][n + 1];\n\n for (int i = 0; i < n; i++) {\n int u = sc.nextInt();\n int k = sc.nextInt();\n for (int j = 0; j < k; j++) {\n int v = sc.nextInt();\n g[u][v] = 1;\n }\n }\n\n int[] d = new int[n + 1];\n for (int i = 0; i <= n; i++) {\n d[i] = -1;\n }\n Queue que = new LinkedList();\n que.add(1);\n d[1] = 0;\n while (!que.isEmpty()) {\n int top = que.poll();\n for (int j = 1; j <= n; j++) {\n if (g[top][j] == 1 && d[j] == -1) {\n que.add(j);\n d[j] = d[top] + 1;\n }\n }\n }\n\n for (int i = 1; i <= n; i++) {\n System.out.println(i + \" \" + d[i]);\n }\n }\n}\n", "test_IO": [ { "input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n", "output": "1 0\n2 1\n3 2\n4 1\n" } ] }, { "id": "s897176066", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s897176066 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n long A[] = new long[N];\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextLong();\n }\n Arrays.sort(A);\n for (int j = 1; j < N; j++) {\n if (A[j] == A[j - 1]) {\n System.out.println(\"NO\");\n System.exit(0);\n }\n }\n System.out.println(\"YES\");\n }\n}\n", "test_IO": [ { "input": "5\n2 6 1 4 5\n", "output": "YES\n" } ] }, { "id": "s648025110", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s648025110 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int n;\n n = sc.nextInt();\n int[] h = new int[n];\n for (int i = 0; i < n; i++) {\n h[i] = sc.nextInt();\n }\n\n int ans = 0;\n int out = 0;\n\n for (int i = 0; i < h.length; i++) {\n if (out < h[i]) {\n ans += h[i] - out;\n out = h[i];\n } else {\n out = h[i];\n }\n }\n\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "4\n1 2 2 1\n", "output": "2\n" } ] }, { "id": "s682993858", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s682993858 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n while (true) {\n int sum = 0;\n String s = sc.next();\n if (s.equals(\"0\")) break;\n for (int i = 0; i < s.length(); i++) {\n char a = s.charAt(i);\n sum += a - '0';\n }\n System.out.printf(\"%d\\n\", sum);\n }\n }\n}\n", "test_IO": [ { "input": "123\n55\n1000\n0\n", "output": "6\n10\n1\n" } ] }, { "id": "s332475184", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\nclass s332475184 {\n static int[] counter;\n static List> graph;\n\n public static void main(String[] args) {\n FastScanner fs = new FastScanner();\n int n = fs.nextInt();\n int q = fs.nextInt();\n graph = new ArrayList<>();\n for (int i = 0; i < n; i++) graph.add(new LinkedList<>());\n\n counter = new int[n];\n Integer a, b;\n for (int i = 0; i < n - 1; i++) {\n a = fs.nextInt() - 1;\n b = fs.nextInt() - 1;\n graph.get(a).add(b);\n graph.get(b).add(a);\n }\n for (int i = 0; i < q; i++) {\n counter[fs.nextInt() - 1] += fs.nextInt();\n }\n dfs(0, -1, 0);\n StringJoiner sj = new StringJoiner(\" \");\n for (int i = 0; i < n; i++) {\n sj.add(String.valueOf(counter[i]));\n }\n System.out.println(sj.toString());\n }\n\n static void dfs(int v, int par, long val) {\n\n for (Integer i : graph.get(v)) {\n if (i != par) {\n dfs(i, v, val + counter[v]);\n }\n }\n counter[v] += val;\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "test_IO": [ { "input": "4 3\n1 2\n2 3\n2 4\n2 10\n1 100\n3 1\n", "output": "100 110 111 110\n" } ] }, { "id": "s280174843", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass s280174843 {\n private static BufferedReader buf;\n\n public static void main(String[] args) throws IOException {\n int[] abc = new int[3];\n String str;\n String[] inp;\n buf = new BufferedReader(new InputStreamReader(System.in));\n str = buf.readLine();\n inp = str.split(\" \", -1);\n for (int i = 0; i < inp.length; i++) abc[i] = Integer.parseInt(inp[i]);\n if (abc[0] < abc[1] && abc[1] < abc[2]) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s584135649", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s584135649 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int i = 0;\n\n for (i = 1; i <= 5; i++) {\n int n = sc.nextInt();\n if (n == 0) {\n break;\n }\n }\n\n System.out.println(i);\n }\n}\n", "test_IO": [ { "input": "0 2 3 4 5\n", "output": "1\n" } ] }, { "id": "s379215956", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s379215956 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n String s1 = s.substring(0, 1);\n String s2 = s.substring(1, 2);\n String s3 = s.substring(2, 3);\n String s4 = s.substring(3, 4);\n int a = 0;\n\n if (s1.equals(s2)) a = 1;\n if (s2.equals(s3)) a = 1;\n if (s3.equals(s4)) a = 1;\n\n if (a == 1) {\n System.out.println(\"Bad\");\n } else {\n System.out.println(\"Good\");\n }\n }\n}\n", "test_IO": [ { "input": "3776\n", "output": "Bad\n" } ] }, { "id": "s580342216", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s580342216 {\n public static void main(String[] args) throws java.lang.Exception {\n new Solution();\n }\n}\n\nclass Solution {\n Scanner scanner;\n\n public Solution() {\n scanner = new Scanner(System.in);\n\n while (scanner.hasNext()) {\n run_case();\n }\n }\n\n private void run_case() {\n\n String line = scanner.nextLine();\n int N = Integer.parseInt(line.split(\"\\\\s+\")[0]);\n int K = Integer.parseInt(line.split(\"\\\\s+\")[1]);\n\n int len = 0;\n while (N > 0) {\n N /= K;\n len++;\n }\n\n System.out.println(len);\n return;\n }\n\n private int[] strToIntArray(String str) {\n String[] vals = str.split(\"\\\\s+\");\n int sz = vals.length;\n int[] res = new int[sz];\n for (int i = 0; i < sz; i++) {\n res[i] = Integer.parseInt(vals[i]);\n }\n return res;\n }\n}\n\nclass LCS {\n int[][] dp;\n\n public int lcs(String A, String B) {\n int sz_a = A.length(), sz_b = B.length();\n dp = new int[sz_a + 1][sz_b + 1];\n\n for (int i = 0; i <= sz_a; i++) dp[i][0] = 0;\n for (int j = 0; j <= sz_b; j++) dp[0][j] = 0;\n\n for (int i = 1; i <= sz_a; i++) {\n for (int j = 1; j <= sz_b; j++) {\n if (A.charAt(i - 1) == B.charAt(j - 1)) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n return dp[sz_a][sz_b];\n }\n\n public String getLCS(String X, String Y) {\n int m = X.length();\n int n = Y.length();\n\n int index = dp[m][n];\n int temp = index;\n\n char[] lcs = new char[index + 1];\n lcs[index] = '\\0';\n\n int i = m;\n int j = n;\n while (i > 0 && j > 0) {\n\n if (X.charAt(i - 1) == Y.charAt(j - 1)) {\n\n lcs[index - 1] = X.charAt(i - 1);\n\n i--;\n j--;\n index--;\n } else if (dp[i - 1][j] > dp[i][j - 1]) i--;\n else j--;\n }\n\n return String.valueOf(lcs).substring(0, temp + 2);\n }\n}\n", "test_IO": [ { "input": "11 2\n", "output": "4\n" } ] }, { "id": "s126744620", "dataset": "codenet", "language": "Java", "code": "import java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.Scanner;\n\npublic class s126744620 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int k = sc.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = sc.nextInt();\n Integer[] x = new Integer[200010];\n Arrays.fill(x, 0);\n for (int i = 0; i < n; i++) {\n x[a[i] - 1]++;\n }\n Arrays.sort(\n x,\n new Comparator() {\n public int compare(Integer p1, Integer p2) {\n return p1 - p2;\n }\n });\n int ans = 0;\n for (int i = 0; i <= 200010 - k - 1; i++) {\n ans += x[i];\n }\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "5 2\n1 1 2 2 5\n", "output": "1\n" } ] }, { "id": "s450226252", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s450226252 {\n public static void main(String[] args) {\n\n Scanner stdIn = new Scanner(System.in);\n\n short r = stdIn.nextShort();\n\n if (r < 1200) {\n System.out.println(\"ABC\");\n return;\n }\n\n if (r < 2800) {\n System.out.println(\"ARC\");\n return;\n }\n\n System.out.println(\"AGC\");\n }\n}\n", "test_IO": [ { "input": "1199\n", "output": "ABC\n" } ] }, { "id": "s824230885", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class s824230885 {\n\n static class InputIterator {\n ArrayList inputLine = new ArrayList(1024);\n int index = 0;\n int max;\n String read;\n\n InputIterator() {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n try {\n while ((read = br.readLine()) != null) {\n inputLine.add(read);\n }\n } catch (IOException e) {\n }\n max = inputLine.size();\n }\n\n boolean hasNext() {\n return (index < max);\n }\n\n String next() {\n if (hasNext()) {\n return inputLine.get(index++);\n } else {\n throw new IndexOutOfBoundsException(\"There is no more input\");\n }\n }\n }\n\n static HashMap CONVSTR = new HashMap();\n static InputIterator ii = new InputIterator();\n static PrintWriter out = new PrintWriter(System.out);\n\n static void flush() {\n out.flush();\n }\n\n static void myout(Object t) {\n out.println(t);\n }\n\n static void myerr(Object t) {\n System.err.print(\"debug:\");\n System.err.println(t);\n }\n\n static String next() {\n return ii.next();\n }\n\n static boolean hasNext() {\n return ii.hasNext();\n }\n\n static int nextInt() {\n return Integer.parseInt(next());\n }\n\n static long nextLong() {\n return Long.parseLong(next());\n }\n\n static double nextDouble() {\n return Double.parseDouble(next());\n }\n\n static ArrayList nextStrArray() {\n return myconv(next(), 8);\n }\n\n static ArrayList nextCharArray() {\n return myconv(next(), 0);\n }\n\n static ArrayList nextIntArray() {\n ArrayList input = nextStrArray();\n ArrayList ret = new ArrayList(input.size());\n for (int i = 0; i < input.size(); i++) {\n ret.add(Integer.parseInt(input.get(i)));\n }\n return ret;\n }\n\n static ArrayList nextLongArray() {\n ArrayList input = nextStrArray();\n ArrayList ret = new ArrayList(input.size());\n for (int i = 0; i < input.size(); i++) {\n ret.add(Long.parseLong(input.get(i)));\n }\n return ret;\n }\n\n static String myconv(Object list, int no) {\n String joinString = CONVSTR.get(no);\n if (list instanceof String[]) {\n return String.join(joinString, (String[]) list);\n } else if (list instanceof ArrayList) {\n return String.join(joinString, (ArrayList) list);\n } else {\n throw new ClassCastException(\"Don't join\");\n }\n }\n\n static ArrayList myconv(String str, int no) {\n String splitString = CONVSTR.get(no);\n return new ArrayList(Arrays.asList(str.split(splitString)));\n }\n\n public static void main(String[] args) {\n CONVSTR.put(8, \" \");\n CONVSTR.put(9, \"\\n\");\n CONVSTR.put(0, \"\");\n solve();\n flush();\n }\n\n static void solve() {\n int N = nextInt();\n ArrayList list = nextIntArray();\n int max = 0;\n int output = 0;\n for (int i = 0; i < N; i++) {\n if (max <= list.get(i)) {\n max = list.get(i);\n output++;\n }\n }\n myout(output);\n }\n}\n", "test_IO": [ { "input": "4\n6 5 6 8\n", "output": "3\n" } ] }, { "id": "s584572995", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s584572995 {\n static int mod = (int) 1e9 + 7;\n static List> to;\n static int dp[];\n\n public static void main(String[] args) {\n FastScanner fs = new FastScanner(System.in);\n int N = fs.nextInt();\n to = new ArrayList<>();\n for (int i = 0; i < N; i++) to.add(new ArrayList());\n int edges[][] = new int[N - 1][2];\n for (int i = 0; i < N - 1; i++) {\n int A = fs.nextInt() - 1, B = fs.nextInt() - 1;\n to.get(A).add(B);\n to.get(B).add(A);\n edges[i][0] = B;\n edges[i][1] = A;\n }\n dp = new int[N];\n rec(0, -1);\n long mulsum = 0;\n for (int e[] : edges) {\n\n int candidate1 = e[0];\n int candidate2 = e[1];\n int child = candidate1;\n if (dp[candidate1] > dp[candidate2]) child = candidate2;\n\n long a = dp[child];\n long b = N - a;\n\n long mul = (modpow(2, a) - 1) * (modpow(2, b) - 1) % mod;\n mulsum += mul;\n mulsum %= mod;\n }\n long cases = modpow(2, N);\n\n long PN = (mulsum + (cases - 1 + mod) % mod) % mod;\n\n long BN = N * modpow(2, N - 1) % mod;\n\n long WN = (PN - BN + mod) % mod;\n long ans = WN * modpow(cases, mod - 2);\n ans %= mod;\n\n System.out.println(ans);\n }\n\n static int rec(int v, int parent) {\n int res = 1;\n for (int next : to.get(v)) {\n if (next == parent) continue;\n res += rec(next, v);\n }\n return dp[v] = res;\n }\n\n static long modpow(long x, long y) {\n if (y == 0) return 1;\n if (y % 2 != 0) return x * modpow(x, y - 1) % mod;\n long tmp = modpow(x, y / 2);\n return tmp * tmp % mod;\n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nextLong();\n return a;\n }\n}\n", "test_IO": [ { "input": "3\n1 2\n2 3\n", "output": "125000001\n" } ] }, { "id": "s125881159", "dataset": "codenet", "language": "Java", "code": "import static java.lang.System.*;\n\nimport java.util.*;\n\npublic class s125881159 {\n public static void main(String[] $) {\n Scanner sc = new Scanner(in);\n int n = sc.nextInt();\n int d = 0;\n for (int i = 0; i < n; i++) {\n d += sc.nextInt() % 2;\n }\n out.println(d % 2 == 0 ? \"YES\" : \"NO\");\n }\n}\n", "test_IO": [ { "input": "3\n1 2 3\n", "output": "YES\n" } ] }, { "id": "s725559666", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s725559666 {\n\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int a = scan.nextInt();\n int b = scan.nextInt();\n int c = scan.nextInt();\n scan.close();\n if (a < b && b < c && a < c) {\n System.out.println(\"Yes\");\n\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s733150445", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.math.BigDecimal;\nimport java.util.StringTokenizer;\n\npublic class s733150445 {\n public static void main(String[] args) throws IOException {\n BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(in.readLine());\n BigDecimal a = new BigDecimal(st.nextToken());\n BigDecimal b = new BigDecimal(st.nextToken());\n BigDecimal mul = a.multiply(b);\n st = new StringTokenizer(mul.toString(), \".\");\n System.out.println(st.nextElement());\n }\n}\n", "test_IO": [ { "input": "198 1.10\n", "output": "217\n" } ] }, { "id": "s387083574", "dataset": "codenet", "language": "Java", "code": "import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class s387083574 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n Map map = new HashMap();\n for (int i = 1; i < N + 1; i++) map.put(i, sc.nextInt());\n System.out.println(\n String.join(\n \" \",\n map.entrySet().stream()\n .sorted(Entry.comparingByValue())\n .map(Map.Entry::getKey)\n .map(String::valueOf)\n .collect(Collectors.toList())));\n }\n}\n", "test_IO": [ { "input": "3\n2 3 1\n", "output": "3 1 2\n" } ] }, { "id": "s601569023", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s601569023 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int num = sc.nextInt();\n if (num < 1200) System.out.println(\"ABC\");\n else System.out.println(\"ARC\");\n }\n}\n", "test_IO": [ { "input": "1000\n", "output": "ABC\n" } ] }, { "id": "s449886393", "dataset": "codenet", "language": "Java", "code": "import static java.lang.System.*;\n\nimport java.math.*;\nimport java.util.*;\n\npublic class s449886393 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String[] youbi = {\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"};\n String s = sc.next();\n int ans = 0;\n for (int i = 0; i < youbi.length; i++) {\n if (youbi[i].equals(s)) {\n ans = 7 - i;\n }\n }\n out.println(ans);\n }\n}\n", "test_IO": [ { "input": "SAT\n", "output": "1\n" } ] }, { "id": "s513933260", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s513933260 {\n public static void main(String[] args) {\n Scanner stdIn = new Scanner(System.in);\n\n long n = stdIn.nextLong();\n\n System.out.println(n * (n + 1) / 2 - n);\n }\n}\n", "test_IO": [ { "input": "2\n", "output": "1\n" } ] }, { "id": "s325080396", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s325080396 {\n static final int MAX = 200000;\n\n public static void main(String[] args) {\n int[] R = new int[MAX];\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n for (int i = 0; i < n; i++) R[i] = in.nextInt();\n int maxv = R[1] - R[0];\n int minv = R[0];\n for (int i = 1; i < n; i++) {\n maxv = Math.max(maxv, R[i] - minv);\n minv = Math.min(minv, R[i]);\n }\n System.out.println(maxv);\n }\n}\n", "test_IO": [ { "input": "6\n5\n3\n1\n3\n4\n3\n", "output": "3\n" } ] }, { "id": "s041542819", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.OutputStreamWriter;\nimport java.io.UncheckedIOException;\nimport java.io.Writer;\nimport java.nio.charset.Charset;\nimport java.util.Arrays;\nimport java.util.NoSuchElementException;\nimport java.util.StringTokenizer;\n\npublic class s041542819 {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n LightScanner in = new LightScanner(inputStream);\n LightWriter out = new LightWriter(outputStream);\n DLazyFaith solver = new DLazyFaith();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class DLazyFaith {\n public void solve(int testNumber, LightScanner in, LightWriter out) {\n int a = in.ints(), b = in.ints(), q = in.ints();\n long[] s = new long[a + 2], t = new long[b + 2];\n s[0] = t[0] = -10_000_000_000L;\n for (int i = 0; i < a; i++) {\n s[i + 1] = in.longs();\n }\n for (int i = 0; i < b; i++) {\n t[i + 1] = in.longs();\n }\n s[a + 1] = t[b + 1] = 20_000_000_000L;\n for (int i = 0; i < q; i++) {\n long x = in.longs();\n long sl = x - s[Math.max(0, ArrayUtil.lowerBound(s, x + 1) - 1)];\n long tl = x - t[Math.max(0, ArrayUtil.lowerBound(t, x + 1) - 1)];\n long sr = s[ArrayUtil.lowerBound(s, x)] - x;\n long tr = t[ArrayUtil.lowerBound(t, x)] - x;\n out.ansln(\n IntMath.min(\n Math.max(sl, tl),\n Math.max(sr, tr),\n 2 * sl + tr,\n 2 * tl + sr,\n sl + 2 * tr,\n tl + 2 * sr));\n }\n }\n }\n\n static class LightScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public LightScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n }\n\n public String string() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new UncheckedIOException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int ints() {\n return Integer.parseInt(string());\n }\n\n public long longs() {\n return Long.parseLong(string());\n }\n }\n\n static class LightWriter implements AutoCloseable {\n private final Writer out;\n private boolean autoflush = false;\n private boolean breaked = true;\n\n public LightWriter(Writer out) {\n this.out = out;\n }\n\n public LightWriter(OutputStream out) {\n this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));\n }\n\n public LightWriter print(char c) {\n try {\n out.write(c);\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter print(String s) {\n try {\n out.write(s, 0, s.length());\n breaked = false;\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n return this;\n }\n\n public LightWriter ans(String s) {\n if (!breaked) {\n print(' ');\n }\n return print(s);\n }\n\n public LightWriter ans(long l) {\n return ans(Long.toString(l));\n }\n\n public LightWriter ansln(long... n) {\n for (long n1 : n) {\n ans(n1).ln();\n }\n return this;\n }\n\n public LightWriter ln() {\n print(System.lineSeparator());\n breaked = true;\n if (autoflush) {\n try {\n out.flush();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n return this;\n }\n\n public void close() {\n try {\n out.close();\n } catch (IOException ex) {\n throw new UncheckedIOException(ex);\n }\n }\n }\n\n static final class IntMath {\n private IntMath() {}\n\n public static long min(long... v) {\n return Arrays.stream(v).min().orElseThrow(NoSuchElementException::new);\n }\n }\n\n static final class ArrayUtil {\n private ArrayUtil() {}\n\n public static int lowerBound(long[] a, long t) {\n return lowerBound(a, t, 0);\n }\n\n public static int lowerBound(long[] a, long t, int min) {\n int max = a.length;\n while (min < max) {\n int mid = (min + max) / 2;\n if (t <= a[mid]) {\n max = mid;\n } else {\n min = mid + 1;\n }\n }\n return min;\n }\n }\n}\n", "test_IO": [ { "input": "2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799\n", "output": "350\n1400\n301\n399\n" } ] }, { "id": "s902370101", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s902370101 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[] array = new int[n];\n int max = 0;\n int min = 10000;\n for (int i = 0; i < array.length; i++) {\n array[i] = sc.nextInt();\n if (max < array[i]) {\n max = array[i];\n }\n\n if (min > array[i]) {\n min = array[i];\n }\n }\n System.out.println(max - min);\n sc.close();\n }\n}\n", "test_IO": [ { "input": "4\n2 3 7 9\n", "output": "7\n" } ] }, { "id": "s573993837", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s573993837 {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n InputReader in = new InputReader(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n solve(in, out);\n out.close();\n }\n\n static int L, R, top, bottom;\n\n public static void solve(InputReader sc, PrintWriter pw) {\n\n int t = 1;\n u:\n while (t-- > 0) {\n long n = sc.nextLong();\n long m = sc.nextLong();\n if (n == 0) {\n pw.println(0);\n continue u;\n }\n if (n == m) {\n pw.println(0);\n continue u;\n }\n if (n > m) {\n n = m + n % m;\n n -= m;\n pw.println(Math.min(m - n, n));\n continue u;\n }\n pw.println(Math.min(m - n, n));\n }\n }\n\n public static void swap(char[] chrr, int i, int j) {\n char temp = chrr[i];\n chrr[i] = chrr[j];\n chrr[j] = temp;\n }\n\n public static int num(int n) {\n int a = 0;\n while (n > 0) {\n a += (n & 1);\n n >>= 1;\n }\n return a;\n }\n\n static class Pair {\n int u, v, i, val;\n\n Pair(int a, int b, int i) {\n this.u = a;\n this.v = b;\n this.i = i;\n }\n }\n\n static boolean isPrime(int n) {\n if (n <= 1) return false;\n if (n <= 3) return true;\n if (n % 2 == 0 || n % 3 == 0) return false;\n for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;\n return true;\n }\n\n static long gcd(long a, long b) {\n if (b == 0) return a;\n return a > b ? gcd(b, a % b) : gcd(a, b % a);\n }\n\n static long fast_pow(long base, long n, long M) {\n if (n == 0) return 1;\n if (n == 1) return base;\n long halfn = fast_pow(base, n / 2, M);\n if (n % 2 == 0) return (halfn * halfn) % M;\n else return (((halfn * halfn) % M) * base) % M;\n }\n\n static long modInverse(long n, long M) {\n return fast_pow(n, M - 2, M);\n }\n\n public static void feedArr(long[] arr, InputReader sc) {\n for (int i = 0; i < arr.length; i++) arr[i] = sc.nextLong();\n }\n\n public static void feedArr(double[] arr, InputReader sc) {\n for (int i = 0; i < arr.length; i++) arr[i] = sc.nextDouble();\n }\n\n public static void feedArr(int[] arr, InputReader sc) {\n for (int i = 0; i < arr.length; i++) arr[i] = sc.nextInt();\n }\n\n public static void feedArr(String[] arr, InputReader sc) {\n for (int i = 0; i < arr.length; i++) arr[i] = sc.next();\n }\n\n public static String printArr(int[] arr) {\n StringBuilder sbr = new StringBuilder();\n for (int i : arr) sbr.append(i + \" \");\n return sbr.toString();\n }\n\n public static String printArr(long[] arr) {\n StringBuilder sbr = new StringBuilder();\n for (long i : arr) sbr.append(i + \" \");\n return sbr.toString();\n }\n\n public static String printArr(String[] arr) {\n StringBuilder sbr = new StringBuilder();\n for (String i : arr) sbr.append(i + \" \");\n return sbr.toString();\n }\n\n public static String printArr(double[] arr) {\n StringBuilder sbr = new StringBuilder();\n for (double i : arr) sbr.append(i + \" \");\n return sbr.toString();\n }\n\n static class InputReader {\n public BufferedReader reader;\n public StringTokenizer tokenizer;\n\n public InputReader(InputStream stream) {\n reader = new BufferedReader(new InputStreamReader(stream), 32768);\n tokenizer = null;\n }\n\n public String next() {\n while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n}\n", "test_IO": [ { "input": "7 4\n", "output": "1\n" } ] }, { "id": "s511234019", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s511234019 {\n public static void main(String[] args) throws java.lang.Exception {\n Scanner in = new Scanner(System.in);\n int a, b;\n a = in.nextInt();\n b = in.nextInt();\n if (a % 2 == 0 || b % 2 == 0) System.out.println(\"No\");\n else System.out.println(\"Yes\");\n }\n}\n", "test_IO": [ { "input": "3 1\n", "output": "Yes\n" } ] }, { "id": "s494783955", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s494783955 {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n String C = sc.next();\n\n System.out.println((char) (C.charAt(0) + 1));\n }\n}\n", "test_IO": [ { "input": "a\n", "output": "b\n" } ] }, { "id": "s059916837", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s059916837 {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String S = scanner.nextLine();\n String T = scanner.nextLine();\n int min = Integer.MAX_VALUE;\n for (int i = 0; i <= S.length() - T.length(); i++) {\n min = Math.min(min, find(S.substring(i, i + T.length()), T));\n }\n if (min != Integer.MAX_VALUE) {\n System.out.println(min);\n } else {\n System.out.println(T.length());\n }\n }\n\n public static int find(String a, String b) {\n int calc = 0;\n for (int x = 0; x < a.length(); x++) {\n if (a.charAt(x) != b.charAt(x)) {\n calc++;\n }\n }\n return calc;\n }\n}\n", "test_IO": [ { "input": "cabacc\nabc\n", "output": "1\n" } ] }, { "id": "s458826999", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s458826999 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n String S = sc.next();\n long MOD = 1000000007;\n long dp[][] = new long[S.length() + 1][13];\n dp[0][0] = 1;\n for (int i = 0; i < S.length(); i++) {\n if (S.substring(i, i + 1).equals(\"?\")) {\n for (int j = 0; j < 10; j++) {\n for (int k = 0; k < 13; k++) {\n dp[i + 1][(k * 10 + j) % 13] += dp[i][k];\n dp[i + 1][(k * 10 + j) % 13] %= MOD;\n }\n }\n } else {\n for (int k = 0; k < 13; k++) {\n int x = Integer.parseInt(S.substring(i, i + 1));\n dp[i + 1][(k * 10 + x) % 13] += dp[i][k];\n dp[i + 1][(k * 10 + x) % 13] %= MOD;\n }\n }\n }\n System.out.println(dp[S.length()][5]);\n }\n}\n", "test_IO": [ { "input": "??2??5\n", "output": "768\n" } ] }, { "id": "s780604068", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s780604068 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n\n int[] map = new int[N * 2];\n for (int i = 0; i < N * 2; i++) {\n map[i] = sc.nextInt();\n }\n\n Arrays.sort(map);\n\n int max = 0;\n for (int i = 0; i < N * 2; i += 2) {\n max += Math.min(map[i], map[i + 1]);\n }\n\n System.out.println(max);\n }\n}\n", "test_IO": [ { "input": "2\n1 3 1 2\n", "output": "3\n" } ] }, { "id": "s685537842", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s685537842 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int t = sc.nextInt();\n double time = 0;\n int count = 0;\n while (time < t + 0.5) {\n count += b;\n time += a;\n if (time > t + 0.5) {\n count -= b;\n break;\n }\n }\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "3 5 7\n", "output": "10\n" } ] }, { "id": "s319823779", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s319823779 {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n int x = sc.nextInt();\n\n int res = 0;\n\n for (int i = 0; i <= a; i++) {\n for (int j = 0; j <= b; j++) {\n for (int k = 0; k <= c; k++) {\n int total = 500 * i + 100 * j + 50 * k;\n\n if (total == x) {\n res++;\n }\n }\n }\n }\n System.out.println(res);\n }\n}\n", "test_IO": [ { "input": "2\n2\n2\n100\n", "output": "2\n" } ] }, { "id": "s320655609", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.nio.charset.StandardCharsets;\nimport java.util.*;\n\npublic class s320655609 {\n List constraints = new ArrayList<>();\n long N;\n long result;\n\n s320655609() throws IOException {\n InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);\n BufferedReader in = new BufferedReader(reader);\n this.N = Long.parseLong(in.readLine());\n for (int i = 0; i < 5; ++i) {\n this.constraints.add(Long.parseLong(in.readLine()));\n }\n in.close();\n\n this.calc();\n }\n\n void calc() {\n long min = Long.MAX_VALUE;\n for (Long c : this.constraints) {\n min = Math.min(min, c);\n }\n long time = this.N / min;\n if (this.N % min != 0) {\n ++time;\n }\n time += 4;\n this.result = time;\n }\n\n public static void main(String[] args) throws IOException {\n s320655609 ins = new s320655609();\n System.out.println(ins.result);\n }\n}\n", "test_IO": [ { "input": "5\n3\n2\n4\n3\n5\n", "output": "7\n" } ] }, { "id": "s047401835", "dataset": "codenet", "language": "Java", "code": "import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\nimport java.util.stream.Collectors;\n\npublic class s047401835 {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int N = scanner.nextInt();\n List numbers = new ArrayList();\n\n for (int i = 0; i < N; i++) {\n numbers.add(Integer.parseInt(scanner.next()));\n }\n\n int count = 0;\n\n do {\n numbers =\n numbers.stream()\n .filter(i -> (i % 2) == 0)\n .map(i -> i / 2)\n .collect(Collectors.toList());\n if (numbers.size() == N) count++;\n } while (numbers.size() == N);\n\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "3\n8 12 40\n", "output": "2\n" } ] }, { "id": "s831281137", "dataset": "codenet", "language": "Java", "code": "import java.io.PrintStream;\nimport java.util.Scanner;\n\npublic class s831281137 {\n static final Scanner sc = new Scanner(System.in);\n static final PrintStream so = System.out;\n\n public static void main(String[] args) {\n int N = nint();\n int W = nint();\n\n int[] v = new int[N + 1];\n int[] w = new int[N + 1];\n\n for (int i = 1; i <= N; i++) {\n v[i] = nint();\n w[i] = nint();\n }\n\n int[][] sumV = new int[N + 1][W + 1];\n\n for (int i = 1; i <= N; i++) {\n for (int i_sum = 0; i_sum < w[i]; i_sum++) {\n sumV[i][i_sum] = sumV[i - 1][i_sum];\n }\n\n for (int i_sum = w[i]; i_sum <= W; i_sum++) {\n sumV[i][i_sum] = Math.max(sumV[i - 1][i_sum], sumV[i - 1][i_sum - w[i]] + v[i]);\n }\n }\n\n so.println(sumV[N][W]);\n }\n\n private static long nlong() {\n return sc.nextLong();\n }\n\n private static int nint() {\n return sc.nextInt();\n }\n\n private static String nstr() {\n return sc.next();\n }\n\n private static char[] nsToChars() {\n return sc.next().toCharArray();\n }\n\n private static long[] nlongs(int n) {\n return nlongs(n, 0, 0);\n }\n\n private static int[] nints(int n) {\n return nints(n, 0, 0);\n }\n\n private static int[] nints(int n, int padL, int padR) {\n int[] a = new int[padL + n + padR];\n for (int i = 0; i < n; i++) a[padL + i] = nint();\n return a;\n }\n\n private static long[] nlongs(int n, int padL, int padR) {\n long[] a = new long[padL + n + padR];\n for (int i = 0; i < n; i++) a[padL + i] = nlong();\n return a;\n }\n\n private static String[] nstrs(int n) {\n String[] a = new String[n];\n for (int i = 0; i < n; i++) a[i] = nstr();\n return a;\n }\n\n private static char[][] nsToChars2D(int h, int w) {\n return nsToChars2D(h, w, 0);\n }\n\n private static char[][] nsToChars2D(int h, int w, int pad) {\n char[][] a2 = new char[h + pad * 2][w + pad * 2];\n for (int i = 0; i < h; i++) System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);\n return a2;\n }\n}\n", "test_IO": [ { "input": "4 5\n4 2\n5 2\n2 1\n8 3\n", "output": "13\n" } ] }, { "id": "s745776078", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s745776078 {\n\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n int n = in.nextInt(), m = in.nextInt(), A[][] = new int[n][m], b[] = new int[m];\n\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) A[i][j] = in.nextInt();\n }\n\n for (int i = 0; i < m; i++) b[i] = in.nextInt();\n\n for (int i = 0; i < n; i++) {\n int c = 0;\n for (int j = 0; j < m; j++) {\n c += A[i][j] * b[j];\n }\n out.println(c);\n }\n\n out.flush();\n }\n}\n", "test_IO": [ { "input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n", "output": "5\n6\n9\n" } ] }, { "id": "s826491904", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s826491904 {\n\n public static final void main(String[] args) {\n new s826491904().solve();\n }\n\n private final Scanner sc = new Scanner(System.in);\n\n void solve() {\n int N = sc.nextInt();\n int max, min;\n max = min = sc.nextInt();\n for (int i = 1; i < N; i++) {\n int in = sc.nextInt();\n max = Math.max(max, in);\n min = Math.min(min, in);\n }\n System.out.println(max - min);\n }\n}\n", "test_IO": [ { "input": "4\n2 3 7 9\n", "output": "7\n" } ] }, { "id": "s893190600", "dataset": "codenet", "language": "Java", "code": "import static java.util.Comparator.*;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.AbstractMap;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.Set;\nimport java.util.Stack;\nimport java.util.TreeMap;\nimport java.util.TreeSet;\n\npublic class s893190600 {\n\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n MyInput in = new MyInput(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n\n Solver solver = new Solver(in, out);\n solver.solve();\n\n out.close();\n }\n\n static class Solver {\n MyInput in;\n PrintWriter out;\n\n public Solver(MyInput in, PrintWriter out) {\n this.in = in;\n this.out = out;\n }\n\n public void solve() {\n int H = ni();\n int W = ni();\n char[][] C = new char[H + 2][W + 2];\n char[] c;\n for (int i = 0; i < H; i++) {\n c = ns().toCharArray();\n for (int j = 0; j < W; j++) {\n C[i + 1][j + 1] = c[j];\n }\n }\n if (H == 1 && W == 1) {\n prn(\"No\");\n return;\n }\n for (int i = 1; i <= H; i++) {\n for (int j = 1; j <= W; j++) {\n if (C[i][j] == '#'\n && C[i - 1][j] != '#'\n && C[i + 1][j] != '#'\n && C[i][j - 1] != '#'\n && C[i][j + 1] != '#') {\n prn(\"No\");\n return;\n }\n }\n }\n prn(\"Yes\");\n }\n\n static class MapCounter {\n private TreeMap map;\n\n public MapCounter() {\n map = new TreeMap<>();\n }\n\n public MapCounter(boolean reverse) {\n if (reverse) {\n map = new TreeMap(Collections.reverseOrder());\n } else {\n map = new TreeMap<>();\n }\n }\n\n public void add(Integer key) {\n add(key, 1);\n }\n\n public void add(Integer key, int cnt) {\n Integer val = map.get(key);\n if (val == null) {\n map.put(key, cnt);\n } else {\n map.put(key, val + cnt);\n }\n }\n\n public void remove(Integer key) {\n sub(key, 1, false);\n }\n\n public void sub(Integer key) {\n sub(key, 1);\n }\n\n public void sub(Integer key, int cnt) {\n sub(key, cnt, true);\n }\n\n public void sub(Integer key, int cnt, boolean minus) {\n Integer val = map.get(key);\n if (val == null) {\n if (minus) {\n map.put(key, -cnt);\n }\n } else if (val > cnt || minus) {\n map.put(key, val - cnt);\n } else {\n map.remove(key);\n }\n }\n\n public void set(Integer key, int cnt) {\n map.put(key, cnt);\n }\n\n public Integer getCountwithNull(Integer key) {\n return map.get(key);\n }\n\n public Integer getCount(Integer key) {\n Integer val = map.get(key);\n if (val == null) return 0;\n else return val;\n }\n\n public Set getKey() {\n return map.keySet();\n }\n\n public int getKeyCount() {\n return map.keySet().size();\n }\n\n public Integer getFirstKey() {\n return map.firstKey();\n }\n\n public Integer getLastKey() {\n return map.lastKey();\n }\n\n public void clear() {\n map.clear();\n }\n }\n\n boolean isRightMin(int[] a, boolean f, int index, int key) {\n if (f && a[index] >= key) return true;\n else if (!f && a[index] > key) return true;\n else return false;\n }\n\n int binarySearchRightMin(int[] a, boolean f, int key) {\n int ng = -1;\n int ok = (int) a.length;\n\n while (Math.abs(ok - ng) > 1) {\n int mid = (ok + ng) / 2;\n\n if (isRightMin(a, f, mid, key)) ok = mid;\n else ng = mid;\n }\n return ok;\n }\n\n boolean isLeftMax(int[] a, boolean f, int index, int key) {\n if (f && a[index] <= key) return true;\n else if (!f && a[index] < key) return true;\n else return false;\n }\n\n int binarySearchLeftMax(int[] a, boolean f, int key) {\n int ng = -1;\n int ok = (int) a.length;\n\n while (Math.abs(ok - ng) > 1) {\n int mid = (ok + ng) / 2;\n\n if (isLeftMax(a, f, mid, key)) ng = mid;\n else ok = mid;\n }\n return ng;\n }\n\n static class EulerTour {\n Graph g;\n List euler_tour = new ArrayList<>();\n int[] begin, end;\n int k = 0, root = 0;\n\n void dfs(int v, int p, PrintWriter out) {\n out.println(\"v = \" + v + \" p = \" + p);\n begin[v] = k;\n euler_tour.add(v);\n k++;\n if (!g.contains(v)) {\n return;\n }\n for (int i : g.get(v)) {\n if (i != p) {\n dfs(i, v, out);\n euler_tour.add(v);\n k++;\n }\n }\n end[v] = k;\n }\n\n public void init(int p_cnt, int root, Graph g, PrintWriter out) {\n begin = new int[p_cnt + 1];\n end = new int[p_cnt + 1];\n this.root = root;\n this.g = g;\n dfs(root, -1, out);\n }\n\n public List getPartTour(int v) {\n return euler_tour.subList(begin[v], end[v]);\n }\n\n public List getPartList(int v) {\n Set set = new TreeSet<>();\n set.addAll(getPartTour(v));\n List ans = new ArrayList<>();\n for (Integer p : set) {\n ans.add(p);\n }\n return ans;\n }\n }\n\n class Graph {\n\n private Map> data = new HashMap>();\n\n void add(int from, int to) {\n List list = data.get(from);\n if (list == null) {\n list = new ArrayList();\n data.put(from, list);\n }\n list.add(to);\n }\n\n void del(int from, int to) {\n List list = data.get(from);\n if (list == null) {\n return;\n }\n if (list.contains(to)) {\n list.remove((Object) to);\n }\n }\n\n List get(int key) {\n return data.get(key);\n }\n\n boolean contains(int key) {\n return data.containsKey(key);\n }\n\n Set keySet() {\n return data.keySet();\n }\n\n boolean isConnect(int key_1, int key_2) {\n List list = data.get(key_1);\n if (list == null) return false;\n else return list.contains(key_2);\n }\n\n List distList(int key) {\n List dist = new ArrayList<>();\n Set mark = new HashSet<>();\n Stack stack = new Stack<>();\n stack.push(new PP(key, 0));\n while (!stack.isEmpty()) {\n PP wk = stack.pop();\n int pp = wk.getKey();\n int dd = wk.getVal();\n mark.add(pp);\n dist.add(new PP(pp, dd));\n List list = get(pp);\n for (int next : list) {\n if (mark.contains(next)) continue;\n stack.push(new PP(next, dd + 1));\n }\n }\n return dist;\n }\n\n int[] distV(int key) {\n int[] dist = new int[data.keySet().size() + 1];\n Arrays.fill(dist, -1);\n Set mark = new HashSet<>();\n Stack stack = new Stack<>();\n stack.push(new PP(key, 0));\n while (!stack.isEmpty()) {\n PP wk = stack.pop();\n int pp = wk.getKey();\n int dd = wk.getVal();\n mark.add(pp);\n dist[pp] = dd;\n List list = get(pp);\n for (int next : list) {\n if (mark.contains(next)) continue;\n stack.push(new PP(next, dd + 1));\n }\n }\n return dist;\n }\n\n Map mapCnt = new HashMap<>();\n Map mapLow = new HashMap<>();\n\n Set mark = new HashSet<>();\n int number;\n\n int bridgeDfs(int now, int pre) {\n\n mark.add(now);\n mapCnt.put(now, number);\n mapLow.put(now, number);\n int low;\n for (int next : get(now)) {\n if (next == pre) continue;\n if (mark.contains(next)) {\n if (mapLow.get(now) > mapLow.get(next)) {\n\n mapLow.put(now, mapLow.get(next));\n }\n continue;\n }\n number++;\n low = bridgeDfs(next, now);\n if (mapLow.get(now) > low) {\n mapLow.put(now, low);\n }\n }\n return mapLow.get(now);\n }\n\n int bridgeCnt(int start) {\n mapCnt.clear();\n mapLow.clear();\n mark.clear();\n number = 0;\n bridgeDfs(start, start);\n int ans = 0;\n for (int key : mapCnt.keySet()) {\n if (mapCnt.get(key) == mapLow.get(key)) {\n ans++;\n }\n }\n return ans - 1;\n }\n\n void dump(PrintWriter out) {\n for (int key : data.keySet()) {\n out.print(key + \" : \");\n for (int val : data.get(key)) {\n out.print(val + \" \");\n }\n out.println(\"\");\n }\n }\n }\n\n static class GraphWith {\n\n private Map> data = new HashMap>();\n\n void add(int key, PP p) {\n List list = data.get(key);\n if (list == null) {\n list = new ArrayList();\n data.put(key, list);\n }\n list.add(p);\n }\n\n List get(int key) {\n return data.get(key);\n }\n\n boolean contains(int key) {\n return data.containsKey(key);\n }\n\n Set keySet() {\n return data.keySet();\n }\n\n boolean isConnect(int key_1, int key_2) {\n List list = data.get(key_1);\n if (list == null) return false;\n boolean ans = false;\n for (PP p : list) {\n if (p.getKey() == key_2) {\n ans = true;\n break;\n }\n }\n return ans;\n }\n\n int distance(int key_1, int key_2) {\n Set mark = new HashSet<>();\n Stack stack = new Stack<>();\n stack.push(new PP(key_1, 0));\n PP wk;\n int key, val;\n List list;\n while (!stack.isEmpty()) {\n wk = stack.pop();\n key = wk.getKey();\n val = wk.getVal();\n mark.add(key);\n if (key == key_2) return val;\n\n list = get(key);\n if (list == null) continue;\n for (PP pp : list) {\n if (mark.contains(pp.getKey())) continue;\n stack.push(new PP(pp.getKey(), val + pp.getVal()));\n }\n }\n return Integer.MAX_VALUE;\n }\n }\n\n static class GraphLong {\n private Map> G = new HashMap>();\n\n void add(long key, long value) {\n List list = G.get(key);\n if (list == null) {\n list = new ArrayList();\n G.put(key, list);\n }\n list.add(value);\n }\n\n List get(long key) {\n return G.get(key);\n }\n }\n\n static class GraphLongWith {\n private Map> G = new HashMap>();\n\n void add(long key, PPL p) {\n List list = G.get(key);\n if (list == null) {\n list = new ArrayList();\n G.put(key, list);\n }\n list.add(p);\n }\n\n List get(long key) {\n return G.get(key);\n }\n }\n\n void prn(String s) {\n out.println(s);\n }\n\n void prn(int i) {\n out.println(i);\n }\n\n void prn(long i) {\n out.println(i);\n }\n\n void prr(String s) {\n out.print(s);\n }\n\n int ni() {\n return in.nextInt();\n }\n\n long nl() {\n return in.nextLong();\n }\n\n double nd() {\n return in.nextDouble();\n }\n\n String ns() {\n return in.nextString();\n }\n\n int[] ndi(int n) {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++) {\n ans[i] = ni();\n }\n return ans;\n }\n\n long[] ndl(int n) {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++) {\n ans[i] = nl();\n }\n return ans;\n }\n\n double[] ndd(int n) {\n double[] ans = new double[n];\n for (int i = 0; i < n; i++) {\n ans[i] = nd();\n }\n return ans;\n }\n\n String[] nds(int n) {\n String[] ans = new String[n];\n for (int i = 0; i < n; i++) {\n ans[i] = ns();\n }\n return ans;\n }\n\n int[][] nddi(int n, int m) {\n int[][] ans = new int[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n ans[i][j] = ni();\n }\n }\n return ans;\n }\n\n long[][] nddl(int n, int m) {\n long[][] ans = new long[n][m];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n ans[i][j] = nl();\n }\n }\n return ans;\n }\n }\n\n static class PP {\n public int key, val;\n\n public PP(int key, int val) {\n this.key = key;\n this.val = val;\n }\n\n public int getKey() {\n return key;\n }\n\n public void setKey(int key) {\n this.key = key;\n }\n\n public int getVal() {\n return val;\n }\n\n public void setVal(int val) {\n this.val = val;\n }\n }\n\n static class PPP {\n public int key, val1, val2;\n\n public PPP(int key, int val1, int val2) {\n this.key = key;\n this.val1 = val1;\n this.val2 = val2;\n }\n\n public int getKey() {\n return key;\n }\n\n public void setKey(int key) {\n this.key = key;\n }\n\n public int getVal1() {\n return val1;\n }\n\n public void setVal1(int val1) {\n this.val1 = val1;\n }\n\n public int getVal2() {\n return val2;\n }\n\n public void setVal2(int val2) {\n this.val2 = val2;\n }\n }\n\n static class PPL {\n public long key, val;\n\n public PPL(long key, long val) {\n this.key = key;\n this.val = val;\n }\n\n public long getKey() {\n return key;\n }\n\n public void setKey(long key) {\n this.key = key;\n }\n\n public long getVal() {\n return val;\n }\n\n public void setVal(long val) {\n this.val = val;\n }\n }\n\n static class PPDL {\n public long key;\n public long[] val;\n\n public PPDL(long key, long[] val) {\n this.key = key;\n this.val = val;\n }\n\n public long getKey() {\n return key;\n }\n\n public void setKey(long key) {\n this.key = key;\n }\n\n public long[] getVal() {\n return val;\n }\n\n public void setVal(long[] val) {\n this.val = val;\n }\n\n public void dump(PrintWriter out) {\n out.print(\"key = \" + key + \" val \");\n for (int i = 0; i < val.length; i++) {\n out.print(\"[\" + val[i] + \"] \");\n }\n out.println(\"\");\n }\n }\n\n static final class PPKEY {\n private final int key, val;\n\n public PPKEY(int key, int val) {\n this.key = key;\n this.val = val;\n }\n\n public int getKey() {\n return key;\n }\n\n public int getVal() {\n return val;\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj instanceof PPKEY) {\n PPKEY dest = (PPKEY) obj;\n return this.key == dest.key && this.val == dest.val;\n } else {\n return false;\n }\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(key, val);\n }\n }\n\n static final class PPLKEY {\n private final long key, val;\n\n public PPLKEY(long key, long val) {\n this.key = key;\n this.val = val;\n }\n\n public long getKey() {\n return key;\n }\n\n public long getVal() {\n return val;\n }\n\n @Override\n public boolean equals(Object obj) {\n if (obj instanceof PPKEY) {\n PPKEY dest = (PPKEY) obj;\n return this.key == dest.key && this.val == dest.val;\n } else {\n return false;\n }\n }\n\n @Override\n public int hashCode() {\n return Objects.hash(key, val);\n }\n }\n\n static class Pair extends AbstractMap.SimpleEntry {\n\n private static final long serialVersionUID = 6411527075103472113L;\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n }\n\n static class MyInput {\n private final BufferedReader in;\n private static int pos;\n private static int readLen;\n private static final char[] buffer = new char[1024 * 8];\n private static char[] str = new char[500 * 8 * 2];\n private static boolean[] isDigit = new boolean[256];\n private static boolean[] isSpace = new boolean[256];\n private static boolean[] isLineSep = new boolean[256];\n\n static {\n for (int i = 0; i < 10; i++) {\n isDigit['0' + i] = true;\n }\n isDigit['-'] = true;\n isSpace[' '] = isSpace['\\r'] = isSpace['\\n'] = isSpace['\\t'] = true;\n isLineSep['\\r'] = isLineSep['\\n'] = true;\n }\n\n public MyInput(InputStream is) {\n in = new BufferedReader(new InputStreamReader(is));\n }\n\n public int read() {\n if (pos >= readLen) {\n pos = 0;\n try {\n readLen = in.read(buffer);\n } catch (IOException e) {\n throw new RuntimeException();\n }\n if (readLen <= 0) {\n throw new MyInput.EndOfFileRuntimeException();\n }\n }\n return buffer[pos++];\n }\n\n public int nextInt() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n int ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public long nextLong() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n long ret = 0L;\n if (str[0] == '-') {\n i = 1;\n }\n for (; i < len; i++) ret = ret * 10 + str[i] - '0';\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public double nextDouble() {\n int len = 0;\n str[len++] = nextChar();\n len = reads(len, isSpace);\n int i = 0;\n double ret = 0;\n if (str[0] == '-') {\n i = 1;\n }\n int cnt = 0;\n for (; i < len; i++) {\n if (str[i] == '.') {\n cnt = 10;\n continue;\n }\n if (cnt == 0) {\n ret = ret * 10 + str[i] - '0';\n } else {\n ret = ret + ((double) (str[i] - '0') / cnt);\n cnt *= 10;\n }\n }\n if (str[0] == '-') {\n ret = -ret;\n }\n return ret;\n }\n\n public String nextString() {\n String ret = new String(nextDChar()).trim();\n return ret;\n }\n\n public char[] nextDChar() {\n int len = 0;\n len = reads(len, isSpace);\n char[] ret = new char[len + 1];\n for (int i = 0; i < len; i++) ret[i] = str[i];\n ret[len] = 0x00;\n return ret;\n }\n\n public char nextChar() {\n while (true) {\n final int c = read();\n if (!isSpace[c]) {\n return (char) c;\n }\n }\n }\n\n int reads(int len, boolean[] accept) {\n try {\n while (true) {\n final int c = read();\n if (accept[c]) {\n break;\n }\n if (str.length == len) {\n char[] rep = new char[str.length * 3 / 2];\n System.arraycopy(str, 0, rep, 0, str.length);\n str = rep;\n }\n str[len++] = (char) c;\n }\n } catch (MyInput.EndOfFileRuntimeException e) {\n }\n return len;\n }\n\n static class EndOfFileRuntimeException extends RuntimeException {}\n }\n}\n", "test_IO": [ { "input": "3 3\n.#.\n###\n.#.\n", "output": "Yes\n" } ] }, { "id": "s739337307", "dataset": "codenet", "language": "Java", "code": "import java.math.*;\nimport java.util.*;\n\nclass s739337307 {\n public static void main(String[] args) {\n\n try (Scanner sc = new Scanner(System.in)) {\n\n int n = Integer.parseInt(sc.next());\n int m = Integer.parseInt(sc.next());\n\n HashMap map = new HashMap<>();\n\n int countAc = 0;\n int countWaAll = 0;\n\n for (int i = 0; i < m; i++) {\n int question = Integer.parseInt(sc.next());\n String waOrAc = sc.next();\n\n if (!map.containsKey(question)) {\n if (waOrAc.equals(\"WA\")) map.put(question, 1);\n else {\n map.put(question, -1);\n countAc++;\n }\n } else {\n int countWa = map.get(question);\n if (countWa < 0)\n ;\n else {\n if (waOrAc.equals(\"WA\")) map.replace(question, countWa, countWa + 1);\n else {\n map.replace(question, countWa, -countWa);\n countAc++;\n countWaAll += countWa;\n }\n }\n }\n }\n\n System.out.println(countAc + \" \" + countWaAll);\n\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n}\n", "test_IO": [ { "input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "output": "2 2\n" } ] }, { "id": "s596918302", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s596918302 {\n public static void main(String args[]) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int[][] arr = new int[n][3];\n\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < 3; j++) arr[i][j] = sc.nextInt();\n }\n\n int ans = 0;\n\n ans = dpx(arr, n);\n System.out.println(ans);\n }\n\n static int min(int[] arr, int n) {\n if (n == 1) return 0;\n if (n == 2) return Math.abs(arr[n - 1] - arr[n - 2]);\n int op1 = Math.abs(arr[n - 1] - arr[n - 2]) + min(arr, n - 1);\n int op2 = Math.abs(arr[n - 1] - arr[n - 3]) + min(arr, n - 2);\n int res = Math.min(op1, op2);\n\n return res;\n }\n\n static int dpc(int[][] arr, int i, int n, int row) {\n if (row == n) return 0;\n int j = 0;\n int k = 0;\n if (i == 1) {\n j = 0;\n k = 2;\n } else if (i == 0) {\n j = 1;\n k = 2;\n } else {\n j = 0;\n k = 1;\n }\n\n return arr[row][i] + Math.max(dpc(arr, j, n, row + 1), dpc(arr, k, n, row + 1));\n }\n\n static int dpx(int[][] arr, int n) {\n int[][] dp = new int[n][3];\n\n dp[0][0] = arr[0][0];\n dp[0][1] = arr[0][1];\n dp[0][2] = arr[0][2];\n\n for (int i = 1; i < n; i++) {\n for (int in = 0; in < 3; in++) {\n int j = 0, k = 0;\n if (in == 1) {\n j = 0;\n k = 2;\n } else if (in == 0) {\n j = 1;\n k = 2;\n } else {\n j = 0;\n k = 1;\n }\n dp[i][in] = Math.max(dp[i - 1][k], dp[i - 1][j]) + arr[i][in];\n }\n }\n\n return Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2]));\n }\n}\n", "test_IO": [ { "input": "3\n10 40 70\n20 50 80\n30 60 90\n", "output": "210\n" } ] }, { "id": "s701317277", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s701317277 {\n\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n int N = sc.nextInt();\n int[] A = new int[N];\n int min = Integer.MAX_VALUE;\n int count = 0;\n long sum = 0;\n for (int i = 0; i < N; i++) {\n A[i] = sc.nextInt();\n if (A[i] < 0) count++;\n min = Math.min(min, Math.abs(A[i]));\n sum += Math.abs(A[i]);\n }\n sc.close();\n\n if (count % 2 == 0) System.out.println(sum);\n else {\n System.out.println(sum - min * 2);\n }\n }\n}\n", "test_IO": [ { "input": "3\n-10 5 -4\n", "output": "19\n" } ] }, { "id": "s125278297", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s125278297 {\n static Scanner scanner = new Scanner(System.in);\n\n public static void main(String[] $) {\n int h = scanner.nextInt();\n int w = scanner.nextInt();\n String[] ans = new String[h];\n for (int i = 0; i < h; i++) {\n ans[i] = \"#\" + scanner.next() + \"#\";\n }\n System.out.println(String.valueOf(new char[w + 2]).replace('\\0', '#'));\n for (String s : ans) {\n System.out.println(s);\n }\n System.out.println(String.valueOf(new char[w + 2]).replace('\\0', '#'));\n }\n}\n", "test_IO": [ { "input": "2 3\nabc\narc\n", "output": "#####\n#abc#\n#arc#\n#####\n" } ] }, { "id": "s670290220", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s670290220 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n char c[] = sc.next().toCharArray();\n for (int i = 0; i < c.length; i++) {\n c[i] = (char) ((c[i] - 'A' + N) % 26 + 'A');\n }\n System.out.println(c);\n }\n}\n", "test_IO": [ { "input": "2\nABCXYZ\n", "output": "CDEZAB\n" } ] }, { "id": "s552480860", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s552480860 {\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int h1 = sc.nextInt();\n int m1 = sc.nextInt();\n int h2 = sc.nextInt();\n int m2 = sc.nextInt();\n int k = sc.nextInt();\n int t1 = h1 * 60 + m1;\n int t2 = h2 * 60 + m2;\n System.out.println(t2 - t1 - k);\n }\n}\n", "test_IO": [ { "input": "10 0 15 0 30\n", "output": "270\n" } ] }, { "id": "s504715611", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.NoSuchElementException;\nimport java.util.Random;\nimport java.util.Scanner;\n\nclass UnionFind {\n int Parent[];\n\n UnionFind(int n) {\n Parent = new int[n];\n Arrays.fill(Parent, -1);\n }\n\n int root(int A) {\n if (Parent[A] < 0) return A;\n return Parent[A] = root(Parent[A]);\n }\n\n int size(int A) {\n return -Parent[root(A)];\n }\n\n boolean connect(int A, int B) {\n A = root(A);\n B = root(B);\n if (A == B) return false;\n if (size(A) < size(B)) {\n int C = 0;\n C = B;\n B = A;\n A = C;\n }\n Parent[A] += Parent[B];\n Parent[B] = A;\n return true;\n }\n}\n\npublic class s504715611 {\n static FastScanner scan = new FastScanner();\n static Scanner scanner = new Scanner(System.in);\n static Random rand = new Random();\n static long mod = 1000000007;\n static double eps = 1.0E-14;\n static int big = Integer.MAX_VALUE;\n static double PI = 3.14159265358979323846262338327950288;\n\n static long modlcm(long a, long b) {\n return a * b * modint(gcd(a, b), mod);\n }\n\n static long gcd(long a, long b) {\n return b > 0 ? gcd(b, a % b) : a;\n }\n\n static long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n static int max(int a, int b) {\n return a > b ? a : b;\n }\n\n static int min(int a, int b) {\n return a < b ? a : b;\n }\n\n static long lmax(long a, long b) {\n return Math.max(a, b);\n }\n\n static long lmin(long a, long b) {\n return Math.min(a, b);\n }\n\n static long factorial(int i) {\n return i == 1 ? 1 : i * factorial(i - 1);\n }\n\n public static void main(String[] args) throws IOException {\n String str = scan.next();\n System.out.println(\n str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5) ? \"Yes\" : \"No\");\n }\n\n static int lower_bound(int a[], int key) {\n int right = a.length;\n int left = 0;\n while (right - left > 1) {\n int mid = (right + left) / 2;\n if (a[mid] < key) {\n left = mid;\n } else {\n right = mid;\n }\n }\n return left;\n }\n\n static int upper_bound(int a[], int key) {\n int right = a.length;\n int left = 0;\n while (right - left > 1) {\n int mid = (right + left) / 2;\n if (a[mid] <= key) {\n left = mid;\n } else {\n right = mid;\n }\n }\n return left;\n }\n\n static boolean isPrime(long n) {\n if (n == 2) return true;\n if (n < 2 || n % 2 == 0) return false;\n double d = Math.sqrt(n);\n for (int i = 3; i <= d; i += 2)\n if (n % i == 0) {\n return false;\n }\n return true;\n }\n\n static int upper_division(int a, int b) {\n if (a % b == 0) {\n return a / b;\n } else {\n return a / b + 1;\n }\n }\n\n static long lupper_division(long a, long b) {\n if (a % b == 0) {\n return a / b;\n } else {\n return a / b + 1;\n }\n }\n\n static int[] setArray(int a) {\n int b[] = new int[a];\n for (int i = 0; i < a; i++) {\n b[i] = scan.nextInt();\n }\n return b;\n }\n\n static long[] lsetArray(int a) {\n long b[] = new long[a];\n for (int i = 0; i < a; i++) {\n b[i] = scan.nextLong();\n }\n return b;\n }\n\n static String reverse(String str) {\n char ch[] = new char[str.length()];\n char chch[] = str.toCharArray();\n int a = str.length();\n for (int i = 0; i < upper_division(a, 2); i++) {\n ch[i] = chch[ch.length - i - 1];\n ch[ch.length - 1 - i] = chch[i];\n }\n return String.valueOf(ch);\n }\n\n public static void printArray(int[] que) {\n for (int i = 0; i < que.length - 1; i++) {\n System.out.print(que[i] + \" \");\n }\n System.out.println(que[que.length - 1]);\n }\n\n public static int[][] doublesort(int[][] a) {\n Arrays.sort(a, (x, y) -> Integer.compare(x[0], y[0]));\n return a;\n }\n\n public static long[][] ldoublesort(long[][] a) {\n Arrays.sort(a, (x, y) -> Long.compare(x[0], y[0]));\n return a;\n }\n\n static long modpow(long x, long n, long mo) {\n long sum = 1;\n while (n > 0) {\n if ((n & 1) == 1) {\n sum = sum * x % mo;\n }\n x = x * x % mo;\n n >>= 1;\n }\n return sum;\n }\n\n public static char[] revch(char ch[]) {\n char ret[] = new char[ch.length];\n for (int i = ch.length - 1, j = 0; i >= 0; i--, j++) {\n ret[j] = ch[i];\n }\n return ret;\n }\n\n public static int[] revint(int ch[]) {\n int ret[] = new int[ch.length];\n for (int i = ch.length - 1, j = 0; i >= 0; i--, j++) {\n ret[j] = ch[i];\n }\n return ret;\n }\n\n public static void warshall_floyd(int v[][], int n) {\n for (int k = 0; k < n; k++)\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) v[i][j] = min(v[i][j], v[i][k] + v[k][j]);\n }\n\n public static long modint(long a, long m) {\n long b = m, u = 1, v = 0;\n while (b != 0) {\n long t = a / b;\n a -= t * b;\n long x = a;\n a = b;\n b = x;\n\n u -= t * v;\n x = u;\n u = v;\n v = x;\n }\n u %= m;\n if (u < 0) u += m;\n return u;\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public char nextchar() {\n try {\n return (char) System.in.read();\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n}\n", "test_IO": [ { "input": "sippuu\n", "output": "Yes\n" } ] }, { "id": "s987117545", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s987117545 {\n final Scanner sc = new Scanner(System.in);\n final long DEVISOR = 1000000000 + 7;\n\n public static void main(String[] args) {\n new s987117545().run();\n }\n\n private void run() {\n long n = sc.nextLong();\n long k = sc.nextLong();\n\n long ans = 0;\n for (long i = k; i <= n + 1; i++) {\n long max = i * (2 * n - i + 1) / 2;\n long min = i * (i - 1) / 2;\n ans += (max - min + 1) % DEVISOR;\n }\n System.out.println(ans % DEVISOR);\n }\n}\n", "test_IO": [ { "input": "3 2\n", "output": "10\n" } ] }, { "id": "s709681166", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s709681166 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.nextLine();\n\n for (int i = 0; i < s.length(); i++) {\n char c = s.charAt(i);\n if (Character.isUpperCase(c)) {\n c += 32;\n System.out.print(c);\n } else if (Character.isLowerCase(c)) {\n c -= 32;\n System.out.print(c);\n } else System.out.print(c);\n }\n System.out.println();\n sc.close();\n }\n}\n", "test_IO": [ { "input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n", "output": "Fair, later, occasionally cloudy.\n" } ] }, { "id": "s905556405", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s905556405 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int[] numlist = new int[5];\n int k;\n\n for (int i = 0; i < 5; i++) {\n numlist[i] = sc.nextInt();\n }\n k = sc.nextInt();\n if ((numlist[4] - numlist[0]) > k) {\n System.out.println(\":(\");\n } else {\n System.out.println(\"Yay!\");\n }\n }\n}\n", "test_IO": [ { "input": "1\n2\n4\n8\n9\n15\n", "output": "Yay!\n" } ] }, { "id": "s943650310", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s943650310 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int X = sc.nextInt();\n int t = sc.nextInt();\n\n if (X - t >= 0) {\n System.out.println(X - t);\n } else {\n System.out.println(0);\n }\n }\n}\n", "test_IO": [ { "input": "100 17\n", "output": "83\n" } ] }, { "id": "s036404962", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s036404962 {\n\n public static void main(String[] args) {\n\n @SuppressWarnings(\"resource\")\n Scanner scan = new Scanner(System.in);\n\n int X = scan.nextInt();\n int t = scan.nextInt();\n\n if (X >= t) {\n System.out.println(X - t);\n } else if (X < t) {\n System.out.print(0);\n }\n }\n}\n", "test_IO": [ { "input": "100 17\n", "output": "83\n" } ] }, { "id": "s951567432", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s951567432 {\n public static void main(String[] args) {\n int count = new Scanner(System.in).nextInt();\n\n int total = 0;\n for (int ix = 1; ix <= count; ix++) {\n total += ix;\n }\n\n System.out.println(total);\n }\n}\n", "test_IO": [ { "input": "3\n", "output": "6\n" } ] }, { "id": "s696692583", "dataset": "codenet", "language": "Java", "code": "import static java.util.Arrays.deepToString;\n\nimport java.util.Scanner;\n\npublic class s696692583 {\n public static void main(String[] args) {\n new s696692583().run();\n }\n\n void tr(Object... os) {\n System.err.println(deepToString(os));\n }\n\n Scanner sc = new Scanner(System.in);\n\n public void run() {\n for (; sc.hasNext(); ) {\n int my1 = sc.nextInt();\n int my2 = sc.nextInt();\n int enemy1 = sc.nextInt();\n boolean[] used = new boolean[11];\n used[my1] = true;\n used[my2] = true;\n used[enemy1] = true;\n int all = 0;\n int safe = 0;\n for (int i = 1; i <= 10; i++)\n if (!used[i]) {\n all++;\n if (my1 + my2 + i <= 20) safe++;\n }\n if (safe * 2 >= all) {\n System.out.println(\"YES\");\n } else {\n System.out.println(\"NO\");\n }\n }\n }\n\n char solve(int[][] a) {\n char[] s = {'d', 'o', 'x'};\n for (int side = 1; side <= 2; side++) {\n for (int i = 0; i < 3; i++) {\n if (a[i][0] == side && a[i][1] == side && a[i][2] == side) return s[side];\n if (a[0][i] == side && a[1][i] == side && a[2][i] == side) return s[side];\n }\n if (a[0][0] == side && a[1][1] == side && a[2][2] == side) return s[side];\n if (a[0][2] == side && a[1][1] == side && a[2][0] == side) return s[side];\n }\n return 'd';\n }\n}\n", "test_IO": [ { "input": "1 2 3\n5 6 9\n8 9 10\n", "output": "YES\nYES\nNO\n" } ] }, { "id": "s378126458", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s378126458 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt(), Q = sc.nextInt();\n String s = sc.next();\n int pre[] = new int[N + 1];\n for (int i = 1; i < N; i++) {\n if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {\n pre[i] = 1;\n }\n }\n\n for (int i = 1; i < N; i++) {\n pre[i] += pre[i - 1];\n }\n\n while (Q-- > 0) {\n int l = sc.nextInt(), r = sc.nextInt();\n r--;\n System.out.println(pre[r] - pre[l - 1]);\n }\n }\n}\n", "test_IO": [ { "input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n", "output": "2\n0\n3\n" } ] }, { "id": "s456888268", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s456888268 {\n static void solve() {\n String tmp = ns();\n char s[] = tmp.toCharArray();\n int n = s.length;\n int ans = 0;\n int cnt = 0;\n for (int i = 0; i < n; i++) {\n if (s[i] == 'S') {\n cnt++;\n } else {\n if (cnt == 0) continue;\n ans++;\n cnt--;\n }\n }\n out.println(n - 2 * ans);\n }\n\n static final long mod = (long) 1e9 + 7;\n static final int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};\n static final int[] dx8 = {-1, -1, -1, 0, 0, 1, 1, 1}, dy8 = {-1, 0, 1, -1, 1, -1, 0, 1};\n static final int inf = Integer.MAX_VALUE / 2;\n static final long linf = Long.MAX_VALUE / 3;\n static final double dinf = Double.MAX_VALUE / 3;\n static final double eps = 1e-10;\n static final double pi = Math.PI;\n static StringBuilder sb = new StringBuilder();\n static InputStream is;\n static PrintWriter out;\n static String INPUT = \"\";\n\n static void reverse(int ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n int t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(long ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n long t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(double ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n double t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void reverse(char ar[]) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n char t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static String getReverse(String s) {\n char c[] = s.toCharArray();\n reverse(c);\n s = String.valueOf(c);\n return s;\n }\n\n static void reverse(List ls) {\n int sz = ls.size();\n for (int i = 0; i < sz / 2; i++) {\n T t = ls.get(i);\n ls.set(i, ls.get(sz - 1 - i));\n ls.set(sz - 1 - i, t);\n }\n }\n\n static void reverse(T[] ar) {\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n T t = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = t;\n }\n }\n\n static void sbnl() {\n sb.append(\"\\n\");\n }\n\n static int lowerBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(int[] a, int x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(long[] a, long x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(double[] a, double x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] < x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int upperBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] <= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rlowerBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] > x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int rupperBound(char[] a, char x) {\n int l = -1, r = a.length;\n while (r - l > 1) {\n int c = (l + r) / 2;\n if (a[c] >= x) {\n l = c;\n } else {\n r = c;\n }\n }\n return r;\n }\n\n static int lowerBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int upperBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int rupperBound(List ls, T x) throws RuntimeException {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int rlowerBound(List ls, T x) {\n if (ls.size() == 0) return -1;\n if (ls.get(0) instanceof Integer) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Long) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);\n } else if (ls.get(0) instanceof Double) {\n return ~Collections.binarySearch(\n ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);\n } else {\n System.err.println(\n String.format(\n \"%s:\u6570\u5024\u3067\u306a\u3044\u30ea\u30b9\u30c8\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u3044\u307e\u3059\u3002\",\n Thread.currentThread().getStackTrace()[1].getMethodName()));\n throw new RuntimeException();\n }\n }\n\n static int[] concat(int x, int arr[]) {\n int ret[] = new int[arr.length + 1];\n System.arraycopy(arr, 0, ret, 1, ret.length - 1);\n ret[0] = x;\n return ret;\n }\n\n static int[] concat(int arr[], int x) {\n int ret[] = new int[arr.length + 1];\n System.arraycopy(arr, 0, ret, 0, ret.length - 1);\n ret[ret.length - 1] = x;\n return ret;\n }\n\n static long[] concat(long x, long arr[]) {\n long ret[] = new long[arr.length + 1];\n System.arraycopy(arr, 0, ret, 1, ret.length - 1);\n ret[0] = x;\n return ret;\n }\n\n static long[] concat(long arr[], long x) {\n long ret[] = new long[arr.length + 1];\n System.arraycopy(arr, 0, ret, 0, ret.length - 1);\n ret[ret.length - 1] = x;\n return ret;\n }\n\n static int max(int x, int y) {\n return Math.max(x, y);\n }\n\n static int min(int x, int y) {\n return Math.min(x, y);\n }\n\n static int max(int x, int y, int z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static int min(int x, int y, int z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static long max(long x, long y) {\n return Math.max(x, y);\n }\n\n static long min(long x, long y) {\n return Math.min(x, y);\n }\n\n static long max(long x, long y, long z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static long min(long x, long y, long z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static double max(double x, double y) {\n return Math.max(x, y);\n }\n\n static double min(double x, double y) {\n return Math.min(x, y);\n }\n\n static double max(double x, double y, double z) {\n x = Math.max(x, y);\n x = Math.max(x, z);\n return x;\n }\n\n static double min(double x, double y, double z) {\n x = Math.min(x, y);\n x = Math.min(x, z);\n return x;\n }\n\n static void sort(int[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(long[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(double[] ar) {\n Arrays.sort(ar);\n }\n\n static void sort(char[] ar) {\n Arrays.sort(ar);\n }\n\n static void rsort(int[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n int tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(long[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n long tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(double[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n double tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void rsort(char[] ar) {\n Arrays.sort(ar);\n int len = ar.length;\n for (int i = 0; i < len / 2; i++) {\n char tmp = ar[i];\n ar[i] = ar[len - 1 - i];\n ar[len - 1 - i] = tmp;\n }\n }\n\n static void fill(int arr[], int x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(long arr[], long x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(boolean arr[], boolean x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(double arr[], double x) {\n Arrays.fill(arr, x);\n }\n\n static void fill(int arr[][], int x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(long arr[][], long x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(double arr[][], double x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static void fill(boolean arr[][], boolean x) {\n for (int i = 0; i < arr.length; i++) Arrays.fill(arr[i], x);\n }\n\n static long plus(long x, long y) {\n long res = (x + y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long sub(long x, long y) {\n long res = (x - y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long mul(long x, long y) {\n long res = (x * y) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long div(long x, long y) {\n long res = x * pow(y, mod - 2) % mod;\n return res < 0 ? res + mod : res;\n }\n\n static long pow(long x, long y) {\n if (y < 0) return 0;\n if (y == 0) return 1;\n if (y % 2 == 1) return (x * pow(x, y - 1)) % mod;\n long root = pow(x, y / 2);\n return root * root % mod;\n }\n\n public static void main(String[] args) throws Exception {\n is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());\n out = new PrintWriter(System.out);\n solve();\n out.flush();\n }\n\n private static byte[] inbuf = new byte[1024];\n static int lenbuf = 0, ptrbuf = 0;\n\n private static int readByte() {\n if (lenbuf == -1) throw new InputMismatchException();\n if (ptrbuf >= lenbuf) {\n ptrbuf = 0;\n try {\n lenbuf = is.read(inbuf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (lenbuf <= 0) return -1;\n }\n return inbuf[ptrbuf++];\n }\n\n private static boolean isSpaceChar(int c) {\n return !(c >= 33 && c <= 126);\n }\n\n private static int skip() {\n int b;\n while ((b = readByte()) != -1 && isSpaceChar(b))\n ;\n return b;\n }\n\n @SuppressWarnings(\"unused\")\n private static double nd() {\n return Double.parseDouble(ns());\n }\n\n @SuppressWarnings(\"unused\")\n private static char nc() {\n return (char) skip();\n }\n\n private static String ns() {\n int b = skip();\n StringBuilder sb = new StringBuilder();\n while (!(isSpaceChar(b))) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n private static char[] ns(int n) {\n char[] buf = new char[n];\n int b = skip(), p = 0;\n while (p < n && !(isSpaceChar(b))) {\n buf[p++] = (char) b;\n b = readByte();\n }\n return n == p ? buf : Arrays.copyOf(buf, p);\n }\n\n @SuppressWarnings(\"unused\")\n private static char[][] nm(int n, int m) {\n char[][] map = new char[n][];\n for (int i = 0; i < n; i++) map[i] = ns(m);\n return map;\n }\n\n @SuppressWarnings(\"unused\")\n private static int[] na(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = ni();\n return a;\n }\n\n @SuppressWarnings(\"unused\")\n private static long[] nla(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nl();\n return a;\n }\n\n private static int ni() {\n int num = 0, b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n\n @SuppressWarnings(\"unused\")\n private static long nl() {\n long num = 0;\n int b;\n boolean minus = false;\n while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))\n ;\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n\n while (true) {\n if (b >= '0' && b <= '9') {\n num = num * 10 + (b - '0');\n } else {\n return minus ? -num : num;\n }\n b = readByte();\n }\n }\n}\n", "test_IO": [ { "input": "TSTTSS\n", "output": "4\n" } ] }, { "id": "s383412435", "dataset": "codenet", "language": "Java", "code": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class s383412435 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n long a[] = new long[N];\n int tmp;\n int ans = 0;\n for (int z = 0; N > z; z++) {\n a[z] = sc.nextInt();\n }\n Arrays.sort(a);\n if (N == 1 && a[0] > 1) {\n ans = 1;\n } else {\n for (int j = 0; N > j; j++) {\n if (j == 0 || a[j] != a[j - 1]) {\n tmp = 1;\n for (int i = j + 1; N > i; i++) {\n if (a[j] == a[i]) {\n tmp++;\n } else {\n break;\n }\n }\n\n if (tmp > a[j]) {\n ans += tmp - a[j];\n } else if (tmp < a[j]) {\n ans += tmp;\n }\n }\n }\n }\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "4\n3 3 3 3\n", "output": "1\n" } ] }, { "id": "s523386612", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s523386612 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int t = sc.nextInt();\n int[] count = new int[t + 1];\n for (int i = 2; i < t + 1; i++) {\n count[sc.nextInt()]++;\n }\n for (int i = 1; i < t + 1; i++) {\n System.out.println(count[i]);\n }\n }\n}\n", "test_IO": [ { "input": "5\n1 1 2 2\n", "output": "2\n2\n0\n0\n0\n" } ] }, { "id": "s291405468", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s291405468 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n System.out.println(sc.nextInt() % 500 <= sc.nextInt() ? \"Yes\" : \"No\");\n }\n}\n", "test_IO": [ { "input": "2018\n218\n", "output": "Yes\n" } ] }, { "id": "s799795787", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s799795787 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n String array[] = new String[n];\n int cnt = 0;\n int cnt2 = 0;\n\n for (int i = 0; i < n; i++) {\n array[i] = sc.next();\n }\n\n Arrays.sort(array);\n\n String a = array[0];\n cnt++;\n for (int i = 0; i < n; i++) {\n\n if (a.equals(array[i])) {\n\n } else {\n cnt++;\n }\n a = array[i];\n }\n System.out.println(cnt);\n }\n}\n", "test_IO": [ { "input": "3\napple\norange\napple\n", "output": "2\n" } ] }, { "id": "s857785109", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s857785109 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n if ((n / 10) % 111 == 0) {\n System.out.println(\"Yes\");\n } else if ((n % 1000) % 111 == 0) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "test_IO": [ { "input": "1118\n", "output": "Yes\n" } ] }, { "id": "s461257670", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s461257670 {\n\n public static void main(String[] args) throws java.lang.Exception {\n\n Scanner sc = new Scanner(System.in);\n int count = sc.nextInt();\n\n for (int i = 0; count > i; i++) {\n int y = sc.nextInt();\n int m = sc.nextInt();\n int d = sc.nextInt();\n\n System.out.println(Answer(y, m, d));\n }\n }\n\n public static int Answer(int y, int m, int d) {\n int result = 1;\n\n if (y % 3 == 0) {\n result += 20 - d;\n } else if (m % 2 == 0) {\n result += 19 - d;\n } else {\n result += 20 - d;\n }\n\n for (m += 1; m <= 10; m++) {\n if (y % 3 == 0) {\n result += 20;\n } else {\n if (m % 2 == 0) {\n result += 19;\n } else {\n result += 20;\n }\n }\n }\n\n for (y += 1; y < 1000; y++) {\n if (y % 3 == 0) {\n result += 200;\n } else {\n result += 195;\n }\n }\n return result;\n }\n}\n", "test_IO": [ { "input": "8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20\n", "output": "196470\n128976\n59710\n160715\n252\n128977\n59712\n1\n" } ] }, { "id": "s575985145", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s575985145 {\n\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int size = scan.nextInt();\n int[][] graph = new int[size][size];\n\n int id = 0;\n int cols = 0;\n int[] row = new int[0];\n for (int i = 0; i < size; i++) {\n id = scan.nextInt();\n cols = scan.nextInt();\n row = new int[size];\n for (int j = 0; j < cols; j++) row[scan.nextInt() - 1] = 1;\n graph[id - 1] = row;\n }\n\n for (int i = 0; i < graph.length; i++) {\n for (int j = 0; j < graph[i].length; j++) {\n System.out.print(graph[i][j]);\n if (j < graph[i].length - 1) System.out.print(\" \");\n }\n System.out.println();\n }\n }\n}\n", "test_IO": [ { "input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n", "output": "0 1 0 1\n0 0 0 1\n0 0 0 0\n0 0 1 0\n" } ] }, { "id": "s835214694", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s835214694 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n if (b % a == 0) System.out.println(a + b);\n else System.out.println(b - a);\n }\n}\n", "test_IO": [ { "input": "4 12\n", "output": "16\n" } ] }, { "id": "s596709252", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s596709252 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int y = sc.nextInt();\n int z = sc.nextInt();\n sc.close();\n\n System.out.println(z + \" \" + x + \" \" + y);\n }\n}\n", "test_IO": [ { "input": "1 2 3\n", "output": "3 1 2\n" } ] }, { "id": "s657273562", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s657273562 {\n static PrintWriter pw;\n static Scanner sc;\n static ArrayList[] adj;\n static boolean[] visit;\n static HashMap dp;\n\n static long ceildiv(long x, long y) {\n return (x + y - 1) / y;\n }\n\n static int mod(long x, int m) {\n return (int) ((x % m + m) % m);\n }\n\n static HashMap map;\n\n static long gcd(long x, long y) {\n return y == 0 ? x : gcd(y, x % y);\n }\n\n static int Int(boolean x) {\n return x ? 1 : 0;\n }\n\n static void put(TreeMap map, Pair p) {\n if (map.containsKey(p)) map.replace(p, map.get(p) + 1);\n else map.put(p, 1);\n }\n\n static void rem(TreeMap map, Pair p) {\n if (map.get(p) == 1) map.remove(p);\n else map.replace(p, map.get(p) - 1);\n }\n\n public static void main(String[] args) throws Exception {\n sc = new Scanner(System.in);\n pw = new PrintWriter(System.out);\n int n = sc.nextInt();\n Integer[] arr = sc.nextsort(n);\n Arrays.sort(arr, Collections.reverseOrder());\n if (n >= 3) {\n TreeMap map = new TreeMap<>(Collections.reverseOrder());\n long ans = arr[0] + arr[1];\n map.put(new Pair(arr[0], arr[1]), 1);\n Pair p1 = new Pair(arr[2], arr[1]), p2 = new Pair(arr[2], arr[0]);\n put(map, p1);\n put(map, p2);\n for (int i = 3; i < n; i++) {\n Pair p = map.firstKey();\n rem(map, p);\n ans += Math.min(p.x, p.y);\n put(map, new Pair(p.x, arr[i]));\n put(map, new Pair(p.y, arr[i]));\n }\n pw.println(ans);\n } else {\n pw.println(arr[0]);\n }\n pw.close();\n }\n\n static void fill(int[] arr, int x) {\n for (int i = 0; i < 30; i++) arr[i] += Int(((1 << i) & x) != 0);\n }\n\n static long pow(long a, long pow) {\n long ans = 1;\n while (pow > 0) {\n if ((pow & 1) == 1) ans *= a;\n a *= a;\n pow >>= 1;\n }\n return ans;\n }\n\n static int getpow(int x) throws Exception {\n int pow = x;\n pw.println(\"B \" + pow);\n pw.flush();\n sc.next();\n pw.println(\"B \" + pow);\n pw.flush();\n if (sc.nextInt() == 1) {\n pow *= x;\n while (true) {\n pw.println(\"B \" + pow);\n pw.flush();\n if (sc.nextInt() == 0) return pow / x;\n pow *= x;\n }\n } else {\n return 1;\n }\n }\n\n static int[] least;\n static TreeSet prime;\n\n static void linearsieve(int x) {\n least = new int[x + 1];\n prime = new TreeSet();\n for (int i = 2; i <= x; i++) {\n if (least[i] == 0) {\n least[i] = i;\n prime.add(i);\n }\n for (int y : prime) {\n if (i * y <= x) least[i * y] = y;\n else break;\n }\n }\n }\n\n static void printArr(int[] arr) {\n for (int i = 0; i < arr.length - 1; i++) pw.print(arr[i] + \" \");\n pw.println(arr[arr.length - 1]);\n }\n\n static void printArr(long[] arr) {\n for (int i = 0; i < arr.length - 1; i++) pw.print(arr[i] + \" \");\n pw.println(arr[arr.length - 1]);\n }\n\n static void printArr(Integer[] arr) {\n for (int i = 0; i < arr.length; i++) pw.print(arr[i] + \" \");\n pw.println();\n }\n\n static void printArr(char[] arr) {\n for (int i = 0; i < arr.length; i++) pw.print(arr[i] == 0 ? '1' : arr[i]);\n pw.println();\n }\n\n static void printArr(ArrayList list) {\n for (int i = 0; i < list.size(); i++) pw.print(list.get(i) + \" \");\n pw.println();\n }\n\n static class Scanner {\n StringTokenizer st;\n BufferedReader br;\n\n public Scanner(InputStream s) {\n br = new BufferedReader(new InputStreamReader(s));\n }\n\n public Scanner(FileReader r) {\n br = new BufferedReader(r);\n }\n\n public String next() throws IOException {\n while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());\n return st.nextToken();\n }\n\n public int nextInt() throws IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws IOException {\n return Long.parseLong(next());\n }\n\n public String nextLine() throws IOException {\n return br.readLine();\n }\n\n public double nextDouble() throws IOException {\n return Double.parseDouble(next());\n }\n\n public int[] nextArr(int n) throws IOException {\n int[] arr = new int[n];\n for (int i = 0; i < arr.length; i++) arr[i] = nextInt();\n return arr;\n }\n\n public Integer[] nextsort(int n) throws IOException {\n Integer[] arr = new Integer[n];\n for (int i = 0; i < n; i++) arr[i] = nextInt();\n return arr;\n }\n\n public Pair nextPair() throws IOException {\n return new Pair(nextInt(), nextInt());\n }\n\n public Pair[] nextPairArr(int n) throws IOException {\n Pair[] arr = new Pair[n];\n for (int i = 0; i < n; i++) arr[i] = nextPair();\n return arr;\n }\n\n public boolean ready() throws IOException {\n return br.ready();\n }\n }\n\n static class Pair implements Comparable {\n int x;\n int y;\n\n public Pair(int x, int y) {\n this.x = x;\n this.y = y;\n }\n\n public int hashCode() {\n return (this.x * 1000 + this.y);\n }\n\n public int compareTo(Pair p) {\n int min1 = Math.min(x, y), min2 = Math.min(p.x, p.y);\n if (min1 != min2) return min1 - min2;\n if (x == p.x) return y - p.y;\n return x - p.x;\n }\n\n public boolean equals(Object obj) {\n if (obj == null) {\n return false;\n }\n if (this.getClass() != obj.getClass()) {\n return false;\n }\n Pair p = (Pair) obj;\n return this.x == p.x && this.y == p.y;\n }\n\n public Pair clone() {\n return new Pair(x, y);\n }\n\n public String toString() {\n return this.x + \" \" + this.y;\n }\n\n public void add(Pair p) {\n x += p.x;\n y += p.y;\n }\n }\n}\n", "test_IO": [ { "input": "4\n2 2 1 3\n", "output": "7\n" } ] }, { "id": "s453440639", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s453440639 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int H = sc.nextInt();\n int W = sc.nextInt();\n sc.nextLine();\n char[][] S = new char[H][W];\n for (int i = 0; i < H; i++) {\n String text = sc.nextLine();\n for (int j = 0; j < W; j++) {\n S[i][j] = text.charAt(j);\n }\n }\n sc.close();\n\n for (int i = 0; i < H; i++) {\n for (int j = 0; j < W; j++) {\n if (S[i][j] == '.') {\n int count = 0;\n for (int a = -1; a <= 1; a++) {\n if (i + a < 0 || H <= i + a) {\n continue;\n }\n for (int b = -1; b <= 1; b++) {\n if (j + b < 0 || W <= j + b) {\n continue;\n }\n if (S[i + a][j + b] == '#') {\n count++;\n }\n }\n }\n S[i][j] = (char) (count + 48);\n }\n System.out.printf(\"%c\", S[i][j]);\n }\n System.out.printf(\"\\n\");\n }\n }\n}\n", "test_IO": [ { "input": "3 5\n.....\n.#.#.\n.....\n", "output": "11211\n1#2#1\n11211\n" } ] }, { "id": "s127819686", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s127819686 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n\n int hb = b / 2;\n\n System.out.println(a + hb);\n }\n}\n", "test_IO": [ { "input": "81 58\n", "output": "110\n" } ] }, { "id": "s302365683", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s302365683 {\n\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n StringTokenizer s = new StringTokenizer(br.readLine());\n\n int n = Integer.parseInt(s.nextToken());\n HashMap hm = new HashMap<>();\n s = new StringTokenizer(br.readLine());\n for (int i = 0; i < n; i++) {\n int val = Integer.parseInt(s.nextToken());\n hm.put(val, hm.getOrDefault(val, 0) + 1);\n }\n int ans = 0;\n for (int val : hm.keySet()) {\n int num = hm.get(val);\n if (num > val) ans += num - val;\n else if (num < val) ans += num;\n }\n pw.println(ans);\n pw.close();\n }\n}\n", "test_IO": [ { "input": "4\n3 3 3 3\n", "output": "1\n" } ] }, { "id": "s789781857", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s789781857 {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int[] c = new int[n - 1];\n int[] s = new int[n - 1];\n int[] f = new int[n - 1];\n\n for (int i = 0; i < n - 1; i++) {\n c[i] = in.nextInt();\n s[i] = in.nextInt();\n f[i] = in.nextInt();\n }\n\n for (int i = 0; i < n - 1; i++) {\n int time = s[i] + c[i];\n for (int j = i + 1; j < n - 1; j++) {\n if (time % f[j] != 0) {\n time += f[j] - (time % f[j]);\n }\n\n if (time < s[j]) {\n time = s[j];\n }\n\n time += c[j];\n }\n\n System.out.println(time);\n }\n System.out.println(0);\n }\n}\n", "test_IO": [ { "input": "3\n6 5 1\n1 10 1\n", "output": "12\n11\n0\n" } ] }, { "id": "s316260310", "dataset": "codenet", "language": "Java", "code": "import java.awt.*;\nimport java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class s316260310 implements Runnable {\n @Override\n public void run() {\n try {\n new Solver().solve();\n System.exit(0);\n } catch (Exception | Error e) {\n e.printStackTrace();\n System.exit(1);\n }\n }\n\n public static void main(String[] args) {\n\n new s316260310().run();\n }\n}\n\nclass Solver {\n final Helper hp;\n final int MAXN = 1000_006;\n final long MOD = (long) 1e9 + 7;\n\n final Timer timer;\n final TimerTask task;\n\n Solver() {\n hp = new Helper(MOD, MAXN);\n hp.initIO(System.in, System.out);\n\n timer = new Timer();\n task =\n new TimerTask() {\n @Override\n public void run() {\n try {\n hp.flush();\n System.exit(0);\n } catch (Exception e) {\n }\n }\n };\n }\n\n void solve() throws Exception {\n int tc = TESTCASES ? hp.nextInt() : 1;\n for (int tce = 1; tce <= tc; ++tce) solve(tce);\n timer.cancel();\n hp.flush();\n }\n\n boolean TESTCASES = false;\n\n void solve(int tc) throws Exception {\n int i, j, k;\n\n int N = hp.nextInt();\n long K = hp.nextLong();\n int[] A = hp.getIntArray(N);\n\n ArrayList straight = new ArrayList<>(), cycle = new ArrayList<>();\n boolean[] vis = new boolean[N];\n int curr = 0;\n while (!vis[curr]) {\n vis[curr] = true;\n curr = A[curr] - 1;\n }\n\n int st = 0;\n while (st != curr) {\n straight.add(st);\n st = A[st] - 1;\n }\n\n cycle.add(curr);\n curr = A[curr] - 1;\n while (curr != cycle.get(0)) {\n cycle.add(curr);\n curr = A[curr] - 1;\n }\n\n if (K < straight.size()) {\n hp.println(straight.get((int) K) + 1);\n } else {\n K -= straight.size();\n hp.println(cycle.get((int) (K % cycle.size())) + 1);\n }\n }\n}\n\nclass Helper {\n final long MOD;\n final int MAXN;\n final Random rnd;\n\n public Helper(long mod, int maxn) {\n MOD = mod;\n MAXN = maxn;\n rnd = new Random();\n }\n\n public static int[] sieve;\n public static ArrayList primes;\n\n public void setSieve() {\n primes = new ArrayList<>();\n sieve = new int[MAXN];\n int i, j;\n for (i = 2; i < MAXN; ++i)\n if (sieve[i] == 0) {\n primes.add(i);\n for (j = i; j < MAXN; j += i) {\n sieve[j] = i;\n }\n }\n }\n\n public static long[] factorial;\n\n public void setFactorial() {\n factorial = new long[MAXN];\n factorial[0] = 1;\n for (int i = 1; i < MAXN; ++i) factorial[i] = factorial[i - 1] * i % MOD;\n }\n\n public long getFactorial(int n) {\n if (factorial == null) setFactorial();\n return factorial[n];\n }\n\n public long ncr(int n, int r) {\n if (r > n) return 0;\n if (factorial == null) setFactorial();\n long numerator = factorial[n];\n long denominator = factorial[r] * factorial[n - r] % MOD;\n return numerator * pow(denominator, MOD - 2, MOD) % MOD;\n }\n\n public long[] getLongArray(int size) throws Exception {\n long[] ar = new long[size];\n for (int i = 0; i < size; ++i) ar[i] = nextLong();\n return ar;\n }\n\n public int[] getIntArray(int size) throws Exception {\n int[] ar = new int[size];\n for (int i = 0; i < size; ++i) ar[i] = nextInt();\n return ar;\n }\n\n public String[] getStringArray(int size) throws Exception {\n String[] ar = new String[size];\n for (int i = 0; i < size; ++i) ar[i] = next();\n return ar;\n }\n\n public String joinElements(long... ar) {\n StringBuilder sb = new StringBuilder();\n for (long itr : ar) sb.append(itr).append(\" \");\n return sb.toString().trim();\n }\n\n public String joinElements(int... ar) {\n StringBuilder sb = new StringBuilder();\n for (int itr : ar) sb.append(itr).append(\" \");\n return sb.toString().trim();\n }\n\n public String joinElements(String... ar) {\n StringBuilder sb = new StringBuilder();\n for (String itr : ar) sb.append(itr).append(\" \");\n return sb.toString().trim();\n }\n\n public String joinElements(Object... ar) {\n StringBuilder sb = new StringBuilder();\n for (Object itr : ar) sb.append(itr).append(\" \");\n return sb.toString().trim();\n }\n\n public long gcd(long a, long b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n public int gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n public long max(long... ar) {\n long ret = ar[0];\n for (long itr : ar) ret = Math.max(ret, itr);\n return ret;\n }\n\n public int max(int... ar) {\n int ret = ar[0];\n for (int itr : ar) ret = Math.max(ret, itr);\n return ret;\n }\n\n public long min(long... ar) {\n long ret = ar[0];\n for (long itr : ar) ret = Math.min(ret, itr);\n return ret;\n }\n\n public int min(int... ar) {\n int ret = ar[0];\n for (int itr : ar) ret = Math.min(ret, itr);\n return ret;\n }\n\n public long sum(long... ar) {\n long sum = 0;\n for (long itr : ar) sum += itr;\n return sum;\n }\n\n public long sum(int... ar) {\n long sum = 0;\n for (int itr : ar) sum += itr;\n return sum;\n }\n\n public void shuffle(int[] ar) {\n int r;\n for (int i = 0; i < ar.length; ++i) {\n r = rnd.nextInt(ar.length);\n if (r != i) {\n ar[i] ^= ar[r];\n ar[r] ^= ar[i];\n ar[i] ^= ar[r];\n }\n }\n }\n\n public void shuffle(long[] ar) {\n int r;\n for (int i = 0; i < ar.length; ++i) {\n r = rnd.nextInt(ar.length);\n if (r != i) {\n ar[i] ^= ar[r];\n ar[r] ^= ar[i];\n ar[i] ^= ar[r];\n }\n }\n }\n\n public void reverse(int[] ar) {\n int r;\n for (int i = 0; i < ar.length; ++i) {\n r = ar.length - 1 - i;\n if (r > i) {\n ar[i] ^= ar[r];\n ar[r] ^= ar[i];\n ar[i] ^= ar[r];\n }\n }\n }\n\n public void reverse(long[] ar) {\n int r;\n for (int i = 0; i < ar.length; ++i) {\n r = ar.length - 1 - i;\n if (r > i) {\n ar[i] ^= ar[r];\n ar[r] ^= ar[i];\n ar[i] ^= ar[r];\n }\n }\n }\n\n public long pow(long base, long exp, long MOD) {\n base %= MOD;\n long ret = 1;\n while (exp > 0) {\n if ((exp & 1) == 1) ret = ret * base % MOD;\n base = base * base % MOD;\n exp >>= 1;\n }\n return ret;\n }\n\n static final int BUFSIZE = 1 << 20;\n static byte[] buf;\n static int index, total;\n static InputStream in;\n static BufferedWriter bw;\n\n public void initIO(InputStream is, OutputStream os) {\n try {\n in = is;\n bw = new BufferedWriter(new OutputStreamWriter(os));\n buf = new byte[BUFSIZE];\n } catch (Exception e) {\n }\n }\n\n public void initIO(String inputFile, String outputFile) {\n try {\n in = new FileInputStream(inputFile);\n bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)));\n buf = new byte[BUFSIZE];\n } catch (Exception e) {\n }\n }\n\n private int scan() throws Exception {\n if (index >= total) {\n index = 0;\n total = in.read(buf);\n if (total <= 0) return -1;\n }\n return buf[index++];\n }\n\n public String next() throws Exception {\n int c;\n for (c = scan(); c <= 32; c = scan())\n ;\n StringBuilder sb = new StringBuilder();\n for (; c > 32; c = scan()) sb.append((char) c);\n return sb.toString();\n }\n\n public int nextInt() throws Exception {\n int c, val = 0;\n for (c = scan(); c <= 32; c = scan())\n ;\n boolean neg = c == '-';\n if (c == '-' || c == '+') c = scan();\n for (; c >= '0' && c <= '9'; c = scan()) val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n\n public long nextLong() throws Exception {\n int c;\n long val = 0;\n for (c = scan(); c <= 32; c = scan())\n ;\n boolean neg = c == '-';\n if (c == '-' || c == '+') c = scan();\n for (; c >= '0' && c <= '9'; c = scan()) val = (val << 3) + (val << 1) + (c & 15);\n return neg ? -val : val;\n }\n\n public void print(Object a) throws Exception {\n bw.write(a.toString());\n }\n\n public void printsp(Object a) throws Exception {\n print(a);\n print(\" \");\n }\n\n public void println() throws Exception {\n bw.write(\"\\n\");\n }\n\n public void println(Object a) throws Exception {\n print(a);\n println();\n }\n\n public void flush() throws Exception {\n bw.flush();\n }\n}\n", "test_IO": [ { "input": "4 5\n3 2 4 1\n", "output": "4\n" } ] }, { "id": "s918596375", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.AbstractMap;\nimport java.util.StringTokenizer;\n\npublic class s918596375 {\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner(System.in);\n PrintWriter out = new PrintWriter(System.out);\n\n solve(sc, out);\n\n out.flush();\n }\n\n public static void solve(FastScanner sc, PrintWriter out) {\n String s = sc.next();\n\n String[] a = {\"a\", \"e\", \"i\", \"o\", \"u\"};\n\n for (String str : a) {\n if (str.equalsIgnoreCase(s)) {\n out.println(\"vowel\");\n return;\n }\n }\n\n out.println(\"consonant\");\n }\n\n public static int gcd(int a, int b) {\n if (a < b) return gcd(b, a);\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n public static long gcd(long a, long b) {\n if (a < b) return gcd(b, a);\n if (b == 0) return a;\n return gcd(b, a % b);\n }\n\n public static int lcm(int a, int b) {\n return (a * b) / gcd(a, b);\n }\n}\n\nclass Pair extends AbstractMap.SimpleEntry {\n\n public Pair(final K key, final V value) {\n super(key, value);\n }\n\n public Pair swap() {\n return new Pair(getValue(), getKey());\n }\n}\n\nclass FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n\n public int[] nextIntArray(int n) {\n int[] a = new int[n];\n for (int i = 0; i < n; i++) a[i] = nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n) {\n long[] a = new long[n];\n for (int i = 0; i < n; i++) a[i] = nextLong();\n return a;\n }\n}\n", "test_IO": [ { "input": "a\n", "output": "vowel\n" } ] }, { "id": "s551454565", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s551454565 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n if (s.equals(\"Sunny\")) {\n System.out.println(\"Cloudy\");\n } else if (s.equals(\"Cloudy\")) {\n System.out.println(\"Rainy\");\n } else {\n System.out.println(\"Sunny\");\n }\n sc.close();\n }\n}\n", "test_IO": [ { "input": "Sunny\n", "output": "Cloudy\n" } ] }, { "id": "s428436430", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass calArea {\n int Area(int w, int h) {\n int area = w * h;\n return area;\n }\n}\n\npublic class s428436430 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n List arr = new ArrayList<>();\n\n for (int i = 0; i < 4; i++) {\n arr.add(Integer.parseInt(sc.next()));\n }\n\n calArea ab = new calArea();\n int area1 = ab.Area(arr.get(0), arr.get(1));\n int area2 = ab.Area(arr.get(2), arr.get(3));\n\n if (area1 > area2) {\n System.out.println(area1);\n } else if (area1 < area2) {\n System.out.println(area2);\n } else if (area1 == area2) {\n System.out.println(area1);\n }\n }\n}\n", "test_IO": [ { "input": "3 5 2 7\n", "output": "15\n" } ] }, { "id": "s607507157", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s607507157 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n if (n % 10 == 9 || n / 10 == 9) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "test_IO": [ { "input": "29\n", "output": "Yes\n" } ] }, { "id": "s010698290", "dataset": "codenet", "language": "Java", "code": "import java.awt.geom.*;\nimport java.io.BufferedReader;\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.OutputStreamWriter;\nimport java.util.*;\n\npublic class s010698290 {\n\n public static void main(String args[]) {\n try {\n FastReader s = new FastReader();\n BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));\n int i, j;\n int m, n, t, max, k, x, y, min, correct_ans, num, num_penal;\n long a, b, sum;\n\n String str;\n\n n = s.nextInt();\n m = s.nextInt();\n\n int penal[] = new int[n + 1];\n boolean solved[] = new boolean[n + 1];\n Arrays.fill(solved, false);\n\n for (i = 0; i < m; i++) {\n num = s.nextInt();\n str = s.next();\n if (str.charAt(0) == 'A') {\n solved[num] = true;\n } else if (solved[num] == false) penal[num]++;\n }\n\n correct_ans = 0;\n num_penal = 0;\n for (i = 1; i <= n; i++) {\n if (solved[i] == true) {\n correct_ans++;\n num_penal += penal[i];\n }\n }\n\n w.write(correct_ans + \" \" + num_penal + \"\\n\");\n w.close();\n\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n}\n\nclass FastReader {\n BufferedReader br;\n StringTokenizer st;\n\n public FastReader() {\n br = new BufferedReader(new InputStreamReader(System.in));\n }\n\n String next() {\n while (st == null || !st.hasMoreElements()) {\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n Double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String nextLine() {\n String str = \"\";\n try {\n str = br.readLine();\n } catch (IOException e) {\n e.printStackTrace();\n }\n return str;\n }\n}\n", "test_IO": [ { "input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "output": "2 2\n" } ] }, { "id": "s525447134", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s525447134 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n if (s.equals(\"Sunny\")) {\n System.out.println(\"Cloudy\");\n } else if (s.equals(\"Cloudy\")) {\n System.out.println(\"Rainy\");\n } else {\n System.out.println(\"Sunny\");\n }\n }\n}\n", "test_IO": [ { "input": "Sunny\n", "output": "Cloudy\n" } ] }, { "id": "s867221485", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s867221485 {\n\n static int N;\n static int K;\n static long Q;\n static int A;\n static int B;\n static long C;\n static double min = 9999999;\n static long ans = 0;\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int N = scanner.nextInt();\n\n scanner.nextLine();\n\n String s = scanner.nextLine();\n\n boolean flag = false;\n int ans = 0;\n int hen = 0;\n int sha = 0;\n int dot = 0;\n int temp = 0;\n boolean first = true;\n for (int i = 0; i < N; i++) {\n\n if (s.charAt(i) == '#') {\n first = false;\n if (sha <= dot) {\n\n ans += sha;\n sha = 0;\n dot = 0;\n first = true;\n\n } else {\n\n }\n\n sha++;\n } else {\n\n dot++;\n }\n }\n\n if (sha <= dot) {\n ans += sha;\n dot = 0;\n } else {\n\n }\n\n System.out.println(ans + dot);\n }\n}\n", "test_IO": [ { "input": "3\n#.#\n", "output": "1\n" } ] }, { "id": "s973587235", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s973587235 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int minN = sc.nextInt() - 1;\n for (int i = 0; i < n - 1; i++) {\n int h = sc.nextInt();\n if (minN == h) {\n minN = h;\n } else if (minN == h - 1) {\n minN = h - 1;\n } else if (minN < h - 1) {\n minN = h - 1;\n } else if (minN > h) {\n System.out.println(\"No\");\n return;\n }\n }\n System.out.println(\"Yes\");\n }\n}\n", "test_IO": [ { "input": "5\n1 2 1 1 3\n", "output": "Yes\n" } ] }, { "id": "s391272180", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s391272180 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n StringBuilder s, t;\n s = new StringBuilder(sc.next());\n t = new StringBuilder(sc.next());\n boolean flag = false;\n for (int i = 0; i < s.length(); i++) {\n s = new StringBuilder(Rotate(s));\n if (t.toString().equals(s.toString())) {\n flag = true;\n break;\n }\n }\n if (flag == true) System.out.println(\"Yes\");\n else System.out.println(\"No\");\n }\n\n public static StringBuilder Rotate(StringBuilder str) {\n int len = str.length();\n char t = str.charAt(0);\n for (int i = 0; i < len - 1; i++) {\n str.setCharAt(i, str.charAt(i + 1));\n }\n str.setCharAt(len - 1, t);\n return str;\n }\n}\n", "test_IO": [ { "input": "kyoto\ntokyo\n", "output": "Yes\n" } ] }, { "id": "s888333881", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class s888333881 {\n\n static class Graph0n {\n private ArrayList dt = new ArrayList<>();\n\n Graph0n(int sz) {\n for (int i = 0; i < sz; i++) {\n Node0n node1 = new Node0n();\n dt.add(node1);\n }\n }\n\n public void add(int vn, int val) {\n dt.get(vn).add(val);\n }\n\n public void add2(int vn, int val) {\n dt.get(vn).add(val);\n dt.get(val).add(vn);\n }\n\n public int get(int vn, int index) {\n return dt.get(vn).get(index);\n }\n\n public ArrayList get(int vn) {\n return dt.get(vn).getAll();\n }\n\n public int sizeOf(int vn) {\n return dt.get(vn).size();\n }\n\n public void clear() {\n for (int i = 0; i < dt.size(); i++) {\n dt.get(i).clear();\n }\n }\n }\n\n static class Node0n {\n private ArrayList next_vs = new ArrayList<>();\n\n public void add(int val) {\n next_vs.add(val);\n }\n\n public int get(int ad) {\n return next_vs.get(ad);\n }\n\n public ArrayList getAll() {\n return next_vs;\n }\n\n public int size() {\n return next_vs.size();\n }\n\n public void clear() {\n next_vs.clear();\n }\n }\n\n static class Edge {\n int from = -1, v2 = -1;\n long weight;\n\n public Edge(int vn, long w) {\n this.v2 = vn;\n this.weight = w;\n }\n\n public Edge(int cm, int vn, long w) {\n this.from = cm;\n this.v2 = vn;\n this.weight = w;\n }\n }\n\n static class Edge2 {\n int v2;\n long cost1, cost2;\n\n public Edge2(int vn, long w1, long w2) {\n this.v2 = vn;\n this.cost1 = w1;\n this.cost2 = w2;\n }\n }\n\n static class Comparator_Edge implements Comparator {\n public int compare(Edge a, Edge b) {\n if (a.weight > b.weight) return -1;\n else if (a.weight < b.weight) return 1;\n else return b.v2 - a.v2;\n }\n }\n\n static class V2Comp implements Comparator {\n public int compare(Edge a, Edge b) {\n if (a.v2 > b.v2) return -1;\n else if (a.v2 < b.v2) return 1;\n else if (a.weight > b.weight) return -1;\n else if (a.weight < b.weight) return 1;\n else return 0;\n }\n }\n\n static class antiV2 implements Comparator {\n public int compare(Edge a, Edge b) {\n if (a.v2 > b.v2) return 1;\n else if (a.v2 < b.v2) return -1;\n else if (a.weight > b.weight) return -1;\n else if (a.weight < b.weight) return 1;\n else return 0;\n }\n }\n\n static class Vector {\n int x, y;\n\n public Vector(int sx, int sy) {\n this.x = sx;\n this.y = sy;\n }\n }\n\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n\n int n = sc.nexI();\n String s = sc.next();\n boolean[] flaged = new boolean[n];\n fill(flaged, false);\n\n long pop1st = 0L;\n for (int i = 0; i < n; i++) {\n if (s.charAt(i) == '1') {\n flaged[i] = true;\n pop1st++;\n }\n }\n\n long surp1 = 0;\n\n for (int i = 0; i < n; i++) {\n surp1 *= 2L;\n if (flaged[i]) surp1++;\n surp1 %= (pop1st + 1L);\n }\n\n long surp9 = 0L;\n if (pop1st > 1) {\n for (int i = 0; i < n; i++) {\n surp9 *= 2L;\n if (flaged[i]) surp9++;\n surp9 %= (pop1st - 1L);\n }\n }\n\n for (int p = 0; p < n; p++) {\n if (flaged[p]) {\n if (pop1st == 1) {\n out.println(0);\n continue;\n }\n long dw = surp9;\n\n long dif = pow10E97(2, n - p - 1, pop1st - 1);\n dw -= dif;\n dw += (pop1st - 1L);\n dw %= (pop1st - 1L);\n\n int ans = 1;\n while (dw != 0) {\n if (dw < 0) out.println(1 / 0);\n int count = countFlaged(dw);\n dw %= count;\n ans++;\n }\n out.println(ans);\n } else {\n long dw = surp1;\n\n long dif = pow10E97(2, n - p - 1, pop1st + 1);\n dw += dif;\n dw %= (pop1st + 1L);\n\n int ans = 1;\n while (dw != 0) {\n if (dw < 0) out.println(1 / 0);\n int count = countFlaged(dw);\n dw %= count;\n ans++;\n }\n out.println(ans);\n }\n }\n\n out.flush();\n }\n\n private static int INF = (int) 1e8;\n private static long INFL = (long) 1e17;\n private static long e97 = (long) 1e9 + 7;\n\n void assertion(boolean b) {\n if (!b) throw new AssertionError();\n }\n\n private static int abs(int a) {\n return (a >= 0) ? a : -a;\n }\n\n private static long abs(long a) {\n return (a >= 0) ? a : -a;\n }\n\n private static double abs(double a) {\n return (a >= 0) ? a : -a;\n }\n\n private static int min(int a, int b) {\n return (a > b) ? b : a;\n }\n\n private static long min(long a, long b) {\n return (a > b) ? b : a;\n }\n\n private static double min(double a, double b) {\n return (a > b) ? b : a;\n }\n\n private static int max(int a, int b) {\n return (a > b) ? a : b;\n }\n\n private static long max(long a, long b) {\n return (a > b) ? a : b;\n }\n\n private static double max(double a, double b) {\n return (a > b) ? a : b;\n }\n\n private static int minN(int... ins) {\n int min = ins[0];\n for (int i = 1; i < ins.length; i++) {\n if (ins[i] < min) min = ins[i];\n }\n return min;\n }\n\n private static int maxN(int... ins) {\n int max = ins[0];\n for (int i = 1; i < ins.length; i++) {\n if (ins[i] > max) max = ins[i];\n }\n return max;\n }\n\n private static long minN(long... ins) {\n long min = ins[0];\n for (int i = 1; i < ins.length; i++) {\n if (ins[i] < min) min = ins[i];\n }\n return min;\n }\n\n private static long maxN(long... ins) {\n long max = ins[0];\n for (int i = 1; i < ins.length; i++) {\n if (ins[i] > max) max = ins[i];\n }\n return max;\n }\n\n private static int minExAd(int[] dt, int ad) {\n int min = INF;\n for (int i = 0; i < dt.length; i++) {\n if ((i != ad) && (dt[i] < min)) min = dt[i];\n }\n return min;\n }\n\n private static long minExAd(long[] dt, int ad) {\n long min = INFL;\n for (int i = 0; i < dt.length; i++) {\n if ((i != ad) && (dt[i] < min)) min = dt[i];\n }\n return min;\n }\n\n private static int minExVal(int[] dt, int ex_val) {\n int min = INF;\n for (int i = 0; i < dt.length; i++) {\n if ((dt[i] != ex_val) && (dt[i] < min)) min = dt[i];\n }\n return min;\n }\n\n private static long minExVal(long[] dt, long ex_val) {\n long min = INFL;\n for (int i = 0; i < dt.length; i++) {\n if ((dt[i] != ex_val) && (dt[i] < min)) min = dt[i];\n }\n return min;\n }\n\n private static int maxExAd(int[] dt, int ad) {\n int max = -INF;\n for (int i = 0; i < dt.length; i++) {\n if ((i != ad) && (dt[i] > max)) max = dt[i];\n }\n return max;\n }\n\n private static long maxExAd(long[] dt, int ad) {\n long max = -INFL;\n for (int i = 0; i < dt.length; i++) {\n if ((i != ad) && (dt[i] > max)) max = dt[i];\n }\n return max;\n }\n\n private static int maxExVal(int[] dt, int ex_val) {\n int max = -INF;\n for (int i = 0; i < dt.length; i++) {\n if ((dt[i] != ex_val) && (dt[i] > max)) max = dt[i];\n }\n return max;\n }\n\n private static long maxExVal(long[] dt, long ex_val) {\n long max = -INFL;\n for (int i = 0; i < dt.length; i++) {\n if ((dt[i] != ex_val) && (dt[i] > max)) max = dt[i];\n }\n return max;\n }\n\n private static int sumA(int[] dt) {\n int sum = 0;\n for (int e : dt) {\n sum += e;\n }\n return sum;\n }\n\n private static long sumA(long[] dt) {\n long sum = 0;\n for (long e : dt) {\n sum += e;\n }\n return sum;\n }\n\n private static int sumA(List dt) {\n int sum = 0;\n for (long e : dt) {\n sum += e;\n }\n return sum;\n }\n\n private static boolean same3(long a, long b, long c) {\n if (a != b) return false;\n if (b != c) return false;\n if (c != a) return false;\n return true;\n }\n\n private static boolean dif3(long a, long b, long c) {\n if (a == b) return false;\n if (b == c) return false;\n if (c == a) return false;\n return true;\n }\n\n private static boolean triangle_inequality(int a, int b, int c) {\n if ((a + b) < c) return false;\n if ((b + c) < a) return false;\n if ((c + a) < b) return false;\n return true;\n }\n\n private static double hypod(double a, double b) {\n return Math.sqrt(a * a + b * b);\n }\n\n private static long factorial(int n) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans *= i;\n }\n return ans;\n }\n\n private static long facP(int n, long p) {\n long ans = 1;\n for (long i = n; i > 0; i--) {\n ans *= i;\n ans %= p;\n }\n return ans;\n }\n\n private static long lcm(long m, long n) {\n long ans = m / gcd(m, n);\n ans *= n;\n return ans;\n }\n\n private static long gcd(long m, long n) {\n if (m < n) return gcd(n, m);\n if (n == 0) return m;\n return gcd(n, m % n);\n }\n\n private static boolean is_prime(long a) {\n if (a == 1) return false;\n for (long i = 2L; i <= Math.sqrt(a); i++) {\n if (a % i == 0) return false;\n }\n return true;\n }\n\n private static long modinv(long a, long p) {\n long b = p, u = 1L, v = 0L;\n while (b > 0) {\n long t = a / b;\n long pe = a % b;\n a = b;\n b = pe;\n pe = u - t * v;\n u = v;\n v = pe;\n }\n u %= p;\n if (u < 0) u += p;\n return u;\n }\n\n private static int pow(int n, int k) {\n int ans = 1;\n for (int i = 0; i < k; i++) ans *= n;\n return ans;\n }\n\n private static long pow(long n, int k) {\n long ans = 1;\n for (int i = 0; i < k; i++) ans *= n;\n return ans;\n }\n\n private static int pow2(int in) {\n return in * in;\n }\n\n private static long pow2(long in) {\n return in * in;\n }\n\n private static double pow2(double in) {\n return in * in;\n }\n\n private static int getDigit2(long num) {\n long cf = 1;\n int d = 0;\n while (num >= cf) {\n d++;\n cf = (1L << d);\n }\n\n return d;\n }\n\n private static int getDigit10(long num) {\n long cf = 1;\n int d = 0;\n while (num >= cf) {\n d++;\n cf *= 10;\n }\n return d;\n }\n\n private static boolean isINF(int in) {\n if (((long) in * 20) > INF) return true;\n else return false;\n }\n\n private static boolean isINFL(long in) {\n if ((in * 10000) > INFL) return true;\n else return false;\n }\n\n private static long pow10E97(long ob, long soeji, long p) {\n if (ob == 0) return 0;\n if (soeji == 0) return 1;\n if (soeji == 2) return (ob * ob) % p;\n\n int d = getDigit2(soeji);\n long[] ob_pow_2pow = new long[d];\n\n ob_pow_2pow[0] = ob;\n for (int i = 1; i < d; i++) {\n ob_pow_2pow[i] = (ob_pow_2pow[i - 1] * ob_pow_2pow[i - 1]) % p;\n }\n\n long ans = 1;\n for (int i = d - 1; i >= 0; i--) {\n if (soeji >= (long) (1 << i)) {\n soeji -= (long) (1 << i);\n ans = (ans * ob_pow_2pow[i]) % p;\n }\n }\n return ans % p;\n }\n\n private static long flag(long pos) {\n return (1L << pos);\n }\n\n private static boolean isFlaged(int bit, int pos) {\n if ((bit & (1 << pos)) > 0) return true;\n else return false;\n }\n\n private static boolean isFlaged(long bit, int pos) {\n if ((bit & (1L << pos)) > 0) return true;\n else return false;\n }\n\n private static int deflag(int bit, int pos) {\n return bit & ~(1 << pos);\n }\n\n private static int countFlaged(int bit) {\n int ans = 0;\n for (int i = 0; i < getDigit2(bit); i++) {\n if ((bit & (1 << i)) > 0) ans++;\n }\n return ans;\n }\n\n private static int countFlaged(long bit) {\n int ans = 0;\n for (long i = 0; i < getDigit2(bit); i++) {\n if ((bit & (1L << i)) > 0) ans++;\n }\n return ans;\n }\n\n private static void showflag(int bit) {\n for (int i = 0; i < getDigit2(bit); i++) {\n if (isFlaged(bit, i)) System.out.print(\"O\");\n else System.out.print(\".\");\n }\n System.out.println();\n }\n\n public static int biSearch(int[] dt, int target) {\n int left = 0, right = dt.length - 1;\n int mid = -1;\n while (left <= right) {\n mid = (right + left) / 2;\n if (dt[mid] == target) return mid;\n if (dt[mid] < target) left = mid + 1;\n else right = mid - 1;\n }\n return -1;\n }\n\n public static int biSearchMax(long[] dt, long target) {\n int left = -1, right = dt.length;\n int mid = -1;\n\n while ((right - left) > 1) {\n mid = left + (right - left) / 2;\n if (dt[mid] <= target) left = mid;\n else right = mid;\n }\n return left;\n }\n\n public static int biSearchMaxAL(ArrayList dt, long target) {\n int left = -1, right = dt.size();\n int mid = -1;\n\n while ((right - left) > 1) {\n mid = left + (right - left) / 2;\n if (dt.get(mid) <= target) left = mid;\n else right = mid;\n }\n return left;\n }\n\n private static void fill_parent(int[] ob) {\n for (int i = 0; i < ob.length; i++) ob[i] = i;\n }\n\n private static int get_root_uf(int[] parent, int index) {\n if (parent[index] == index) return index;\n int root = get_root_uf(parent, parent[index]);\n parent[index] = root;\n return root;\n }\n\n private static boolean is_same_uf(int[] parent, int x, int y) {\n if (get_root_uf(parent, x) == get_root_uf(parent, y)) return true;\n else return false;\n }\n\n private static void unite_uf(int[] parent, int receiver, int attacker) {\n parent[get_root_uf(parent, attacker)] = get_root_uf(parent, receiver);\n }\n\n private static int[] Xdir4 = {1, 0, 0, -1};\n private static int[] Ydir4 = {0, 1, -1, 0};\n\n private static int[] Xdir8 = {1, 1, 1, 0, 0, -1, -1, -1};\n private static int[] Ydir8 = {1, 0, -1, 1, -1, 1, 0, -1};\n\n private static boolean is_in_area(int y, int x, int h, int w) {\n if (y < 0) return false;\n if (x < 0) return false;\n if (y >= h) return false;\n if (x >= w) return false;\n return true;\n }\n\n static void show2(boolean[][] dt, int lit_x, int lit_y) {\n PrintWriter out = new PrintWriter(System.out);\n for (int j = 0; j < dt.length; j++) {\n for (int i = 0; i < dt[j].length; i++) {\n if ((i == lit_y) && (j == lit_x)) out.print(\"X\");\n else if (dt[j][i]) out.print(\"O\");\n else out.print(\".\");\n }\n out.println();\n }\n out.flush();\n }\n\n static void show2(int[][] dt, String cmnt) {\n PrintWriter out = new PrintWriter(System.out);\n for (int i = 0; i < dt.length; i++) {\n for (int j = 0; j < dt[i].length; j++) {\n out.print(dt[i][j] + \",\");\n }\n out.println(\"<-\" + cmnt + \":\" + i);\n }\n out.flush();\n }\n\n static void show2(long[][] dt, String cmnt) {\n PrintWriter out = new PrintWriter(System.out);\n for (int i = 0; i < dt.length; i++) {\n for (int j = 0; j < dt[i].length; j++) {\n out.print(dt[i][j] + \",\");\n }\n out.println(\"<-\" + cmnt + \":\" + i);\n }\n out.flush();\n }\n\n static void disp_que(ArrayDeque dt) {\n long a = 0;\n while (dt.size() > 0) {\n a = dt.removeFirst();\n System.out.print(a);\n }\n System.out.println(\"\\n\");\n }\n\n static void disp_list(List dt) {\n for (int i = 0; i < dt.size(); i++) {\n System.out.print(dt.get(i) + \",\");\n }\n System.out.println(\"\\n\");\n }\n\n private static void prtlnas(int[] as) {\n PrintWriter out = new PrintWriter(System.out);\n for (int i = 0; i < as.length; i++) {\n out.println(as[i]);\n }\n out.flush();\n }\n\n private static void prtlnas(long[] as) {\n PrintWriter out = new PrintWriter(System.out);\n for (int i = 0; i < as.length; i++) {\n out.println(as[i]);\n }\n out.flush();\n }\n\n private static void prtspas(int[] as) {\n PrintWriter out = new PrintWriter(System.out);\n out.print(as[0]);\n for (int i = 1; i < as.length; i++) {\n out.print(\" \" + as[i]);\n }\n out.println();\n out.flush();\n }\n\n private static void prtspas(long[] as) {\n PrintWriter out = new PrintWriter(System.out);\n out.print(as[0]);\n for (int i = 1; i < as.length; i++) {\n out.print(\" \" + as[i]);\n }\n out.println();\n out.flush();\n }\n\n private static void prtspas(List as) {\n PrintWriter out = new PrintWriter(System.out);\n out.print(as.get(0));\n for (int i = 1; i < as.size(); i++) {\n out.print(\" \" + as.get(i));\n }\n out.println();\n out.flush();\n }\n\n private static void fill(boolean[] ob, boolean res) {\n for (int i = 0; i < ob.length; i++) {\n ob[i] = res;\n }\n }\n\n private static void fill(int[] ob, int res) {\n for (int i = 0; i < ob.length; i++) {\n ob[i] = res;\n }\n }\n\n private static void fill(long[] ob, long res) {\n for (int i = 0; i < ob.length; i++) {\n ob[i] = res;\n }\n }\n\n private static void fill(char[] ob, char res) {\n for (int i = 0; i < ob.length; i++) {\n ob[i] = res;\n }\n }\n\n private static void fill(double[] ob, double res) {\n for (int i = 0; i < ob.length; i++) {\n ob[i] = res;\n }\n }\n\n private static void fill(boolean[][] ob, boolean res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n ob[i][j] = res;\n }\n }\n }\n\n private static void fill(int[][] ob, int res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n ob[i][j] = res;\n }\n }\n }\n\n private static void fill(long[][] ob, long res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n ob[i][j] = res;\n }\n }\n }\n\n private static void fill(char[][] ob, char res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n ob[i][j] = res;\n }\n }\n }\n\n private static void fill(double[][] ob, double res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n ob[i][j] = res;\n }\n }\n }\n\n private static void fill(int[][][] ob, int res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n for (int k = 0; k < ob[0][0].length; k++) {\n ob[i][j][k] = res;\n }\n }\n }\n }\n\n private static void fill(long[][][] ob, long res) {\n for (int i = 0; i < ob.length; i++) {\n for (int j = 0; j < ob[0].length; j++) {\n for (int k = 0; k < ob[0][0].length; k++) {\n ob[i][j][k] = res;\n }\n }\n }\n }\n\n static class FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nexL() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b) || b == ':') {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nexI() {\n long nl = nexL();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nexD() {\n return Double.parseDouble(next());\n }\n\n public void ni(long[] array2) {\n for (int i = 0; i < array2.length; i++) {\n array2[i] = nexL();\n }\n return;\n }\n\n public void ni(int[] array2) {\n for (int i = 0; i < array2.length; i++) {\n array2[i] = nexI();\n }\n return;\n }\n\n public void ni(int[] as, int[] bs) {\n for (int i = 0; i < as.length; i++) {\n as[i] = nexI();\n bs[i] = nexI();\n }\n return;\n }\n\n public void ni(long[] as, long[] bs) {\n for (int i = 0; i < as.length; i++) {\n as[i] = nexL();\n bs[i] = nexL();\n }\n return;\n }\n\n public void ni(int[] as, int[] bs, int[] cs) {\n for (int i = 0; i < as.length; i++) {\n as[i] = nexI();\n bs[i] = nexI();\n cs[i] = nexI();\n }\n return;\n }\n\n public void nisan(int[][] as) {\n for (int i = 0; i < as.length; i++) {\n for (int j = 0; j < as[0].length; j++) {\n as[i][j] = nexI();\n }\n }\n return;\n }\n }\n}\n", "test_IO": [ { "input": "3\n011\n", "output": "2\n1\n1\n" } ] }, { "id": "s910447421", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.math.*;\nimport java.util.*;\n\npublic class s910447421 {\n static int ans = 100;\n static int[][] balls;\n static int N;\n static boolean[] taken;\n\n public static void main(String[] args) {\n\n FastScanner I = new FastScanner();\n OutPut O = new OutPut();\n N = I.nextInt();\n ans = N;\n balls = new int[N][2];\n for (int i = 0; i < N; i++) {\n balls[i][0] = I.nextInt();\n balls[i][1] = I.nextInt();\n }\n Arrays.sort(balls, (a, b) -> Integer.compare(a[0], b[0]));\n solve();\n for (int i = 0; i < N; i++) {\n int x = balls[i][0];\n int y = balls[i][1];\n balls[i][0] = y;\n balls[i][1] = x;\n }\n Arrays.sort(balls, (a, b) -> Integer.compare(a[0], b[0]));\n solve();\n O.pln(ans);\n }\n\n public static void solve() {\n for (int add = 1; add < N; add++) {\n taken = new boolean[N];\n int p = balls[add][0] - balls[0][0];\n int q = balls[add][1] - balls[0][1];\n ans = min(ans, check(p, q));\n }\n }\n\n public static int check(int p, int q) {\n int ret = 0;\n while (true) {\n boolean added = false;\n int start = 0;\n int x = -1;\n int y = -1;\n for (int i = 0; i < N; i++) {\n if (!taken[i]) {\n added = true;\n ret++;\n start = i;\n taken[i] = true;\n x = balls[i][0] + p;\n y = balls[i][1] + q;\n break;\n }\n }\n if (!added) break;\n for (int i = start + 1; i < N; i++) {\n if (balls[i][0] == x && balls[i][1] == y) {\n taken[i] = true;\n x += p;\n y += q;\n }\n }\n }\n return ret;\n }\n\n public static double max(double a, double b) {\n return Math.max(a, b);\n }\n\n public static double min(double a, double b) {\n return Math.min(a, b);\n }\n\n public static long min(long a, long b) {\n return Math.min(a, b);\n }\n\n public static long max(long a, long b) {\n return Math.max(a, b);\n }\n\n public static int min(int a, int b) {\n return Math.min(a, b);\n }\n\n public static int max(int a, int b) {\n return Math.max(a, b);\n }\n\n public static long abs(long x) {\n return Math.abs(x);\n }\n\n public static long ceil(long num, long den) {\n long ans = num / den;\n if (num % den != 0) ans++;\n return ans;\n }\n\n public static long GCD(long a, long b) {\n if (a == 0 || b == 0) return max(a, b);\n return GCD(min(a, b), max(a, b) % min(a, b));\n }\n\n public static long FastExp(long base, long exp, long mod) {\n long ans = 1;\n while (exp > 0) {\n if (exp % 2 == 1) ans *= base;\n exp /= 2;\n base *= base;\n base %= mod;\n ans %= mod;\n }\n return ans;\n }\n\n public static long ModInv(long num, long mod) {\n return FastExp(num, mod - 2, mod);\n }\n\n public static int pop(long x) {\n int cnt = 0;\n while (x > 0) {\n if (x % 2 == 1) cnt++;\n x /= 2;\n }\n return cnt;\n }\n\n static class FastScanner {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n StringTokenizer st = new StringTokenizer(\"\");\n\n String next() {\n while (!st.hasMoreTokens())\n try {\n st = new StringTokenizer(br.readLine());\n } catch (IOException e) {\n e.printStackTrace();\n }\n return st.nextToken();\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n ;\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n }\n\n static class OutPut {\n PrintWriter w = new PrintWriter(System.out);\n\n void pln(double x) {\n w.println(x);\n w.flush();\n }\n\n void pln(boolean x) {\n w.println(x);\n w.flush();\n }\n\n void pln(int x) {\n w.println(x);\n w.flush();\n }\n\n void pln(long x) {\n w.println(x);\n w.flush();\n }\n\n void pln(String x) {\n w.println(x);\n w.flush();\n }\n\n void pln(char x) {\n w.println(x);\n w.flush();\n }\n\n void pln(StringBuilder x) {\n w.println(x);\n w.flush();\n }\n\n void pln(BigInteger x) {\n w.println(x);\n w.flush();\n }\n\n void p(int x) {\n w.print(x);\n w.flush();\n }\n\n void p(long x) {\n w.print(x);\n w.flush();\n }\n\n void p(String x) {\n w.print(x);\n w.flush();\n }\n\n void p(char x) {\n w.print(x);\n w.flush();\n }\n\n void p(StringBuilder x) {\n w.print(x);\n w.flush();\n }\n\n void p(BigInteger x) {\n w.print(x);\n w.flush();\n }\n\n void p(double x) {\n w.print(x);\n w.flush();\n }\n\n void p(boolean x) {\n w.print(x);\n w.flush();\n }\n }\n}\n", "test_IO": [ { "input": "2\n1 1\n2 2\n", "output": "1\n" } ] }, { "id": "s836223717", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s836223717 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n long[] ryuka = new long[n + 1];\n ryuka[0] = 2;\n ryuka[1] = 1;\n for (int i = 2; i < n + 1; i++) {\n ryuka[i] = ryuka[i - 1] + ryuka[i - 2];\n }\n System.out.println(ryuka[n]);\n }\n}\n", "test_IO": [ { "input": "5\n", "output": "11\n" } ] }, { "id": "s163827828", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s163827828 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int N = Integer.parseInt(sc.next());\n String s[] = new String[N];\n int a_num = 0;\n int b_num = 0;\n boolean flag = true;\n int ans = 0;\n for (int i = 0; i < N; i++) {\n s[i] = sc.next();\n if (s[i].substring(0, 1).equals(\"B\")) {\n b_num++;\n }\n if (s[i].substring(s[i].length() - 1, s[i].length()).equals(\"A\")) {\n a_num++;\n }\n if (s[i].substring(0, 1).equals(\"B\")\n || s[i].substring(s[i].length() - 1, s[i].length()).equals(\"A\")) {\n if (!(s[i].substring(0, 1).equals(\"B\")\n && s[i].substring(s[i].length() - 1, s[i].length()).equals(\"A\"))) {\n flag = false;\n }\n }\n for (int j = 0; j < s[i].length() - 1; j++) {\n if (s[i].substring(j, j + 2).equals(\"AB\")) ans++;\n }\n }\n ans += Math.min(a_num, b_num);\n if (Math.min(a_num, b_num) != 0 && flag) {\n ans--;\n }\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "3\nABCA\nXBAZ\nBAD\n", "output": "2\n" } ] }, { "id": "s798589501", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s798589501 {\n public static void main(String[] args) throws Exception {\n\n Scanner s = new Scanner(System.in);\n int E = s.nextInt();\n int Y = s.nextInt();\n\n if (E == 0) {\n if (Y <= 1911) {\n System.out.print(\"M\");\n System.out.println(Y - 1867);\n } else if (Y <= 1925) {\n System.out.print(\"T\");\n System.out.println(Y - 1911);\n } else if (Y <= 1988) {\n System.out.print(\"S\");\n System.out.println(Y - 1925);\n } else {\n System.out.print(\"H\");\n System.out.println(Y - 1988);\n }\n } else if (E == 1) {\n System.out.println(1867 + Y);\n } else if (E == 2) {\n System.out.println(1911 + Y);\n } else if (E == 3) {\n System.out.println(1925 + Y);\n } else {\n System.out.println(1988 + Y);\n }\n }\n}\n", "test_IO": [ { "input": "0 2015\n", "output": "H27\n" } ] }, { "id": "s858314534", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s858314534 {\n public static void main(String[] args) {\n @SuppressWarnings(\"resource\")\n Scanner scanner = new Scanner(System.in);\n\n int A = scanner.nextInt();\n\n int B = scanner.nextInt();\n\n int T = scanner.nextInt();\n\n log((T / A) * B);\n }\n\n private static void log(String str) {\n System.out.println(str);\n }\n\n private static void log(int str) {\n System.out.println(str);\n }\n}\n", "test_IO": [ { "input": "3 5 7\n", "output": "10\n" } ] }, { "id": "s233008404", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.StringTokenizer;\n\npublic class s233008404 {\n\n String[][] colorMtr;\n int h;\n int w;\n int k;\n\n public static void main(String[] args) throws IOException {\n s233008404 mainObj = new s233008404();\n mainObj.solve();\n }\n\n public void solve() throws IOException {\n FastScanner fs = new FastScanner();\n\n h = fs.nextInt();\n w = fs.nextInt();\n k = fs.nextInt();\n\n colorMtr = new String[h][];\n for (int i = 0; i < h; i++) {\n colorMtr[i] = fs.next().split(\"\");\n }\n\n int hPattern = pow(2, h);\n int wPattern = pow(2, w);\n\n int ans = 0;\n\n for (int i = 0; i < hPattern; i++) {\n for (int j = 0; j < wPattern; j++) {\n if (judge(i, j)) {\n ans++;\n }\n }\n }\n\n System.out.println(ans);\n }\n\n boolean judge(int hPattern, int wPattern) {\n\n int[] hBitArr = new int[h];\n int[] wBitArr = new int[w];\n\n for (int i = 0; i < h; i++) {\n if (((hPattern >> i) & 1) == 1) {\n hBitArr[i] = 1;\n }\n }\n\n for (int i = 0; i < w; i++) {\n if (((wPattern >> i) & 1) == 1) {\n wBitArr[i] = 1;\n }\n }\n\n int black = 0;\n\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n if (hBitArr[i] == 1 || wBitArr[j] == 1) {\n continue;\n }\n\n if (colorMtr[i][j].equals(\"#\")) {\n black++;\n }\n }\n }\n\n if (black == k) {\n return true;\n } else {\n return false;\n }\n }\n\n public int pow(int base, int n) {\n int retVal = 1;\n while (n > 0) {\n if ((n & 1) == 1) {\n retVal *= base;\n }\n n >>= 1;\n base *= base;\n }\n return retVal;\n }\n\n public class FastScanner {\n\n BufferedReader reader;\n private StringTokenizer st;\n\n public FastScanner() {\n st = null;\n reader = new BufferedReader(new InputStreamReader(System.in));\n }\n\n public String next() throws IOException {\n if (st == null || !st.hasMoreElements()) {\n st = new StringTokenizer(reader.readLine());\n }\n return st.nextToken();\n }\n\n public String nextLine() throws IOException {\n st = null;\n String readLine = null;\n readLine = reader.readLine();\n return readLine;\n }\n\n public int nextInt() throws NumberFormatException, IOException {\n return Integer.parseInt(next());\n }\n\n public long nextLong() throws NumberFormatException, IOException {\n return Long.parseLong(next());\n }\n\n public int[] nextIntArr(int n) throws NumberFormatException, IOException {\n int[] retArr = new int[n];\n for (int i = 0; i < n; i++) {\n retArr[i] = nextInt();\n }\n return retArr;\n }\n\n public long[] nextLongArr(int n) throws NumberFormatException, IOException {\n long[] retArr = new long[n];\n for (int i = 0; i < n; i++) {\n retArr[i] = nextLong();\n }\n return retArr;\n }\n\n public void close() throws IOException {\n reader.close();\n }\n }\n}\n", "test_IO": [ { "input": "2 3 2\n..#\n###\n", "output": "5\n" } ] }, { "id": "s880132387", "dataset": "codenet", "language": "Java", "code": "import static java.lang.System.*;\n\nimport java.math.BigInteger;\nimport java.util.*;\n\nclass s880132387 {\n public static Scanner sc = new Scanner(in);\n public static Random rand = new Random();\n\n public void run() {\n TCase:\n while (true) {\n int W = sc.nextInt(), H = sc.nextInt();\n if (W == 0 && H == 0) return;\n char[][] map = new char[H][W];\n\n for (int h = 0; h < H; h++) {\n map[h] = sc.next().toCharArray();\n }\n\n BigInteger[][] dp = new BigInteger[H][W];\n\n for (int h = 0; h < H; h++)\n for (int w = 0; w < W; w++) {\n BigInteger hprev = BigInteger.ZERO;\n if (h >= 1) {\n hprev = dp[h - 1][w];\n }\n BigInteger wprev = BigInteger.ZERO;\n if (w >= 1) {\n wprev = dp[h][w - 1];\n }\n if (Character.isDigit(map[h][w])) {\n BigInteger max;\n if (hprev.compareTo(wprev) > 0) {\n max = hprev;\n } else {\n max = wprev;\n }\n dp[h][w] = max.multiply(BigInteger.TEN).add(new BigInteger(map[h][w] + \"\"));\n } else {\n dp[h][w] = BigInteger.ZERO;\n }\n }\n BigInteger max = BigInteger.ZERO;\n for (int h = 0; h < H; h++)\n for (int w = 0; w < W; w++) {\n if (dp[h][w].compareTo(max) > 0) max = dp[h][w];\n }\n ln(max);\n }\n }\n\n public static void main(String[] args) {\n new s880132387().run();\n }\n\n public int[] nextIntArray(int n) {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) {\n res[i] = sc.nextInt();\n }\n return res;\n }\n\n public static void pr(Object o) {\n out.print(o);\n }\n\n public static void ln(Object o) {\n out.println(o);\n }\n\n public static void ln() {\n out.println();\n }\n}\n", "test_IO": [ { "input": "7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJH03HE\nID7722\n0DA1AH\n30C9G5\n99971A\nCA7EAI\nAHLBEM\n20 2\nA1234567891234CBDEGH\nBDEDF908034265091499\n0 0\n", "output": "23900037\n771971\n12345908034265091499\n" } ] }, { "id": "s066389476", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s066389476 {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in); ) {\n solve(sc);\n }\n }\n\n public static void solve(Scanner sc) {\n char[] a = sc.next().toCharArray();\n if (a[0] == a[1] || a[1] == a[2] || a[2] == a[0]) {\n System.out.println(\"No\");\n } else {\n System.out.println(\"Yes\");\n }\n }\n}\n", "test_IO": [ { "input": "bac\n", "output": "Yes\n" } ] }, { "id": "s927992720", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s927992720 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n while (true) {\n int a = sc.nextInt();\n String op = sc.next();\n int b = sc.nextInt();\n\n if (op.equals(\"?\")) break;\n if (op.equals(\"+\")) System.out.println(a + b);\n if (op.equals(\"-\")) System.out.println(a - b);\n if (op.equals(\"*\")) System.out.println(a * b);\n if (op.equals(\"/\")) System.out.println(a / b);\n }\n }\n}\n", "test_IO": [ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ] }, { "id": "s369598583", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s369598583 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int count = 0;\n int next = 10;\n for (int i = 1; i <= N; i++) {\n count++;\n if (i == next - 1) {\n i = next * 10 - 1;\n next *= 100;\n }\n }\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "11\n", "output": "9\n" } ] }, { "id": "s967693306", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\nclass s967693306 {\n static final long INF = Long.MAX_VALUE / 2;\n static final int MOD = 1_000_000_007;\n static final int SIZE = 1_000_000;\n long[] fac = new long[SIZE];\n long[] inv = new long[SIZE];\n long[] finv = new long[SIZE];\n FastScanner sc = new FastScanner();\n\n public static void main(String[] args) {\n new s967693306().solve();\n }\n\n void solve() {\n\n int n = sc.nextInt();\n int m = sc.nextInt();\n Map map = new HashMap<>();\n\n for (int i = 0; i < m; i++) {\n int s = sc.nextInt();\n int c = sc.nextInt();\n if (map.get(s) != null && map.get(s) != c) {\n System.out.println(-1);\n System.exit(0);\n }\n map.put(s, c);\n }\n\n for (int i = 0; i < 1000; i++) {\n String s = \"\" + i;\n boolean flag = true;\n if (s.length() < n) continue;\n for (int j = 0; j < n; j++) {\n if ((map.get(j + 1) != null\n && map.get(j + 1) != Character.getNumericValue(s.charAt(j)))\n || (map.get(j + 1) == null\n && Character.getNumericValue(s.charAt(j)) != 0)) {\n if (map.get(j + 1) == null\n && j == 0\n && Character.getNumericValue(s.charAt(j)) == 1) {\n continue;\n }\n flag = false;\n break;\n }\n }\n if (flag && s.length() == n) {\n System.out.println(s);\n System.exit(0);\n }\n }\n\n System.out.println(-1);\n }\n\n long gcd(long a, long b) {\n if (b == 0) {\n return a;\n }\n return gcd(b, a % b);\n }\n\n long lcm(long a, long b) {\n return a * b / gcd(a, b);\n }\n\n long inv(long a) {\n return pow(a, MOD - 2);\n }\n\n long pow(long a, long r) {\n long sum = 1;\n while (r > 0) {\n if ((r & 1) == 1) {\n sum *= a;\n sum %= MOD;\n }\n a *= a;\n a %= MOD;\n r >>= 1;\n }\n return sum;\n }\n\n long modFact(long n) {\n if (n == 0) {\n return 1;\n }\n return n * modFact(n - 1) % MOD;\n }\n\n long fact(long n) {\n if (n == 0) {\n return 1;\n }\n return n * fact(n - 1);\n }\n\n void initCOMB() {\n fac[0] = fac[1] = 1;\n inv[1] = 1;\n finv[0] = finv[1] = 1;\n for (int i = 2; i < SIZE; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;\n finv[i] = finv[i - 1] * inv[i] % MOD;\n }\n }\n\n long modComb(int n, int r) {\n if (n < r || n < 0 || r < 0) return 0;\n return fac[n] * finv[r] % MOD * finv[n - r] % MOD;\n }\n\n long comb(long n, long r) {\n long num = 1;\n for (long i = 1; i <= r; i++) {\n num = num * (n - i + 1) / i;\n }\n return num;\n }\n\n boolean isPrime(long a) {\n if (a <= 1) return false;\n for (int i = 2; i * i <= a; i++) {\n if (a % i == 0) return false;\n }\n return true;\n }\n\n String nextPermutation(String s) {\n ArrayList list = new ArrayList<>();\n for (int i = 0; i < s.length(); i++) list.add(s.charAt(i));\n\n int pivotPos = -1;\n char pivot = 0;\n for (int i = list.size() - 2; i >= 0; i--) {\n if (list.get(i) < list.get(i + 1)) {\n pivotPos = i;\n pivot = list.get(i);\n break;\n }\n }\n\n if (pivotPos == -1 && pivot == 0) return null;\n\n int L = pivotPos + 1;\n int R = list.size() - 1;\n int minPos = -1;\n char min = Character.MAX_VALUE;\n for (int i = R; i >= L; i--) {\n if (pivot < list.get(i)) {\n if (list.get(i) < min) {\n min = list.get(i);\n minPos = i;\n }\n }\n }\n\n Collections.swap(list, pivotPos, minPos);\n Collections.sort(list.subList(L, R + 1));\n\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < list.size(); i++) sb.append(list.get(i));\n\n return sb.toString();\n }\n\n boolean nextPermutation(long[] a) {\n for (int i = a.length - 1; i > 0; i--) {\n if (a[i - 1] < a[i]) {\n int swapIndex = find(a[i - 1], a, i, a.length - 1);\n long temp = a[swapIndex];\n a[swapIndex] = a[i - 1];\n a[i - 1] = temp;\n Arrays.sort(a, i, a.length);\n return true;\n }\n }\n return false;\n }\n\n int find(long dest, long[] a, int s, int e) {\n if (s == e) {\n return s;\n }\n int m = (s + e + 1) / 2;\n return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);\n }\n\n void elimination(int[][] a, int[] b) {\n int n = a.length;\n double f;\n for (int k = 0; k < n - 1; k++) {\n for (int i = k + 1; i < n; i++) {\n f = -a[i][k] / a[k][k];\n for (int j = k + 1; j < n; j++) {\n a[i][j] += f * a[k][j];\n }\n b[i] += f * b[k];\n }\n for (int i = n - 1; i >= 0; i--) {\n for (int j = i + 1; j < n; j++) {\n b[i] -= a[i][j] * b[j];\n }\n b[i] = b[i] / a[i][i];\n }\n }\n }\n}\n\nclass Pair implements Comparable {\n long a, b;\n\n public Pair(long i, long j) {\n a = i;\n b = j;\n }\n\n @Override\n public int compareTo(Pair p) {\n if (this.b < p.b) return -1;\n else if (this.b > p.b) return 1;\n else return 0;\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "test_IO": [ { "input": "3 3\n1 7\n3 2\n1 7\n", "output": "702\n" } ] }, { "id": "s910008321", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s910008321 {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int h = scanner.nextInt();\n int a = scanner.nextInt();\n if (h % a == 0) {\n System.out.println(h / a);\n } else {\n System.out.println(h / a + 1);\n }\n }\n}\n", "test_IO": [ { "input": "10 4\n", "output": "3\n" } ] }, { "id": "s659026534", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s659026534 {\n\n public static void main(String[] args) {\n @SuppressWarnings(\"resource\")\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int count = 0;\n for (int i = 1; i <= n; i++) {\n count += i;\n }\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "3\n", "output": "6\n" } ] }, { "id": "s912747097", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s912747097 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int r = sc.nextInt();\n System.out.println(3 * r * r);\n }\n}\n", "test_IO": [ { "input": "4\n", "output": "48\n" } ] }, { "id": "s012761786", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s012761786 {\n\n static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) {\n\n long n = nextLong();\n long a = nextLong();\n long b = nextLong();\n\n long sa = Math.abs(a - b);\n\n long ans = 0;\n\n if (sa % 2 == 0) {\n ans = sa / 2;\n } else {\n long AAA = Math.min((n - a), (a - 1));\n long BBB = Math.min((n - b), (b - 1));\n\n ans = Math.min(AAA, BBB);\n\n sa -= 1;\n ans += 1;\n\n ans += sa / 2;\n }\n\n System.out.println(ans);\n }\n\n static String next() {\n return sc.next();\n }\n\n static int nextInt() {\n return Integer.parseInt(sc.next());\n }\n\n static long nextLong() {\n return Long.parseLong(sc.next());\n }\n\n static double nextDouble() {\n return Double.parseDouble(sc.next());\n }\n\n static String[] splitString(String s) {\n return s.split(\"\");\n }\n\n static char[] splitChar(String s) {\n return s.toCharArray();\n }\n\n static int charToInt(char aaa) {\n return aaa - 48;\n }\n\n public static int maxInt(int[] a, int lng) {\n int max = a[0];\n for (int i = 1; i < lng; i++) {\n max = Math.max(max, a[i]);\n }\n return max;\n }\n\n public static int minInt(int[] a, int lng) {\n int min = a[0];\n for (int i = 1; i < lng; i++) {\n min = Math.min(min, a[i]);\n }\n return min;\n }\n\n public static long maxLong(long[] a, int lng) {\n long max = a[0];\n for (int i = 1; i < lng; i++) {\n max = Math.max(max, a[i]);\n }\n return max;\n }\n\n public static long minLong(long[] a, int lng) {\n long min = a[0];\n for (int i = 1; i < lng; i++) {\n min = Math.min(min, a[i]);\n }\n return min;\n }\n}\n", "test_IO": [ { "input": "5 2 4\n", "output": "1\n" } ] }, { "id": "s799557290", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s799557290 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n int a = sc.nextInt();\n int b = sc.nextInt();\n boolean ju[] = new boolean[100001];\n int pe[] = new int[100001];\n int wa = 0;\n int ac = 0;\n\n for (int i = 0; i < b; i++) {\n int n = sc.nextInt();\n String res = sc.next();\n\n if (res.equals(\"WA\") && ju[n - 1] != true) {\n pe[n - 1]++;\n }\n\n if (res.equals(\"AC\")) {\n ju[n - 1] = true;\n }\n }\n\n for (int i = 0; i < a; i++) {\n if (ju[i]) {\n ac++;\n wa += pe[i];\n }\n }\n\n System.out.println(\"\" + ac + \" \" + wa);\n }\n}\n", "test_IO": [ { "input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "output": "2 2\n" } ] }, { "id": "s537034016", "dataset": "codenet", "language": "Java", "code": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class s537034016 {\n static long[] dp;\n static int mod = 1000000007;\n\n public static void main(String[] args) throws Exception {\n Scanner sc = new Scanner(System.in);\n int s = sc.nextInt();\n sc.close();\n\n dp = new long[s + 1];\n Arrays.fill(dp, -1);\n dp[0] = 1;\n System.out.println(dfs(s));\n }\n\n static long dfs(int s) {\n if (dp[s] != -1) {\n return dp[s];\n }\n\n long ret = 0;\n for (int i = s - 3; i >= 0; i--) {\n ret += dfs(i);\n ret %= mod;\n }\n return dp[s] = ret;\n }\n}\n", "test_IO": [ { "input": "7\n", "output": "3\n" } ] }, { "id": "s818271374", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s818271374 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int count1 = 0;\n int count2 = 0;\n for (int i = 0; i < N; i++) {\n int a = sc.nextInt();\n if (a % 4 == 0) {\n count1++;\n } else if (a % 2 == 0 && (a / 2) % 2 == 1) {\n count2++;\n }\n }\n if (count1 >= N / 2) {\n System.out.println(\"Yes\");\n } else if (((N / 2 - count1) * 2 + N % 2) == count2) {\n System.out.println(\"Yes\");\n } else {\n System.out.println(\"No\");\n }\n }\n}\n", "test_IO": [ { "input": "3\n1 10 100\n", "output": "Yes\n" } ] }, { "id": "s518927375", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s518927375 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n\n long k = sc.nextLong();\n long a = sc.nextLong();\n long b = sc.nextLong();\n\n if (b <= a + 2) {\n System.out.println(1 + k);\n return;\n }\n\n long x = k - (a - 1);\n long ans = a + (x / 2) * (b - a) + (x % 2);\n\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "4 2 6\n", "output": "7\n" } ] }, { "id": "s518990279", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class s518990279 {\n\n public static final int BIG_NUM = 2000000000;\n public static final int MOD = 1000000007;\n\n public static void main(String[] args) {\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n int ans;\n\n while (true) {\n\n try {\n String inputed = br.readLine();\n if (inputed.length() == 1 && inputed.equals(\"0\")) break;\n\n ans = 0;\n for (int i = 0; i < inputed.length(); i++) {\n ans += inputed.charAt(i) - '0';\n }\n\n System.out.printf(\"%d\\n\", ans);\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }\n}\n", "test_IO": [ { "input": "123\n55\n1000\n0\n", "output": "6\n10\n1\n" } ] }, { "id": "s287007304", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class s287007304 {\n\n public static void main(String[] args) {\n\n String[] s = readLine().split(\" \");\n int a = Integer.parseInt(s[0]);\n int b = Integer.parseInt(s[1]);\n if (b % a == 0) {\n System.out.println(a + b);\n } else {\n System.out.println(b - a);\n }\n return;\n }\n\n private static String readLine() {\n BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n try {\n return reader.readLine();\n } catch (Exception e) {\n return e.getMessage();\n }\n }\n}\n", "test_IO": [ { "input": "4 12\n", "output": "16\n" } ] }, { "id": "s302760734", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s302760734 {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n char[] s = scanner.next().toCharArray(), t = scanner.next().toCharArray();\n boolean check = false;\n for (int i = s.length - t.length; i >= 0; i--) {\n boolean check2 = true;\n for (int j = 0; j < t.length; j++) {\n if (s[i + j] != '?' && s[i + j] != t[j]) {\n check2 = false;\n }\n }\n if (check2) {\n check = true;\n for (int j = 0; j < t.length; j++) {\n s[i + j] = t[j];\n }\n }\n if (check) {\n break;\n }\n }\n if (check) {\n for (int i = 0; i < s.length; i++) {\n if (s[i] == '?') {\n System.out.print(\"a\");\n } else {\n System.out.print(s[i]);\n }\n }\n System.out.println();\n } else {\n System.out.println(\"UNRESTORABLE\");\n }\n }\n}\n", "test_IO": [ { "input": "?tc????\ncoder\n", "output": "atcoder\n" } ] }, { "id": "s022525398", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\nclass s022525398 {\n\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n String a = in.next();\n String b = in.next();\n System.out.println(b + a);\n }\n}\n", "test_IO": [ { "input": "oder atc\n", "output": "atcoder\n" } ] }, { "id": "s193347311", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s193347311 {\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int intLoop = scan.nextInt();\n String strTaro = \"\";\n String strHana = \"\";\n int intTaro = 0;\n int intHana = 0;\n\n for (int i = 0; i < intLoop; i++) {\n strTaro = scan.next();\n strHana = scan.next();\n int intJudge = strTaro.compareTo(strHana);\n if (intJudge < 0) {\n intHana += 3;\n } else if (intJudge == 0) {\n intTaro++;\n intHana++;\n } else if (0 < intJudge) {\n intTaro += 3;\n }\n }\n System.out.println(intTaro + \" \" + intHana);\n scan.close();\n }\n}\n", "test_IO": [ { "input": "3\ncat dog\nfish fish\nlion tiger\n", "output": "1 7\n" } ] }, { "id": "s498914558", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\npublic class s498914558 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int m = sc.nextInt();\n int po[] = new int[n];\n for (int i = 0; i < n; i++) {\n po[i] = sc.nextInt();\n m -= po[i];\n }\n Arrays.sort(po);\n System.out.println(n + m / po[0]);\n }\n}\n", "test_IO": [ { "input": "3 1000\n120\n100\n140\n", "output": "9\n" } ] }, { "id": "s566905615", "dataset": "codenet", "language": "Java", "code": "import java.util.*;\n\nclass s566905615 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n int c = sc.nextInt();\n String answer = \"No\";\n if (a + b >= c) {\n answer = \"Yes\";\n }\n System.out.println(answer);\n }\n}\n", "test_IO": [ { "input": "50 100 120\n", "output": "Yes\n" } ] }, { "id": "s967858671", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s967858671 {\n public static void main(String[] args) {\n int[] Num;\n Num = new int[11];\n Scanner n = new Scanner(System.in);\n for (int i = 0; i < 10; i++) {\n Num[i] = n.nextInt();\n }\n\n for (int a = 9; a >= 0; a--) {\n for (int b = 0; b < a; b++) {\n if (Num[b] < Num[b + 1]) {\n Num[10] = Num[b];\n Num[b] = Num[b + 1];\n Num[b + 1] = Num[10];\n }\n }\n }\n\n System.out.println(Num[0]);\n System.out.println(Num[1]);\n System.out.println(Num[2]);\n }\n}\n", "test_IO": [ { "input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n", "output": "3776\n2848\n2840\n" } ] }, { "id": "s201062219", "dataset": "codenet", "language": "Java", "code": "import java.io.IOException;\nimport java.util.Scanner;\n\npublic class s201062219 {\n public static void main(String[] args) throws IOException {\n Scanner scan = new Scanner(System.in);\n String mark;\n int c = 0;\n int b = 0;\n int a[] = new int[100000];\n int x = 0;\n do {\n c = scan.nextInt();\n mark = scan.next();\n b = scan.nextInt();\n if (mark.equals(\"?\")) {\n a[x] = 2000001;\n break;\n } else if (mark.equals(\"+\")) {\n a[x] = c + b;\n } else if (mark.equals(\"-\")) {\n a[x] = c - b;\n } else if (mark.equals(\"*\")) {\n a[x] = c * b;\n } else if (mark.equals(\"/\")) {\n a[x] = c / b;\n }\n x++;\n } while (true);\n x = 0;\n do {\n if (a[x] == 2000001) break;\n System.out.println(a[x]);\n x++;\n } while (true);\n scan.close();\n }\n}\n", "test_IO": [ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ] }, { "id": "s004995062", "dataset": "codenet", "language": "Java", "code": "import java.math.*;\nimport java.util.*;\n\npublic class s004995062 {\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n String sa = sc.next();\n String sb = sc.next();\n BigDecimal A = new BigDecimal(sa);\n BigDecimal B = new BigDecimal(sb);\n System.out.println(A.multiply(B).setScale(0, BigDecimal.ROUND_DOWN));\n }\n}\n", "test_IO": [ { "input": "198 1.10\n", "output": "217\n" } ] }, { "id": "s185737640", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s185737640 {\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n String S = sc.nextLine();\n sc.close();\n\n if (S.length() % 2 == 1) {\n S = S.substring(0, S.length() - 1);\n } else {\n S = S.substring(0, S.length() - 2);\n }\n\n for (; S.length() > 0; S = S.substring(0, S.length() - 2)) {\n if (isEvenString(S)) {\n break;\n }\n }\n System.out.println(S.length());\n }\n\n static boolean isEvenString(String s) {\n String a = s.substring(0, s.length() / 2);\n String b = s.substring(s.length() / 2);\n if (a.equals(b)) {\n return true;\n } else {\n return false;\n }\n }\n}\n", "test_IO": [ { "input": "abaababaab\n", "output": "6\n" } ] }, { "id": "s612878490", "dataset": "codenet", "language": "Java", "code": "import static java.lang.Integer.parseInt;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\n\npublic class s612878490 {\n\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line;\n String[] words;\n\n line = br.readLine();\n\n int N, M;\n N = parseInt(line.substring(0, line.indexOf(' ')));\n M = parseInt(line.substring(line.indexOf(' ') + 1));\n\n int[] shortage = new int[M];\n\n for (int i = 0; i < M; i++) {\n line = br.readLine();\n int A = parseInt(line.substring(0, line.indexOf(' ')));\n shortage[i] = N > A ? N - A : 0;\n }\n\n Arrays.sort(shortage);\n\n int ans = 0;\n\n for (int i = 0; i < M - 1; i++) {\n ans += shortage[i];\n }\n\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "4 5\n1 7\n6 2\n3 5\n4 4\n0 8\n", "output": "4\n" } ] }, { "id": "s312529015", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s312529015 {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A = sc.nextInt();\n int B = sc.nextInt();\n if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {\n System.out.println(\"Possible\");\n } else {\n System.out.println(\"Impossible\");\n }\n }\n}\n", "test_IO": [ { "input": "4 5\n", "output": "Possible\n" } ] }, { "id": "s699933302", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s699933302 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = Integer.parseInt(sc.next());\n int b = Integer.parseInt(sc.next());\n int c = Integer.parseInt(sc.next());\n int count = 0;\n for (int i = a; i <= b; i++) {\n if (c % i == 0) {\n count++;\n }\n }\n System.out.println(count);\n }\n}\n", "test_IO": [ { "input": "5 14 80\n", "output": "3\n" } ] }, { "id": "s493101281", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s493101281 {\n public static final long MOD = 1000000007;\n\n public static void main(String[] args) {\n FastScanner sc = new FastScanner();\n PrintWriter out = new PrintWriter(System.out);\n Integer i, j, k, n = 0, m = 0, h = 0, w = 0, ans = 0;\n long a = 0, b = 0, c = 0, d = 0, x = 0, y = 0, z = 0;\n List l = new ArrayList<>();\n List s = new ArrayList<>();\n List p = new ArrayList<>();\n\n n = sc.nextInt();\n\n for (i = 0; i < n; i++) {\n l.add(sc.nextInt());\n }\n\n Collections.sort(l);\n\n print(l.get(n / 2) - l.get(n / 2 - 1));\n\n out.flush();\n }\n\n private static void print(Object o) {\n System.out.println(o.toString());\n }\n\n private static long lcm(long m, long n) {\n return m * n / gcd(m, n);\n }\n\n private static long gcd(long m, long n) {\n if (m < n) return gcd(n, m);\n if (n == 0) return m;\n return gcd(n, m % n);\n }\n\n private static class Pair {\n private int key;\n private int value;\n\n public Pair(int key, int value) {\n this.key = key;\n this.value = value;\n }\n\n public int getValue() {\n return this.value;\n }\n\n public int getKey() {\n return this.key;\n }\n }\n}\n\nclass FastScanner {\n private final InputStream in = System.in;\n private final byte[] buffer = new byte[1024];\n private int ptr = 0;\n private int buflen = 0;\n\n private boolean hasNextByte() {\n if (ptr < buflen) {\n return true;\n } else {\n ptr = 0;\n try {\n buflen = in.read(buffer);\n } catch (IOException e) {\n e.printStackTrace();\n }\n if (buflen <= 0) {\n return false;\n }\n }\n return true;\n }\n\n private int readByte() {\n if (hasNextByte()) return buffer[ptr++];\n else return -1;\n }\n\n private static boolean isPrintableChar(int c) {\n return 33 <= c && c <= 126;\n }\n\n public boolean hasNext() {\n while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;\n return hasNextByte();\n }\n\n public String next() {\n if (!hasNext()) throw new NoSuchElementException();\n StringBuilder sb = new StringBuilder();\n int b = readByte();\n while (isPrintableChar(b)) {\n sb.appendCodePoint(b);\n b = readByte();\n }\n return sb.toString();\n }\n\n public long nextLong() {\n if (!hasNext()) throw new NoSuchElementException();\n long n = 0;\n boolean minus = false;\n int b = readByte();\n if (b == '-') {\n minus = true;\n b = readByte();\n }\n if (b < '0' || '9' < b) {\n throw new NumberFormatException();\n }\n while (true) {\n if ('0' <= b && b <= '9') {\n n *= 10;\n n += b - '0';\n } else if (b == -1 || !isPrintableChar(b)) {\n return minus ? -n : n;\n } else {\n throw new NumberFormatException();\n }\n b = readByte();\n }\n }\n\n public int nextInt() {\n long nl = nextLong();\n if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();\n return (int) nl;\n }\n\n public double nextDouble() {\n return Double.parseDouble(next());\n }\n}\n", "test_IO": [ { "input": "6\n9 1 4 4 6 7\n", "output": "2\n" } ] }, { "id": "s890213274", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s890213274 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int A1 = sc.nextInt();\n int A2 = sc.nextInt();\n int A3 = sc.nextInt();\n\n if ((A1 + A2 + A3) >= 22) {\n System.out.println(\"bust\");\n } else {\n System.out.println(\"win\");\n }\n }\n}\n", "test_IO": [ { "input": "5 7 9\n", "output": "win\n" } ] }, { "id": "s264878779", "dataset": "codenet", "language": "Java", "code": "import java.util.Scanner;\n\npublic class s264878779 {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String s = sc.next();\n int n = s.length();\n long ans = 0;\n for (int mask = 0; mask < 1 << (n - 1); mask++) {\n long sum = 0;\n String x = \"\" + s.charAt(0);\n for (int i = 0; i < n - 1; i++) {\n if ((mask & (1 << i)) >= 1) {\n x += \"+\" + s.charAt(i + 1);\n } else {\n x += s.charAt(i + 1);\n }\n }\n String[] split = x.split(\"\\\\+\");\n for (int i = 0; i < split.length; i++) {\n sum += Long.valueOf(split[i]);\n }\n ans += sum;\n }\n System.out.println(ans);\n }\n}\n", "test_IO": [ { "input": "125\n", "output": "176\n" } ] }, { "id": "s968213233", "dataset": "codenet", "language": "Java", "code": "import java.io.*;\nimport java.util.*;\n\npublic class s968213233 {\n\n public s968213233(FastScanner in, PrintWriter out, int test) {\n int N = in.nextInt();\n int[] A = new int[N];\n for (int i = 0; i < N; i++) A[i] = in.nextInt();\n Arrays.sort(A);\n\n long res = 0;\n\n PriorityQueue q =\n new PriorityQueue<>(\n Comparator.comparingInt((int[] e) -> Math.min(e[0], e[1])).reversed());\n q.add(new int[] {A[N - 1], A[N - 1]});\n\n for (int i = N - 2; i >= 0; i--) {\n int a = A[i];\n int[] place = q.remove();\n res += Math.min(place[0], place[1]);\n q.add(new int[] {place[0], a});\n q.add(new int[] {a, place[1]});\n }\n out.println(res);\n }\n\n public static void main(String[] args) {\n PrintWriter out = new PrintWriter(System.out);\n\n FastScanner in = new FastScanner(System.in);\n\n for (int t = 1; t <= 1; t++) {\n s968213233 sol = new s968213233(in, out, t);\n }\n\n out.close();\n }\n}\n\nclass FastScanner {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n\n public FastScanner(InputStream stream) {\n this.stream = stream;\n }\n\n int read() {\n if (numChars == -1) throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0) return -1;\n }\n return buf[curChar++];\n }\n\n boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n boolean isEndline(int c) {\n return c == '\\n' || c == '\\r' || c == -1;\n }\n\n int nextInt() {\n return Integer.parseInt(next());\n }\n\n long nextLong() {\n return Long.parseLong(next());\n }\n\n double nextDouble() {\n return Double.parseDouble(next());\n }\n\n String next() {\n int c = read();\n while (isSpaceChar(c)) c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isSpaceChar(c));\n return res.toString();\n }\n\n String nextLine() {\n int c = read();\n while (isEndline(c)) c = read();\n StringBuilder res = new StringBuilder();\n do {\n res.appendCodePoint(c);\n c = read();\n } while (!isEndline(c));\n return res.toString();\n }\n}\n", "test_IO": [ { "input": "4\n2 2 1 3\n", "output": "7\n" } ] }, { "id": "s445598069", "dataset": "codenet", "language": "Java", "code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class s445598069 {\n\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n int n = Integer.parseInt(br.readLine());\n\n String str[] = br.readLine().split(\" \");\n\n int s[] = new int[100010];\n\n for (int i = 0; i < n; i++) {\n s[Integer.parseInt(str[i])]++;\n }\n\n int dec = 0;\n\n for (int i = 0; i < s.length; i++) {\n if (s[i] != 0) {\n if (s[i] % 2 == 0) {\n s[i] = 2;\n } else {\n s[i] = 1;\n }\n }\n }\n\n int one = 0;\n int two = 0;\n\n for (int i = 0; i < s.length; i++) {\n if (s[i] == 2) {\n two++;\n } else if (s[i] == 1) {\n one++;\n }\n }\n\n if (two % 2 != 0) {\n one--;\n }\n\n System.out.println(two + one);\n }\n}\n", "test_IO": [ { "input": "5\n1 2 1 3 7\n", "output": "3\n" } ] }, { "id": "s805561051", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\ntypedef struct {\n int parent;\n int right;\n int left;\n} BT;\n\nBT bt[26];\nint n;\n\nvoid Preorder(int a) {\n if (a == -1) return;\n\n printf(\" %d\", a);\n Preorder(bt[a].left);\n Preorder(bt[a].right);\n}\n\nvoid Inorder(int a) {\n if (a == -1) return;\n\n Inorder(bt[a].left);\n printf(\" %d\", a);\n Inorder(bt[a].right);\n}\n\nvoid Postorder(int a) {\n if (a == -1) return;\n\n Postorder(bt[a].left);\n Postorder(bt[a].right);\n printf(\" %d\", a);\n}\n\nint main() {\n int i, j, num, depth = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; ++i) bt[i].parent = -1;\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &num);\n scanf(\"%d%d\", &(bt[num].left), &(bt[num].right));\n\n if (bt[num].left != -1 && bt[num].right != -1) {\n bt[bt[num].left].parent = num;\n bt[bt[num].right].parent = num;\n\n } else if (bt[num].left != -1)\n bt[bt[num].left].parent = num;\n else if (bt[num].right != -1)\n bt[bt[num].right].parent = num;\n }\n\n for (i = 0; bt[i].parent != -1; ++i)\n ;\n\n printf(\"Preorder\\n\");\n Preorder(i);\n printf(\"\\n\");\n\n printf(\"Inorder\\n\");\n Inorder(i);\n printf(\"\\n\");\n\n printf(\"Postorder\\n\");\n Postorder(i);\n printf(\"\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n", "output": "Preorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n" } ] }, { "id": "s719593355", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nstruct node {\n unsigned int key;\n struct node *next;\n struct node *prev;\n};\n\ntypedef struct node *NodePointer;\n\nNodePointer nil;\n\nNodePointer listSearch(int);\nvoid init(void);\nvoid printList(void);\nvoid deleteNode(NodePointer);\nvoid deleteFirst(void);\nvoid deleteLast(void);\nvoid delete(int);\nvoid insert(int);\n\nint main() {\n int key, n, i;\n int size = 0;\n char com[20];\n int np = 0, nd = 0;\n\n scanf(\"%d\", &n);\n\n init();\n\n for (i = 0; i < n; i++) {\n scanf(\"%s%d\", com, &key);\n\n if (com[0] == 'i') {\n insert(key);\n np++;\n size++;\n }\n\n else if (com[0] == 'd') {\n if (strlen(com) > 6) {\n if (com[6] == 'F')\n deleteFirst();\n\n else if (com[6] == 'L')\n deleteLast();\n }\n\n else\n delete (key);\n nd++;\n\n size--;\n }\n }\n\n printList();\n\n return 0;\n}\n\nNodePointer listSearch(int key) {\n NodePointer cur = nil->next;\n\n while (cur != nil && cur->key != key) cur = cur->next;\n\n return cur;\n}\n\nvoid init(void) {\n nil = (NodePointer)malloc(sizeof(struct node));\n nil->next = nil;\n nil->prev = nil;\n}\n\nvoid printList(void) {\n NodePointer cur = nil->next;\n int isf = 1;\n while (1) {\n if (cur == nil) break;\n if (isf == 0) printf(\" \");\n printf(\"%d\", cur->key);\n cur = cur->next;\n isf = 0;\n }\n printf(\"\\n\");\n}\n\nvoid deleteNode(NodePointer t) {\n t->prev->next = t->next;\n t->next->prev = t->prev;\n free(t);\n}\n\nvoid deleteFirst(void) {\n NodePointer t = nil->next;\n if (t == nil) return;\n\n deleteNode(t);\n}\n\nvoid deleteLast(void) {\n NodePointer t = nil->prev;\n if (t == nil) return;\n\n deleteNode(t);\n}\n\nvoid delete(int key) {\n NodePointer t = listSearch(key);\n\n if (t == nil) return;\n\n deleteNode(t);\n}\n\nvoid insert(int key) {\n NodePointer x;\n x = (NodePointer)malloc(sizeof(struct node));\n x->key = key;\n\n x->next = nil->next;\n nil->next->prev = x;\n nil->next = x;\n x->prev = nil;\n}", "test_IO": [ { "input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n", "output": "6 1 2\n" } ] }, { "id": "s383338432", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int height, width, i;\n scanf(\"%d %d\", &height, &width);\n char input_str[width + 1];\n for (i = 0; i < width + 2; i++) {\n printf(\"#\");\n }\n printf(\"\\n\");\n for (i = 0; i < height; i++) {\n scanf(\"%s\", input_str);\n printf(\"#%s#\\n\", input_str);\n }\n for (i = 0; i < width + 2; i++) {\n printf(\"#\");\n }\n printf(\"\\n\");\n return 0;\n}", "test_IO": [ { "input": "2 3\nabc\narc\n", "output": "#####\n#abc#\n#arc#\n#####\n" } ] }, { "id": "s073208348", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define ll long long\n#define rep(i, l, r) for (ll i = (l); i < (r); i++)\n#define max(p, q) ((p) > (q) ? (p) : (q))\n\ntypedef struct edge {\n ll s, g, c;\n} E;\ntypedef struct graph {\n int vcnt, ecnt;\n E e[200010];\n int id[100010];\n} G;\n\nint esort(const void* a, const void* b) {\n E *p = (E*)a, *q = (E*)b;\n if ((*p).s < (*q).s) return -1;\n if ((*p).s > (*q).s) return 1;\n if ((*p).g < (*q).g) return -1;\n return 1;\n}\n\nG g;\nvoid readgraph() {\n ll n;\n scanf(\"%lld\", &n);\n rep(i, 0, n - 1) {\n ll x, y, c;\n scanf(\"%lld%lld%lld\", &x, &y, &c);\n g.e[2 * i].s = x;\n g.e[2 * i].g = y;\n g.e[2 * i].c = c;\n g.e[2 * i + 1].s = y;\n g.e[2 * i + 1].g = x;\n g.e[2 * i + 1].c = c;\n }\n g.vcnt = n;\n g.ecnt = 2 * n - 2;\n qsort(g.e, g.ecnt, sizeof(E), esort);\n\n int p = 0;\n rep(i, 0, g.vcnt) {\n while (p < g.ecnt && g.e[p].s < i) p++;\n g.id[i] = p;\n }\n g.id[g.vcnt] = g.ecnt;\n}\n\nint* tyokkeitemp;\nvoid tyokkeidfs(ll s) {\n for (int i = g.id[s]; i < g.id[s + 1]; i++) {\n if (tyokkeitemp[g.e[i].g] == 0) {\n tyokkeitemp[g.e[i].g] = tyokkeitemp[s] + g.e[i].c;\n tyokkeidfs(g.e[i].g);\n }\n }\n}\nint tyokkei() {\n tyokkeitemp = (int*)calloc(g.vcnt + 10, sizeof(int));\n tyokkeitemp[0] = 1;\n tyokkeidfs(0);\n int M = 0, Mi;\n rep(i, 0, g.vcnt) {\n if (tyokkeitemp[i] > M) {\n M = tyokkeitemp[i];\n Mi = i;\n }\n }\n rep(i, 0, g.vcnt) tyokkeitemp[i] = 0;\n tyokkeitemp[Mi] = 1;\n tyokkeidfs(Mi);\n rep(i, 0, g.vcnt) M = max(M, tyokkeitemp[i]);\n free(tyokkeitemp);\n return M - 1;\n}\n\nint main() {\n readgraph();\n printf(\"%d\\n\", tyokkei());\n}", "test_IO": [ { "input": "4\n0 1 2\n1 2 1\n1 3 3\n", "output": "5\n" } ] }, { "id": "s065149518", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define MAX 21\n\nvoid init(int);\nvoid move(int);\n\nint n, x, y;\nchar fld[MAX][MAX];\n\nint main(void) {\n int m;\n while (~scanf(\"%d\", &n), n) {\n init(n);\n scanf(\"%d\", &m);\n move(m);\n printf(\"%s\\n\", n ? \"No\" : \"Yes\");\n }\n return 0;\n}\n\nvoid init(int i) {\n int a, b;\n x = y = 10;\n memset(fld, 0, sizeof(fld));\n while (i--) {\n scanf(\"%d %d\", &a, &b);\n fld[b][a] = 1;\n }\n}\n\nvoid move(int i) {\n int a, d;\n char buf[2];\n while (i--) {\n scanf(\"%1s %d\", buf, &a);\n switch (buf[0]) {\n case 'N':\n d = 0;\n break;\n case 'E':\n d = 1;\n break;\n case 'S':\n d = 2;\n break;\n case 'W':\n d = 3;\n break;\n }\n while (a--) {\n d % 2 ? ~-d ? x-- : x++ : d ? y-- : y++;\n if (fld[y][x]) {\n fld[y][x] = 0;\n n--;\n }\n }\n }\n}", "test_IO": [ { "input": "2\n10 11\n11 12\n2\nN 2\nE 1\n2\n10 11\n11 12\n2\nN 2\nW 1\n3\n0 15\n5 10\n5 15\n5\nW 10\nS 10\nN 20\nE 10\nS 10\n0\n", "output": "Yes\nNo\nNo\n" } ] }, { "id": "s555338838", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int key, i, j, len, a[101];\n scanf(\"%d\", &len);\n for (i = 0; i < len; i++) scanf(\"%d\", a + i);\n\n for (j = 1; j < len; j++) {\n for (i = 0; i < len; i++) printf(i != 0 ? \" %d\" : \"%d\", a[i]);\n puts(\"\");\n key = a[j];\n for (i = j - 1; i >= 0 && a[i] > key; i--) a[i + 1] = a[i];\n a[i + 1] = key;\n }\n\n for (i = 0; i < len; i++) printf(i != 0 ? \" %d\" : \"%d\", a[i]);\n puts(\"\");\n return 0;\n}", "test_IO": [ { "input": "6\n5 2 4 6 1 3\n", "output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n" } ] }, { "id": "s746512291", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int x;\n scanf(\"%d\", &x);\n printf(\"%d\\n\", x * x * x);\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s574777006", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int n, i, j, q, x[10000], y[500], sum = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &x[i]);\n }\n\n scanf(\"%d\", &q);\n\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &y[i]);\n }\n\n for (i = 0; i < q; i++) {\n for (j = 0; j < n; j++) {\n if (y[i] == x[j]) {\n sum = sum + 1;\n break;\n }\n }\n }\n\n printf(\"%d\\n\", sum);\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s479404625", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n char A[20], B[20], C[20];\n\n scanf(\"%s %s %s\", A, B, C);\n\n int la = strlen(A), lb = strlen(B);\n\n if (A[la - 1] == B[0] && B[lb - 1] == C[0]) {\n printf(\"YES\\n\");\n } else {\n printf(\"NO\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "rng gorilla apple\n", "output": "YES\n" } ] }, { "id": "s957555615", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nstruct node {\n struct node *right;\n struct node *left;\n struct node *parent;\n int key;\n};\ntypedef struct node *Node;\n#define NIL NULL\n\nNode root;\n\nNode treeMinimum(Node x) {\n while (x->left != NIL) x = x->left;\n return x;\n}\n\nNode treeMaximum(Node x) {\n while (x->right != NIL) x = x->right;\n return x;\n}\n\nNode treeSearch(Node u, int k) {\n if (u == NIL || k == u->key) return u;\n\n if (k < u->key)\n return treeSearch(u->left, k);\n else\n return treeSearch(u->right, k);\n}\n\nNode treeSuccessor(Node x) {\n Node y;\n if (x->right != NIL) return treeMinimum(x->right);\n\n y = x->parent;\n while (y != NIL && x == y->right) {\n x = y;\n y = y->parent;\n }\n return y;\n}\n\nvoid treeDelete(Node z) {\n Node y;\n Node x;\n\n if (z->left == NIL || z->right == NIL)\n y = z;\n else\n y = treeSuccessor(z);\n\n if (y->left != NIL)\n x = y->left;\n else\n x = y->right;\n\n if (x != NIL) x->parent = y->parent;\n\n if (y->parent == NIL)\n root = x;\n else if (y == y->parent->left)\n y->parent->left = x;\n else\n y->parent->right = x;\n\n if (y != z) z->key = y->key;\n}\n\nvoid insert(int k) {\n Node y = NIL;\n Node x = root;\n Node z;\n\n z = malloc(sizeof(struct node));\n z->key = k;\n z->left = NIL;\n z->right = NIL;\n\n while (x != NIL) {\n y = x;\n if (z->key < x->key) {\n x = x->left;\n } else {\n x = x->right;\n }\n }\n z->parent = y;\n if (y == NIL)\n root = z;\n else if (z->key < y->key)\n y->left = z;\n else\n (y->right = z);\n}\n\nvoid inorder(Node u) {\n if (u == NIL) return;\n inorder(u->left);\n printf(\" %d\", u->key);\n inorder(u->right);\n}\nvoid preorder(Node u) {\n if (u == NIL) return;\n printf(\" %d\", u->key);\n preorder(u->left);\n preorder(u->right);\n}\n\nint main() {\n int n, i, x;\n char com[20];\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%s\", com);\n if (com[0] == 'f') {\n scanf(\"%d\", &x);\n Node t = treeSearch(root, x);\n if (t != NIL)\n printf(\"yes\\n\");\n else\n printf(\"no\\n\");\n } else if (com[0] == 'i') {\n scanf(\"%d\", &x);\n insert(x);\n } else if (com[0] == 'p') {\n inorder(root);\n printf(\"\\n\");\n preorder(root);\n printf(\"\\n\");\n } else if (com[0] == 'd') {\n scanf(\"%d\", &x);\n treeDelete(treeSearch(root, x));\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint\n", "output": "yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22\n 8 2 1 3 7 22\n 1 2 8 22\n 8 2 1 22\n" } ] }, { "id": "s019421829", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\n#define MAX 707106\nchar tbl[MAX + 1];\n\nint sz;\nint prime[57100] = {\n 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,\n 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,\n 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,\n 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,\n 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379,\n 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,\n 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571,\n 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,\n 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761,\n 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853};\n\nint sqp[147] = {\n 4, 9, 25, 49, 121, 169, 289, 361, 529,\n 841, 961, 1369, 1681, 1849, 2209, 2809, 3481, 3721,\n 4489, 5041, 5329, 6241, 6889, 7921, 9409, 10201, 10609,\n 11449, 11881, 12769, 16129, 17161, 18769, 19321, 22201, 22801,\n 24649, 26569, 27889, 29929, 32041, 32761, 36481, 37249, 38809,\n 39601, 44521, 49729, 51529, 52441, 54289, 57121, 58081, 63001,\n 66049, 69169, 72361, 73441, 76729, 78961, 80089, 85849, 94249,\n 96721, 97969, 100489, 109561, 113569, 120409, 121801, 124609, 128881,\n 134689, 139129, 143641, 146689, 151321, 157609, 160801, 167281, 175561,\n 177241, 185761, 187489, 192721, 196249, 201601, 208849, 212521, 214369,\n 218089, 229441, 237169, 241081, 249001, 253009, 259081, 271441, 273529,\n 292681, 299209, 310249, 316969, 323761, 326041, 332929, 344569, 351649,\n 358801, 361201, 368449, 375769, 380689, 383161, 398161, 410881, 413449,\n 418609, 426409, 434281, 436921, 452929, 458329, 466489, 477481, 491401,\n 502681, 516961, 528529, 537289, 546121, 552049, 564001, 573049, 579121,\n 591361, 597529, 619369, 635209, 654481, 657721, 674041, 677329, 683929,\n 687241, 703921, 727609};\n\nvoid sieve() {\n int i, j, k;\n\n for (i = 1; i < 147; i++) {\n k = prime[i];\n for (j = sqp[i]; j < MAX; j += k) tbl[j] = 1;\n }\n for (sz = 146, i = 853; i <= MAX; i += 2)\n if (!tbl[i]) prime[sz++] = i;\n}\n\nint base[1000002];\nint idx[1000002];\nlong long pp[41];\n\nint bsch(int x) {\n int m, l = 0, r = sz;\n\n while (l < r) {\n m = (l + r) >> 1;\n if (prime[m] == x) return m;\n if (prime[m] < x)\n l = m + 1;\n else\n r = m;\n }\n return l - 1;\n}\n\nint main() {\n int i, k, p, ans;\n long long A, B, a, b, j, ll, rr;\n\n sieve();\n\n scanf(\"%lld%lld\", &A, &B);\n a = A - B, b = A + B;\n if (b <= 1) {\n puts(\"0\");\n return 0;\n }\n if (a <= 1) a = 2;\n\n sz = bsch((int)sqrt((double)(b >> 1)));\n\n memset(idx, 1, sizeof(idx));\n for (i = 0; i <= sz; i++) {\n p = prime[i];\n for (k = 1, j = p; j <= b; j *= p) pp[k++] = j;\n while (--k) {\n j = pp[k], ll = j * (1 + (a - 1) / j), rr = j * (b / j);\n for (; ll <= rr; ll += j) {\n int x = (int)(ll - a);\n if (!idx[x] || base[x] == p) continue;\n if (idx[x] < k)\n idx[x] = 0;\n else\n base[x] = p, idx[x] = k;\n }\n }\n }\n\n ans = 0, i = (int)(b - a + 1);\n while (i--)\n if (idx[i]) ans++;\n printf(\"%d\\n\", ans);\n return 0;\n}", "test_IO": [ { "input": "18 2\n", "output": "4\n" } ] }, { "id": "s062562864", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c, d, i, j;\n\n scanf(\"%d %d %d %d\", &a, &b, &c, &d);\n\n i = a * b;\n j = c * d;\n if (i > j) {\n printf(\"%d\\n\", i);\n } else {\n printf(\"%d\\n\", j);\n }\n\n return 0;\n}", "test_IO": [ { "input": "3 5 2 7\n", "output": "15\n" } ] }, { "id": "s110919613", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int i, j, k, L, tmp, d, def, end, aj, max, min;\n\n for (;;) {\n int an[20], a1[6], a2[6];\n scanf(\"%d %d\", &an[0], &L);\n if (!L) break;\n\n aj = an[0];\n end = 0;\n for (k = 1; k < 21; k++) {\n for (i = L - 1; i >= 0; i--, aj /= 10) {\n a1[i] = aj % 10;\n a2[i] = aj % 10;\n }\n for (i = 1; i < L; i++) {\n for (j = 1; j < L; j++) {\n if (a1[j - 1] < a1[j]) {\n tmp = a1[j - 1];\n a1[j - 1] = a1[j];\n a1[j] = tmp;\n }\n if (a2[j - 1] > a2[j]) {\n tmp = a2[j - 1];\n a2[j - 1] = a2[j];\n a2[j] = tmp;\n }\n }\n }\n d = 1;\n max = 0;\n min = 0;\n for (i = L - 1; i >= 0; i--, d *= 10) {\n max += (a1[i] % 10) * d;\n min += (a2[i] % 10) * d;\n }\n def = max - min;\n for (i = 0; i < k; i++) {\n if (def == an[i]) {\n printf(\"%d %d %d\\n\", i, def, k - i);\n end = 1;\n break;\n }\n }\n if (end == 1) break;\n an[k] = def;\n aj = def;\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "2012 4\n83268 6\n1112 4\n0 1\n99 2\n0 0\n", "output": "3 6174 1\n1 862632 7\n5 6174 1\n0 0 1\n1 0 1\n" } ] }, { "id": "s090095029", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nint main() {\n int n, m;\n scanf(\"%d%d\", &n, &m);\n bool r0[n];\n memset(r0, 0x00, n);\n int r1[n];\n int nr1 = 0;\n for (int i = 0; i < m; i++) {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n if (a > b) {\n int t = a;\n a = b;\n b = t;\n }\n if (a == 1) r0[b - 1] = true;\n if (b == n) r1[nr1++] = a - 1;\n }\n bool res = false;\n for (int i = 0; i < nr1; i++) {\n if (r0[r1[i]]) res = true;\n }\n puts(res ? \"POSSIBLE\" : \"IMPOSSIBLE\");\n return 0;\n}", "test_IO": [ { "input": "3 2\n1 2\n2 3\n", "output": "POSSIBLE\n" } ] }, { "id": "s400146413", "dataset": "codenet", "language": "C", "code": "#include \n\nint linearsearch(int S[], int n, int key) {\n int i = 0;\n int count = 0;\n while (S[i] != key) {\n i++;\n if (i >= n) {\n count = 1;\n return count;\n }\n }\n return count;\n}\n\nint main() {\n int i, j, n, q, S[10000], T[10000];\n int count = 0, key;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &S[i]);\n }\n\n scanf(\"%d\", &q);\n for (j = 0; j < q; j++) {\n scanf(\"%d\", &T[j]);\n }\n\n for (j = 0; j < q; j++) {\n key = T[j];\n if (linearsearch(S, n, key) == 0) {\n count++;\n }\n }\n\n printf(\"%d\\n\", count);\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s329517742", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n if (500 * a >= b)\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n return 0;\n}", "test_IO": [ { "input": "2 900\n", "output": "Yes\n" } ] }, { "id": "s445709355", "dataset": "codenet", "language": "C", "code": "#include \n\n#define gc() getchar_unlocked()\n\nint in() {\n int n = 0, c = gc();\n do n = 10 * n + (c & 0xf);\n while ((c = gc()) >= '0');\n return n;\n}\n\nint f1[100], f2[100];\n\nvoid calc(int n) {\n int k = n % 10;\n while (n >= 10) n /= 10;\n ++f1[10 * k + n], ++f2[n * 10 + k];\n}\n\nint main() {\n int i, N, ans;\n\n N = in();\n while (N) calc(N--);\n\n ans = 0;\n for (i = 0; i < 100; ++i) ans += f1[i] * f2[i];\n printf(\"%d\\n\", ans);\n return 0;\n}", "test_IO": [ { "input": "25\n", "output": "17\n" } ] }, { "id": "s957824161", "dataset": "codenet", "language": "C", "code": "#include \nint x, y;\nint main() {\n scanf(\"%d %d\", &x, &y);\n printf(\"%d %d\\n\", x * y, 2 * x + 2 * y);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s744346876", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int A, B;\n scanf(\"%d %d\", &A, &B);\n if (A < 10 && B < 10)\n printf(\"%d\\n\", A * B);\n else\n printf(\"-1\\n\");\n return 0;\n}", "test_IO": [ { "input": "2 5\n", "output": "10\n" } ] }, { "id": "s340712303", "dataset": "codenet", "language": "C", "code": "#include \n#define N 2000\nint num1, math[N + 1];\nint main() {\n int a, num2, ans, sum = 0, math[N + 1];\n int i, j;\n\n math[0] = 1;\n\n scanf(\"%d\", &num1);\n for (i = 0; i < num1; i++) {\n scanf(\"%d\", &a);\n sum += a;\n for (j = sum - a; j >= 0; j--) {\n if (math[j] == 1) math[j + a] = 1;\n }\n }\n\n scanf(\"%d\", &num2);\n for (i = 0; i < num2; i++) {\n scanf(\"%d\", &ans);\n math[ans] == 1 ? printf(\"yes\\n\") : printf(\"no\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n", "output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n" } ] }, { "id": "s266720248", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\n#define LEN 100005\n\ntypedef struct pp {\n char name[100];\n int t;\n} P;\n\nP Q[LEN];\nint head, tail, n;\n\nvoid enqueue(P x) {\n Q[tail] = x;\n tail = (tail + 1) % LEN;\n}\n\nP dequeue() {\n P x = Q[head];\n head = (head + 1) % LEN;\n return x;\n}\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint main() {\n int elaps = 0, c;\n int i, q;\n P u;\n\n scanf(\"%d %d\", &n, &q);\n\n for (i = 1; i <= n; i++) {\n scanf(\"%s\", Q[i].name);\n scanf(\"%d\", &Q[i].t);\n }\n head = 1;\n tail = n + 1;\n\n while (head != tail) {\n u = dequeue();\n c = min(q, u.t);\n u.t -= c;\n elaps += c;\n if (u.t > 0)\n enqueue(u);\n else {\n printf(\"%s %d\\n\", u.name, elaps);\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n", "output": "p2 180\np5 400\np1 450\np3 550\np4 800\n" } ] }, { "id": "s050123290", "dataset": "codenet", "language": "C", "code": "#include \n#define N 1000\n\nint main(void) {\n char su[N] = {'0'};\n int susum = 0;\n int j = 0;\n\n while (1) {\n for (j = 0; j <= N; j++) {\n scanf(\"%c\", &su[j]);\n if (su[j] == '\\n') break;\n susum = susum + (su[j] - '0');\n }\n if (su[0] == '0') break;\n printf(\"%d\\n\", susum);\n susum = 0;\n }\n return 0;\n}", "test_IO": [ { "input": "123\n55\n1000\n0\n", "output": "6\n10\n1\n" } ] }, { "id": "s000061454", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, n;\n int sum;\n int i, j;\n while (1) {\n if (scanf(\"%d %d %d\", &a, &b, &n) == -1) break;\n a -= a / b * b;\n sum = 0;\n for (i = 1; i <= n; i++) {\n a *= 10;\n for (j = 9; j >= 0; j--) {\n if (b * j <= a) break;\n }\n a -= b * j;\n sum += j;\n }\n printf(\"%d\\n\", sum);\n }\n return 0;\n}", "test_IO": [ { "input": "1 2 3\n2 3 4\n5 4 3\n4 3 2\n", "output": "5\n24\n7\n6\n" } ] }, { "id": "s681783549", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n int i;\n char S[6];\n scanf(\"%s\", S);\n for (i = 0; S[i] != '\\0'; i++) {\n if (S[i] == 'A' && S[i + 1] == 'C') {\n printf(\"Yes\\n\");\n return 0;\n }\n }\n printf(\"No\\n\");\n return 0;\n}", "test_IO": [ { "input": "BACD\n", "output": "Yes\n" } ] }, { "id": "s989417036", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c, d, e, i;\n scanf(\"%d%d%d\", &a, &b, &c);\n if (b <= c) {\n printf(\"NO\\n\");\n return 0;\n } else {\n d = a;\n e = d % b;\n for (i = 0; i < b; i++) {\n d = d % b;\n if (d == c) {\n printf(\"YES\\n\");\n return 0;\n } else if (i != 0 && d == c) {\n printf(\"NO\\n\");\n return 0;\n }\n d += a;\n }\n }\n printf(\"NO\\n\");\n return 0;\n}", "test_IO": [ { "input": "7 5 1\n", "output": "YES\n" } ] }, { "id": "s582614433", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#define ll long long\n#define rep(i, l, r) for (ll i = (l); i < (r); i++)\n#define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k))\n#define INF ((1LL << 62) - (1LL << 31))\n#define max(p, q) ((p) > (q) ? (p) : (q))\n#define min(p, q) ((p) < (q) ? (p) : (q))\n#define bit(n, m) (((n) >> (m)) & 1)\nint upll(const void* a, const void* b) {\n return *(ll*)a < *(ll*)b ? -1 : *(ll*)a > *(ll*)b ? 1 : 0;\n}\nint downll(const void* a, const void* b) {\n return *(ll*)a < *(ll*)b ? 1 : *(ll*)a > *(ll*)b ? -1 : 0;\n}\nvoid sortup(ll* a, int n) { qsort(a, n, sizeof(ll), upll); }\nvoid sortdown(ll* a, int n) { qsort(a, n, sizeof(ll), downll); }\nll pom(ll a, ll n, int m) {\n ll x = 1;\n for (a %= m; n; n /= 2) n& 1 ? x = x * a % m : 0, a = a * a % m;\n return x;\n}\n\n#define MOD 1000000007\n#define invp(a, p) pom(a, p - 2, p)\n\ntypedef struct edge {\n ll p, i;\n char s[20];\n} E;\nint esort(const void* a, const void* b) {\n E *p = (E*)a, *q = (E*)b;\n if (strcmp((*p).s, (*q).s)) return strcmp((*p).s, (*q).s);\n if ((*p).p < (*q).p) return 1;\n return -1;\n}\n\nE data[100];\nll n, m;\nint main() {\n scanf(\"%lld\", &n);\n rep(i, 0, n) {\n scanf(\" %s%lld\", data[i].s, &data[i].p);\n data[i].i = i;\n }\n qsort(data, n, sizeof(E), esort);\n rep(i, 0, n) printf(\"%lld\\n\", data[i].i + 1);\n}", "test_IO": [ { "input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n", "output": "3\n4\n6\n1\n5\n2\n" } ] }, { "id": "s467564704", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int input[4][4], tc;\n for (int i = 0; i < 3; i++) {\n for (int j = 0; j < 3; j++) {\n scanf(\"%d\", &input[i][j]);\n }\n }\n scanf(\"%d\", &tc);\n int testcase;\n for (int i = 0; i < tc; i++) {\n scanf(\"%d\", &testcase);\n for (int i = 0; i < 3; i++) {\n for (int j = 0; j < 3; j++) {\n if (input[i][j] == testcase) {\n input[i][j] = 0;\n }\n }\n }\n }\n if (input[0][0] == 0 && input[1][1] == 0 && input[2][2] == 0) {\n puts(\"Yes\");\n } else if (input[0][2] == 0 && input[1][1] == 0 && input[2][0] == 0) {\n puts(\"Yes\");\n } else if (input[0][0] == 0 && input[0][1] == 0 && input[0][2] == 0) {\n puts(\"Yes\");\n } else if (input[1][0] == 0 && input[1][1] == 0 && input[1][2] == 0) {\n puts(\"Yes\");\n } else if (input[2][0] == 0 && input[2][1] == 0 && input[2][2] == 0) {\n puts(\"Yes\");\n } else if (input[0][0] == 0 && input[1][0] == 0 && input[2][0] == 0) {\n puts(\"Yes\");\n } else if (input[0][1] == 0 && input[1][1] == 0 && input[2][1] == 0) {\n puts(\"Yes\");\n } else if (input[0][2] == 0 && input[1][2] == 0 && input[2][2] == 0) {\n puts(\"Yes\");\n } else {\n puts(\"No\");\n }\n return 0;\n}", "test_IO": [ { "input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n", "output": "Yes\n" } ] }, { "id": "s205656765", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\nint main() {\n int X, A, B, C;\n int i = 0;\n int j = 0;\n int k = 0;\n int kosu = 0;\n\n scanf(\"%d\", &A);\n scanf(\"%d\", &B);\n scanf(\"%d\", &C);\n scanf(\"%d\", &X);\n\n X = X / 50;\n\n for (i = 0; i <= A; i++) {\n for (j = 0; j <= B; j++) {\n for (k = 0; k <= C; k++) {\n if (X == (10 * i) + (2 * j) + k) kosu++;\n }\n }\n }\n\n printf(\"%d\\n\", kosu);\n\n return 0;\n}", "test_IO": [ { "input": "2\n2\n2\n100\n", "output": "2\n" } ] }, { "id": "s218426876", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint main(void) {\n int i, sum = 0;\n int flag = 0;\n char x[1002];\n scanf(\"%s\", x);\n do {\n for (i = 0; i < 1002; i++) {\n if (x[i] == 0) {\n printf(\"%d\\n\", sum);\n break;\n } else {\n sum += x[i] - 0x30;\n }\n }\n sum = 0;\n scanf(\"%s\", x);\n } while (x[0] != 0x30);\n\n return 0;\n}", "test_IO": [ { "input": "123\n55\n1000\n0\n", "output": "6\n10\n1\n" } ] }, { "id": "s302860389", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n char inputNumbers[5];\n char temp[2];\n int a, b, c, d;\n int sum;\n char symbols[3];\n\n scanf(\"%s\", &inputNumbers);\n\n temp[1] = '\\0';\n\n temp[0] = inputNumbers[0];\n a = atoi(temp);\n temp[0] = inputNumbers[1];\n b = atoi(temp);\n temp[0] = inputNumbers[2];\n c = atoi(temp);\n temp[0] = inputNumbers[3];\n d = atoi(temp);\n\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j < 2; j++) {\n for (int k = 0; k < 2; k++) {\n if (i == 0) {\n sum = a + b;\n symbols[0] = '+';\n } else {\n sum = a - b;\n symbols[0] = '-';\n }\n\n if (j == 0) {\n sum = sum + c;\n symbols[1] = '+';\n } else {\n sum = sum - c;\n symbols[1] = '-';\n }\n\n if (k == 0) {\n sum = sum + d;\n symbols[2] = '+';\n } else {\n sum = sum - d;\n symbols[2] = '-';\n }\n\n if (sum == 7) {\n printf(\"%d%c%d%c%d%c%d=7\\n\", a, symbols[0], b, symbols[1],\n c, symbols[2], d);\n\n return 0;\n }\n }\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "1222\n", "output": "1+2+2+2=7\n" } ] }, { "id": "s993124238", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nvoid main() {\n int n, d;\n scanf(\"%d%d\", &n, &d);\n int point[n + 1][d + 1];\n\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= d; j++) {\n scanf(\"%d\", &point[i][j]);\n }\n }\n\n int count = 0;\n for (int i = 1; i <= n - 1; i++) {\n for (int j = i + 1; j <= n; j++) {\n int sum = 0;\n for (int k = 1; k <= d; k++) {\n sum = sum +\n (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);\n }\n double kyori = sqrt(sum);\n if (ceil(kyori) == floor(kyori)) {\n count++;\n }\n }\n }\n\n printf(\"%d\\n\", count);\n}", "test_IO": [ { "input": "3 2\n1 2\n5 5\n-2 8\n", "output": "1\n" } ] }, { "id": "s175895052", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n char n[10];\n scanf(\"%s\", n);\n if (((n[0] == n[1]) && (n[1] == n[2])) ||\n ((n[1] == n[2]) && (n[2] == n[3]))) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n return 0;\n}", "test_IO": [ { "input": "1118\n", "output": "Yes\n" } ] }, { "id": "s494952667", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n char str[21];\n int i, len;\n\n scanf(\"%s\", str);\n\n len = strlen(str);\n\n for (i = len - 1; i >= 0; i--) {\n putchar(str[i]);\n }\n printf(\"\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "w32nimda\n", "output": "admin23w\n" } ] }, { "id": "s375200717", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int n, i, a;\n scanf(\"%d\", &n);\n for (i = 1; i <= n; i++) {\n a = i;\n if ((a % 3) == 0) {\n printf(\" %d\", i);\n } else {\n for (; a;) {\n if ((a % 10) == 3) {\n printf(\" %d\", i);\n a = 0;\n }\n a = a / 10;\n }\n }\n }\n putchar('\\n');\n return 0;\n}", "test_IO": [ { "input": "30\n", "output": " 3 6 9 12 13 15 18 21 23 24 27 30\n" } ] }, { "id": "s867013108", "dataset": "codenet", "language": "C", "code": "#include \n#define DAYS 365\n\nint main(void) {\n int n, i;\n int nyuyoku_ticket[DAYS], pool_ticket[DAYS];\n int nyuyoku_member[DAYS], pool_member[DAYS];\n int seiki_ryoukin[DAYS], waribiki_ryoukin[DAYS], saiyasune[DAYS];\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d %d %d %d\", &nyuyoku_ticket[i], &pool_ticket[i],\n &nyuyoku_member[i], &pool_member[i]);\n if (nyuyoku_member[i] >= 5 && pool_member[i] >= 2) {\n seiki_ryoukin[i] = (((nyuyoku_ticket[i] * nyuyoku_member[i]) +\n (pool_ticket[i] * pool_member[i])) *\n 8) /\n 10;\n saiyasune[i] = seiki_ryoukin[i];\n } else if (nyuyoku_member[i] >= 5) {\n seiki_ryoukin[i] = (nyuyoku_ticket[i] * nyuyoku_member[i]) +\n (pool_ticket[i] * pool_member[i]);\n waribiki_ryoukin[i] = (((nyuyoku_ticket[i] * nyuyoku_member[i]) +\n (pool_ticket[i] * 2)) *\n 8) /\n 10;\n if (seiki_ryoukin[i] >= waribiki_ryoukin[i]) {\n saiyasune[i] = waribiki_ryoukin[i];\n } else {\n saiyasune[i] = seiki_ryoukin[i];\n }\n } else if (pool_member[i] >= 2) {\n seiki_ryoukin[i] = (nyuyoku_ticket[i] * nyuyoku_member[i]) +\n (pool_ticket[i] * pool_member[i]);\n waribiki_ryoukin[i] =\n (((nyuyoku_ticket[i] * 5) + (pool_ticket[i] * pool_member[i])) *\n 8) /\n 10;\n if (seiki_ryoukin[i] >= waribiki_ryoukin[i]) {\n saiyasune[i] = waribiki_ryoukin[i];\n } else {\n saiyasune[i] = seiki_ryoukin[i];\n }\n } else {\n seiki_ryoukin[i] = (nyuyoku_ticket[i] * nyuyoku_member[i]) +\n (pool_ticket[i] * pool_member[i]);\n waribiki_ryoukin[i] =\n (((nyuyoku_ticket[i] * 5) + (pool_ticket[i] * 2)) * 8) / 10;\n if (seiki_ryoukin[i] >= waribiki_ryoukin[i]) {\n saiyasune[i] = waribiki_ryoukin[i];\n } else {\n saiyasune[i] = seiki_ryoukin[i];\n }\n }\n }\n for (i = 0; i < n; i++) {\n printf(\"%d\\n\", saiyasune[i]);\n }\n return 0;\n}", "test_IO": [ { "input": "2\n100 100 1 1\n1000 500 5 2\n", "output": "200\n4800\n" } ] }, { "id": "s552669377", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int i, n, tmp;\n long long int min = 1000000, max = -1000000, sum = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &tmp);\n if (min > tmp) min = tmp;\n if (max < tmp) max = tmp;\n sum += tmp;\n }\n\n printf(\"%ld %ld %ld\\n\", min, max, sum);\n\n return 0;\n}", "test_IO": [ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ] }, { "id": "s905557267", "dataset": "codenet", "language": "C", "code": "#include \n\nint min(int a, int b) {\n if (a <= b) {\n return (a);\n }\n return (b);\n}\n\nint Chain(int b[10000], int n) {\n int i, j;\n int count;\n int color;\n int a[10000];\n\n for (i = 0; i < n; i++) {\n a[i] = b[i];\n }\n\n for (i = 0; i < n - 4; i++) {\n if (a[i] != 0 && a[i] == a[i + 1] && a[i] == a[i + 2] &&\n a[i] == a[i + 3]) {\n#if 0\n\t\t\tprintf(\"-----\\n\");\n\t\t\tfor (j = 0; j < n; j++){\n\t\t\t\tprintf(\"%d\\n\", a[j]);\n\t\t\t}\n\t\t\tprintf(\"-----\\n\");\n#endif\n\n count = 0;\n color = a[i];\n\n for (j = i; a[j] == color; j++) {\n a[j] = 0;\n count++;\n }\n\n for (j = 0; i + j + count < 10000; j++) {\n a[i + j] = a[i + j + count];\n a[i + j + count] = 0;\n }\n\n#if 0\n\t\t\tprintf(\"-----\\n\");\n\t\t\tfor (j = 0; j < n; j++){\n\t\t\t\tprintf(\"%d\\n\", a[j]);\n\t\t\t}\n\t\t\tprintf(\"-----\\n\");\n\t\t\tgetch();\n#endif\n\n i = 0;\n }\n }\n\n count = 0;\n while (a[count] != 0) {\n count++;\n }\n\n if (count == 4 && a[0] == a[1] && a[0] == a[2] && a[0] == a[3]) {\n return (0);\n }\n\n return (count);\n}\n\nint main(void) {\n int n;\n int i, j;\n int a[10000];\n int ans;\n int color;\n\n while (1) {\n for (i = 0; i < 10000; i++) {\n a[i] = 0;\n }\n\n scanf(\"%d\", &n);\n if (n == 0) {\n break;\n }\n ans = n;\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n\n for (i = 0; i < n - 4; i++) {\n int count[3] = {0, 0, 0};\n for (j = i; j < i + 4; j++) {\n if (a[j] - 1 >= 0) {\n count[a[j] - 1]++;\n }\n }\n\n color = 0;\n for (j = 0; j < 3; j++) {\n if (count[j] >= 3) {\n color = j + 1;\n break;\n }\n }\n\n if (color != 0) {\n for (j = i; j < i + 4; j++) {\n int buf;\n buf = a[j];\n a[j] = color;\n ans = min(ans, Chain(a, n));\n a[j] = buf;\n }\n }\n }\n\n printf(\"%d\\n\", ans);\n }\n\n return (0);\n}", "test_IO": [ { "input": "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n", "output": "3\n12\n" } ] }, { "id": "s845656342", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nint main(void) {\n int x;\n scanf(\"%d\", &x);\n\n if (x == 1)\n printf(\"0\\n\");\n else\n printf(\"1\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "1\n", "output": "0\n" } ] }, { "id": "s305090452", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\ntypedef struct binaryHeap {\n void *array;\n size_t heap_size;\n size_t max_size;\n size_t val_size;\n int (*cmp)(const void *, const void *);\n} heap;\n\nheap *new_binary_heap(const size_t val_size,\n int (*cmpF)(const void *, const void *)) {\n heap *h = (heap *)calloc(1, sizeof(heap));\n h->array = malloc(val_size * (1 + 1));\n h->heap_size = 0;\n h->max_size = 1;\n h->val_size = val_size;\n h->cmp = cmpF;\n return h;\n}\n\nint32_t get_heap_size(const heap *h) { return h->heap_size; }\n\nint is_empty(const heap *h) { return h->heap_size == 0; }\n\nvoid free_heap(heap *h) {\n free(h->array);\n free(h);\n}\n\nvoid init_heap(heap *h) { h->heap_size = 0; }\n\nstatic void heap_func_swap(void *restrict a, void *restrict b,\n size_t val_size) {\n if ((val_size & 7) == 0) {\n uint64_t *p = (uint64_t *)a;\n uint64_t *q = (uint64_t *)b;\n val_size /= sizeof(uint64_t);\n while (val_size--) {\n uint64_t tmp = *p;\n *p++ = *q;\n *q++ = tmp;\n }\n } else {\n uint8_t *p = (uint8_t *)a;\n uint8_t *q = (uint8_t *)b;\n while (val_size--) {\n uint8_t tmp = *p;\n *p++ = *q;\n *q++ = tmp;\n }\n }\n}\n\nstatic void heap_func_copy(void *restrict dst, const void *restrict src,\n size_t val_size) {\n if ((val_size & 7) == 0) {\n uint64_t *p = (uint64_t *)src;\n uint64_t *q = (uint64_t *)dst;\n val_size /= sizeof(uint64_t);\n while (val_size--) {\n *q++ = *p++;\n }\n } else {\n uint8_t *p = (uint8_t *)src;\n uint8_t *q = (uint8_t *)dst;\n while (val_size--) {\n *q++ = *p++;\n }\n }\n}\n\nvoid push(heap *h, const void *val) {\n if (h->heap_size == h->max_size) {\n h->max_size = 2 * h->max_size + 1;\n h->array = realloc(h->array, h->val_size * (h->max_size + 1));\n }\n h->heap_size++;\n uint8_t *array = (uint8_t *)h->array;\n size_t k = h->heap_size;\n const size_t val_size = h->val_size;\n int (*cmp)(const void *, const void *) = h->cmp;\n heap_func_copy(array + k * val_size, val, val_size);\n while (k > 1) {\n size_t parent = k / 2;\n if (cmp(array + parent * val_size, array + k * val_size) <= 0) {\n return;\n }\n heap_func_swap(array + parent * val_size, array + k * val_size,\n val_size);\n k = parent;\n }\n}\n\nvoid pop(heap *h, void *res) {\n uint8_t *array = (uint8_t *)h->array;\n const size_t val_size = h->val_size;\n if (res != NULL) {\n heap_func_copy(res, array + val_size, val_size);\n }\n heap_func_copy(array + val_size, array + val_size * h->heap_size, val_size);\n h->heap_size--;\n int (*const cmp)(const void *, const void *) = h->cmp;\n const size_t n = h->heap_size;\n size_t k = 1;\n while (2 * k + 1 <= n) {\n int c = cmp(array + val_size * 2 * k, array + val_size * (2 * k + 1));\n size_t next = 2 * k + (c <= 0 ? 0 : 1);\n if (cmp(array + val_size * k, array + val_size * next) <= 0) return;\n heap_func_swap(array + val_size * k, array + val_size * next, val_size);\n k = next;\n }\n if (2 * k <= n && cmp(array + val_size * k, array + val_size * 2 * k) > 0) {\n heap_func_swap(array + val_size * k, array + val_size * 2 * k,\n val_size);\n }\n}\n\nvoid top(const heap *h, void *res) {\n uint8_t *array = (uint8_t *)h->array;\n const size_t val_size = h->val_size;\n if (res != NULL) {\n heap_func_copy(res, array + val_size, val_size);\n }\n}\n\ntypedef struct UnionFind {\n int32_t *parent;\n int32_t size;\n} UnionFind;\n\nvoid initUnionFind(UnionFind *u) {\n for (int32_t i = 0; i < u->size; ++i) {\n u->parent[i] = -1;\n }\n}\n\nUnionFind *newUnionFind(const int32_t size) {\n UnionFind *u = (UnionFind *)calloc(1, sizeof(UnionFind));\n u->parent = (int32_t *)calloc(size, sizeof(int32_t));\n u->size = size;\n initUnionFind(u);\n return u;\n}\n\nvoid freeUnionFind(UnionFind *u) {\n free(u->parent);\n free(u);\n}\n\nint32_t root(UnionFind *u, int32_t x) {\n int32_t index[32];\n int32_t len = 0;\n while (u->parent[x] >= 0) {\n index[len++] = x;\n x = u->parent[x];\n }\n while (len > 0) {\n u->parent[index[--len]] = x;\n }\n return x;\n}\n\nint same(UnionFind *u, int32_t x, int32_t y) {\n return root(u, x) == root(u, y);\n}\n\nint32_t getSize(UnionFind *u, int32_t x) { return -(u->parent[root(u, x)]); }\n\nvoid unite(UnionFind *u, int32_t x, int32_t y) {\n x = root(u, x);\n y = root(u, y);\n if (x == y) return;\n if (u->parent[x] > u->parent[y]) {\n int32_t swap = x;\n x = y;\n y = swap;\n }\n u->parent[x] += u->parent[y];\n u->parent[y] = x;\n}\n\ntypedef struct segment_tree_void {\n void *array;\n int32_t size;\n size_t val_size;\n void (*func)(void *, const void *, const void *);\n} segment_tree;\n\nstatic inline void segment_tree_memcpy(void *dst, const void *src,\n size_t size) {\n uint8_t *p = dst;\n const uint8_t *q = src;\n while (size--) {\n *p++ = *q++;\n }\n}\n\nsegment_tree *new_segment_tree(const void *ini, const int32_t n,\n const size_t val_size,\n void (*func)(void *, const void *,\n const void *)) {\n int32_t k = 1;\n while (k < n) k *= 2;\n segment_tree *s = (segment_tree *)calloc(1, sizeof(segment_tree));\n s->array = calloc(2 * k, val_size);\n s->size = k;\n s->val_size = val_size;\n s->func = func;\n for (int32_t i = k; i < 2 * k; ++i) {\n segment_tree_memcpy((uint8_t *)s->array + i * val_size, ini, val_size);\n }\n uint8_t *a = s->array;\n for (int32_t i = k - 1; i > 0; --i) {\n func(a + i * val_size, a + (2 * i) * val_size,\n a + (2 * i + 1) * val_size);\n }\n return s;\n}\n\nvoid update(segment_tree *const s, int32_t k, const void *val) {\n k += s->size;\n uint8_t *p = s->array;\n const size_t size = s->val_size;\n segment_tree_memcpy(p + k * size, val, size);\n for (k >>= 1; k > 0; k >>= 1) {\n s->func(p + k * size, p + 2 * k * size, p + (2 * k + 1) * size);\n }\n}\n\nvoid update_tmp(segment_tree *const s, int32_t k, const void *val) {\n k += s->size;\n uint8_t *p = s->array;\n const size_t size = s->val_size;\n segment_tree_memcpy(p + k * size, val, size);\n}\n\nvoid update_all(segment_tree *const s) {\n uint8_t *const a = s->array;\n const size_t size = s->val_size;\n for (int32_t i = s->size - 1; i > 0; --i) {\n s->func(a + i * size, a + (2 * i) * size, a + (2 * i + 1) * size);\n }\n}\n\nvoid find(const segment_tree *s, int32_t l, int32_t r, void *res) {\n int32_t lindex[32];\n int32_t rindex[32];\n int32_t llen = 0;\n int32_t rlen = 0;\n for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {\n if (l & 1) lindex[llen++] = l++;\n if (r & 1) rindex[rlen++] = --r;\n }\n const uint8_t *p = s->array;\n if (llen == 0) {\n lindex[llen++] = rindex[--rlen];\n }\n segment_tree_memcpy(res, p + lindex[0] * s->val_size, s->val_size);\n for (int32_t i = 1; i < llen; ++i) {\n s->func(res, res, p + lindex[i] * s->val_size);\n }\n for (int32_t i = rlen - 1; i >= 0; --i) {\n s->func(res, res, p + rindex[i] * s->val_size);\n }\n}\n\ntypedef int32_t i32;\ntypedef int64_t i64;\n\ntypedef struct index_val {\n i32 index;\n i32 val;\n} index_val;\n\nint cmp_index_val(const void *a, const void *b) {\n i32 d = ((index_val *)a)->val - ((index_val *)b)->val;\n return d == 0 ? 0 : d > 0 ? -1 : 1;\n}\n\ntypedef struct segment_node {\n i32 index;\n i64 val;\n} segment_node;\n\nvoid func_segment_node(void *c, const void *a, const void *b) {\n const segment_node *p = (const segment_node *)a;\n const segment_node *q = (const segment_node *)b;\n *(segment_node *)c = p->val < q->val ? *p : *q;\n}\n\ntypedef struct edge {\n i32 a, b;\n i64 c;\n} edge;\n\nint cmp_edge(const void *a, const void *b) {\n i64 d = ((edge *)a)->c - ((edge *)b)->c;\n return d == 0 ? 0 : d < 0 ? -1 : 1;\n}\n\nvoid run(void) {\n i32 n, d;\n scanf(\"%\" SCNi32 \"%\" SCNi32, &n, &d);\n i32 *a = (i32 *)calloc(n, sizeof(i32));\n index_val *p = (index_val *)calloc(n, sizeof(index_val));\n for (i32 i = 0; i < n; ++i) {\n scanf(\"%\" SCNi32, a + i);\n p[i] = (index_val){i, a[i]};\n }\n qsort(p, n, sizeof(index_val), cmp_index_val);\n const segment_node ini = {n, (i64)(n + 2) * 1000000000 + 1};\n segment_tree *l =\n new_segment_tree(&ini, n, sizeof(segment_node), func_segment_node);\n segment_tree *r =\n new_segment_tree(&ini, n, sizeof(segment_node), func_segment_node);\n for (i32 i = 0; i < n; ++i) {\n update_tmp(l, i, &((segment_node){i, a[i] + (i64)(n - 1 - i) * d}));\n update_tmp(r, i, &((segment_node){i, a[i] + (i64)i * d}));\n }\n update_all(l);\n update_all(r);\n heap *h = new_binary_heap(sizeof(edge), cmp_edge);\n for (i32 i = 0; i < n; ++i) {\n i32 v = p[i].index;\n if (v > 0) {\n segment_node t;\n find(l, 0, v, &t);\n push(h, &((edge){v, t.index,\n p[i].val + t.val - (i64)(n - 1 - v) * d}));\n }\n if (v + 1 < n) {\n segment_node t;\n find(r, v + 1, n, &t);\n push(h, &((edge){v, t.index, p[i].val + t.val - (i64)v * d}));\n }\n update(l, v, &ini);\n update(r, v, &ini);\n }\n i64 sum = 0;\n UnionFind *u = newUnionFind(n);\n while (getSize(u, 0) < n) {\n edge e;\n pop(h, &e);\n if (same(u, e.a, e.b)) continue;\n unite(u, e.a, e.b);\n sum += e.c;\n }\n printf(\"%\" PRIi64 \"\\n\", sum);\n}\n\nint main(void) {\n run();\n return 0;\n}", "test_IO": [ { "input": "3 1\n1 100 1\n", "output": "106\n" } ] }, { "id": "s907732757", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\ntypedef struct _node {\n int key;\n struct _node *next;\n struct _node *prev;\n} node;\n\nnode *head;\n\nnode *makenode(int);\nvoid insert(int);\nvoid delete(int);\nvoid deleteFirst();\nvoid deleteLast();\n\nint main() {\n int i, n, a;\n char op[16];\n node *x;\n\n head = makenode(0);\n head->next = head;\n head->prev = head;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%s\", op);\n if (strcmp(op, \"insert\") == 0) {\n scanf(\"%d\", &a);\n insert(a);\n } else if (strcmp(op, \"delete\") == 0) {\n scanf(\"%d\", &a);\n delete (a);\n } else if (strcmp(op, \"deleteFirst\") == 0) {\n deleteFirst();\n } else if (strcmp(op, \"deleteLast\") == 0) {\n deleteLast();\n }\n }\n\n x = head;\n while (x->next != head) {\n printf(\"%d\", x->next->key);\n x = x->next;\n if (x->next != head) {\n printf(\" \");\n }\n }\n printf(\"\\n\");\n\n return 0;\n}\n\nnode *makenode(int a) {\n node *x;\n x = malloc(sizeof(node));\n x->key = a;\n return x;\n}\nvoid insert(int a) {\n node *x;\n x = makenode(a);\n x->next = head->next;\n head->next->prev = x;\n head->next = x;\n x->prev = head;\n}\nvoid delete(int a) {\n node *x;\n x = head;\n\n while (x->next != head) {\n x = x->next;\n if (x->key == a) {\n x->prev->next = x->next;\n x->next->prev = x->prev;\n free(x);\n break;\n }\n }\n}\nvoid deleteFirst() {\n node *x;\n x = head->next;\n head->next = x->next;\n x->next->prev = head;\n free(x);\n}\nvoid deleteLast() {\n node *x;\n x = head->prev;\n head->prev = x->prev;\n x->prev->next = head;\n free(x);\n}", "test_IO": [ { "input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n", "output": "6 1 2\n" } ] }, { "id": "s791230408", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, c, i, j, k;\n int max;\n\n scanf(\"%d\", &j);\n\n for (i = 0; i < j; i++) {\n scanf(\"%d\", &a);\n scanf(\"%d\", &b);\n scanf(\"%d\", &c);\n\n max = a;\n k = 0;\n if (max <= b) {\n max = b;\n k = 1;\n }\n if (max <= c) {\n max = c;\n k = 2;\n }\n\n max = max * max;\n a = a * a;\n b = b * b;\n c = c * c;\n if (k == 0 && max == b + c) {\n printf(\"YES\\n\");\n } else if (k == 1 && max == a + c) {\n printf(\"YES\\n\");\n } else if (k == 2 && max == a + b) {\n printf(\"YES\\n\");\n } else {\n printf(\"NO\\n\");\n }\n }\n\n return (0);\n}", "test_IO": [ { "input": "3\n4 3 5\n4 3 6\n8 8 8\n", "output": "YES\nNO\nNO\n" } ] }, { "id": "s154738543", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int x, y;\n\n scanf(\"%d\", &x);\n\n y = x * x * x;\n\n printf(\"%d\\n\", y);\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s168792702", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, c;\n scanf(\"%d %d %d\", &a, &b, &c);\n\n if (a < b && b < c)\n puts(\"Yes\");\n else\n puts(\"No\");\n\n return 0;\n}", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s660035552", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\nint low[200000];\nint high[200000];\nint a[200000];\n\nint part(int a[], int b[], int l, int r) {\n int i, j, x, t;\n\n i = l - 1;\n j = r;\n\n x = b[r];\n\n while (1) {\n while (b[++i] < x)\n ;\n while (i < --j && x < b[j])\n ;\n\n if (i >= j) break;\n\n t = a[i];\n a[i] = a[j];\n a[j] = t;\n t = b[i];\n b[i] = b[j];\n b[j] = t;\n }\n\n t = a[i];\n a[i] = a[r];\n a[r] = t;\n t = b[i];\n b[i] = b[r];\n b[r] = t;\n return i;\n}\n\nvoid quicksort(int a[], int b[], int n) {\n int l, r, v;\n int sp;\n\n low[0] = 0;\n high[0] = n - 1;\n sp = 1;\n\n while (sp > 0) {\n sp--;\n l = low[sp];\n r = high[sp];\n\n if (l >= r)\n ;\n\n else {\n v = part(a, b, l, r);\n\n if (v - l < r - v) {\n low[sp] = v + 1;\n high[sp++] = r;\n low[sp] = l;\n high[sp++] = v - 1;\n }\n\n else {\n low[sp] = l;\n high[sp++] = v - 1;\n low[sp] = v + 1;\n high[sp++] = r;\n }\n }\n }\n}\n\nint main() {\n int n, m;\n int i;\n int a[100006];\n int b[100006];\n int cnt = 0;\n int t;\n\n scanf(\"%d %d\", &n, &m);\n\n for (i = 0; i < m; i++) scanf(\"%d %d\", &a[i], &b[i]);\n\n quicksort(a, b, m);\n\n t = 0;\n for (i = 0; i < m; i++) {\n if (t <= a[i]) {\n t = b[i];\n cnt++;\n }\n }\n\n printf(\"%d\\n\", cnt);\n\n return 0;\n}", "test_IO": [ { "input": "5 2\n1 4\n2 5\n", "output": "1\n" } ] }, { "id": "s235028939", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int n, m;\n scanf(\"%d %d\", &n, &m);\n printf(\"%d\\n\", (n - 1) * (m - 1));\n fflush(stdout);\n return 0;\n}", "test_IO": [ { "input": "3 4\n", "output": "6\n" } ] }, { "id": "s120278714", "dataset": "codenet", "language": "C", "code": "#include \n\n#define MAX 25\n\ntypedef struct {\n int l, r, par;\n} node;\n\nnode N[MAX];\n\nvoid init(int);\nvoid Preorder(int);\nvoid Inorder(int);\nvoid Postorder(int);\n\nint main() {\n int n, i, id, l, r;\n int p;\n\n scanf(\"%d\", &n);\n init(n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d%d%d\", &id, &l, &r);\n\n if (l != -1) {\n N[id].l = l;\n N[l].par = id;\n }\n if (r != -1) {\n N[id].r = r;\n N[r].par = id;\n }\n }\n\n for (i = 0; i < n; i++) {\n if (N[i].par == -1) {\n p = i;\n break;\n }\n }\n\n puts(\"Preorder\");\n Preorder(p);\n puts(\"\");\n\n puts(\"Inorder\");\n Inorder(p);\n puts(\"\");\n\n puts(\"Postorder\");\n Postorder(p);\n puts(\"\");\n\n return 0;\n}\n\nvoid init(int n) {\n int i;\n\n for (i = 0; i < n; i++) {\n N[i].par = N[i].l = N[i].r = -1;\n }\n}\n\nvoid Preorder(int p) {\n if (p != -1) {\n printf(\" %d\", p);\n Preorder(N[p].l);\n Preorder(N[p].r);\n }\n}\n\nvoid Inorder(int p) {\n if (p != -1) {\n Inorder(N[p].l);\n printf(\" %d\", p);\n Inorder(N[p].r);\n }\n}\n\nvoid Postorder(int p) {\n if (p != -1) {\n Postorder(N[p].l);\n Postorder(N[p].r);\n printf(\" %d\", p);\n }\n}", "test_IO": [ { "input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n", "output": "Preorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n" } ] }, { "id": "s470461127", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int x, y;\n x = 0;\n y = 0;\n\n scanf(\"%d\", &x);\n scanf(\"%d\", &y);\n\n printf(\"%d %d\\n\", x * y, (2 * x) + (2 * y));\n\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s539307012", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int n, x, min, m, i;\n scanf(\"%d %d %d\", &n, &x, &min);\n x -= min;\n for (i = 1; i < n; i++) {\n scanf(\"%d\", &m);\n x -= m;\n if (min > m) {\n min = m;\n }\n }\n printf(\"%d\\n\", n + x / min);\n return 0;\n}", "test_IO": [ { "input": "3 1000\n120\n100\n140\n", "output": "9\n" } ] }, { "id": "s906878895", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, x, w;\n while (scanf(\"%d %d\", &a, &b) != EOF) {\n x = a + b;\n w = 0;\n while (x) {\n w++;\n x /= 10;\n }\n printf(\"%d\\n\", w);\n }\n return 0;\n}", "test_IO": [ { "input": "5 7\n1 99\n1000 999\n", "output": "2\n3\n4\n" } ] }, { "id": "s787964396", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define I 10000\nvoid CountingSort(int *, int *, int);\nint main() {\n int *a, *b, i, max = 0, n;\n scanf(\"%d\", &n);\n a = (int *)malloc((n + 1) * sizeof(int));\n b = (int *)malloc((n + 1) * sizeof(int));\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i + 1]);\n }\n CountingSort(a, b, n);\n printf(\"%d\", b[1]);\n for (i = 2; i < n + 1; i++) printf(\" %d\", b[i]);\n printf(\"\\n\");\n free(a);\n free(b);\n return 0;\n}\nvoid CountingSort(int a[], int b[], int k) {\n int c[I], i, j;\n for (i = 0; i <= I; i++) c[i] = 0;\n for (j = 0; j < k; j++) c[a[j + 1]]++;\n for (i = 1; i < I + 1; i++) c[i] += c[i - 1];\n for (j = k; 0 < j; j--) {\n b[c[a[j]]] = a[j];\n c[a[j]]--;\n }\n}", "test_IO": [ { "input": "7\n2 5 1 3 2 3 0\n", "output": "0 1 2 2 3 3 5\n" } ] }, { "id": "s198852827", "dataset": "codenet", "language": "C", "code": "#include \n\n#define ABS(x) (((x) < (0)) ? (-(x)) : (x))\n\nint main(void) {\n int N, t, x, y, nx = 0, ny = 0, nt = 0;\n int i, j, k, tmp;\n scanf(\"%d\", &N);\n for (i = 0; i < N; i++) {\n scanf(\"%d%d%d\", &t, &x, &y);\n tmp = t - nt - (ABS(x - nx) + ABS(y - ny));\n if (tmp < 0 || tmp % 2) {\n puts(\"No\");\n return 0;\n }\n }\n puts(\"Yes\");\n return 0;\n}", "test_IO": [ { "input": "2\n3 1 2\n6 1 1\n", "output": "Yes\n" } ] }, { "id": "s410235811", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int n;\n scanf(\"%d\", &n);\n if (n % 2 == 0) {\n printf(\"%d\\n\", n / 2);\n } else {\n printf(\"%d\\n\", (n / 2) + 1);\n }\n\n return 0;\n}", "test_IO": [ { "input": "5\n", "output": "3\n" } ] }, { "id": "s389564195", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void)\n\n{\n int x, kotae;\n\n scanf(\"%d\", &x);\n\n kotae = x * x * x;\n\n printf(\"%d\\n\", kotae);\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s683308527", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint main() {\n int n;\n char s[10010], *c;\n scanf(\"%d%*c\", &n);\n while (n--) {\n fgets(s, 1010, stdin);\n while (c = strstr(s, \"Hoshino\")) *(c + 6) = 'a';\n printf(\"%s\", s);\n }\n return 0;\n}", "test_IO": [ { "input": "3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n", "output": "Hoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.\n" } ] }, { "id": "s263479532", "dataset": "codenet", "language": "C", "code": "#include \n#define MAX 100\n#define INF 999999\n#define NIL -1\n#define WHITE 0\n#define BLACK 2\n\nint prim();\n\nint n, G[MAX][MAX];\n\nint main() {\n int i, j;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n scanf(\"%d\", &G[i][j]);\n }\n }\n\n printf(\"%d\\n\", prim());\n\n return 0;\n}\n\nint prim() {\n int u, i, v, mincost, d[n], pi[n], color[n], sum = 0;\n\n for (u = 0; u < n; u++) {\n d[u] = INF;\n pi[u] = NIL;\n color[u] = WHITE;\n }\n\n d[0] = 0;\n while (1) {\n mincost = INF;\n\n for (i = 0; i < n; i++) {\n if (color[i] != BLACK && d[i] < mincost) {\n mincost = d[i];\n u = i;\n }\n }\n\n if (mincost == INF) break;\n\n color[u] = BLACK;\n\n for (v = 0; v < n; v++) {\n if (color[v] != BLACK && G[u][v] < d[v] && G[u][v] != -1) {\n pi[v] = u;\n d[v] = G[u][v];\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n if (d[i] != INF) sum += d[i];\n }\n\n return sum;\n}", "test_IO": [ { "input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n", "output": "5\n" } ] }, { "id": "s753632359", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int N, D;\n int ans, rem;\n\n scanf(\"%d%d\", &N, &D);\n\n ans = N / (D * 2 + 1);\n rem = N % (D * 2 + 1);\n\n if (rem != 0) {\n ans = ans + 1;\n }\n\n printf(\"%d\\n\", ans);\n\n return 0;\n}", "test_IO": [ { "input": "6 2\n", "output": "2\n" } ] }, { "id": "s426986656", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int A, B, flag = 0;\n scanf(\"%d %d\", &A, &B);\n\n for (int i = 1; i <= 3; ++i) {\n if ((A * B * i) % 2 == 1) {\n flag = 1;\n break;\n }\n }\n\n if (flag)\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "3 1\n", "output": "Yes\n" } ] }, { "id": "s388748526", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n double r;\n scanf(\"%lf\", &r);\n printf(\"%lf %lf\\n\", r * r * M_PI, 2 * M_PI * r);\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "12.566371 12.566371\n" } ] }, { "id": "s387404795", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main(void) {\n char str[201], tmp[101];\n char p[101];\n int slen, plen;\n int i, j, flag;\n\n scanf(\"%s %s\", str, p);\n\n strcpy(tmp, str);\n strcat(str, tmp);\n\n slen = strlen(str);\n plen = strlen(p);\n\n flag = 0;\n for (i = 0; i < slen - plen; i++) {\n if (strncmp(&str[i], p, plen) == 0) flag = 1;\n }\n\n if (flag)\n puts(\"Yes\");\n else\n puts(\"No\");\n\n return 0;\n}", "test_IO": [ { "input": "vanceknowledgetoad\nadvance\n", "output": "Yes\n" } ] }, { "id": "s190193281", "dataset": "codenet", "language": "C", "code": "#include \n#define N 1000000\n#define Q 50000\nint n, S[N], T[Q];\n\nint binarySearch(int key) {\n int left = 0, right = n, mid;\n while (left < right) {\n mid = (left + right) / 2;\n if (S[mid] == key)\n return 1;\n else if (key < S[mid])\n right = mid;\n else\n left = mid + 1;\n }\n return 0;\n}\n\nint main() {\n int i, j, q, c = 0;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &S[i]);\n }\n\n scanf(\"%d\", &q);\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &T[i]);\n if (binarySearch(T[i]) == 1) c++;\n }\n\n printf(\"%d\\n\", c);\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s141680236", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nvoid push(int);\nint pop();\n\nint top, kinbo[1000];\n\nint main() {\n int chonda, yamagami;\n top = 0;\n char null[100];\n\n while (scanf(\"%s\", null) != EOF) {\n if (null[0] == '+') {\n chonda = pop();\n yamagami = pop();\n push(chonda + yamagami);\n } else if (null[0] == '-') {\n yamagami = pop();\n chonda = pop();\n push(chonda - yamagami);\n } else if (null[0] == '*') {\n chonda = pop();\n yamagami = pop();\n push(chonda * yamagami);\n } else\n push(atoi(null));\n }\n\n printf(\"%d\\n\", pop());\n\n return 0;\n}\n\nvoid push(int chonda) { kinbo[++top] = chonda; }\n\nint pop() {\n top--;\n return kinbo[top + 1];\n}", "test_IO": [ { "input": "1 2 +\n", "output": "3\n" } ] }, { "id": "s882312203", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main(int argc, char *argv[]) {\n char s[26];\n\n scanf(\"%s\", s);\n\n for (int j = 0; j < strlen(s); j++) {\n for (int i = 0; i < strlen(s); i++) {\n if ((i != j) && (s[i] == s[j])) {\n puts(\"no\");\n return 0;\n }\n }\n }\n\n puts(\"yes\");\n\n return 0;\n}", "test_IO": [ { "input": "uncopyrightable\n", "output": "yes\n" } ] }, { "id": "s372829880", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int x, a;\n scanf(\"%d %d\", &x, &a);\n printf(\"%d\\n\", (x >= a) * 10);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "0\n" } ] }, { "id": "s451461278", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define MAX 100000\n\nint Partition(char[], int[], int, int);\nvoid Quicksort(char[], int[], int, int);\n\nvoid Merge(char[], int[], int, int, int);\nvoid Merge_Sort(char[], int[], int, int);\n\nint q;\n\nint main(void) {\n int A[MAX + 1];\n char C[MAX + 1];\n char MC[MAX + 1];\n int MN[MAX + 1];\n\n int i, p, n;\n int count = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 1; i <= n; i++) scanf(\" %c %d\", &C[i], &A[i]);\n\n for (i = 1; i <= n; i++) {\n MC[i] = C[i];\n MN[i] = A[i];\n }\n\n Merge_Sort(MC, MN, 1, n);\n\n p = 1;\n Quicksort(C, A, p, n);\n\n for (i = 1; i <= n; i++) {\n if (MN[i] == A[i] && MC[i] == C[i]) count++;\n }\n\n if (count == n)\n printf(\"Stable\\n\");\n\n else\n printf(\"Not stable\\n\");\n\n for (i = 1; i <= n; i++) printf(\"%c %d\\n\", C[i], A[i]);\n\n return 0;\n}\n\nint Partition(char C[], int A[], int p, int r) {\n int i, j;\n char tmpC, x;\n int tmpN, y;\n\n x = C[r];\n y = A[r];\n i = p - 1;\n\n for (j = p; j < r; j++) {\n if (A[j] <= y) {\n i = i + 1;\n tmpN = A[j];\n tmpC = C[j];\n A[j] = A[i];\n C[j] = C[i];\n A[i] = tmpN;\n C[i] = tmpC;\n }\n }\n\n tmpN = A[i + 1];\n tmpC = C[i + 1];\n A[i + 1] = A[r];\n C[i + 1] = C[r];\n A[r] = tmpN;\n C[r] = tmpC;\n\n return i + 1;\n}\n\nvoid Quicksort(char C[], int A[], int p, int r) {\n if (p < r) {\n q = Partition(C, A, p, r);\n Quicksort(C, A, p, q - 1);\n Quicksort(C, A, q + 1, r);\n }\n}\n\nvoid Merge(char MC[], int MN[], int left, int mid, int right) {\n int n1 = mid - left + 1;\n int n2 = right - mid;\n int LN[n1 + 1];\n int RN[n2 + 1];\n int LC[n1 + 1];\n int RC[n2 + 1];\n\n int i, j, k;\n\n for (i = 1; i <= n1; i++) {\n LN[i] = MN[left + i - 1];\n LC[i] = MC[left + i - 1];\n }\n\n for (i = 1; i <= n2; i++) {\n RN[i] = MN[mid + i];\n RC[i] = MC[mid + i];\n }\n\n LN[n1 + 1] = 1000000000;\n RN[n2 + 1] = 1000000000;\n\n i = 1;\n j = 1;\n\n for (k = left; k <= right; k++) {\n if (LN[i] <= RN[j]) {\n MN[k] = LN[i];\n MC[k] = LC[i++];\n } else {\n MN[k] = RN[j];\n MC[k] = RC[j++];\n }\n }\n}\n\nvoid Merge_Sort(char MC[], int MN[], int left, int right) {\n int mid;\n\n if (left < right) {\n mid = (left + right) / 2;\n Merge_Sort(MC, MN, left, mid);\n Merge_Sort(MC, MN, mid + 1, right);\n Merge(MC, MN, left, mid, right);\n }\n}", "test_IO": [ { "input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n", "output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n" } ] }, { "id": "s237922865", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int n;\n scanf(\"%d\", &n);\n\n int cnt4 = 0, cnt2 = 0;\n\n for (int i = 0; i < n; i++) {\n int wk;\n scanf(\"%d\", &wk);\n if (wk % 4 == 0)\n cnt4++;\n else if (wk % 2 == 0)\n cnt2++;\n }\n\n if (cnt4 + cnt2 / 2 >= n / 2)\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "3\n1 10 100\n", "output": "Yes\n" } ] }, { "id": "s808208135", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\n#define N 100000\n#define INF 1000000\n\ntypedef struct {\n int go, back, cost;\n} Date;\n\nint n, d[N];\nDate a[500000];\nvoid root(int);\n\nint main() {\n int i, j, k, u, count = 0;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d%d\", &u, &k);\n for (j = 0; j < k; j++) {\n a[count].back = u;\n scanf(\"%d%d\", &a[count].go, &a[count].cost);\n count++;\n }\n }\n root(count);\n for (i = 0; i < n; i++) printf(\"%d %d\\n\", i, d[i]);\n return 0;\n}\n\nvoid root(int b) {\n int i, flag = 1;\n\n for (i = 0; i < n; i++) d[i] = INF;\n d[0] = 0;\n\n while (flag != 0) {\n flag = 0;\n for (i = 0; i < b; i++) {\n if (a[i].cost + d[a[i].back] < d[a[i].go]) {\n d[a[i].go] = a[i].cost + d[a[i].back];\n flag = 1;\n }\n }\n }\n}", "test_IO": [ { "input": "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n", "output": "0 0\n1 2\n2 2\n3 1\n4 3\n" } ] }, { "id": "s817872520", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\n#define INF 0x5fffffff\nint a[100002];\nint b[100002];\n\nchar buf[700002], *p;\nint getint() {\n int n = 0;\n if (*p == '-') {\n p++;\n while (*p >= '0') n = (n << 3) + (n << 1) + (*p++ & 0xf);\n return -n;\n }\n while (*p >= '0') n = (n << 3) + (n << 1) + (*p++ & 0xf);\n return n;\n}\n\nint main() {\n int w, i, k, f, close, ans;\n\n fgets(p = buf, 10, stdin), w = getint();\n fgets(p = buf, sizeof(buf), stdin);\n for (ans = 0, f = 0, i = 1; i <= w; i++) {\n a[i] = k = getint(), p++;\n if (!k)\n f |= 1;\n else if (k < 0)\n f |= 2;\n else\n ans += k;\n }\n if (!ans || !(f & 1)) {\n puts(\"0\");\n return 0;\n }\n if (!(f & 2)) {\n printf(\"%d\\n\", ans);\n return 0;\n }\n\n for (close = 0, f = 0, i = 1; i <= w; i++) {\n if (!a[i])\n close = INF, f = -1;\n else if (a[i] < 0) {\n if (f < 0 || close - (i - f) > -a[i]) close = -a[i], f = i;\n } else {\n if (f < 0)\n b[i] = INF;\n else {\n k = close - (i - f);\n if (k < 0) k = 0;\n b[i] = k;\n }\n }\n }\n\n for (close = 0, f = w, i = w; i >= 1; i--) {\n if (!a[i])\n close = INF, f = -1;\n else if (a[i] < 0) {\n if (f < 0 || close - (f - i) > -a[i]) close = -a[i], f = i;\n } else {\n if (f < 0)\n b[i] = INF;\n else {\n k = close - (f - i);\n if (k < 0) k = 0;\n if (k > b[i]) b[i] = k;\n }\n }\n }\n\n for (ans = 0, i = 1; i <= w; i++) {\n if (a[i] > 0) {\n if (b[i] > a[i])\n ans += a[i];\n else\n ans += b[i];\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "test_IO": [ { "input": "7\n2 0 -2 3 2 -2 0\n", "output": "4\n" } ] }, { "id": "s128781606", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int A, B, C, D, E, max;\n scanf(\"%d %d\", &A, &B);\n C = A + B;\n D = A - B;\n E = A * B;\n max = C;\n if (max < D) {\n max = D;\n }\n if (max < E) {\n max = E;\n }\n printf(\"%d\\n\", max);\n return 0;\n}", "test_IO": [ { "input": "-13 3\n", "output": "-10\n" } ] }, { "id": "s730748220", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\nint main() {\n int i, j, k, n;\n\n scanf(\"%d\", &n);\n\n printf(\"%d\\n\", 24 + (24 - n));\n\n return 0;\n}", "test_IO": [ { "input": "21\n", "output": "27\n" } ] }, { "id": "s264533675", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n char str[30];\n gets(str);\n str[5] = ' ';\n str[13] = ' ';\n printf(\"%s\\n\", str);\n return 0;\n}", "test_IO": [ { "input": "happy,newyear,enjoy\n", "output": "happy newyear enjoy\n" } ] }, { "id": "s961413659", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n if (a == 1) a = 14;\n if (b == 1) b = 14;\n if (a < b)\n printf(\"Bob\\n\");\n else if (a > b)\n printf(\"Alice\\n\");\n else\n printf(\"Draw\\n\");\n return 0;\n}", "test_IO": [ { "input": "8 6\n", "output": "Alice\n" } ] }, { "id": "s069149000", "dataset": "codenet", "language": "C", "code": "#include \n#define INF 100000\n#define MAX 101\n#define NIL -6\n#define WHITE 0\n#define GRAY 1\n#define BLACK 2\n\nint G[MAX][MAX];\nint n;\n\nvoid prim() {\n int i, j;\n int d[MAX];\n int pi[MAX];\n int color[MAX];\n int min, u, v, sum = 0;\n\n for (i = 0; i < n; i++) {\n d[i] = INF;\n pi[i] = NIL;\n color[i] = WHITE;\n }\n\n d[0] = 0;\n\n while (1) {\n min = INF;\n u = NIL;\n for (i = 0; i < n; i++) {\n if (color[i] != BLACK && d[i] < min) {\n min = d[i];\n u = i;\n }\n }\n if (u == NIL) {\n break;\n }\n color[u] = BLACK;\n for (v = 0; v < n; v++) {\n if (color[v] != BLACK && G[u][v] != INF) {\n if (d[v] > G[u][v]) {\n d[v] = G[u][v];\n pi[v] = u;\n color[v] = GRAY;\n }\n }\n }\n }\n for (i = 0; i < n; i++) {\n if (pi[i] != NIL) sum += G[i][pi[i]];\n }\n printf(\"%d\\n\", sum);\n}\n\nint main() {\n int e;\n int i, j;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n scanf(\"%d\", &e);\n if (e == -1) {\n G[i][j] = INF;\n } else {\n G[i][j] = e;\n }\n }\n }\n\n prim();\n return 0;\n}", "test_IO": [ { "input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n", "output": "5\n" } ] }, { "id": "s132677252", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\ntypedef int32_t i32;\ntypedef int64_t i64;\n\ntypedef struct directed_edge {\n int32_t vertex;\n int32_t next;\n} graph_edge;\n\ntypedef struct directedGraph {\n graph_edge *edge;\n int32_t *start;\n int32_t pointer;\n int32_t vertex_num;\n int32_t edge_max_size;\n} graph;\n\ngraph *new_graph(const int vertex_num) {\n graph *g = (graph *)calloc(1, sizeof(graph));\n g->edge = (graph_edge *)calloc(1, sizeof(graph_edge));\n g->start = (int32_t *)calloc(vertex_num, sizeof(int32_t));\n g->pointer = 0;\n g->vertex_num = vertex_num;\n g->edge_max_size = 1;\n for (int32_t i = 0; i < vertex_num; ++i) {\n g->start[i] = -1;\n }\n return g;\n}\n\nvoid add_edge(graph *g, int32_t from, int32_t to) {\n if (g->pointer == g->edge_max_size) {\n g->edge_max_size *= 2;\n g->edge = (graph_edge *)realloc(g->edge,\n sizeof(graph_edge) * g->edge_max_size);\n }\n g->edge[g->pointer] = (graph_edge){to, g->start[from]};\n g->start[from] = g->pointer++;\n}\n\nconst i32 mod = 1000000007;\n\ni32 mod_pow(i32 r, i32 n) {\n i32 t = 1;\n i32 s = r;\n while (n > 0) {\n if (n & 1) t = (i64)t * s % mod;\n s = (i64)s * s % mod;\n n >>= 1;\n }\n return t;\n}\n\ntypedef struct dp_node {\n i32 one;\n i32 zero;\n} node;\n\nnode merge(node *a, i32 n) {\n i64 one = 0;\n i64 zero = 1;\n i64 total = 1;\n for (i32 i = 0; i < n; ++i) {\n one = (one * a[i].zero + zero * a[i].one) % mod;\n zero = zero * a[i].zero % mod;\n total = total * (a[i].zero + a[i].one) % mod;\n }\n return (node){one, (total + mod - one) % mod};\n}\n\ntypedef node deque_val;\n\ntypedef struct Deque {\n deque_val *array;\n size_t front;\n size_t last;\n size_t mask;\n} deque;\n\ndeque *new_deque(void) {\n const size_t len = 2;\n deque *d = (deque *)calloc(len, sizeof(deque));\n d->array = (deque_val *)calloc(len, sizeof(deque_val));\n d->front = d->last = 0;\n d->mask = len - 1;\n return d;\n}\n\nvoid free_deque(deque *const d) {\n free(d->array);\n free(d);\n}\n\nsize_t get_size(const deque *d) {\n return (d->last + (~d->front + 1)) & d->mask;\n}\n\nvoid deque_realloc(deque *const d) {\n deque_val *array =\n (deque_val *)calloc(2 * (d->mask + 1), sizeof(deque_val));\n size_t k = 0;\n for (size_t i = d->front; i != d->last; i = (i + 1) & d->mask) {\n array[k++] = d->array[i];\n }\n free(d->array);\n d->array = array;\n d->front = 0;\n d->last = k;\n d->mask = 2 * d->mask + 1;\n}\n\ndeque_val get_at(const deque *d, size_t x) {\n return d->array[(d->front + x) & d->mask];\n}\n\nvoid assign_at(const deque *d, size_t x, deque_val v) {\n d->array[(d->front + x) & d->mask] = v;\n}\n\nvoid push_front(deque *const d, const deque_val v) {\n if (((d->last + 1) & d->mask) == d->front) {\n deque_realloc(d);\n }\n d->front = (d->front + d->mask) & d->mask;\n d->array[d->front] = v;\n}\n\nint cmp_deque_size(const void *a, const void *b) {\n deque *p = *(deque **)a;\n deque *q = *(deque **)b;\n i32 d = get_size(p) - get_size(q);\n return d == 0 ? 0 : d > 0 ? -1 : 1;\n}\n\nvoid run(void) {\n i32 n;\n scanf(\"%\" SCNi32, &n);\n i32 *p = (i32 *)calloc(n + 1, sizeof(i32));\n i32 *depth = (i32 *)calloc(n + 1, sizeof(i32));\n i32 *cnt = (i32 *)calloc(n + 1, sizeof(i32));\n cnt[0] = 1;\n graph *g = new_graph(n + 1);\n for (i32 i = 1; i <= n; ++i) {\n scanf(\"%\" SCNi32, p + i);\n add_edge(g, p[i], i);\n depth[i] = depth[p[i]] + 1;\n cnt[depth[i]]++;\n }\n deque **dp = (deque **)calloc(n + 1, sizeof(deque *));\n deque **child = (deque **)calloc(n + 1, sizeof(deque *));\n node *lst = (node *)calloc(n + 1, sizeof(node));\n for (i32 i = n; i >= 0; --i) {\n i32 v = i;\n if (g->start[v] == -1) {\n dp[v] = new_deque();\n push_front(dp[v], (node){1, 1});\n continue;\n }\n i32 len = 0;\n for (i32 p = g->start[v]; p != -1; p = g->edge[p].next) {\n i32 u = g->edge[p].vertex;\n child[len++] = dp[u];\n }\n if (len > 1) {\n qsort(child, len, sizeof(deque *), cmp_deque_size);\n for (i32 d = 0; d < (i32)get_size(child[1]); ++d) {\n i32 j = 0;\n for (; j < len && d < (i32)get_size(child[j]); ++j) {\n lst[j] = get_at(child[j], d);\n }\n assign_at(child[0], d, merge(lst, j));\n }\n for (i32 j = 1; j < len; ++j) {\n free_deque(child[j]);\n }\n }\n dp[v] = child[0];\n push_front(dp[v], (node){1, 1});\n }\n i64 ans = 0;\n for (i32 i = 0; i < (i32)get_size(dp[0]); ++i) {\n ans += (i64)mod_pow(2, n + 1 - cnt[i]) * get_at(dp[0], i).one % mod;\n }\n printf(\"%\" PRIi64 \"\\n\", ans % mod);\n}\n\nint main(void) {\n run();\n return 0;\n}", "test_IO": [ { "input": "2\n0 0\n", "output": "8\n" } ] }, { "id": "s762168196", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int a[10000], min, max, n, i;\n long long sum = 0;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n sum += a[i];\n }\n max = min = a[0];\n for (i = 1; i < n; i++) {\n if (a[i] > max) max = a[i];\n if (a[i] < min) min = a[i];\n }\n printf(\"%d %d %lld\\n\", min, max, sum);\n\n return 0;\n}", "test_IO": [ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ] }, { "id": "s176519935", "dataset": "codenet", "language": "C", "code": "#include \n\nlong long heap[100000], sz = 0;\nvoid push(int x) {\n int i = sz++;\n while (i > 0) {\n int p = (i - 1) / 2;\n if (heap[p] >= x) break;\n heap[i] = heap[p];\n i = p;\n }\n heap[i] = x;\n}\nint pop() {\n int ret = heap[0];\n int x = heap[--sz];\n int i = 0;\n while (i * 2 + 1 < sz) {\n int a = i * 2 + 1, b = i * 2 + 2;\n if (b < sz && heap[b] > heap[a]) a = b;\n if (heap[a] <= x) break;\n heap[i] = heap[a];\n i = a;\n }\n heap[i] = x;\n return ret;\n}\n\nint main() {\n int n, m, i, j;\n long long a[100000];\n scanf(\"%d%d\", &n, &m);\n for (i = 0; i < n; i++) scanf(\"%lld\", &a[i]);\n for (i = 0; i < n; i++) push(a[i]);\n for (i = 0; i < m; i++) {\n long long tm = pop();\n tm /= 2;\n push(tm);\n }\n long long ans = 0;\n for (i = 0; i < n; i++) ans += heap[i];\n printf(\"%lld\\n\", ans);\n return 0;\n}", "test_IO": [ { "input": "3 3\n2 13 8\n", "output": "9\n" } ] }, { "id": "s517438056", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nint main(void) {\n int N, D, i, j, k = 0, n = 0;\n double l;\n int** matrix;\n scanf(\"%d%d\", &N, &D);\n matrix = (int**)malloc(sizeof(int*) * N);\n for (i = 0; i < N; i++) {\n matrix[i] = (int*)malloc(sizeof(int) * D);\n }\n for (i = 0; i < N; i++) {\n for (j = 0; j < D; j++) {\n scanf(\"%d\", &matrix[i][j]);\n }\n }\n for (i = 0; i < N - 1; i++) {\n for (j = i + 1; j < N; j++) {\n int m = 0;\n for (n = 0; n < D; n++) {\n m = (matrix[i][n] - matrix[j][n]) *\n (matrix[i][n] - matrix[j][n]) +\n m;\n }\n l = sqrt(m);\n if (ceil(l) == floor(l)) k++;\n }\n }\n printf(\"%d\\n\", k);\n free(matrix);\n return 0;\n}", "test_IO": [ { "input": "3 2\n1 2\n5 5\n-2 8\n", "output": "1\n" } ] }, { "id": "s585881557", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int h, r;\n scanf(\"%d%d\", &h, &r);\n if (r > -h) {\n printf(\"1\\n\");\n } else if (r == -h) {\n printf(\"0\\n\");\n } else {\n printf(\"-1\\n\");\n }\n return 0;\n}", "test_IO": [ { "input": "-3 3\n", "output": "0\n" } ] }, { "id": "s072370813", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int N;\n scanf(\"%d\", &N);\n\n int i;\n long long sum = 0;\n long long wa = 0;\n int A[N];\n int sa[N];\n int ans;\n int shou;\n long long min = 1123456789;\n\n for (i = 0; i < N; i++) {\n scanf(\"%d\", A + i);\n sum += A[i];\n wa += i + 1;\n }\n\n if (sum % wa)\n ans = 0;\n else {\n shou = sum / wa;\n for (i = 0; i < N; i++) {\n sa[i] = A[(i + 1) % N] - A[i] - shou;\n }\n\n for (i = 0; i < N - 1; i++) {\n if (sa[i] <= 0 && !(sa[i] % N))\n ans = 1;\n else {\n ans = 0;\n break;\n }\n }\n }\n\n if (ans)\n puts(\"YES\");\n else {\n puts(\"NO\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "5\n4 5 1 2 3\n", "output": "YES\n" } ] }, { "id": "s898107093", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nint main() {\n char **t, **h;\n int n, taro = 0, hanako = 0, i;\n scanf(\"%d\", &n);\n t = malloc(n * sizeof(char *));\n h = malloc(n * sizeof(char *));\n for (i = 0; i < n; i++) {\n t[i] = malloc(100 * sizeof(char));\n h[i] = malloc(100 * sizeof(char));\n scanf(\"%s\", t[i]);\n scanf(\"%s\", h[i]);\n if (strcmp(t[i], h[i]) < 0) hanako += 3;\n if (strcmp(t[i], h[i]) > 0) taro += 3;\n if (strcmp(t[i], h[i]) == 0) {\n taro += 1;\n hanako += 1;\n }\n free(t[i]);\n free(h[i]);\n }\n printf(\"%d %d\\n\", taro, hanako);\n return 0;\n}", "test_IO": [ { "input": "3\ncat dog\nfish fish\nlion tiger\n", "output": "1 7\n" } ] }, { "id": "s164093814", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\n#define M 1046527\n#define L 14\n\nchar H[M][L];\n\nint getChar(char ch) {\n if (ch == 'A')\n return 1;\n else if (ch == 'C')\n return 2;\n else if (ch == 'G')\n return 3;\n else if (ch == 'T')\n return 4;\n return 0;\n}\n\nlong long getKey(char str[]) {\n long long sum = 0, p = 1;\n int i;\n for (i = 0; i < (int)strlen(str); i++) {\n sum += p * (getChar(str[i]));\n p *= 5;\n }\n return sum;\n}\n\nint h1(int key) { return key % M; }\nint h2(int key) { return 1 + (key % (M - 1)); }\n\nint find(char str[]) {\n int i, hash, key;\n key = getKey(str);\n i = 0;\n while (1) {\n hash = (h1(key) + i * h2(key)) % M;\n if (strcmp(H[hash], str) == 0)\n return 1;\n else if (strlen(H[hash]) == 0)\n return 0;\n i++;\n }\n return 0;\n}\n\nint insert(char str[]) {\n int i, hash, key;\n key = getKey(str);\n i = 0;\n while (1) {\n hash = (h1(key) + i * h2(key)) % M;\n if (strcmp(H[hash], str) == 0)\n return 1;\n else if (strlen(H[hash]) == 0) {\n strcpy(H[hash], str);\n return 0;\n }\n i++;\n }\n return 0;\n}\n\nint main() {\n int i, n;\n char str[L], com[9];\n for (i = 0; i < M; i++) H[i][0] = '\\0';\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%s %s\", com, str);\n\n if (com[0] == 'i') {\n insert(str);\n } else {\n if (find(str)) {\n printf(\"yes\\n\");\n } else {\n printf(\"no\\n\");\n }\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "5\ninsert A\ninsert T\ninsert C\nfind G\nfind A\n", "output": "no\nyes\n" } ] }, { "id": "s215012367", "dataset": "codenet", "language": "C", "code": "#include \n\nint main()\n\n{\n int a, b, s;\n\n scanf(\"%d %d\", &a, &b);\n\n s = (a * b) - (a + b) + 1;\n\n printf(\"%d\\n\", s);\n}", "test_IO": [ { "input": "2 2\n", "output": "1\n" } ] }, { "id": "s826185217", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, c, d;\n\n scanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\n if (a + b > c + d)\n printf(\"Left\\n\");\n else if (a + b < c + d)\n printf(\"Right\\n\");\n else\n printf(\"Balanced\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "3 8 7 1\n", "output": "Left\n" } ] }, { "id": "s534239171", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, n;\n scanf(\"%d %d\", &a, &b);\n n = (a + b) / 2;\n printf(\"%d\\n\", n);\n return 0;\n}", "test_IO": [ { "input": "1000 3000\n", "output": "2000\n" } ] }, { "id": "s381222101", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, h;\n scanf(\"%d%d%d\", &a, &b, &h);\n printf(\"%d\\n\", (a + b) * h / 2);\n return 0;\n}", "test_IO": [ { "input": "3\n4\n2\n", "output": "7\n" } ] }, { "id": "s701716787", "dataset": "codenet", "language": "C", "code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n\n#define U1 unsigned char\n#define S1 char\n#define S4 int\n#define DU double\n#define VD void\n\n#define COMMAND_LENGTH (10)\n\ntypedef struct st_node ST_NODE;\ntypedef struct st_node {\n ST_NODE* st_parent;\n ST_NODE* st_left;\n ST_NODE* st_right;\n S4 s4_key;\n};\n\nVD vd_d_insert(ST_NODE**, S4);\nVD vd_d_print(ST_NODE*);\nstatic VD vd_s_printPreOrder(ST_NODE*);\nstatic VD vd_s_printInOrder(ST_NODE*);\nST_NODE* st_dp_newST_NODE(S4);\n\nS4 main() {\n ST_NODE* st_tp_root;\n S4 s4_t_numCommand;\n S4 s4_t_iCommand;\n S1 s1_tp_command[COMMAND_LENGTH];\n S4 s4_t_insertKey;\n S4 s4_t_RtnStrcmp;\n\n st_tp_root = (ST_NODE*)NULL;\n\n (VD) scanf(\"%d\", &s4_t_numCommand);\n\n for (s4_t_iCommand = (S4)0; s4_t_iCommand < s4_t_numCommand;\n s4_t_iCommand++) {\n (VD) scanf(\"%s\", s1_tp_command);\n\n s4_t_RtnStrcmp = (S4)strcmp(s1_tp_command, \"insert\");\n if (s4_t_RtnStrcmp == (S4)0) {\n (VD) scanf(\"%d\", &s4_t_insertKey);\n vd_d_insert(&st_tp_root, s4_t_insertKey);\n } else {\n vd_d_print(st_tp_root);\n }\n }\n\n return ((S4)0);\n}\n\nVD vd_d_insert(ST_NODE** st_ap2_root, S4 s4_a_key) {\n ST_NODE* st_tp_parentNode;\n ST_NODE* st_tp_indexNode;\n ST_NODE* st_tp_insertNode;\n\n st_tp_insertNode = st_dp_newST_NODE(s4_a_key);\n\n st_tp_parentNode = (ST_NODE*)NULL;\n st_tp_indexNode = *st_ap2_root;\n\n while (st_tp_indexNode != (ST_NODE*)NULL) {\n st_tp_parentNode = st_tp_indexNode;\n if (st_tp_insertNode->s4_key < st_tp_indexNode->s4_key) {\n st_tp_indexNode = st_tp_indexNode->st_left;\n } else {\n st_tp_indexNode = st_tp_indexNode->st_right;\n }\n }\n st_tp_insertNode->st_parent = st_tp_parentNode;\n\n if (st_tp_parentNode == (ST_NODE*)NULL) {\n *st_ap2_root = st_tp_insertNode;\n } else if (s4_a_key < st_tp_parentNode->s4_key) {\n st_tp_parentNode->st_left = st_tp_insertNode;\n } else {\n st_tp_parentNode->st_right = st_tp_insertNode;\n }\n}\n\nVD vd_d_print(ST_NODE* st_ap_root) {\n vd_s_printInOrder(st_ap_root);\n printf(\"\\n\");\n vd_s_printPreOrder(st_ap_root);\n printf(\"\\n\");\n}\n\nstatic VD vd_s_printPreOrder(ST_NODE* st_ap_node) {\n if (st_ap_node == (ST_NODE*)NULL) {\n return;\n }\n\n printf(\" %d\", st_ap_node->s4_key);\n vd_s_printPreOrder(st_ap_node->st_left);\n vd_s_printPreOrder(st_ap_node->st_right);\n}\n\nstatic VD vd_s_printInOrder(ST_NODE* st_ap_node) {\n static s4_s_printedNumNode = (S4)0;\n\n if (st_ap_node == (ST_NODE*)NULL) {\n return;\n }\n\n vd_s_printInOrder(st_ap_node->st_left);\n printf(\" %d\", st_ap_node->s4_key);\n vd_s_printInOrder(st_ap_node->st_right);\n}\n\nST_NODE* st_dp_newST_NODE(S4 s4_a_key) {\n ST_NODE* st_tp_node;\n st_tp_node = (ST_NODE*)malloc(sizeof(ST_NODE));\n st_tp_node->st_parent = (ST_NODE*)NULL;\n st_tp_node->st_left = (ST_NODE*)NULL;\n st_tp_node->st_right = (ST_NODE*)NULL;\n st_tp_node->s4_key = s4_a_key;\n\n return (st_tp_node);\n}", "test_IO": [ { "input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n", "output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n" } ] }, { "id": "s860117222", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n long long int a, b, c;\n scanf(\"%lld %lld %lld\", &a, &b, &c);\n\n long long int d = c - a - b;\n if ((d > 0) && ((4 * a * b) < d * d))\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "2 3 9\n", "output": "No\n" } ] }, { "id": "s414827596", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int a, b, c, d, e, f;\n double x, y;\n while (scanf(\"%d %d %d %d %d %d\", &a, &b, &c, &d, &e, &f) != -1) {\n y = (double)(c * d - f * a) / (b * d - e * a);\n x = (double)(c * e - f * b) / (a * e - d * b);\n if (y <= 0 && y > -0.0005) y = 0;\n if (x <= 0 && x > -0.0005) x = 0;\n printf(\"%.3f %.3f\\n\", x, y);\n }\n return 0;\n}", "test_IO": [ { "input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n", "output": "-1.000 2.000\n1.000 4.000\n" } ] }, { "id": "s814977152", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint miyukiti(const void* asumisu, const void* mizuhasu) {\n int isihasu = *(const int*)asumisu, matukisu = *(const int*)mizuhasu;\n return isihasu < matukisu ? -1 : isihasu > matukisu;\n}\n\nint N;\nint A[114514];\n\nint yukinnko;\nint tomatu[114514];\n\nint mikakosi[114514];\n\nint sumipe(int hayaminn) {\n int satorina = 0, zaasan = yukinnko - 1;\n while (satorina <= zaasan) {\n int yukati = satorina + (zaasan - satorina) / 2;\n if (tomatu[yukati] == hayaminn)\n return yukati;\n else if (tomatu[yukati] < hayaminn)\n satorina = yukati + 1;\n else\n zaasan = yukati - 1;\n }\n return 114513;\n}\n\nint main(void) {\n int inorinn;\n int emirinn = 0;\n if (scanf(\"%d\", &N) != 1) return 1;\n for (inorinn = 0; inorinn < N; inorinn++) {\n if (scanf(\"%d\", &A[inorinn]) != 1) return 1;\n tomatu[inorinn] = A[inorinn];\n }\n qsort(tomatu, N, sizeof(*tomatu), miyukiti);\n yukinnko = 1;\n for (inorinn = 1; inorinn < N; inorinn++) {\n if (tomatu[inorinn] != tomatu[yukinnko - 1]) {\n tomatu[yukinnko++] = tomatu[inorinn];\n }\n }\n for (inorinn = 0; inorinn < N; inorinn++) {\n int kugyu = sumipe(A[inorinn]);\n mikakosi[kugyu] = !mikakosi[kugyu];\n }\n for (inorinn = 0; inorinn < yukinnko; inorinn++) {\n if (mikakosi[inorinn]) emirinn++;\n }\n printf(\"%d\\n\", emirinn);\n return 0;\n}", "test_IO": [ { "input": "3\n6\n2\n6\n", "output": "1\n" } ] }, { "id": "s344526598", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int i, j, x[10000];\n\n for (i = 0; i < 10000; i++) {\n x[i] = 0;\n }\n i = 0;\n scanf(\"%d\", &x[i]);\n\n while (x[i] != 0) {\n i++;\n scanf(\"%d\", &x[i]);\n }\n\n for (j = 0; j < i; j++) {\n printf(\"Case %d: %d\\n\", j + 1, x[j]);\n }\n\n return 0;\n}", "test_IO": [ { "input": "3\n5\n11\n7\n8\n19\n0\n", "output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n" } ] }, { "id": "s997849905", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nstruct node {\n int key;\n struct node *next;\n struct node *prev;\n};\n\ntypedef struct node *NodePointer;\nNodePointer N;\n\nvoid init() {\n N = malloc(sizeof(struct node));\n N->next = N;\n N->prev = N;\n}\n\nvoid printList() {\n NodePointer cur = N->next;\n int snl = 1;\n while (cur != N) {\n if (snl == 0) printf(\" \");\n printf(\"%d\", cur->key);\n cur = cur->next;\n snl = 0;\n }\n printf(\"\\n\");\n}\n\nvoid deleteFirst() {\n NodePointer t = N->next;\n N->next = t->next;\n t->next->prev = N;\n}\n\nvoid deleteLast() {\n NodePointer delnode = N->prev;\n\n N->prev = delnode->prev;\n delnode->prev->next = N;\n free(delnode);\n}\n\nvoid delete(int skey) {\n int judge = 0;\n NodePointer t;\n NodePointer n;\n\n for (n = N->next; n != N; n = n->next) {\n if (n->key == skey) {\n judge = 1;\n }\n }\n\n if (judge == 1) {\n n = N->next;\n while (n != N) {\n if (n->key == skey) break;\n n = n->next;\n }\n t = n->prev;\n t->next = n->next;\n t->next->prev = t;\n free(n);\n }\n}\n\nvoid insert(int skey) {\n NodePointer new;\n static int count = 0;\n new = malloc(sizeof(struct node));\n new->key = skey;\n\n if (count == 0) {\n new->next = N;\n N->next = new;\n new->prev = N;\n N->prev = new;\n count++;\n }\n\n else {\n new->next = N->next;\n N->next->prev = new;\n N->next = new;\n new->prev = N;\n count++;\n }\n}\n\nint main() {\n int key, n, i;\n char com[12];\n\n scanf(\"%d\", &n);\n init();\n for (i = 0; i < n; i++) {\n scanf(\"%s\", com);\n if (strcmp(com, \"insert\") == 0) {\n scanf(\"%d\", &key);\n insert(key);\n } else if (strcmp(com, \"deleteFirst\") == 0)\n deleteFirst();\n else if (strcmp(com, \"deleteLast\") == 0)\n deleteLast();\n else {\n scanf(\"%d\", &key);\n delete (key);\n }\n }\n printList();\n return 0;\n}", "test_IO": [ { "input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n", "output": "6 1 2\n" } ] }, { "id": "s502470583", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c, d;\n scanf(\"%d %d\", &a, &b);\n c = a * b;\n d = 2 * a + 2 * b;\n printf(\"%d %d\\n\", c, d);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s962042834", "dataset": "codenet", "language": "C", "code": "#include \n\nvoid kansu(int, int);\n\nint main(void) {\n int a, b;\n\n scanf(\"%d %d\", &a, &b);\n while (a != 0 && b != 0) {\n kansu(a, b);\n scanf(\"%d %d\", &a, &b);\n }\n return 0;\n}\nvoid kansu(int a, int b) {\n int i, j, x, y, n;\n int suu[17][17];\n int kouji[17][17];\n\n scanf(\"%d\", &n);\n for (i = 1; i <= a; i++) {\n for (j = 1; j <= b; j++) {\n kouji[i][j] = 0;\n }\n }\n for (i = 0; i < n; i++) {\n scanf(\"%d %d\", &x, &y);\n kouji[x][y] = 1;\n }\n for (i = 1; i <= a; i++) {\n for (j = 1; j <= b; j++) {\n if (kouji[i][j] == 1) {\n suu[i][j] = 0;\n } else {\n if (i == 1 && j == 1) {\n suu[i][j] = 1;\n } else {\n if (i == 1) {\n suu[i][j] = suu[i][j - 1];\n } else if (j == 1) {\n suu[i][j] = suu[i - 1][j];\n } else {\n suu[i][j] = suu[i][j - 1] + suu[i - 1][j];\n }\n }\n }\n }\n }\n printf(\"%d\\n\", suu[a][b]);\n}", "test_IO": [ { "input": "5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n", "output": "5\n5\n" } ] }, { "id": "s933220798", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n double a;\n double ave = 0;\n int i;\n\n for (i = 0; i < 5; i++) {\n scanf(\"%lf\", &a);\n if (a <= 40) {\n ave += 40;\n } else {\n ave += a;\n }\n }\n\n ave /= 5.0;\n\n printf(\"%.0f\\n\", ave);\n\n return (0);\n}", "test_IO": [ { "input": "10\n65\n100\n30\n95\n", "output": "68\n" } ] }, { "id": "s608809394", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int n, i, j, m, s, t;\n scanf(\"%d\", &n);\n int a[n];\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n t = 0;\n for (i = 0; i < n; i++) {\n s = 0;\n for (j = 1; j < n; j++) {\n if (j <= i) {\n continue;\n }\n m = a[i] * a[j];\n s = s + m;\n }\n t = t + s;\n }\n printf(\"%d\\n\", t);\n return 0;\n}", "test_IO": [ { "input": "3\n3 1 2\n", "output": "11\n" } ] }, { "id": "s001352307", "dataset": "codenet", "language": "C", "code": "#include \n\nint W, N;\nint input[1024][2];\n\nint main() {\n int i, j;\n int ans[1024][2];\n int t;\n\n for (t = 0;; t++) {\n for (i = 0; i < 1024; i++) {\n ans[i][0] = 0;\n ans[i][1] = 0;\n input[i][0] = 0;\n input[i][1] = 0;\n }\n\n scanf(\"%d%d\", &W, &N);\n if (W == 0) break;\n for (i = 0; i < N; i++) scanf(\"%d,%d\", &input[i][0], &input[i][1]);\n\n for (i = 0; i < N; i++) {\n for (j = 1023; j >= input[i][1]; j--) {\n if (ans[j][0] < input[i][0] + ans[j - input[i][1]][0]) {\n ans[j][0] = input[i][0] + ans[j - input[i][1]][0];\n ans[j][1] = input[i][1] + ans[j - input[i][1]][1];\n }\n }\n }\n\n for (j = 0; ans[W][0] == ans[W - j - 1][0]; j++)\n ;\n\n printf(\"Case %d:\\n%d\\n%d\\n\", t + 1, ans[W - j][0], ans[W - j][1]);\n }\n\n return 0;\n}", "test_IO": [ { "input": "50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n", "output": "Case 1:\n220\n49\nCase 2:\n220\n49\n" } ] }, { "id": "s105543399", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n long long n, a, m, M, c, b, i;\n c = 0;\n m = 100000000;\n M = -100000000;\n scanf(\"%lld\", &n);\n\n for (i = 1; i <= n; i++) {\n scanf(\"%lld\", &a);\n if (a > M) {\n M = a;\n }\n if (a < m) {\n m = a;\n }\n c = c + a;\n }\n printf(\"%lld %lld %lld\\n\", m, M, c);\n\n return 0;\n}", "test_IO": [ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ] }, { "id": "s123216992", "dataset": "codenet", "language": "C", "code": "#include \nvoid swap(int *a, int *b) {\n int tmp;\n tmp = *a;\n *a = *b;\n *b = tmp;\n}\nint main() {\n int a, b;\n while (1) {\n scanf(\"%d %d\", &a, &b);\n if (a == 0 && b == 0) break;\n if (b < a) swap(&a, &b);\n printf(\"%d %d\\n\", a, b);\n }\n return 0;\n}", "test_IO": [ { "input": "3 2\n2 2\n5 3\n0 0\n", "output": "2 3\n2 2\n3 5\n" } ] }, { "id": "s264203612", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n double r;\n double s, l;\n double p = 3.141592653589;\n scanf(\"%lf\", &r);\n\n s = r * r * p;\n l = 2 * p * r;\n\n printf(\"%f %f\\n\", s, l);\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "12.566371 12.566371\n" } ] }, { "id": "s375567191", "dataset": "codenet", "language": "C", "code": "#include \n#define MAX 101\n#define WHITE 0\n#define BLACK 2\n#define GRAY 1\nint time, n, g[MAX][MAX] = {0};\nint d[MAX], f[MAX], color[MAX] = {WHITE};\n\nvoid visit(int u) {\n int i;\n\n color[u] = GRAY;\n d[u] = ++time;\n\n for (i = 0; i < n; i++) {\n if (g[u][i] == 0) continue;\n if (color[i] == WHITE) visit(i);\n }\n\n color[u] = BLACK;\n f[u] = ++time;\n}\n\nvoid dfs(void) {\n int i;\n time = 0;\n\n for (i = 0; i < n; i++)\n if (color[i] == WHITE) visit(i);\n\n for (i = 0; i < n; i++) printf(\"%d %d %d\\n\", i + 1, d[i], f[i]);\n}\n\nint main() {\n int i, j, x, y, z;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d %d\", &x, &y);\n for (j = 0; j < y; j++) {\n scanf(\"%d\", &z);\n g[x - 1][z - 1] = 1;\n }\n }\n\n dfs();\n return 0;\n}", "test_IO": [ { "input": "4\n1 1 2\n2 1 4\n3 0\n4 1 3\n", "output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n" } ] }, { "id": "s764865959", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int x;\n scanf(\"%d\", &x);\n x = x * x * x;\n printf(\"%d\\n\", x);\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s722111534", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int hcell, wcell, hpaint, wpaint, nblack, nwhite;\n\n scanf(\"%d %d\", &hcell, &wcell);\n scanf(\"%d %d\", &hpaint, &wpaint);\n nblack = (wcell * hpaint) + (hcell * wpaint) - (hpaint * wpaint);\n nwhite = (hcell * wcell) - nblack;\n printf(\"%d\\n\", nwhite);\n return 0;\n}", "test_IO": [ { "input": "3 2\n2 1\n", "output": "1\n" } ] }, { "id": "s628392045", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nint main() {\n int n, i;\n int h[100001];\n int max = -1;\n int flag = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &h[i]);\n if (max < h[i]) max = h[i];\n\n if (max - h[i] >= 2) flag = 1;\n }\n\n if (flag == 1)\n printf(\"No\\n\");\n\n else\n printf(\"Yes\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 1 1 3\n", "output": "Yes\n" } ] }, { "id": "s784438440", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n printf(\"%d\\n\", ((b - 1) + (a - 2)) / (a - 1));\n return 0;\n}", "test_IO": [ { "input": "4 10\n", "output": "3\n" } ] }, { "id": "s423495369", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int A, B, C;\n\n scanf(\"%d %d %d\", &A, &B, &C);\n\n if (A < C && C < B) {\n printf(\"Yes\\n\");\n } else if (A > C && C > B) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n}", "test_IO": [ { "input": "3 8 5\n", "output": "Yes\n" } ] }, { "id": "s764427553", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n const int MAX_V = 999999;\n int prime[MAX_V + 1];\n int i, k, n;\n for (i = 2; i <= MAX_V; i++) {\n prime[i] = 1;\n }\n for (i = 2; i * i <= MAX_V; i++) {\n if (prime[i]) {\n for (k = 2 * i; k <= MAX_V; k += i) {\n prime[k] = 0;\n }\n }\n }\n prime[0] = 0;\n prime[1] = 0;\n int count = 0;\n while (scanf(\"%d\", &n) != EOF) {\n count++;\n int cnt = 0;\n for (i = n; i > 0; i--) {\n if (prime[i] == 1) {\n cnt++;\n }\n }\n printf(\"%d\\n\", cnt);\n if (count == 30) break;\n }\n return 0;\n}", "test_IO": [ { "input": "10\n3\n11\n", "output": "4\n2\n5\n" } ] }, { "id": "s639919182", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int v[10];\n int sum = 0;\n int i;\n\n for (i = 0; i < 10; i++) scanf(\"%d\", &v[i]);\n\n for (i = 0; i < 10; i++) sum += v[i];\n\n printf(\"%d\\n\", sum);\n\n return 0;\n}", "test_IO": [ { "input": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "output": "55\n" } ] }, { "id": "s619964871", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define unko 1e12\nlong int sort(long int *a, int left, int middle, int right) {\n long int l_arr[middle - left + 1], r_arr[right - middle + 1];\n long int cnt = 0;\n for (int i = 0; i < middle - left; i++) l_arr[i] = a[i + left];\n for (int i = 0; i < right - middle; i++) r_arr[i] = a[i + middle];\n l_arr[middle - left] = unko;\n r_arr[right - middle] = unko;\n int l = 0, r = 0;\n for (int i = 0; i < right - left; i++) {\n if (l_arr[l] <= r_arr[r]) {\n a[left + i] = l_arr[l++];\n } else {\n a[left + i] = r_arr[r++];\n cnt += middle - left - l;\n }\n }\n return cnt;\n}\nlong int merge(long int *a, int left, int right) {\n if (left + 1 < right) {\n int middle = (left + right) / 2;\n long int x1 = merge(a, left, middle);\n long int x2 = merge(a, middle, right);\n long int x3 = sort(a, left, middle, right);\n return x1 + x2 + x3;\n } else {\n return 0;\n }\n}\n\nint main(void) {\n int n;\n scanf(\"%d\", &n);\n long int *a = malloc(n * sizeof(long int));\n for (int i = 0; i < n; i++) scanf(\"%ld\", a + i);\n printf(\"%ld\\n\", merge(a, 0, n));\n free(a);\n return 0;\n}", "test_IO": [ { "input": "5\n3 5 2 1 4\n", "output": "6\n" } ] }, { "id": "s797932052", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b;\n scanf(\"%d\", &a);\n scanf(\"%d\", &b);\n if ((a * b) % 2 == 0) {\n printf(\"Even\\n\");\n } else {\n printf(\"Odd\\n\");\n }\n return 0;\n}", "test_IO": [ { "input": "3 4\n", "output": "Even\n" } ] }, { "id": "s606068991", "dataset": "codenet", "language": "C", "code": "#include \n\nvoid white(int n, int A[]) {\n int i;\n for (i = 0; i < n - 1; i++) {\n printf(\"%d \", A[i]);\n }\n printf(\"%d\\n\", A[i]);\n}\n\nvoid insertionsort(int n, int A[]) {\n int i, j, a;\n for (i = 0; i < n; i++) {\n for (j = 0; j < i; j++) {\n if (A[i] < A[j]) {\n a = A[i];\n A[i] = A[j];\n A[j] = a;\n }\n }\n white(n, A);\n }\n}\n\nint main() {\n int i, n, A[100];\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &A[i]);\n }\n insertionsort(n, A);\n\n return 0;\n}", "test_IO": [ { "input": "6\n5 2 4 6 1 3\n", "output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n" } ] }, { "id": "s327468529", "dataset": "codenet", "language": "C", "code": "#if 0\ncat <mistaken-paste\n#endif\n\n#pragma GCC diagnostic ignored \"-Wincompatible-pointer-types\"\n#define _USE_MATH_DEFINES\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define BIG 2000000007\n#define VERYBIG 20000000000000007LL\n\n#define MOD 1000000007\n#define FOD 998244353\ntypedef uint64_t ull;\ntypedef int64_t sll;\n\n#define N_MAX 1048576\n\n#ifdef __cplusplus\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing std::get;\nusing std::greater;\nusing std::map;\nusing std::pair;\nusing std::priority_queue;\nusing std::queue;\nusing std::set;\nusing std::stack;\nusing std::string;\nusing std::tuple;\nusing std::vector;\n\ntemplate \npair operator+(pair l, pair r) {\n return pair(l.first + r.first, l.second + r.second);\n}\n\n#endif\n\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338327950\n#endif\n\ntypedef struct {\n sll a;\n sll b;\n} hwll;\n\ntypedef struct {\n sll a;\n sll b;\n sll c;\n} hwllc;\n\ntypedef struct {\n hwll a;\n hwll b;\n} linell;\n\ntypedef struct {\n double a;\n double b;\n} hwreal;\n\nsll n, m;\nsll h, w;\nsll k;\nsll q;\nsll va, vb, vc, vd, ve, vf;\null ua, ub, uc, ud, ue, uf;\nlong double vra, vrb, vrc;\ndouble vda, vdb, vdc;\nchar ch, dh;\n\null umin(ull x, ull y) { return (x < y) ? x : y; }\n\null umax(ull x, ull y) { return (x > y) ? x : y; }\n\nsll smin(sll x, sll y) { return (x < y) ? x : y; }\n\nsll smax(sll x, sll y) { return (x > y) ? x : y; }\n\null gcd(ull x, ull y) {\n if (y == 0) {\n return x;\n } else {\n return gcd(y, x % y);\n }\n}\n\null bitpow(ull a, ull x, ull modulo) {\n ull result = 1;\n while (x) {\n if (x & 1) {\n result *= a;\n result %= modulo;\n }\n x /= 2;\n a = (a * a) % modulo;\n }\n return result;\n}\n\null divide(ull a, ull b, ull modulo) {\n return (a * bitpow(b, modulo - 2, modulo)) % modulo;\n}\n\null udiff(ull a, ull b) {\n if (a >= b) {\n return a - b;\n } else {\n return b - a;\n }\n}\n\nsll sdiff(sll a, sll b) {\n if (a >= b) {\n return a - b;\n } else {\n return b - a;\n }\n}\n\nint bitcount(ull n) {\n int result = 0;\n while (n) {\n if (n & 1) result++;\n n /= 2;\n }\n return result;\n}\n\n#define BEGCMP(NAME) int32_t NAME(const void *left, const void *right)\n#define DEFLR(TYPE) TYPE l = *(TYPE *)left, r = *(TYPE *)right\n#define CMPRET(L, R) \\\n if ((L) < (R)) return -1; \\\n if ((L) > (R)) return +1\n\nBEGCMP(pullcomp) {\n DEFLR(ull);\n CMPRET(l, r);\n return 0;\n}\nBEGCMP(prevcomp) {\n DEFLR(sll);\n CMPRET(r, l);\n return 0;\n}\nBEGCMP(psllcomp) {\n DEFLR(sll);\n CMPRET(l, r);\n return 0;\n}\nBEGCMP(pcharcomp) {\n DEFLR(char);\n CMPRET(l, r);\n return 0;\n}\nBEGCMP(pdoublecomp) {\n DEFLR(double);\n CMPRET(l, r);\n return 0;\n}\n\nint32_t pstrcomp(const void *left, const void *right) {\n char *l = *(char **)left;\n char *r = *(char **)right;\n\n return strcmp(l, r);\n}\n\nBEGCMP(phwllABcomp) {\n DEFLR(hwll);\n CMPRET(l.a, r.a);\n CMPRET(l.b, r.b);\n return 0;\n}\nBEGCMP(phwllREVcomp) {\n DEFLR(hwll);\n CMPRET(l.b, r.b);\n CMPRET(l.a, r.a);\n return 0;\n}\nBEGCMP(ptriplecomp) {\n DEFLR(hwllc);\n CMPRET(l.a, r.a);\n CMPRET(l.b, r.b);\n CMPRET(l.c, r.c);\n return 0;\n}\nBEGCMP(ptripleREVcomp) {\n DEFLR(hwllc);\n CMPRET(l.b, r.b);\n CMPRET(l.a, r.a);\n CMPRET(l.c, r.c);\n return 0;\n}\nBEGCMP(ptripleCABcomp) {\n DEFLR(hwllc);\n CMPRET(l.c, r.c);\n CMPRET(l.a, r.a);\n CMPRET(l.b, r.b);\n return 0;\n}\nBEGCMP(phwrealcomp) {\n DEFLR(hwreal);\n CMPRET(l.a, r.a);\n CMPRET(l.b, r.b);\n return 0;\n}\n\nint32_t pquadcomp(const void *left, const void *right) {\n linell l = *(linell *)left;\n linell r = *(linell *)right;\n\n sll ac = phwllABcomp(&(l.a), &(r.a));\n if (ac) return ac;\n sll bc = phwllABcomp(&(l.b), &(r.b));\n if (bc) return bc;\n\n return 0;\n}\nint32_t pfracomp(const void *left, const void *right) {\n hwllc l = *(hwllc *)left;\n hwllc r = *(hwllc *)right;\n\n CMPRET(l.a * r.b, l.b * r.a);\n return 0;\n}\nbool isinrange(sll left, sll x, sll right) { return (left <= x && x <= right); }\n\nbool isinrange_soft(sll left, sll x, sll right) {\n return (left <= x && x <= right) || (left >= x && x >= right);\n}\n\nvoid sw(sll *l, sll *r) {\n if (*l == *r) return;\n sll t = *l;\n *l = *r;\n *r = t;\n}\n\null frac[N_MAX * 3], invf[N_MAX * 3];\null ncr(sll n, sll r, ull m) {\n if (n < 0 || r < 0 || n < r) return 0;\n return frac[n] * (invf[r] * invf[n - r] % m) % m;\n}\n\nsll a[N_MAX + 5];\n\nsll b[N_MAX + 5];\n\nsll c[N_MAX + 5];\nsll d[N_MAX + 5];\nsll e[N_MAX * 4];\nchar s[N_MAX + 1];\n\nchar t[N_MAX + 1];\n\nchar u[N_MAX + 1];\nhwll xy[N_MAX + 5];\nhwllc tup[N_MAX + 5];\nsll table[3005][3005];\null gin[N_MAX];\n\nsll cnt[3], pcnt;\null x[3005][3005];\n\null solve() {\n sll i, j, ki, li;\n\n sll result = 0;\n double dresult = 0;\n\n sll maybe = 0;\n\n sll sum = 0;\n sll item;\n sll *dpcell;\n\n result = 1;\n for (i = 0; i < n * 3; i++) {\n ull v;\n switch (s[i]) {\n case 'R':\n v = 0;\n break;\n case 'G':\n v = 1;\n break;\n case 'B':\n v = 2;\n break;\n }\n\n if (cnt[(v + 1) % 3] && cnt[(v + 2) % 3]) {\n result *= pcnt;\n pcnt--;\n result %= FOD;\n cnt[(v + 1) % 3]--;\n cnt[(v + 2) % 3]--;\n } else {\n if ((cnt[(v + 1) % 3] + cnt[(v + 2) % 3]) > cnt[v]) {\n result *= (cnt[(v + 1) % 3] + cnt[(v + 2) % 3]) - cnt[v];\n result %= FOD;\n pcnt++;\n }\n\n cnt[v]++;\n }\n }\n\n for (i = 1; i <= n; i++) {\n result = (result * i) % FOD;\n }\n\n printf(\"%lld\\n\", result);\n\n return 0;\n\nsuccess:\n\n puts(\"Yes\");\n\n return 0;\n\nfail:\n\n puts(\"-1\");\n\n return 1;\n}\n\nint32_t main(int argc, char *argv[]) {\n int32_t i, j;\n\n n = 4;\n m = 0;\n\n scanf(\"%llu\", &n, &m);\n\n scanf(\"%s\", s);\n\n for (i = 0; i < 0; i++) {\n scanf(\"%lld\", &a[i]);\n }\n\n solve();\n\n return 0;\n}", "test_IO": [ { "input": "3\nRRRGGGBBB\n", "output": "216\n" } ] }, { "id": "s701648392", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c;\n scanf(\"%d%d%d\", &a, &b, &c);\n if (a < b && b < c) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n return 0;\n}", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s343830814", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main(int argc, char *argv[]) {\n char buf[512];\n int len;\n fgets(buf, sizeof(buf), stdin);\n len = strlen(buf);\n printf(\"%c%d%c\\n\", buf[0], len - 3, buf[len - 2]);\n return 0;\n}", "test_IO": [ { "input": "internationalization\n", "output": "i18n\n" } ] }, { "id": "s858832157", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int i = 1, Input;\n while (1) {\n scanf(\"%d\", &Input);\n if (Input == 0) {\n break;\n }\n printf(\"Case %d: %d\\n\", i, Input);\n i++;\n }\n return 0;\n}", "test_IO": [ { "input": "3\n5\n11\n7\n8\n19\n0\n", "output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n" } ] }, { "id": "s735953430", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\nint main() {\n int i_min, min;\n int i, j, k;\n int X, N;\n scanf(\"%d %d\", &X, &N);\n if (N == 0) {\n printf(\"%d\\n\", X);\n exit(0);\n }\n\n int plus[256];\n int minus[256];\n for (i = 0; i < 256; i++) {\n plus[i] = i;\n minus[i] = (-1 * i);\n }\n for (i = 0; i < N; i++) {\n scanf(\"%d\", &j);\n plus[j] = 0;\n }\n\n i_min = 0;\n min = 1000;\n for (i = 255; i >= 0; i--) {\n if (plus[i] == 0 && i > 0) {\n continue;\n }\n k = X - plus[i];\n if (k < 0) {\n k *= -1;\n }\n if (k <= min) {\n min = k;\n i_min = i;\n }\n }\n\n printf(\"%d\\n\", i_min);\n\n return 0;\n}", "test_IO": [ { "input": "6 5\n4 7 10 6 5\n", "output": "8\n" } ] }, { "id": "s435885409", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint calc_score() {\n int out = 0;\n char str[100];\n int score = 0;\n int base = 0;\n\n while (out < 3) {\n scanf(\"%s\", str);\n if (strcmp(str, \"OUT\") == 0) {\n out++;\n } else if (strcmp(str, \"HIT\") == 0) {\n if (base == 3) {\n score++;\n } else {\n base++;\n }\n } else if (strcmp(str, \"HOMERUN\") == 0) {\n score += (base + 1);\n base = 0;\n }\n }\n\n return score;\n}\n\nint main(void) {\n int n;\n int inning = 0;\n\n scanf(\"%d\", &n);\n\n while (inning < n) {\n printf(\"%d\\n\", calc_score());\n inning++;\n }\n\n return 0;\n}", "test_IO": [ { "input": "2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n", "output": "7\n0\n" } ] }, { "id": "s325320702", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\ntypedef long double ld;\n#define rep(i, l, r) for (ll i = (l); i < (r); i++)\n#define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k))\n#define rrep(i, l, r) for (ll i = (l); i >= (r); i--)\n#define INF (1LL << 60)\n#define MOD1 1000000007\n#define MOD2 998244353\n#define MAX_N (1 << 20)\n#define YES printf(\"Yes\\n\")\n#define NO printf(\"No\\n\")\n#define PN printf(\"\\n\")\n#define charsize 100005\n#define PI 3.141592653589793238\n\nvoid swap(ll *a, ll *b) {\n ll c;\n c = *b;\n *b = *a;\n *a = c;\n}\nvoid cin(ll *n) { scanf(\"%lld\", &(*n)); }\nll max2(ll a, ll b) { return a >= b ? a : b; }\nll min2(ll a, ll b) { return a >= b ? b : a; }\nll min3(ll a, ll b, ll c) { return (a <= b && a <= c) ? a : b <= c ? b : c; }\nll max3(ll a, ll b, ll c) { return (a >= b && a >= c) ? a : b >= c ? b : c; }\nll minn(ll n, ll a[]) {\n ll b = INF;\n rep(i, 0, n) b = min2(b, a[i]);\n return b;\n}\nll maxn(ll n, ll a[]) {\n ll b = -INF;\n rep(i, 0, n) b = max2(b, a[i]);\n return b;\n}\nll POW(ll a, ll b) {\n ll c = 1;\n rep(i, 0, b) c *= a;\n return c;\n}\ndouble POW_d(double a, double b) {\n double c = 1;\n rep(i, 0, b) c *= a;\n return c;\n}\nll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }\nll lcm(ll a, ll b) { return a / gcd(a, b) * b; }\nll mod_MOD1(ll n) {\n n += n < 0 ? ((-n) / MOD1 + 1) * MOD1 : 0;\n return n %= MOD1;\n}\nll mod_p(ll n, ll p) {\n n += n < 0 ? ((-n) / p + 1) * p : 0;\n return n %= p;\n}\nll change_into_num(char s[], ll len, ll p) {\n return !p ? 0\n : POW(10, p - 1) * (s[len - p] - '0') +\n change_into_num(s, len, p - 1);\n}\nll digits(ll a, ll b) { return a / b ? 1 + digits(a / b, b) : 1; }\nll base(ll n, ll a, ll i) { return i == 1 ? n % a : base(n / a, a, i - 1); }\nll is_inArr1(ll x, ll n) { return (x < 0 || x >= n) ? 0 : 1; }\nll is_inArr2(ll y, ll x, ll h, ll w) {\n return (y < 0 || y >= h || x < 0 || x >= w) ? 0 : 1;\n}\n\nvoid lr_lower(int *l, int *r, ll am, ll val, int type) {\n (type < 3) ? (am < val ? (*l = (*l + *r) / 2) : (*r = (*l + *r) / 2))\n : (am <= val ? (*l = (*l + *r) / 2) : (*r = (*l + *r) / 2));\n}\nvoid lr_upper(int *l, int *r, ll am, ll val, int type) {\n (type < 3) ? (am <= val ? (*l = (*l + *r) / 2) : (*r = (*l + *r) / 2))\n : (am < val ? (*l = (*l + *r) / 2) : (*r = (*l + *r) / 2));\n}\nint cmp_lower(ll a, ll b, int type) {\n return (type == 1) ? (a == b ? 1 : 0)\n : (type == 2) ? (a >= b ? 1 : 0)\n : (a > b ? 1 : 0);\n}\nint cmp_upper(ll a, ll b, int type) {\n return (type == 1) ? (a == b ? 1 : 0)\n : (type == 2) ? (a <= b ? 1 : 0)\n : (a < b ? 1 : 0);\n}\n\nll lower_bound(ll a[], int l, int r, ll val, int type) {\n while (r - l > 1) lr_lower(&l, &r, a[(l + r) / 2], val, type);\n return cmp_lower(a[l], val, type) ? l : cmp_lower(a[r], val, type) ? r : -1;\n}\n\nll upper_bound(ll a[], int l, int r, ll val, int type) {\n while (r - l > 1) lr_upper(&l, &r, a[(l + r) / 2], val, type);\n return cmp_upper(a[r], val, type) ? r : cmp_upper(a[l], val, type) ? l : -1;\n}\n\nll count(ll a[], int l, int r, ll x) {\n int p = lower_bound(a, l, r, x, 1);\n return p == -1 ? 0 : upper_bound(a, p, r, x, 1) - p + 1;\n}\n\nll *factors[2], fac_cnt = 0, is_factor_prepared = 0;\nll factor_pre() {\n rep(i, 0, 1) {\n if (is_factor_prepared++) return 0;\n }\n ll tmp = (1e6) / 2 + 1, fac_tmp[tmp];\n rep(i, 0, tmp) { fac_tmp[i] = i ? 2 * i + 1 : 2; }\n rep(i, 1, tmp) {\n if (fac_tmp[i]) {\n repp(j, 3, tmp / (2 * i + 1) + 1, 2) {\n if (j * (2 * i + 1) < tmp)\n fac_tmp[(j * (2 * i + 1) - 1) / 2] = 0;\n }\n } else\n continue;\n }\n rep(i, 0, tmp) {\n if (fac_tmp[i]) {\n rep(j, 0, 2) {\n factors[j] = realloc(factors[j], sizeof(ll) * (fac_cnt + 1));\n factors[j][j ? fac_cnt++ : fac_cnt] = j ? 0 : fac_tmp[i];\n }\n }\n }\n return 0;\n}\nll factor(ll n, ll new_common_plus) {\n factor_pre();\n rep(i, 0, fac_cnt) {\n ll cnt = 0;\n rep(j, 0, 1) {\n while ((cnt += n % factors[0][i] == 0 ? 1 : 0) &&\n (n /= factors[0][i]) % factors[0][i] == 0)\n continue;\n }\n factors[1][i] = new_common_plus == 1 ? cnt\n : new_common_plus == 2 ? max2(factors[1][i], cnt)\n : factors[1][i] + cnt;\n if (factors[0][i] > n) break;\n }\n return n;\n}\nll judge_prime(ll n) {\n factor_pre();\n rep(i, 0, fac_cnt) {\n if (n < factors[0][i] * factors[0][i] || n == factors[0][i])\n break;\n else if (n % factors[0][i] == 0)\n n /= n;\n }\n return n == 1 ? 0 : 1;\n}\n\nll *mf_arr, *inv_arr, *finv_arr, is_minv_made = 0, is_mf_made = 0,\n num_of_inv = 2 * 1e6 + 10;\nll makeinv(ll n, ll mod) {\n rep(i, 0, 1) {\n if (is_minv_made++) return 0;\n }\n inv_arr = realloc(inv_arr, sizeof(ll) * 2);\n finv_arr = realloc(finv_arr, sizeof(ll) * 2);\n inv_arr[1] = 1;\n finv_arr[0] = finv_arr[1] = 1;\n rep(i, 2, n + 1) {\n inv_arr = realloc(inv_arr, sizeof(ll) * (i + 1));\n finv_arr = realloc(finv_arr, sizeof(ll) * (i + 1));\n inv_arr[i] = mod - inv_arr[mod % i] * (mod / i) % mod;\n finv_arr[i] = finv_arr[i - 1] * inv_arr[i] % mod;\n }\n return 0;\n}\nll make_mf(ll n, ll mod) {\n rep(i, 0, 1) {\n if (is_mf_made++) return 0;\n }\n mf_arr = realloc(mf_arr, sizeof(ll) * 2);\n ll x = 1;\n mf_arr[0] = mf_arr[1] = x;\n rep(i, 2, n + 1) {\n x = x * i % mod;\n mf_arr = realloc(mf_arr, sizeof(ll) * (i + 1));\n mf_arr[i] = x;\n }\n return 0;\n}\nll m_inv(ll x, ll mod, ll is_fac) {\n makeinv(num_of_inv, mod);\n return is_fac ? finv_arr[x] : inv_arr[x];\n}\nll m_f(ll x, ll mod) {\n make_mf(num_of_inv, mod);\n return mf_arr[x];\n}\nll mod_nck(ll n, ll k, ll mod) {\n return m_f(n, mod) * m_inv(k, mod, 1) % mod * m_inv(n - k, mod, 1) % mod;\n}\nll m_p(ll r, ll n, ll mod) {\n ll t = 1, s = r;\n while (n > 0) {\n t = (n & 1) ? t * s % mod : t;\n s = s * s % mod;\n n >>= 1;\n }\n return r ? t : 0;\n}\nll m_mul2(ll a, ll b, ll mod) { return a * b % mod; }\nll m_mul3(ll a, ll b, ll c, ll mod) { return m_mul2(a * b % mod, c, mod); }\nll m_mul4(ll a, ll b, ll c, ll d, ll mod) {\n return m_mul3(a * b % mod, c, d, mod);\n}\nll m_mul5(ll a, ll b, ll c, ll d, ll e, ll mod) {\n return m_mul4(a * b % mod, c, d, e, mod);\n}\n\nint upll(const void *a, const void *b) {\n return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0;\n}\nint downll(const void *a, const void *b) {\n return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0;\n}\nint cmp_string(const void *a, const void *b) {\n return strcmp((char *)a, (char *)b);\n}\nint cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }\nvoid sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }\nvoid sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }\nvoid sort_string(int n, int size, char s[][size]) {\n qsort((void *)s, n, sizeof(s[0]), cmp_string);\n}\nvoid sort_char(char *s) { qsort((void *)s, strlen(s), sizeof(char), cmp_char); }\nll unique_string(ll n, ll size, char s[][size]) {\n ll ans = 1;\n rep(i, 1, n) if (strcmp(s[i], s[i - 1])) ans++;\n return ans;\n}\nll unique_num(ll n, ll a[]) {\n ll ans = 1;\n rep(i, 1, n) if (a[i] != a[i - 1]) ans++;\n return ans;\n}\n\ntypedef struct {\n ll a, b;\n} fr;\nint cmp1(const void *p, const void *q) { return ((fr *)p)->a - ((fr *)q)->a; }\nint cmp2(const void *p, const void *q) { return ((fr *)q)->a - ((fr *)p)->a; }\nvoid strsortup(fr *a, int n) { qsort(a, n, sizeof(fr), cmp1); }\nvoid strsortdown(fr *a, int n) { qsort(a, n, sizeof(fr), cmp2); }\n\nchar s[1151154];\nint main(void) {\n ll l, r, d;\n ll ans = 0;\n cin(&l);\n cin(&r);\n cin(&d);\n\n rep(i, l, r + 1) {\n if (i % d == 0) ans++;\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}", "test_IO": [ { "input": "5 10 2\n", "output": "3\n" } ] }, { "id": "s647939399", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n char m;\n int a, b, c[256], i, j;\n for (i = 0; i > -1; i++) {\n scanf(\"%d %c %d\", &a, &m, &b);\n if (m == '?') {\n break;\n }\n if (m == '+') {\n c[i] = a + b;\n }\n if (m == '-') {\n c[i] = a - b;\n }\n if (m == '*') {\n c[i] = a * b;\n }\n if (m == '/') {\n c[i] = a / b;\n }\n }\n for (j = 0; j < i; j++) {\n printf(\"%d\\n\", c[j]);\n }\n return (0);\n}", "test_IO": [ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ] }, { "id": "s171933389", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\n#define max(a, b) ((a) > (b) ? (a) : (b))\n#define min(a, b) ((a) > (b) ? (b) : (a))\n\nint get_int4(int *a1, int *a2, int *a3, int *a4) {\n scanf(\"%d %d %d %d\", a1, a2, a3, a4);\n return 0;\n}\n\nint fget_array(int64_t *arr, int size) {\n int i;\n for (i = 0; i < size; i++) {\n scanf(\"%lld\", &arr[i]);\n }\n return 0;\n}\n\n#define NUM_MAX 1000\n#define NUM2_MAX (NUM_MAX * NUM_MAX)\n#define RANK_MAX 3000\n\nint asc(const void *a1, const void *a2) {\n int64_t aa1 = *(int64_t *)a1;\n int64_t aa2 = *(int64_t *)a2;\n if (aa1 > aa2) return 1;\n if (aa1 == aa2) return 0;\n return -1;\n}\n\nint desc(const void *a1, const void *a2) {\n int64_t aa1 = *(int64_t *)a1;\n int64_t aa2 = *(int64_t *)a2;\n if (aa1 > aa2) return -1;\n if (aa1 == aa2) return 0;\n return 1;\n}\n\n#define VAL_MAX (int64_t)(1e+10)\n#define SUM_MAX (VAL_MAX * 3)\n\nstruct range {\n int start;\n int end;\n};\nint lower_bound(int64_t *arr, struct range r, int64_t key) {\n int low = r.start;\n ;\n int high = r.end;\n while (low + 1 < high) {\n int mid = (low + high) / 2;\n if (arr[mid] < key) {\n low = mid;\n } else {\n high = mid;\n }\n }\n return low + 1;\n}\n\nint main(void) {\n int x, y, z, rank;\n get_int4(&x, &y, &z, &rank);\n static int64_t xrr[NUM_MAX];\n static int64_t yrr[NUM_MAX];\n static int64_t zrr[NUM_MAX];\n fget_array(xrr, x);\n fget_array(yrr, y);\n fget_array(zrr, z);\n int64_t min_sum = VAL_MAX + 1;\n int64_t max_sum = 0;\n int i, j;\n for (i = 0; i < z; i++) min_sum = min(min_sum, zrr[i]);\n for (i = 0; i < z; i++) max_sum = max(max_sum, zrr[i]);\n\n static int64_t pair[NUM2_MAX];\n int idx = 0;\n for (i = 0; i < x; i++) {\n for (j = 0; j < y; j++) {\n pair[idx++] = xrr[i] + yrr[j];\n }\n }\n qsort(pair, idx, sizeof(int64_t), asc);\n min_sum += pair[0];\n max_sum += pair[idx - 1];\n\n static int cache[NUM_MAX];\n static int cnt_map[NUM_MAX];\n static int64_t ans[RANK_MAX];\n int size = x * y * z;\n int64_t prev = min_sum;\n int r;\n for (r = rank; r >= 1; r--) {\n int64_t low = prev - 1;\n int64_t high = max_sum + 1;\n while (low + 1 < high) {\n int64_t mid = (low + high) / 2;\n int cnt = 0;\n for (i = 0; i < z; i++) {\n int64_t pivot = zrr[i];\n struct range r = {cache[i] - 1, idx};\n int tmp = lower_bound(pair, r, mid - pivot);\n cnt_map[i] = tmp;\n cnt += tmp;\n }\n if (cnt <= size - r) {\n memcpy(cache, cnt_map, sizeof(int) * z);\n low = mid;\n } else {\n high = mid;\n }\n }\n ans[r - 1] = low;\n if (low == max_sum) break;\n prev = low;\n }\n for (i = 0; i < rank; i++) {\n printf(\"%lld\\n\", (ans[i] == 0) ? max_sum : ans[i]);\n }\n\n return 0;\n}", "test_IO": [ { "input": "2 2 2 8\n4 6\n1 5\n3 8\n", "output": "19\n17\n15\n14\n13\n12\n10\n8\n" } ] }, { "id": "s910176756", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c;\n char op;\n scanf(\"%d %c %d\", &a, &op, &b);\n while (1) {\n if (op == '+') {\n c = a + b;\n printf(\"%d\\n\", c);\n } else if (op == '-') {\n c = a - b;\n printf(\"%d\\n\", c);\n } else if (op == '*') {\n c = a * b;\n printf(\"%d\\n\", c);\n } else if (op == '/') {\n c = a / b;\n printf(\"%d\\n\", c);\n } else {\n break;\n }\n scanf(\"%d %c %d\", &a, &op, &b);\n }\n return 0;\n}", "test_IO": [ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ] }, { "id": "s858559569", "dataset": "codenet", "language": "C", "code": "#include \n#define N 4\n\ntypedef struct {\n int P[N][N];\n} Pazz;\n\nPazz Q;\nint dx[4] = {0, 1, 0, -1};\nint dy[4] = {1, 0, -1, 0};\n\nint Heu(Pazz Q) {\n int i, j;\n int hx, hy, sum = 0;\n for (i = 0; i < N; i++) {\n for (j = 0; j < N; j++) {\n if (Q.P[i][j] == 0) continue;\n\n hx = (Q.P[i][j] - 1) % N - j;\n hy = (Q.P[i][j] - 1) / N - i;\n\n if (hx < 0)\n sum -= hx;\n else\n sum += hx;\n\n if (hy < 0)\n sum -= hy;\n else\n sum += hy;\n }\n }\n return sum;\n}\nint dfs(int x, int y, int max, int count, int n) {\n int i, temp;\n int x0, y0, ans = -1, h;\n\n h = Heu(Q);\n\n if (h == 0) return count;\n if ((count + h) > max) return -1;\n\n for (i = 0; i < 4; i++) {\n x0 = x + dx[i];\n y0 = y + dy[i];\n\n if (((i == (n + 2) % 4) && (n != -1)) ||\n !((0 <= x0) && (x0 < N) && (0 <= y0) && (y0 < N)))\n continue;\n temp = Q.P[y][x];\n Q.P[y][x] = Q.P[y0][x0];\n Q.P[y0][x0] = temp;\n\n ans = dfs(x0, y0, max, count + 1, i);\n\n if (ans != -1) return ans;\n temp = Q.P[y][x];\n Q.P[y][x] = Q.P[y0][x0];\n Q.P[y0][x0] = temp;\n }\n\n return -1;\n}\n\nint main() {\n int i, j;\n int kx, ky, ans, a;\n Pazz tP;\n\n for (i = 0; i < N; i++) {\n for (j = 0; j < N; j++) {\n scanf(\"%d\", &a);\n Q.P[i][j] = a;\n if (a == 0) {\n kx = j;\n ky = i;\n }\n }\n }\n\n tP = Q;\n for (i = 1; i < 46; i++) {\n Q = tP;\n ans = dfs(kx, ky, i, 0, -1);\n if (ans != -1) {\n printf(\"%d\\n\", ans);\n break;\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "1 2 3 4\n6 7 8 0\n5 10 11 12\n9 13 14 15\n", "output": "8\n" } ] }, { "id": "s866461201", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int n, fd[6] = {}, i, j;\n double height;\n\n scanf(\"%d\", &n);\n while (n--) {\n scanf(\"%lf\", &height);\n if (height >= 185.0)\n fd[5]++;\n else if (height >= 180.0)\n fd[4]++;\n else if (height >= 175.0)\n fd[3]++;\n else if (height >= 170.0)\n fd[2]++;\n else if (height >= 165.0)\n fd[1]++;\n else\n fd[0]++;\n }\n\n for (i = 0; i < 6; i++) {\n printf(\"%d:\", i + 1);\n for (j = 0; j < fd[i]; j++) putchar('*');\n puts(\"\");\n }\n return 0;\n}", "test_IO": [ { "input": "4\n180.3\n168.2\n165.5\n175.3\n", "output": "1:\n2:**\n3:\n4:*\n5:*\n6:\n" } ] }, { "id": "s105551633", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\ntypedef long long int int64;\n\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define ABS(a) ((a) > (0) ? (a) : -(a))\n\nint digit(int64 n) {\n int res = 0;\n while (n > 0) {\n res++;\n n /= 10;\n }\n return res;\n}\n\nvoid run(void) {\n int64 n;\n scanf(\"%lld\", &n);\n int min = digit(n);\n int i;\n for (i = 1; (int64)i * i <= n; i++) {\n if (n % i != 0) continue;\n int64 a = i;\n int64 b = n / i;\n min = MIN(min, MAX(digit(a), digit(b)));\n }\n printf(\"%d\\n\", min);\n}\n\nint main(void) {\n run();\n return 0;\n}", "test_IO": [ { "input": "10000\n", "output": "3\n" } ] }, { "id": "s572139754", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int n;\n scanf(\"%d\", &n);\n if (n % 1000 == 0)\n printf(\"%d\\n\", 0);\n else\n printf(\"%d\\n\", (n / 1000 + 1) * 1000 - n);\n}", "test_IO": [ { "input": "1900\n", "output": "100\n" } ] }, { "id": "s772119380", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int a[1000], n, i, j, d = 0;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) scanf(\"%d\", &a[i]);\n for (i = 0; i < n; i++) {\n for (j = n - 1; j >= i + 1; j--) {\n if (a[j] < a[j - 1]) {\n int temp = a[j];\n a[j] = a[j - 1];\n a[j - 1] = temp;\n d++;\n }\n }\n }\n printf(\"%d\", a[0]);\n for (i = 1; i < n; i++) {\n printf(\" %d\", a[i]);\n }\n printf(\"\\n%d\\n\", d);\n return 0;\n}", "test_IO": [ { "input": "5\n5 3 2 4 1\n", "output": "1 2 3 4 5\n8\n" } ] }, { "id": "s286163362", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint data[111111];\nint seq[222222];\n\nint max(int a, int b);\n\nint main(void) {\n int n, k, t, i, p, ret = 0;\n\n while (1) {\n scanf(\"%d %d\", &n, &k);\n if (!n && !k) break;\n\n memset(data, 0, sizeof(data));\n memset(seq, 0, sizeof(seq));\n\n for (i = 0; i < k; i++) {\n scanf(\"%d\", &t);\n data[t]++;\n }\n\n p = 0;\n for (i = 1; i <= n; i++) {\n if (data[i]) {\n seq[p]++;\n } else {\n p += 2;\n }\n }\n p++;\n\n if (data[0]) {\n for (i = 0; i < p; i++) {\n ret = max(ret, seq[i] + seq[i + 2] + 1);\n }\n } else {\n for (i = 0; i < p; i++) {\n ret = max(ret, seq[i]);\n }\n }\n\n printf(\"%d\\n\", ret);\n }\n\n return 0;\n}\n\nint max(int a, int b) {\n if (a > b) {\n return a;\n }\n return b;\n}", "test_IO": [ { "input": "7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0\n", "output": "2\n4\n" } ] }, { "id": "s419237275", "dataset": "codenet", "language": "C", "code": "#include \n\n#define N 200\n#define SHIRO 0\n#define HAI 1\n#define KURO 2\n\nvoid aaaaa();\nvoid bbbbb(int);\n\nint n, A[N][N];\nint color[N], d[N], f[N];\nint TT;\n\nint main() {\n int u, k, v;\n int i, j;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n A[i][j] = 0;\n }\n }\n for (i = 0; i < n; i++) {\n scanf(\"%d %d\", &u, &k);\n u--;\n for (j = 0; j < k; j++) {\n scanf(\"%d\", &v);\n v--;\n A[u][v] = 1;\n }\n }\n\n aaaaa();\n\n return 0;\n}\n\nvoid aaaaa() {\n int u, i;\n\n for (i = 0; i < n; i++) {\n color[i] = SHIRO;\n }\n\n TT = 0;\n\n for (u = 0; u < n; u++) {\n if (color[u] == SHIRO) {\n bbbbb(u);\n }\n }\n\n for (i = 0; i < n; i++) {\n printf(\"%d %d %d\\n\", i + 1, d[i], f[i]);\n }\n}\n\nvoid bbbbb(int k) {\n int v;\n color[k] = HAI;\n TT++;\n d[k] = TT;\n for (v = 0; v < n; v++) {\n if (A[k][v] == 0) continue;\n if (color[v] == SHIRO) {\n bbbbb(v);\n }\n }\n color[k] = KURO;\n f[k] = ++TT;\n}", "test_IO": [ { "input": "4\n1 1 2\n2 1 4\n3 0\n4 1 3\n", "output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n" } ] }, { "id": "s792612560", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int n;\n unsigned long long int m;\n scanf(\"%d\", &n);\n m = n;\n n--;\n for (; n > 1; n--) {\n m *= n;\n }\n printf(\"%lld\\n\", m);\n return 0;\n}", "test_IO": [ { "input": "5\n", "output": "120\n" } ] }, { "id": "s891514124", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int S;\n scanf(\"%d\", &S);\n\n if (S < 60) {\n printf(\"0:0:%d\\n\", S);\n }\n\n else if (S < 3600) {\n printf(\"0:%d:%d\\n\", (int)S / 60, S % 60);\n }\n\n else {\n printf(\"%d:%d:%d\\n\", (int)S / 3600, (int)(S % 3600) / 60,\n (S % 60) % 60);\n }\n return 0;\n}", "test_IO": [ { "input": "46979\n", "output": "13:2:59\n" } ] }, { "id": "s541856674", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int N = 0;\n int R = 0;\n\n scanf(\"%d %d\", &N, &R);\n\n if (N >= 10) {\n printf(\"%d\\n\", R);\n } else {\n printf(\"%d\\n\", R + 100 * (10 - N));\n }\n\n return 0;\n}", "test_IO": [ { "input": "2 2919\n", "output": "3719\n" } ] }, { "id": "s646324174", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint top, S[10000];\n\nvoid push(int x) { S[++top] = x; }\n\nint pop() { return S[top--]; }\n\nint main() {\n int a, b;\n char s[200];\n top = 0;\n\n while (scanf(\"%s\", s) != EOF) {\n if (s[0] == '+') {\n b = pop();\n a = pop();\n push(a + b);\n } else if (s[0] == '-') {\n b = pop();\n a = pop();\n push(a - b);\n } else if (s[0] == '*') {\n b = pop();\n a = pop();\n push(a * b);\n } else {\n push(atoi(s));\n }\n }\n printf(\"%d\\n\", pop());\n return 0;\n}", "test_IO": [ { "input": "1 2 +\n", "output": "3\n" } ] }, { "id": "s224842101", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int i, a, b, s;\n int count[4];\n for (i = 0; i < 4; i++) count[i] = 0;\n for (i = 0; i < 3; i++) {\n scanf(\"%d %d\", &a, &b);\n count[a - 1]++;\n count[b - 1]++;\n }\n s = 1;\n for (i = 0; i < 4; i++) s *= count[i];\n if (s == 4)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}", "test_IO": [ { "input": "4 2\n1 3\n2 3\n", "output": "YES\n" } ] }, { "id": "s811544640", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, c;\n\n scanf(\"%d %d %d\", &a, &b, &c);\n\n if (b > a * c) {\n printf(\"%d\\n\", c);\n } else {\n printf(\"%d\\n\", b / a);\n }\n\n return 0;\n}", "test_IO": [ { "input": "2 11 4\n", "output": "4\n" } ] }, { "id": "s536445669", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int n, k;\n scanf(\"%d%d\", &n, &k);\n if (n % k == 0)\n printf(\"0\\n\");\n else\n printf(\"1\\n\");\n return 0;\n}", "test_IO": [ { "input": "7 3\n", "output": "1\n" } ] }, { "id": "s327850243", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int m, n;\n int i, j;\n int A[100][100];\n int B[100];\n int S[100] = {0};\n\n scanf(\"%d %d\", &m, &n);\n\n for (i = 0; i < m; i++) {\n for (j = 0; j < n - 1; j++) {\n scanf(\"%d \", &A[i][j]);\n }\n scanf(\"%d\\n\", &A[i][n - 1]);\n }\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\\n\", &B[i]);\n }\n\n for (i = 0; i < m; i++) {\n for (j = 0; j < n; j++) {\n S[i] = S[i] + A[i][j] * B[j];\n }\n }\n\n for (i = 0; i < m; i++) {\n printf(\"%d\\n\", S[i]);\n }\n\n return 0;\n}", "test_IO": [ { "input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n", "output": "5\n6\n9\n" } ] }, { "id": "s784517449", "dataset": "codenet", "language": "C", "code": "#include \n\nint A[1000000], n;\n\nint binarySearch(int key) {\n int left = 0;\n int right = n;\n int mid;\n while (left < right) {\n mid = (left + right) / 2;\n if (key == A[mid]) return 1;\n if (key > A[mid])\n left = mid + 1;\n else if (key < A[mid])\n right = mid;\n }\n return 0;\n}\n\nint main(void) {\n int i, q, k, sum = 0;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &A[i]);\n }\n scanf(\"%d\", &q);\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &k);\n if (binarySearch(k)) sum++;\n }\n printf(\"%d\\n\", sum);\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s821904390", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int in;\n int h, m, s;\n scanf(\"%d\", &in);\n\n h = in / 3600;\n in %= 3600;\n\n m = in / 60;\n in %= 60;\n\n s = in;\n\n printf(\"%d:%d:%d\\n\", h, m, s);\n}", "test_IO": [ { "input": "46979\n", "output": "13:2:59\n" } ] }, { "id": "s654514838", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#define NIL NULL\n\ntypedef struct node {\n int key;\n int priority;\n struct node *right, *left;\n} Node;\n\nNode *Delete(Node **, int);\nNode *delete(Node **, int);\n\nint find(Node *p, int x) {\n while (p != NIL) {\n if (p->key == x)\n return 1;\n else if (p->key > x)\n p = p->left;\n else\n p = p->right;\n }\n return 0;\n}\n\nvoid inorder(Node *a) {\n if (a->left != NIL) inorder(a->left);\n printf(\" %d\", a->key);\n if (a->right != NIL) inorder(a->right);\n return;\n}\n\nvoid preorder(Node *p) {\n printf(\" %d\", p->key);\n if (p->left != NIL) preorder(p->left);\n if (p->right != NIL) preorder(p->right);\n return;\n}\n\nvoid print(Node *p) {\n inorder(p);\n printf(\"\\n\");\n preorder(p);\n printf(\"\\n\");\n return;\n}\n\nNode *makenode(int x, int y) {\n Node *new = malloc(sizeof(Node));\n new->key = x;\n new->priority = y;\n new->left = NIL;\n new->right = NIL;\n return new;\n}\n\nNode *rightRotate(Node *p) {\n Node *q = p->left;\n p->left = q->right;\n q->right = p;\n return q;\n}\n\nNode *leftRotate(Node *p) {\n Node *q = p->right;\n p->right = q->left;\n q->left = p;\n return q;\n}\n\nNode *insert(Node **t, int key, int priority) {\n Node *new;\n if ((*t) == NIL) return new = makenode(key, priority);\n if ((*t)->key == key) return *t;\n\n if (key < (*t)->key) {\n (*t)->left = insert(&(*t)->left, key, priority);\n if ((*t)->priority < (*t)->left->priority) (*t) = rightRotate(*t);\n } else {\n (*t)->right = insert(&(*t)->right, key, priority);\n if ((*t)->priority < (*t)->right->priority) (*t) = leftRotate((*t));\n }\n return *t;\n}\n\nNode *Delete(Node **t, int key) {\n if ((*t) == NIL) return NIL;\n\n if (key < (*t)->key)\n (*t)->left = Delete(&((*t)->left), key);\n\n else if (key > (*t)->key)\n (*t)->right = Delete(&((*t)->right), key);\n\n else\n return delete (t, key);\n return *t;\n}\n\nNode *delete(Node **t, int key) {\n if ((*t)->left == NIL && (*t)->right == NIL) {\n return NIL;\n } else if ((*t)->left == NIL) {\n (*t) = leftRotate(*t);\n } else if ((*t)->right == NIL) {\n (*t) = rightRotate(*t);\n } else {\n if ((*t)->left->priority > (*t)->right->priority)\n (*t) = rightRotate(*t);\n else\n (*t) = leftRotate(*t);\n }\n return Delete(t, key);\n}\n\nint main(void) {\n int num, x, y;\n char com[8];\n Node *root = NIL;\n scanf(\"%d\", &num);\n\n for (int i = 0; i < num; i++) {\n scanf(\"%s\", com);\n switch (com[0]) {\n case 'i':\n scanf(\"%d %d\", &x, &y);\n root = insert(&root, x, y);\n break;\n case 'd':\n scanf(\"%d\", &x);\n root = Delete(&root, x);\n break;\n case 'f':\n scanf(\"%d\", &x);\n if (find(root, x))\n printf(\"yes\\n\");\n else\n printf(\"no\\n\");\n break;\n case 'p':\n print(root);\n break;\n }\n }\n return 0;\n}", "test_IO": [ { "input": "16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint\n", "output": " 1 3 6 7 14 21 35 42 80 86\n 35 6 3 1 14 7 21 80 42 86\nyes\nno\n 1 3 6 7 14 21 42 80 86\n 6 3 1 80 14 7 21 42 86\n" } ] }, { "id": "s878644875", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n char s[4], t[4];\n scanf(\"%s\", s);\n scanf(\"%s\", t);\n int hit = 0;\n for (int i = 0; i < 3; i++) {\n if (s[i] == t[i]) hit++;\n }\n printf(\"%d\\n\", hit);\n return 0;\n}", "test_IO": [ { "input": "CSS\nCSR\n", "output": "2\n" } ] }, { "id": "s310320755", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int r, c, n, flag, cnt;\n int arr[16][16] = {0};\n\n while (1) {\n scanf(\"%d\", &n);\n if (n == 0) {\n break;\n }\n flag = 1;\n r = (n + 1) / 2 + 1;\n c = (n + 1) / 2;\n arr[r][c] = cnt = 1;\n\n while (cnt != n * n + 1) {\n ++cnt;\n if (flag) {\n ++r;\n ++c;\n if (c > n) {\n c = 1;\n }\n\n if (r > n) {\n r = 1;\n }\n\n if (arr[r][c]) {\n flag = 0;\n --cnt;\n } else {\n arr[r][c] = cnt;\n }\n } else {\n ++r;\n --c;\n if (c < 1) {\n c = n;\n }\n\n if (r > n) {\n r = 1;\n }\n\n if (arr[r][c]) {\n flag = 0;\n } else {\n arr[r][c] = cnt;\n flag = 1;\n }\n }\n }\n\n for (r = 1; r < n + 1; r++) {\n for (c = 1; c < n + 1; c++) {\n printf(\"%4d\", arr[r][c]);\n arr[r][c] = 0;\n if (c == n) {\n printf(\"\\n\");\n }\n }\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "3\n5\n0\n", "output": " 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15\n" } ] }, { "id": "s972081311", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int n, sum;\n scanf(\"%d\", &n);\n sum = (n * (n + 1)) / 2;\n printf(\"%d\\n\", sum);\n return 0;\n}", "test_IO": [ { "input": "3\n", "output": "6\n" } ] }, { "id": "s387232787", "dataset": "codenet", "language": "C", "code": "#include \n\nint c[26];\n\nint main(void) {\n char str[1200];\n for (; scanf(\"%s\", str) > 0;) {\n for (char *p = str; *p; p++) {\n if ('a' <= *p && *p <= 'z') {\n c[*p - 'a']++;\n } else if ('A' <= *p && *p <= 'Z') {\n c[*p - 'A']++;\n }\n }\n }\n for (int i = 0; i < 26; i++) {\n printf(\"%c : %d\\n\", 'a' + i, c[i]);\n }\n return 0;\n}", "test_IO": [ { "input": "This is a pen.\n", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n" } ] }, { "id": "s776764195", "dataset": "codenet", "language": "C", "code": "#include \n\n#define PutChar(c) \\\n ; \\\n *p = (char)(c); \\\n ++p;\n\n#define MAX_N (2000001)\n#define MAX_Ai (10001)\n#define STR_SIZE (10000010)\n\nint getNum(void);\nvoid putNum(int n);\nvoid CountingSort(int A[], int B[], int k, int len);\n\nint A[MAX_N];\nint B[MAX_N];\nchar str[STR_SIZE];\nchar *p = str;\n\nint main(void) {\n register int i;\n int n;\n\n fread(str, 1, STR_SIZE, stdin);\n\n n = getNum();\n for (i = 1; i <= n; ++i) {\n A[i] = getNum();\n }\n\n CountingSort(A, B, MAX_Ai, n);\n\n p = str;\n --n;\n for (i = 1; i <= n; ++i) {\n putNum(B[i]);\n PutChar(' ');\n }\n putNum(B[i]);\n PutChar('\\0');\n\n puts(str);\n\n return 0;\n}\n\nint getNum(void) {\n int n = 0;\n while ((*p >= '0') && (*p <= '9')) {\n n = n * 10 + (int)(*p - '0');\n ++p;\n }\n ++p;\n return n;\n}\n\nvoid putNum(int n) {\n int d;\n if (n < 10) {\n PutChar('0' + n);\n return;\n }\n d = n / 10;\n if (d) putNum(d);\n PutChar('0' + (n - (d * 10)));\n}\n\nvoid CountingSort(int A[], int B[], int k, int len) {\n int C[MAX_Ai] = {0};\n int i, j;\n for (j = 1; j <= len; ++j) {\n ++C[A[j]];\n }\n for (i = 1; i <= k; ++i) {\n C[i] += C[i - 1];\n }\n for (j = len; j > 0; --j) {\n B[C[A[j]]] = A[j];\n --C[A[j]];\n }\n}", "test_IO": [ { "input": "7\n2 5 1 3 2 3 0\n", "output": "0 1 2 2 3 3 5\n" } ] }, { "id": "s869953757", "dataset": "codenet", "language": "C", "code": "#include \n\n#define M 100\n#define whi 0\n#define gra 1\n#define bla 2\n\nint n;\nint T[M][M];\nint color[M], d[M];\nint Q[M], head = 0, tail = 0;\n\nvoid enqueue(int x) {\n Q[tail] = x;\n tail = (tail + 1) % M;\n}\n\nint dequeue(void) {\n int x;\n x = Q[head];\n head = (head + 1) % M;\n return x;\n}\n\nvoid bfs(int s) {\n int i, u, v;\n\n for (i = 0; i < n; i++) {\n color[i] = whi;\n d[i] = 1000000;\n }\n\n color[s] = gra;\n d[s] = 0;\n enqueue(s);\n\n while (head != tail) {\n u = dequeue();\n for (v = 0; v < n; v++) {\n if (T[u][v] == 1 && color[v] == whi) {\n color[v] = gra;\n d[v] = d[u] + 1;\n enqueue(v);\n }\n }\n color[u] = bla;\n }\n}\n\nint main() {\n int i, j;\n int u, k, v;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n T[i][j] = 0;\n }\n }\n\n for (i = 0; i < n; i++) {\n scanf(\"%d %d\", &u, &k);\n u--;\n for (j = 0; j < k; j++) {\n scanf(\"%d\", &v);\n v--;\n T[u][v] = 1;\n }\n }\n\n bfs(0);\n\n for (i = 0; i < n; i++) {\n if (d[i] == 1000000) d[i] = -1;\n printf(\"%d %d\\n\", i + 1, d[i]);\n }\n\n return 0;\n}", "test_IO": [ { "input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n", "output": "1 0\n2 1\n3 2\n4 1\n" } ] }, { "id": "s418782460", "dataset": "codenet", "language": "C", "code": "#pragma warning(disable : 4996)\n#include \n#include \n#include \n#include \n#define MAX_STRING 30\n#define MAX_LINE 2000000\n#define MAX_HUMAN 200000\n\nchar sLongInputLine[MAX_LINE + 1] = \"\";\nint anComingSec[MAX_HUMAN];\n\nint main() {\n char sInput[MAX_STRING + 1] = \"\";\n char* psWord = NULL;\n char* psInput = NULL;\n\n int nHumanNumber = 0;\n int nNextHumanIndex = 0;\n int nWaterLength = 0;\n int nWaterLife = 0;\n int nStart = 0;\n int nStop = 0;\n\n int nIndex = 0;\n int i = 0;\n int j = 0;\n\n fgets(sInput, MAX_STRING, stdin);\n if (strchr(sInput, '\\n') != NULL) {\n sInput[strlen(sInput) - 1] = '\\0';\n }\n psInput = strtok(sInput, \" \");\n nHumanNumber = atoi(psInput);\n psInput = strtok(NULL, \" \");\n nWaterLength = atoi(psInput);\n\n fgets(sLongInputLine, MAX_LINE, stdin);\n if (strchr(sLongInputLine, '\\n') != NULL) {\n sLongInputLine[strlen(sLongInputLine) - 1] = '\\0';\n }\n psInput = strtok(sLongInputLine, \" \");\n for (i = 0; i < nHumanNumber; i++) {\n anComingSec[i] = atoi(psInput);\n psInput = strtok(NULL, \" \");\n }\n\n nStart = anComingSec[0];\n\n while (nNextHumanIndex < nHumanNumber) {\n if (nNextHumanIndex == nHumanNumber) {\n break;\n } else {\n nStop = nStart + nWaterLength;\n if (anComingSec[nNextHumanIndex] < nStop) {\n while (nNextHumanIndex < nHumanNumber &&\n anComingSec[nNextHumanIndex] < nStop) {\n if (nStop <= anComingSec[nNextHumanIndex] + nWaterLength) {\n nStop = anComingSec[nNextHumanIndex] + nWaterLength;\n nNextHumanIndex++;\n }\n }\n if (nNextHumanIndex == nHumanNumber) {\n nWaterLife = nWaterLife + (nStop - nStart);\n break;\n }\n }\n nWaterLife = nWaterLife + (nStop - nStart);\n nStart = nStop;\n if (nStart < anComingSec[nNextHumanIndex]) {\n nStart = anComingSec[nNextHumanIndex];\n }\n }\n }\n printf(\"%d\\n\", nWaterLife);\n\n return 0;\n}", "test_IO": [ { "input": "2 4\n0 3\n", "output": "7\n" } ] }, { "id": "s977214798", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef __cplusplus\n#include \n#endif\n\nint32_t nextint(void) {\n char c = getchar_unlocked();\n while (c != '-' && (c < '0' || '9' < c)) c = getchar_unlocked();\n bool s = false;\n if (c == '-') {\n s = true;\n c = getchar_unlocked();\n }\n uint32_t x = 0;\n while ('0' <= c && c <= '9') {\n x = x * 10 + c - '0';\n c = getchar_unlocked();\n }\n return s ? -x : x;\n}\n\nint n;\n\nint p(int a, int b) {\n if (a < b) {\n return a + b * n;\n } else {\n return b + a * n;\n }\n}\n\nint a[1000][999];\n\nint e1[1000000];\nint e2[1000000];\nint d[1000000];\nbool b[1000000];\n\nint f(int from) {\n if (b[from]) return -1;\n if (d[from]) return d[from];\n b[from] = true;\n int to;\n to = e1[from];\n int max = 0;\n if (to != 0) {\n int now = f(to);\n if (now < 0) return now;\n if (now > max) max = now;\n }\n to = e2[from];\n if (to != 0) {\n int now = f(to);\n if (now < 0) return now;\n if (now > max) max = now;\n }\n b[from] = false;\n return d[from] = max + 1;\n}\n\nint main(void) {\n n = nextint();\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n - 1; j++) {\n a[i][j] = nextint() - 1;\n }\n }\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n - 2; j++) {\n int from = p(i, a[i][j]);\n int to = p(i, a[i][j + 1]);\n if (e1[from] == 0) {\n e1[from] = to;\n } else if (e2[from] == 0) {\n e2[from] = to;\n } else {\n puts(\"-1\");\n return 0;\n }\n }\n }\n int ans = 0;\n for (int i = 0; i < n; i++) {\n int from = p(i, a[i][0]);\n int now = f(from);\n if (now < 0) {\n ans = -1;\n break;\n }\n if (now > ans) ans = now;\n }\n printf(\"%d\\n\", ans);\n}", "test_IO": [ { "input": "3\n2 3\n1 3\n1 2\n", "output": "3\n" } ] }, { "id": "s167283321", "dataset": "codenet", "language": "C", "code": "#include \n#define NIL -1\nstruct Node {\n int parent, left, right;\n};\nstruct Node R[10000];\nint n;\nvoid preorder(int);\nvoid inorder(int);\nvoid postorder(int);\n\nvoid preorder(int x) {\n if (x == NIL) return;\n printf(\" %d\", x);\n preorder(R[x].left);\n preorder(R[x].right);\n}\nvoid inorder(int x) {\n if (x == NIL) return;\n inorder(R[x].left);\n printf(\" %d\", x);\n inorder(R[x].right);\n}\nvoid postorder(int x) {\n if (x == NIL) return;\n postorder(R[x].left);\n postorder(R[x].right);\n printf(\" %d\", x);\n}\n\nint main() {\n int i, a, b, c, root;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) R[i].parent = NIL;\n for (i = 0; i < n; i++) {\n scanf(\"%d %d %d\", &a, &b, &c);\n R[a].left = b;\n R[a].right = c;\n if (b != NIL) R[b].parent = a;\n if (c != NIL) R[c].parent = a;\n }\n for (i = 0; i < n; i++) {\n if (R[i].parent == NIL) root = i;\n }\n printf(\"Preorder\\n\");\n preorder(root);\n printf(\"\\n\");\n printf(\"Inorder\\n\");\n inorder(root);\n printf(\"\\n\");\n printf(\"Postorder\\n\");\n postorder(root);\n printf(\"\\n\");\n return 0;\n}", "test_IO": [ { "input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n", "output": "Preorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n" } ] }, { "id": "s033933040", "dataset": "codenet", "language": "C", "code": "#include \n\nmain() {\n int a, b, mawari, menseki;\n\n scanf(\"%d %d\", &a, &b);\n mawari = a + a + b + b;\n menseki = a * b;\n printf(\"%d %d\\n\", menseki, mawari);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s648501684", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n long int n, k, q;\n\n scanf(\"%ld%ld%ld\", &n, &k, &q);\n\n int arr[n];\n for (long int i = 0; i <= n; i++) {\n arr[i] = 0;\n }\n\n for (long int i = 0; i < q; i++) {\n long int temp;\n scanf(\"%ld\", &temp);\n arr[temp] += 1;\n }\n\n for (long int i = 1; i <= n; i++) {\n if (arr[i] > (q - k)) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "6 3 4\n3\n1\n3\n2\n", "output": "No\nNo\nYes\nNo\nNo\nNo\n" } ] }, { "id": "s999424066", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, c, x, y;\n scanf(\"%d%d%d%d%d\", &a, &b, &c, &x, &y);\n c *= 2;\n if (a + b <= c)\n printf(\"%d\\n\", a * x + b * y);\n else {\n if (x <= y) {\n if (b <= c)\n printf(\"%d\\n\", c * x + (y - x) * b);\n else\n printf(\"%d\\n\", c * y);\n } else {\n if (a <= c)\n printf(\"%d\\n\", c * y + (x - y) * a);\n else\n printf(\"%d\\n\", c * x);\n }\n }\n return 0;\n}", "test_IO": [ { "input": "1500 2000 1600 3 2\n", "output": "7900\n" } ] }, { "id": "s108384974", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nstruct node {\n int key;\n struct node *p;\n struct node *l;\n struct node *r;\n};\n\ntypedef struct node *NodePointer;\n\nNodePointer r, NIL;\n\nNodePointer find(NodePointer x, int k) {\n while (x != NIL && k != x->key) {\n if (k < x->key) {\n x = x->l;\n } else {\n x = x->r;\n }\n }\n return x;\n}\n\nvoid insert(int k) {\n NodePointer y = NIL;\n NodePointer x = r;\n\n NodePointer z = (NodePointer)malloc(sizeof(struct node));\n z->key = k;\n z->l = NIL;\n z->r = NIL;\n\n while (x != NIL) {\n y = x;\n if (z->key < x->key) {\n x = x->l;\n } else {\n x = x->r;\n }\n }\n z->p = y;\n\n if (y == NIL) {\n r = z;\n } else if (z->key < y->key) {\n y->l = z;\n } else {\n y->r = z;\n }\n}\n\nvoid inorder(NodePointer u) {\n if (u == NIL) {\n return;\n }\n inorder(u->l);\n printf(\" %d\", u->key);\n inorder(u->r);\n}\n\nvoid preorder(NodePointer u) {\n if (u == NIL) {\n return;\n }\n printf(\" %d\", u->key);\n preorder(u->l);\n preorder(u->r);\n}\n\nvoid print() {\n inorder(r);\n puts(\"\");\n preorder(r);\n puts(\"\");\n}\n\nint main() {\n int n, i, j, z, x;\n char s[10];\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%s\", s);\n if (s[0] == 'f') {\n scanf(\"%d\", &x);\n NodePointer t = find(r, x);\n if (t == NIL)\n printf(\"no\\n\");\n else\n printf(\"yes\\n\");\n\n } else if (s[0] == 'i') {\n scanf(\"%d\", &z);\n insert(z);\n } else {\n print();\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n", "output": "yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n" } ] }, { "id": "s476941540", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n int i, alpha[26];\n char ch;\n\n for (i = 0; i < 26; i++) alpha[i] = 0;\n\n while (1) {\n ch = getchar();\n if (ch == EOF) break;\n\n if (isalpha(ch)) {\n if (isupper(ch))\n alpha[ch - 65]++;\n else\n alpha[ch - 97]++;\n }\n }\n\n ch = 'a';\n for (i = 0; i < 26; i++, ch++) {\n printf(\"%c : %d\\n\", ch, alpha[i]);\n }\n}", "test_IO": [ { "input": "This is a pen.\n", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n" } ] }, { "id": "s846328722", "dataset": "codenet", "language": "C", "code": "#include \nint linersearch(int[], int, int);\n\nint main() {\n int i, n, s[100000], q, t, count = 0;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &s[i]);\n }\n\n scanf(\"%d\", &q);\n\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &t);\n if (linersearch(s, n, t)) count++;\n }\n printf(\"%d\\n\", count);\n\n return 0;\n}\n\nint linersearch(int a[], int n, int key) {\n int i = 0;\n\n a[n] = key;\n\n while (a[i] != key) {\n i++;\n }\n return i != n;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s484809551", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define N_MAX (100)\n#define P_MAX (100)\n#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)\n\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define ABS(a) ((a) < 0 ? -(a) : (a))\n#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))\n\nstatic char *strrstr(const char *string, const char *pattern) {\n size_t offset = 0;\n char *lastP = NULL;\n\n char *searchResult = NULL;\n while ((searchResult = strstr(&(string[offset]), pattern)) != NULL &&\n string[offset] != '\\0') {\n lastP = searchResult;\n offset++;\n }\n\n return lastP;\n}\n\nint compare_f(const void *a, const void *b) {\n return *((size_t *)a) < *((size_t *)b) ? -1 : 1;\n}\n\nstatic size_t comb(const size_t n, const size_t r) {\n size_t result = 1;\n\n for (size_t i = 0; i < r; i++) {\n result *= n - i;\n result /= i + 1;\n }\n\n return result;\n}\n\nstatic uint64_t gcd(uint64_t m, uint64_t n) {\n uint64_t temp;\n\n while (m % n != 0) {\n temp = n;\n n = m % n;\n m = temp;\n }\n\n return n;\n}\n\nint main(void) {\n const char patternBase[] = \"keyence\";\n char top[8], bottom[8];\n char S[101];\n\n scanf(\"%s\", S);\n\n const size_t len = strlen(S);\n bool found = false;\n\n for (size_t offset = 0; offset < strlen(patternBase); offset++) {\n strncpy(top, patternBase, offset);\n top[offset] = '\\0';\n strncpy(bottom, &(patternBase[offset]), strlen(patternBase) - offset);\n bottom[strlen(patternBase) - offset] = '\\0';\n\n const char *topSearch = strstr(S, top);\n if (topSearch != NULL) {\n const char *bottomSearch = strrstr(&(topSearch[offset]), bottom);\n if (bottomSearch != NULL) {\n size_t sepCount = 0;\n\n if (topSearch != S) {\n sepCount++;\n }\n if (&(topSearch[offset]) != bottomSearch) {\n sepCount++;\n }\n if (bottomSearch[strlen(bottom)] != '\\0') {\n sepCount++;\n }\n\n if (sepCount <= 1) {\n found = true;\n break;\n }\n }\n }\n }\n\n puts((found ? \"YES\" : \"NO\"));\n\n return 0;\n}", "test_IO": [ { "input": "keyofscience\n", "output": "YES\n" } ] }, { "id": "s990550009", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint main() {\n int n, a[100000], cnt = 1;\n bool isup;\n bool issame = false;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n if (a[0] < a[1])\n isup = true;\n else if (a[0] > a[1])\n isup = false;\n else\n issame = true;\n for (int i = 1; i < n - 1; i++) {\n if (issame) {\n if (a[i] != a[i + 1]) {\n issame = false;\n if (a[i] < a[i + 1])\n isup = true;\n else\n isup = false;\n }\n } else {\n if (isup && a[i] <= a[i + 1]) {\n ;\n } else if (!isup && a[i] >= a[i + 1]) {\n ;\n } else {\n if (i + 2 < n) {\n if (a[i + 1] < a[i + 2])\n isup = true;\n else if (a[i + 1] > a[i + 2])\n isup = false;\n else\n issame = true;\n cnt++;\n } else {\n cnt++;\n break;\n }\n }\n }\n }\n printf(\"%d\\n\", cnt);\n return 0;\n}", "test_IO": [ { "input": "6\n1 2 3 2 2 1\n", "output": "2\n" } ] }, { "id": "s030068105", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint main() {\n int n;\n int *data;\n scanf(\"%d\\n\", &n);\n data = (int *)malloc(sizeof(int) * n);\n for (int i = 0; i < n; i++) scanf(\"%d\", &data[i]);\n int max = 0, index;\n for (int i = 0; i < n; i++)\n if (data[i] > max) {\n max = data[i];\n index = i;\n }\n int a = 0;\n for (int i = 0; i < n; i++)\n if (i != index) a += data[i];\n if (a > max)\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n return 0;\n}", "test_IO": [ { "input": "4\n3 8 5 1\n", "output": "Yes\n" } ] }, { "id": "s764482816", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int i, j, max, max_j, buf;\n int io[5];\n scanf(\"%d %d %d %d %d\", &io[0], &io[1], &io[2], &io[3], &io[4]);\n for (i = 0; i < 5; i++) {\n max = io[i];\n max_j = i;\n for (j = i + 1; j < 5; j++) {\n if (max < io[j]) {\n max = io[j];\n max_j = j;\n }\n }\n buf = io[i];\n io[i] = io[max_j];\n io[max_j] = buf;\n i < 4 ? printf(\"%d \", io[i]) : printf(\"%d\\n\", io[i]);\n }\n return 0;\n}", "test_IO": [ { "input": "3 6 9 7 5\n", "output": "9 7 6 5 3\n" } ] }, { "id": "s616182260", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a[3], b[3];\n int c[3][3];\n int i, j;\n for (i = 0; i < 3; i++) {\n scanf(\"%d%d%d\", &c[i][0], &c[i][1], &c[i][2]);\n }\n a[0] = 0;\n for (i = 0; i < 3; i++) {\n b[i] = c[0][i];\n }\n for (i = 1; i < 3; i++) {\n a[i] = c[i][0] - b[0];\n }\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 3; j++) {\n if (c[i][j] != a[i] + b[j]) {\n puts(\"No\");\n return 0;\n }\n }\n }\n puts(\"Yes\");\n return 0;\n}", "test_IO": [ { "input": "1 0 1\n2 1 2\n1 0 1\n", "output": "Yes\n" } ] }, { "id": "s670350109", "dataset": "codenet", "language": "C", "code": "#include \n#include \nchar str1[100], str2[100], temp[100];\nint main() {\n int i, j = 0, t;\n scanf(\"%s[^\\n]\", str1);\n scanf(\"%s[^\\n]\", str2);\n i = strlen(str1);\n t = i - 1;\n if (strlen(str1) != strlen(str2)) {\n printf(\"NO\\n\");\n } else {\n while (str1[j] != '\\0') {\n temp[j] = str1[t];\n j++;\n t--;\n }\n t = 0;\n i = 0;\n while (temp[i] != '\\0') {\n if (temp[i] == str2[i]) {\n t++;\n }\n i++;\n }\n if (strlen(str2) == t) {\n printf(\"YES\\n\");\n } else if (strlen(str2) != t) {\n printf(\"NO\\n\");\n }\n }\n return 0;\n}", "test_IO": [ { "input": "pot\ntop\n", "output": "YES\n" } ] }, { "id": "s500706216", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint a[200000], tmpa[200000], light[200010] = {0};\ntypedef long long ll;\nint main() {\n int n, k;\n scanf(\"%d%d\", &n, &k);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n\n for (int i = 0; i < n; i++) {\n int r, l;\n r = i - a[i];\n l = i + a[i];\n light[(r < 0 ? 0 : r)]++;\n light[(l + 1 > n ? n + 1 : l + 1)]--;\n }\n\n for (int i = 0; i < k; i++) {\n int sum = 0;\n for (int j = 0; j < n; j++) {\n tmpa[j] = a[j];\n sum += light[j];\n a[j] = sum;\n }\n for (int j = 0; j < n; j++) {\n int r = j - tmpa[j];\n int l = j + tmpa[j];\n light[(r < 0 ? 0 : r)]--;\n light[(l + 1 > n ? n + 1 : l + 1)]++;\n r = j - a[j];\n l = j + a[j];\n light[(r < 0 ? 0 : r)]++;\n light[(l + 1 > n ? n + 1 : l + 1)]--;\n }\n bool isSame = true;\n for (int j = 0; j < n - 1; j++) {\n if (a[j] != a[j + 1]) {\n isSame = false;\n break;\n }\n }\n if (isSame && a[0] == n) {\n break;\n }\n }\n for (int j = 0; j < n; j++) {\n printf(\"%d\", a[j]);\n printf(j == n - 1 ? \"\\n\" : \" \");\n }\n return 0;\n}", "test_IO": [ { "input": "5 1\n1 0 0 1 0\n", "output": "1 2 2 1 2\n" } ] }, { "id": "s992866158", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int n, k, cnt;\n\n scanf(\"%d%d\", &n, &k);\n cnt = 0;\n while (n--) {\n int h;\n\n scanf(\"%d\", &h);\n if (h >= k) cnt++;\n }\n printf(\"%d\\n\", cnt);\n return 0;\n}", "test_IO": [ { "input": "4 150\n150 140 100 200\n", "output": "2\n" } ] }, { "id": "s305455869", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n#include \n#include \n\nint main(int argc, char *argv[]) {\n int a, b;\n int ans;\n\n scanf(\"%d %d\", &a, &b);\n\n ans = 0;\n if (a >= 13) {\n ans = b;\n } else if (a >= 6) {\n ans = b / 2;\n }\n\n printf(\"%d\\n\", ans);\n\n return 0;\n}", "test_IO": [ { "input": "30 100\n", "output": "100\n" } ] }, { "id": "s427349585", "dataset": "codenet", "language": "C", "code": "#include \n\ntypedef struct {\n char s;\n int v;\n} card;\n\ncard L[100000 / 2 + 2], R[100000 / 2 + 2];\n\nvoid me(card *a, int n, int l, int m, int r) {\n int i, j, k;\n int n1 = m - l;\n int n2 = r - m;\n\n for (i = 0; i < n1; i++) L[i] = a[l + i];\n for (i = 0; i < n2; i++) R[i] = a[m + i];\n L[n1].v = R[n2].v = 2000000000;\n i = 0;\n j = 0;\n for (k = l; k < r; k++) {\n if (L[i].v <= R[j].v) {\n a[k] = L[i++];\n } else {\n a[k] = R[j++];\n }\n }\n}\n\nvoid ms(card *a, int n, int l, int r) {\n int m;\n if (l + 1 < r) {\n m = (l + r) / 2;\n ms(a, n, l, m);\n ms(a, n, m, r);\n me(a, n, l, m, r);\n }\n}\n\nint partiton(card *a, int n, int p, int r) {\n int i, j;\n card t, x;\n x = a[r];\n i = p - 1;\n for (j = p; j < r; j++) {\n if (a[j].v <= x.v) {\n i++;\n t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n }\n t = a[i + 1];\n a[i + 1] = a[r];\n a[r] = t;\n return i + 1;\n}\n\nvoid qs(card *a, int n, int p, int r) {\n int q;\n\n if (p < r) {\n q = partiton(a, n, p, r);\n qs(a, n, p, q - 1);\n qs(a, n, q + 1, r);\n }\n}\n\nint main() {\n int n, i, v;\n card a[200000], b[200000];\n char s[10];\n int stable = 1;\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%s%d\", s, &v);\n a[i].s = b[i].s = s[0];\n a[i].v = b[i].v = v;\n }\n\n ms(a, n, 0, n);\n qs(b, n, 0, n - 1);\n\n for (i = 0; i < n; i++) {\n if (a[i].s != b[i].s) {\n stable = 0;\n }\n }\n if (stable == 1) {\n printf(\"Stable\\n\");\n } else {\n printf(\"Not stable\\n\");\n }\n for (i = 0; i < n; i++) {\n printf(\"%c %d\\n\", b[i].s, b[i].v);\n }\n\n return 0;\n}", "test_IO": [ { "input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n", "output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n" } ] }, { "id": "s008026706", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int a, b, x, y;\n scanf(\"%d%d\", &a, &b);\n x = 2 * a + 2 * b;\n y = a * b;\n printf(\"%d %d\\n\", y, x);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s400285050", "dataset": "codenet", "language": "C", "code": "#include \n\nint you(int, int);\nint main() {\n int x, y, z;\n scanf(\"%d %d\", &x, &y);\n if (x >= y)\n z = you(x, y);\n else\n z = you(y, x);\n printf(\"%d\\n\", z);\n return 0;\n}\nint you(int x, int y) {\n int z;\n while (1) {\n z = x % y;\n x = y;\n y = z;\n if (y <= 0) break;\n }\n return x;\n}", "test_IO": [ { "input": "54 20\n", "output": "2\n" } ] }, { "id": "s401511324", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int n, l[2001], i, j, k, cnt = 0, tmp = 0;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &l[i]);\n }\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n if (l[j] < l[i]) {\n tmp = l[i];\n l[i] = l[j];\n l[j] = tmp;\n }\n }\n }\n for (i = 0; i < n - 2; i++) {\n for (j = i + 1; j < n - 1; j++) {\n for (k = j + 1; k < n; k++) {\n if (l[i] + l[j] > l[k]) {\n cnt++;\n } else {\n break;\n }\n }\n }\n }\n printf(\"%d\\n\", cnt);\n return 0;\n}", "test_IO": [ { "input": "4\n3 4 2 1\n", "output": "1\n" } ] }, { "id": "s497487985", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))\n#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))\nint compare_int(const void *a, const void *b) {\n return *(long int *)b - *(long int *)a;\n}\n\nlong int gcd(long int a, long int b) {\n if (b == 0) {\n return a;\n } else {\n return gcd(b, a % b);\n }\n}\n\nlong int lcm(long int a, long int b) { return a * b / gcd(a, b); }\n\nint main(void) {\n long int n;\n long long int k;\n long int q;\n long int a[100001];\n long long int point[100001] = {0};\n\n scanf(\"%ld%lld%ld\", &n, &k, &q);\n\n for (long int i = 0; i < q; i++) {\n scanf(\"%ld\", &a[i]);\n point[a[i] - 1]++;\n }\n\n for (long int i = 0; i < n; i++) {\n if (k - (q - point[i]) > 0) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "6 3 4\n3\n1\n3\n2\n", "output": "No\nNo\nYes\nNo\nNo\nNo\n" } ] }, { "id": "s844088973", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int K, X;\n scanf(\"%d %d\", &K, &X);\n for (int i = X - K + 1; i <= X + K - 1; i++) {\n printf(\"%d\", i);\n if (i < X + K - 1) printf(\" \");\n }\n printf(\"\\n\");\n return 0;\n}", "test_IO": [ { "input": "3 7\n", "output": "5 6 7 8 9\n" } ] }, { "id": "s736909850", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int sheep;\n int wolf;\n\n scanf(\"%d %d\", &sheep, &wolf);\n\n if (wolf >= sheep) {\n printf(\"unsafe\\n\");\n } else {\n printf(\"safe\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "4 5\n", "output": "unsafe\n" } ] }, { "id": "s982114524", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int i, N, x;\n x = 0;\n scanf(\"%d\", &N);\n for (i = 1; i <= N; i++) x += i;\n printf(\"%d\\n\", x);\n return 0;\n}", "test_IO": [ { "input": "3\n", "output": "6\n" } ] }, { "id": "s805240083", "dataset": "codenet", "language": "C", "code": "#include \n\n#define MAX 100005\n#define N 100\n\ntypedef struct {\n char name[N];\n int t;\n} P;\n\nP Q[MAX + 1];\nint head, tail;\n\nvoid Enqueue(P x) {\n if (MAX == tail) tail = 0;\n Q[tail] = x;\n tail++;\n}\n\nP Dequeue(void) {\n if (head == MAX) head = 0;\n return Q[head++];\n}\n\nint main() {\n int i, q, n, T = 0;\n P a;\n scanf(\"%d %d\", &n, &q);\n\n for (i = 0; i < n; i++) {\n scanf(\"%s%d\", a.name, &a.t);\n Enqueue(a);\n }\n\n while (n != 0) {\n a = Dequeue();\n if (a.t > q) {\n a.t = a.t - q;\n T += q;\n Enqueue(a);\n } else {\n T = T + a.t;\n printf(\"%s %d\\n\", a.name, T);\n n--;\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n", "output": "p2 180\np5 400\np1 450\np3 550\np4 800\n" } ] }, { "id": "s180134172", "dataset": "codenet", "language": "C", "code": "#include \nsigned main() {\n int n, k, p[99999], i, j, l, m, o = 0;\n scanf(\"%d %d\", &n, &k);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &p[i]);\n }\n for (i = 0; i < n; i++) {\n l = i;\n for (j = i + 1; j < n; j++) {\n if (p[j] < p[l]) {\n l = j;\n }\n }\n if (l != i) {\n m = p[i];\n p[i] = p[l];\n p[l] = m;\n }\n }\n for (i = 0; i < k; i++) {\n o += p[i];\n }\n printf(\"%d\\n\", o);\n return (0);\n}", "test_IO": [ { "input": "5 3\n50 100 80 120 80\n", "output": "210\n" } ] }, { "id": "s859058692", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n long sum = 0;\n int m, n, i, min, max;\n scanf(\"%d\\n\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &m);\n sum += m;\n if (i == 0) {\n min = m;\n max = m;\n }\n\n if (min > m) {\n min = m;\n }\n if (max < m) {\n max = m;\n }\n }\n printf(\"%d %d %ld\\n\", min, max, sum);\n}", "test_IO": [ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ] }, { "id": "s405782513", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int c[3];\n\n while (scanf(\"%d %d %d\", &c[0], &c[1], &c[2]) != EOF) {\n char card[10] = {0};\n int i;\n int count = 0;\n int sum = c[0] + c[1];\n\n for (i = 0; i < 3; i++) {\n card[c[i] - 1] = 1;\n }\n for (i = 0; i < 10; i++) {\n if (card[i] == 0 && sum + i + 1 <= 20) {\n count++;\n }\n }\n if (count >= 4) {\n puts(\"YES\");\n } else {\n puts(\"NO\");\n }\n }\n\n return 0;\n}", "test_IO": [ { "input": "1 2 3\n5 6 9\n8 9 10\n", "output": "YES\nYES\nNO\n" } ] }, { "id": "s201325376", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int a, b, c, i, count;\n scanf(\"%d%d%d\", &a, &b, &c);\n count = 0;\n for (i = a; i <= b; i++) {\n if (c % i == 0) count++;\n }\n printf(\"%d\\n\", count);\n\n return 0;\n}", "test_IO": [ { "input": "5 14 80\n", "output": "3\n" } ] }, { "id": "s912810100", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, x, y;\n\n scanf(\"%d%d\", &a, &b);\n\n x = a * b;\n y = (a + b) * 2;\n\n printf(\"%d %d\\n\", x, y);\n\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s044733418", "dataset": "codenet", "language": "C", "code": "#include \n\nint compare(int *a, int *b) { return (*b - *a); }\n\nint main(void) {\n int array[10], i;\n for (i = 0; i != 10; i++) scanf(\"%d\", array + i);\n qsort(array, 10, sizeof(int), compare);\n for (i = 0; i != 3; i++) printf(\"%d\\n\", array[i]);\n return 0;\n}", "test_IO": [ { "input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n", "output": "3776\n2848\n2840\n" } ] }, { "id": "s874174693", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n#include \n\n#define ll long long\n\nvoid swap(int *x, int *y) {\n int temp;\n\n temp = *x;\n *x = *y;\n *y = temp;\n\n return;\n}\n\nlong int gcd(long int a, long int b) {\n long int c;\n\n while (b > 0) {\n c = a % b;\n a = b;\n b = c;\n }\n\n return a;\n}\n\nint upll(const void *a, const void *b) {\n return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0;\n}\n\nint downll(const void *a, const void *b) {\n return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0;\n}\n\nvoid sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }\n\nvoid sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }\n\nlong int modpow(long int a, long int n, long int mod) {\n long int ans = 1;\n while (n > 0) {\n if (n & 1) {\n ans = ans * a % mod;\n }\n a = a * a % mod;\n n /= 2;\n }\n return ans;\n}\n\nlong int modinv(long int a, long int mod) { return modpow(a, mod - 2, mod); }\n\nint max(int a, int b) {\n if (a < b) {\n return b;\n } else {\n return a;\n }\n}\n\nint min(int a, int b) {\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\n\nvoid chmax(int *a, int b) {\n if (*a < b) {\n *a = b;\n }\n\n return;\n}\n\nvoid chmin(int *a, int b) {\n if (*a > b) {\n *a = b;\n }\n\n return;\n}\n\nint main(void) {\n int n;\n scanf(\"%d\", &n);\n int sum = 0;\n int m = n;\n for (int i = 0; i < 9; i++) {\n sum += n % 10;\n n /= 10;\n }\n if (m % sum == 0) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n return 0;\n}", "test_IO": [ { "input": "12\n", "output": "Yes\n" } ] }, { "id": "s746638117", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b, ar, le;\n scanf(\"%d %d\", &a, &b);\n ar = a * b;\n le = 2 * (a + b);\n printf(\"%d %d\\n\", ar, le);\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s762058481", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint chmin(int a, int b) {\n if (a > b)\n return b;\n else\n return a;\n}\n\nint main(int argc, char const *argv[]) {\n int n;\n scanf(\"%d\", &n);\n int dp[n];\n int h[n];\n for (int i = 0; i < n; ++i) dp[i] = 10000;\n\n for (int i = 0; i < n; ++i) scanf(\"%d\", &h[i]);\n\n dp[0] = 0;\n for (int i = 1; i < n; ++i) {\n if (i == 1)\n dp[1] = abs(h[1] - h[0]);\n else\n dp[i] = chmin(dp[i - 1] + abs(h[i] - h[i - 1]),\n dp[i - 2] + abs(h[i] - h[i - 2]));\n }\n printf(\"%d\\n\", dp[n - 1]);\n return 0;\n}", "test_IO": [ { "input": "4\n10 30 40 20\n", "output": "30\n" } ] }, { "id": "s012871529", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n printf(\"%d %d\\n\", a * b, 2 * (a + b));\n return 0;\n}", "test_IO": [ { "input": "3 5\n", "output": "15 16\n" } ] }, { "id": "s116510273", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n char mes[101];\n scanf(\"%s\", mes);\n printf(\"%c%lu%c\\n\", mes[0], strlen(mes) - 2, mes[strlen(mes) - 1]);\n\n return 0;\n}", "test_IO": [ { "input": "internationalization\n", "output": "i18n\n" } ] }, { "id": "s497921090", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n unsigned long long int n, a, b = 0, i, j;\n scanf(\"%llu\", &n);\n b = (n * (n - 1)) / 2;\n printf(\"%llu\\n\", b);\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "1\n" } ] }, { "id": "s403900151", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int n, r, p, c;\n int i, j, k, l;\n int a[51], b[51];\n\n while (1) {\n scanf(\"%d %d \", &n, &r);\n if (!n && !r) break;\n\n for (i = 0; i < n; i++) a[i] = i + 1;\n\n for (i = 0; i < r; i++) {\n scanf(\"%d %d \", &p, &c);\n\n for (j = 0; j < c; j++) b[j] = a[n - p - c + 1 + j];\n for (j = 0; j < p - 1; j++) a[n - p - c + 1 + j] = a[n - p + j + 1];\n for (j = n - p - c + 1 + j, k = 0; k < c; j++, k++) {\n a[j] = b[k];\n }\n }\n printf(\"%d\\n\", a[n - 1]);\n }\n return 0;\n}", "test_IO": [ { "input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n", "output": "4\n4\n" } ] }, { "id": "s113351650", "dataset": "codenet", "language": "C", "code": "#include \nint main(void) {\n int x;\n\n scanf(\"%d\", &x);\n\n if (x == 0) printf(\"1\\n\");\n if (x == 1) printf(\"0\\n\");\n\n return 0;\n}", "test_IO": [ { "input": "1\n", "output": "0\n" } ] }, { "id": "s132873327", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int x;\n\n scanf(\"%d\", &x);\n printf(\"%d\\n\", x * x * x);\n\n return 0;\n}", "test_IO": [ { "input": "2\n", "output": "8\n" } ] }, { "id": "s326049239", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint main() {\n int a, c, k, b;\n while (~scanf(\"%d\", &a)) {\n c = 0, k = 0;\n if (a < 3)\n printf(\"0\\n\");\n else {\n b = a;\n while (a--) {\n b--;\n c++;\n if (c == 3) {\n k++;\n c = 0;\n }\n }\n printf(\"%d\\n\", k);\n }\n }\n}", "test_IO": [ { "input": "8\n", "output": "2\n" } ] }, { "id": "s986241762", "dataset": "codenet", "language": "C", "code": "#include \nint main() {\n int n;\n long sum = 0;\n scanf(\"%d\", &n);\n int a[n];\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n for (int i = 1; i < n; i++) {\n if (a[i - 1] > a[i]) {\n sum += a[i - 1] - a[i];\n a[i] = a[i - 1];\n }\n }\n printf(\"%ld\\n\", sum);\n}", "test_IO": [ { "input": "5\n2 1 5 4 3\n", "output": "4\n" } ] }, { "id": "s858205159", "dataset": "codenet", "language": "C", "code": "#include \n#include \n#include \n\nstruct node {\n unsigned int key;\n struct node *next;\n struct node *prev;\n};\n\ntypedef struct node *NodePointer;\n\nNodePointer nil;\n\nNodePointer listSearch(int key) {\n NodePointer cur = nil->next;\n while (cur != nil) {\n if (cur->key == key) break;\n cur = cur->next;\n }\n return cur;\n}\n\nvoid init() {\n nil = (NodePointer)malloc(sizeof(struct node));\n nil->next = nil;\n nil->prev = nil;\n}\n\nvoid printList() {\n NodePointer cur = nil->next;\n int isf = 1;\n while (1) {\n if (cur == nil) break;\n if (isf == 0) printf(\" \");\n printf(\"%d\", cur->key);\n cur = cur->next;\n isf = 0;\n }\n printf(\"\\n\");\n}\n\nvoid deleteNode(NodePointer t) {\n if (t == nil) return;\n t->prev->next = t->next;\n t->next->prev = t->prev;\n free(t);\n}\n\nvoid deleteFirst() {\n NodePointer t = nil->next;\n if (t == nil) return;\n deleteNode(t);\n}\n\nvoid deleteLast() {\n NodePointer t = nil->prev;\n if (t == nil) return;\n deleteNode(t);\n}\n\nvoid deleteKey(int key) {\n NodePointer t = listSearch(key);\n if (t != nil) deleteNode(t);\n}\n\nvoid insert(int key) {\n NodePointer x;\n x = (NodePointer)malloc(sizeof(struct node));\n x->key = key;\n x->prev = nil;\n x->next = nil->next;\n x->next->prev = x;\n nil->next = x;\n}\n\nint main() {\n int key, n, i;\n int size = 0;\n char com[20];\n int np = 0, nd = 0;\n scanf(\"%d\", &n);\n init();\n for (i = 0; i < n; i++) {\n scanf(\"%s%d\", com, &key);\n if (com[0] == 'i') {\n insert(key);\n np++;\n size++;\n } else if (com[0] == 'd') {\n if (strlen(com) > 6) {\n if (com[6] == 'F')\n deleteFirst();\n else if (com[6] == 'L')\n deleteLast();\n } else {\n deleteKey(key);\n nd++;\n }\n size--;\n }\n }\n\n printList();\n return 0;\n}", "test_IO": [ { "input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n", "output": "6 1 2\n" } ] }, { "id": "s501370664", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nint *flag;\n\nvoid prime(int num) {\n int i, j;\n\n flag = (int *)calloc(sizeof(int), num + 1);\n\n for (i = 2; i * i <= num; i++) {\n if (flag[i] == 0) {\n for (j = 2; i * j <= num; j++) {\n flag[i * j] = 1;\n }\n }\n }\n}\n\nint main() {\n int n, i, cnt;\n\n prime(50000);\n\n while (1) {\n scanf(\"%d\", &n);\n if (n == 0) {\n break;\n }\n i = 2;\n cnt = 0;\n while (i * 2 <= n) {\n if (!flag[i] && !flag[n - i]) {\n cnt++;\n }\n i++;\n }\n printf(\"%d\\n\", cnt);\n }\n\n return 0;\n}", "test_IO": [ { "input": "10\n11\n0\n", "output": "2\n0\n" } ] }, { "id": "s669832162", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int m1, d1, m2, d2;\n scanf(\"%d%d%d%d\", &m1, &d1, &m2, &d2);\n if (m1 != m2)\n printf(\"1\\n\");\n else\n printf(\"0\\n\");\n}", "test_IO": [ { "input": "11 16\n11 17\n", "output": "0\n" } ] }, { "id": "s157790373", "dataset": "codenet", "language": "C", "code": "#include \n#define LEN 300\n#define TRUE 1\n#define FALSE -1\n\nint solve(int, int);\nint n, A[LEN];\nint flag;\n\nint main() {\n int q, M;\n int i, j, k;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) scanf(\"%d\", &A[i]);\n\n scanf(\"%d\", &q);\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &M);\n flag = FALSE;\n\n solve(-1, M);\n if (flag == TRUE)\n printf(\"yes\\n\");\n else\n printf(\"no\\n\");\n }\n\n return 0;\n}\n\nint solve(int i, int m) {\n if (i > n)\n return FALSE;\n else if (m < 0)\n return FALSE;\n else if (m == 0 || m - A[i + 1] == 0) {\n flag = TRUE;\n return TRUE;\n } else {\n solve(i + 1, m);\n\n solve(i + 1, m - A[i]);\n }\n}", "test_IO": [ { "input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n", "output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n" } ] }, { "id": "s622875333", "dataset": "codenet", "language": "C", "code": "#include \n\nint n, r, i, j, p, c;\nint a[100], b[100];\n\nint main() {\n while (1) {\n scanf(\"%d %d\", &n, &r);\n if (n == 0 && r == 0) break;\n\n for (i = 0; i < n; i++) {\n a[i] = n - i;\n }\n\n for (i = 0; i < r; i++) {\n for (j = 0; j < n; j++) {\n b[j] = a[j];\n }\n scanf(\"%d %d\", &p, &c);\n\n for (j = 0; j < c; j++) {\n a[j] = b[p - 1 + j];\n }\n\n for (j = c; j < c + p - 1; j++) {\n a[j] = b[j - c];\n }\n }\n printf(\"%d\\n\", a[0]);\n }\n return 0;\n}", "test_IO": [ { "input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n", "output": "4\n4\n" } ] }, { "id": "s044095882", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n long int n;\n\n scanf(\"%ld\", &n);\n long int a[n];\n long int count[n];\n\n for (long int i = 1; i < n; i++) scanf(\"%ld\", &a[i]);\n\n for (long int i = 0; i < n; i++) count[i] = 0;\n\n for (long int i = 1; i < n; i++) count[a[i] - 1]++;\n\n for (long int i = 0; i < n; i++) printf(\"%ld\\n\", count[i]);\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 1 2 2\n", "output": "2\n2\n0\n0\n0\n" } ] }, { "id": "s540088752", "dataset": "codenet", "language": "C", "code": "#include \n\nint main(void) {\n int N;\n scanf(\"%d\", &N);\n\n int A[N + 1];\n int B[N];\n int i;\n\n for (i = 0; i < N + 1; i++) {\n scanf(\"%d\", &A[i]);\n }\n\n for (i = 0; i < N; i++) {\n scanf(\"%d\", &B[i]);\n }\n\n long ans = 0;\n\n for (i = 0; i < N; i++) {\n if (A[i] >= B[i]) {\n ans = ans + B[i];\n A[i] = A[i] - B[i];\n B[i] = 0;\n } else {\n ans = ans + A[i];\n B[i] = B[i] - A[i];\n A[i] = 0;\n }\n\n if (A[i + 1] >= B[i]) {\n ans = ans + B[i];\n A[i + 1] = A[i + 1] - B[i];\n B[i] = 0;\n } else {\n ans = ans + A[i + 1];\n B[i] = B[i] - A[i + 1];\n A[i + 1] = 0;\n }\n }\n\n printf(\"%ld\\n\", ans);\n\n return 0;\n}", "test_IO": [ { "input": "2\n3 5 2\n4 5\n", "output": "9\n" } ] }, { "id": "s120311699", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int a, b, c;\n scanf(\"%d %d %d\", &a, &b, &c);\n\n if (a < b && b < c) {\n printf(\"Yes\\n\");\n } else {\n printf(\"No\\n\");\n }\n\n return 0;\n}", "test_IO": [ { "input": "1 3 8\n", "output": "Yes\n" } ] }, { "id": "s977107185", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int i, j, N, A[100], tmp, count = 0;\n\n scanf(\"%d\", &N);\n\n for (i = 0; i < N; i++) {\n scanf(\"%d\", &A[i]);\n }\n\n for (i = 0; i < N - 1; i++) {\n for (j = N - 1; j > i; j--) {\n if (A[j] < A[j - 1]) {\n tmp = A[j];\n A[j] = A[j - 1];\n A[j - 1] = tmp;\n\n count++;\n }\n }\n }\n\n for (i = 0; i < N; i++) {\n printf(\"%d\", A[i]);\n\n if (i < N - 1) printf(\" \");\n }\n\n printf(\"\\n\");\n\n printf(\"%d\\n\", count);\n\n return 0;\n}", "test_IO": [ { "input": "5\n5 3 2 4 1\n", "output": "1 2 3 4 5\n8\n" } ] }, { "id": "s858795471", "dataset": "codenet", "language": "C", "code": "#include \nint search(int A[], int n, int key) {\n int i = 0;\n A[n] = key;\n while (A[i] != key) i++;\n return i != n;\n}\n\nint main(void) {\n int n, A[10000 + 1], q, key, sum = 0;\n int i;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) scanf(\"%d\", &A[i]);\n scanf(\"%d\", &q);\n for (i = 0; i < q; i++) {\n scanf(\"%d\", &key);\n if (search(A, n, key)) sum++;\n }\n printf(\"%d\\n\", sum);\n\n return 0;\n}", "test_IO": [ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ] }, { "id": "s352097291", "dataset": "codenet", "language": "C", "code": "#include \n#include \nint main() {\n char c[11], ans[11] = {'\\0'};\n scanf(\"%s\", c);\n for (int i = 0; c[i] != '\\0'; i++) {\n if (c[i] != 'B')\n ans[strlen(ans)] = c[i];\n else\n ans[strlen(ans) - 1] = '\\0';\n }\n printf(\"%s\\n\", ans);\n}", "test_IO": [ { "input": "01B0\n", "output": "00\n" } ] }, { "id": "s575722828", "dataset": "codenet", "language": "C", "code": "#include \n\nint main() {\n int S;\n\n scanf(\"%d\", &S);\n\n printf(\"%d:%d:%d\\n\", (int)(S / 3600), (int)((S % 3600) / 60), S % 60);\n\n return 0;\n}", "test_IO": [ { "input": "46979\n", "output": "13:2:59\n" } ] }, { "id": "s436432602", "dataset": "codenet", "language": "C", "code": "#include \n#include \n\nvoid run(void) {\n int n, k;\n scanf(\"%d%d\", &n, &k);\n int a[100];\n int i, j;\n for (i = 0; i < n; i++) scanf(\"%d\", a + i);\n int *dp = (int *)calloc(k + 1, sizeof(int));\n for (i = 1; i <= k; i++) {\n int win = 0;\n for (j = 0; j < n && a[j] <= i; j++) {\n if (dp[i - a[j]] == 0) {\n win = 1;\n }\n }\n dp[i] = win;\n }\n printf(\"%s\\n\", dp[k] ? \"First\" : \"Second\");\n}\n\nint main(void) {\n run();\n return 0;\n}", "test_IO": [ { "input": "2 4\n2 3\n", "output": "First\n" } ] } ]