diff --git "a/languages/cpp/test_in_distribution.jsonl" "b/languages/cpp/test_in_distribution.jsonl" new file mode 100644--- /dev/null +++ "b/languages/cpp/test_in_distribution.jsonl" @@ -0,0 +1,1000 @@ +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s303282397", "group_id": "codeNet:p00005", "input_text": "#include\n\nusing namespace std;\n\nint main() {\n\tlong long int a, b, c, d, m, i;\n\twhile (cin >> a >> b) {\n\t\tfor (i = 0;i < b;i++) {\n\t\t\tfor (m = 0;m < a;m++) {\n\t\t\t\tif (a*(i + 1) == b*(m + 1)) {\n\t\t\t\t\tc = a*(i + 1);\n\t\t\t\t\ti = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i == -1) { break; }\n\t\t}\n\t\tif(a > b){\n\t\t\tfor (i = a;i > 0;i--) {\n\t\t\t\tif (a%i == 0 && b%i == 0) { break; }\n\t\t\t}\n\t\t}else{\n\t\t\tfor (i = b;i > 0;i--) {\n\t\t\t\tif (b%i == 0 && a%i == 0) { break; }\n\t\t\t}\n\t\t}\n\t\td = i;\n\t\tcout << d << ' ' << c << endl;\n\t} \n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1443893411, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p00005.html", "problem_id": "p00005", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00005/input.txt", "sample_output_relpath": "derived/input_output/data/p00005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00005/C++/s303282397.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s303282397", "user_id": "u256874901"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "#include\n\nusing namespace std;\n\nint main() {\n\tlong long int a, b, c, d, m, i;\n\twhile (cin >> a >> b) {\n\t\tfor (i = 0;i < b;i++) {\n\t\t\tfor (m = 0;m < a;m++) {\n\t\t\t\tif (a*(i + 1) == b*(m + 1)) {\n\t\t\t\t\tc = a*(i + 1);\n\t\t\t\t\ti = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i == -1) { break; }\n\t\t}\n\t\tif(a > b){\n\t\t\tfor (i = a;i > 0;i--) {\n\t\t\t\tif (a%i == 0 && b%i == 0) { break; }\n\t\t\t}\n\t\t}else{\n\t\t\tfor (i = b;i > 0;i--) {\n\t\t\t\tif (b%i == 0 && a%i == 0) { break; }\n\t\t\t}\n\t\t}\n\t\td = i;\n\t\tcout << d << ' ' << c << endl;\n\t} \n\treturn 0;\n}", "problem_context": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "sample_input": "8 6\n50000000 30000000\n"}, "reference_outputs": ["2 24\n10000000 150000000\n"], "source_document_id": "p00005", "source_text": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 5920, "memory_kb": 1156}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s368442390", "group_id": "codeNet:p00200", "input_text": "#include\n#include\n#include\n#include\nusing namespace std;\ntypedef pair P;\ntypedef struct{\n\tint next;\n\tint cost[2];\n}edge;\n\nint n,m;\nvector mapp[111];\nint bfs(int now,int goal,int k);\n\nint main(){\n\twhile(1){\n\t\tcin >> n >> m;\n\t\tif(n == 0 && m == 0) break;\n\t\tfor(int i=0;i> a >> b >> cost >> tim;\n\t\t\tedge x;\n\t\t\tx.next = a; x.cost[0] = cost; x.cost[1] = tim;\n\t\t\tmapp[b].push_back(x);\n\t\t\tx.next = b; x.cost[0] = cost; x.cost[1] = tim;\n\t\t\tmapp[a].push_back(x);\n\t\t}\n\t\tint k;\n\t\tcin >> k;\n\t\tint ans;\n\t\tfor(int i=0;i> p >> q >> r;\n\t\t\tif(r == 0) ans = bfs(p,q,r);\n\t\t\telse if(r == 1) ans = bfs(p,q,r);\n\t\t\tcout << ans << endl;\n\t\t}\n\t}\n}\n\nint bfs(int now,int goal,int k){\n\tvector min_cost;\n\tmin_cost.resize(m+1,-1);\n\tpriority_queue,greater

> que;\n\tque.push(P(0,now));\n\tmin_cost[now] = 0;\n\twhile(!que.empty()){\n\t\tP p = que.top(); que.pop();\n\t\tint no = p.second;\n\t\tint co = p.first;\n\t\tif(no == goal) return co;\n\t\tif(co > min_cost[no]) continue;\n\t\tint len=mapp[no].size();\n\t\tfor(int i=0;i\n#include\n#include\n#include\nusing namespace std;\ntypedef pair P;\ntypedef struct{\n\tint next;\n\tint cost[2];\n}edge;\n\nint n,m;\nvector mapp[111];\nint bfs(int now,int goal,int k);\n\nint main(){\n\twhile(1){\n\t\tcin >> n >> m;\n\t\tif(n == 0 && m == 0) break;\n\t\tfor(int i=0;i> a >> b >> cost >> tim;\n\t\t\tedge x;\n\t\t\tx.next = a; x.cost[0] = cost; x.cost[1] = tim;\n\t\t\tmapp[b].push_back(x);\n\t\t\tx.next = b; x.cost[0] = cost; x.cost[1] = tim;\n\t\t\tmapp[a].push_back(x);\n\t\t}\n\t\tint k;\n\t\tcin >> k;\n\t\tint ans;\n\t\tfor(int i=0;i> p >> q >> r;\n\t\t\tif(r == 0) ans = bfs(p,q,r);\n\t\t\telse if(r == 1) ans = bfs(p,q,r);\n\t\t\tcout << ans << endl;\n\t\t}\n\t}\n}\n\nint bfs(int now,int goal,int k){\n\tvector min_cost;\n\tmin_cost.resize(m+1,-1);\n\tpriority_queue,greater

> que;\n\tque.push(P(0,now));\n\tmin_cost[now] = 0;\n\twhile(!que.empty()){\n\t\tP p = que.top(); que.pop();\n\t\tint no = p.second;\n\t\tint co = p.first;\n\t\tif(no == goal) return co;\n\t\tif(co > min_cost[no]) continue;\n\t\tint len=mapp[no].size();\n\t\tfor(int i=0;i\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 \nusing namespace std;\n# define INF ((int)(1<<25))\n# define REP(i,n) for(int i=0;i<(int)n;i++)\n# define FOR(i,n) REP(i,n)\n# define TORAD 2.0*M_PI/360.0\n# define INT(x) int x;cin>>x;\n# define ALL(x) (x).begin(),(x).end()\n# define RALL(x) (x).rbegin(),(x).rend()\n# define DEBUG(x) cout<<#x<<\" :\"< void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef pair piii;\nint dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };\n\nsigned main()\n{\n\tint n;\n\twhile (cin >> n&&n)\n\t{\n\t\tint ans = 0;\n\t\tbool ok = false;\n\t\tFOR(i, n)\n\t\t{\n\t\t\tINT(x);\n\t\t\tif (x > 1)ok = true;\n\t\t\tif(x)ans++;\n\t\t}\n\t\tif (ok)cout << ans+1 << endl;\n\t\telse cout << \"NA\" << endl;\n\t}\n}", "language": "C++", "metadata": {"date": 1470894371, "filename_ext": "cpp", "original_language": "C++14", "problem_description_relpath": "problem_descriptions/p00274.html", "problem_id": "p00274", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00274/input.txt", "sample_output_relpath": "derived/input_output/data/p00274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00274/C++/s049135579.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s049135579", "user_id": "u195954908"}, "prompt_components": {"gold_output": "3\nNA\n2\n", "input_to_evaluate": "# define _CRT_SECUREj_NO_WARNINGS 1\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# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \nusing namespace std;\n# define INF ((int)(1<<25))\n# define REP(i,n) for(int i=0;i<(int)n;i++)\n# define FOR(i,n) REP(i,n)\n# define TORAD 2.0*M_PI/360.0\n# define INT(x) int x;cin>>x;\n# define ALL(x) (x).begin(),(x).end()\n# define RALL(x) (x).rbegin(),(x).rend()\n# define DEBUG(x) cout<<#x<<\" :\"< void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef pair piii;\nint dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };\n\nsigned main()\n{\n\tint n;\n\twhile (cin >> n&&n)\n\t{\n\t\tint ans = 0;\n\t\tbool ok = false;\n\t\tFOR(i, n)\n\t\t{\n\t\t\tINT(x);\n\t\t\tif (x > 1)ok = true;\n\t\t\tif(x)ans++;\n\t\t}\n\t\tif (ok)cout << ans+1 << endl;\n\t\telse cout << \"NA\" << endl;\n\t}\n}", "problem_context": "おそろいの景品\n\nジョウ君とヤエさんは仲の良いカップルです。ジョウ君はカプセル玩具自販機(ガチャポン)の景品を集めており、二人で出かけたときも、ガチャポンを見つけると何度かやってみるほどの熱の入りようです。ヤエさんは楽しそうなジョウ君をそばで見ているだけでしたが、ジョウ君の今度の誕生日プレゼントにガチャポンの景品をひとつあげることにしました。ヤエさんはガチャポン自体にはあまり興味がわきませんでしたが、できればジョウ君とおそろいの景品が欲しいと思っています。\n\nヤエさんがやってみようと思うガチャポンは、1回のチャレンジで景品がひとつ出ます。品切れのものも含め景品が何種類あるのかと、それぞれの景品がいくつ残っているのかはわかります。しかし、1回のチャレンジでどの景品が出るかはわかりません。そこで、景品が出る順番にかかわらず、ヤエさんが同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\nk1 k2 ... kN\n\n各データセットは2行であり、1行目に景品が何種類あるかを表す整数N(1 ≤ N ≤ 10000)が与えられる。続く1行に各景品がいくつ残っているのかを表す整数ki(0 ≤ ki ≤ 10000)が与えられる。\n\nデータセットの数は100を超えない。\n\n出力\n\nデータセットごとに、同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力する。ただし、不可能な場合はNAと出力する。\n\n入力例\n\n2\n3 2\n3\n0 1 1\n1\n1000\n0\n\n出力例\n\n3\nNA\n2\n\n1つ目のデータセットでは、運良く1種類目か2種類目の景品が連続で出て2回で済む可能性はあるが、同じ種類の景品を必ず2つ得るためには3回チャレンジする必要がある。\n\n2つ目のデータセットでは、2つ以上残っている景品がもともと無いので不可能である。\n\n3つ目のデータセットでは、景品は1種類だけなので2回のチャレンジでその景品が必ず2つ得られる。", "sample_input": "2\n3 2\n3\n0 1 1\n1\n1000\n0\n"}, "reference_outputs": ["3\nNA\n2\n"], "source_document_id": "p00274", "source_text": "おそろいの景品\n\nジョウ君とヤエさんは仲の良いカップルです。ジョウ君はカプセル玩具自販機(ガチャポン)の景品を集めており、二人で出かけたときも、ガチャポンを見つけると何度かやってみるほどの熱の入りようです。ヤエさんは楽しそうなジョウ君をそばで見ているだけでしたが、ジョウ君の今度の誕生日プレゼントにガチャポンの景品をひとつあげることにしました。ヤエさんはガチャポン自体にはあまり興味がわきませんでしたが、できればジョウ君とおそろいの景品が欲しいと思っています。\n\nヤエさんがやってみようと思うガチャポンは、1回のチャレンジで景品がひとつ出ます。品切れのものも含め景品が何種類ある���かと、それぞれの景品がいくつ残っているのかはわかります。しかし、1回のチャレンジでどの景品が出るかはわかりません。そこで、景品が出る順番にかかわらず、ヤエさんが同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\nk1 k2 ... kN\n\n各データセットは2行であり、1行目に景品が何種類あるかを表す整数N(1 ≤ N ≤ 10000)が与えられる。続く1行に各景品がいくつ残っているのかを表す整数ki(0 ≤ ki ≤ 10000)が与えられる。\n\nデータセットの数は100を超えない。\n\n出力\n\nデータセットごとに、同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力する。ただし、不可能な場合はNAと出力する。\n\n入力例\n\n2\n3 2\n3\n0 1 1\n1\n1000\n0\n\n出力例\n\n3\nNA\n2\n\n1つ目のデータセットでは、運良く1種類目か2種類目の景品が連続で出て2回で済む可能性はあるが、同じ種類の景品を必ず2つ得るためには3回チャレンジする必要がある。\n\n2つ目のデータセットでは、2つ以上残っている景品がもともと無いので不可能である。\n\n3つ目のデータセットでは、景品は1種類だけなので2回のチャレンジでその景品が必ず2つ得られる。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1296, "cpu_time_ms": 90, "memory_kb": 3124}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s781465824", "group_id": "codeNet:p00438", "input_text": "#include\n#include\nint hyou[16][16],A,B;\n\nint solve(int a,int b){\n\tif(hyou[a][b]==-1) return 0;\n\tif(a==0 || b==0) return 1;\n\treturn solve(a-1,b)+solve(a,b-1);\n}\nint main(){\n\tint n,a,b;\n\tscanf(\"%d%d\",&A,&B);\n\tif(A==0&&B==0)\treturn 0;\n\tmemset(hyou,0,sizeof(hyou));\n\tscanf(\"%d\",&n);\n\twhile(n--){\n\t\tscanf(\"%d%d\",&a,&b);\n\t\thyou[a-1][b-1]=-1;\n\t}\n\tprintf(\"%d\\n\",solve(A-1,B-1));\n\tmain();\n}", "language": "C++", "metadata": {"date": 1304931322, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p00438.html", "problem_id": "p00438", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00438/input.txt", "sample_output_relpath": "derived/input_output/data/p00438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00438/C++/s781465824.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s781465824", "user_id": "u611853667"}, "prompt_components": {"gold_output": "5\n5\n", "input_to_evaluate": "#include\n#include\nint hyou[16][16],A,B;\n\nint solve(int a,int b){\n\tif(hyou[a][b]==-1) return 0;\n\tif(a==0 || b==0) return 1;\n\treturn solve(a-1,b)+solve(a,b-1);\n}\nint main(){\n\tint n,a,b;\n\tscanf(\"%d%d\",&A,&B);\n\tif(A==0&&B==0)\treturn 0;\n\tmemset(hyou,0,sizeof(hyou));\n\tscanf(\"%d\",&n);\n\twhile(n--){\n\t\tscanf(\"%d%d\",&a,&b);\n\t\thyou[a-1][b-1]=-1;\n\t}\n\tprintf(\"%d\\n\",solve(A-1,B-1));\n\tmain();\n}", "problem_context": "通学経路\n\n問題\n\n太郎君の住んでいるJOI市は,南北方向にまっすぐに伸びる a 本の道路と,東西方向にまっすぐに伸びる b 本の道路により,碁盤の目の形に区分けされている.\n\n南北方向の a 本の道路には,西から順に 1, 2, ... , a の番号が付けられている.また,東西方向の b 本の道路には,南から順に 1, 2, ... , b の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路が交わる交差点を (i, j) で表す.\n\n太郎君は,交差点 (1, 1) の近くに住んでおり,交差点 (a, b) の近くのJOI高校に自転車で通っている.自転車は道路に沿ってのみ移動することができる.太郎君は,通学時間を短くするため,東または北にのみ向かって移動して通学している.\n\n現在, JOI市では, n 個の交差点 (x1, y1), (x2, y2), ... , (xn, yn) で工事を行っている.太郎君は工事中の交差点を通ることができない.\n\n太郎君が交差点 (1, 1) から交差点 (a, b) まで,工事中の交差点を避けながら,東または北にのみ向かっ���移動して通学する方法は何通りあるだろうか.太郎君の通学経路の個数 m を求めるプログラムを作成せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.入力はゼロを2つ含む行で終了する.\n\n1行目には,空白を区切りとして2個の整数 a, b が書かれている.これは,南北方向の道路の本数と,東西方向の道路の本数を表す. a, b は 1 ≤ a, b ≤ 16 をみたす.\n\n2行目には, 工事中の交差点の個数を表す整数 n が書かれている. n は 1 ≤ n ≤ 40 をみたす.\n\n続く n 行 (3行目から n+2 行目) には,工事中の交差点の位置が書かれている. i+2 行目には空白で区切られた整数 xi, yi が書かれており,交差点 (xi, yi) が工事中であることを表す. xi, yi は 1 ≤ xi, yi ≤ 16 をみたす.\n\nデータセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 太郎君の通学経路の個数 m を1行に出力する.\n\n入出力例\n\n入力例\n\n5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n\n出力例\n\n5\n5\n\n下図は a=5, b=4, n=3 で,工事中の交差点が (2,2), (2,3), (4,2) の場合を表している.\n\nこの場合,通学経路は m=5 通りある. 5通りの通学経路を全て図示すると,以下の通り.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n"}, "reference_outputs": ["5\n5\n"], "source_document_id": "p00438", "source_text": "通学経路\n\n問題\n\n太郎君の住んでいるJOI市は,南北方向にまっすぐに伸びる a 本の道路と,東西方向にまっすぐに伸びる b 本の道路により,碁盤の目の形に区分けされている.\n\n南北方向の a 本の道路には,西から順に 1, 2, ... , a の番号が付けられている.また,東西方向の b 本の道路には,南から順に 1, 2, ... , b の番号が付けられている.西から i 番目の南北方向の道路と,南から j 番目の東西方向の道路が交わる交差点を (i, j) で表す.\n\n太郎君は,交差点 (1, 1) の近くに住んでおり,交差点 (a, b) の近くのJOI高校に自転車で通っている.自転車は道路に沿ってのみ移動することができる.太郎君は,通学時間を短くするため,東または北にのみ向かって移動して通学している.\n\n現在, JOI市では, n 個の交差点 (x1, y1), (x2, y2), ... , (xn, yn) で工事を行っている.太郎君は工事中の交差点を通ることができない.\n\n太郎君が交差点 (1, 1) から交差点 (a, b) まで,工事中の交差点を避けながら,東または北にのみ向かって移動して通学する方法は何通りあるだろうか.太郎君の通学経路の個数 m を求めるプログラムを作成せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.入力はゼロを2つ含む行で終了する.\n\n1行目には,空白を区切りとして2個の整数 a, b が書かれている.これは,南北方向の道路の本数と,東西方向の道路の本数を表す. a, b は 1 ≤ a, b ≤ 16 をみたす.\n\n2行目には, 工事中の交差点の個数を表す整数 n が書かれている. n は 1 ≤ n ≤ 40 をみたす.\n\n続く n 行 (3行目から n+2 行目) には,工事中の交差点の位置が書かれている. i+2 行目には空白で区切られた整数 xi, yi が書かれており,交差点 (xi, yi) が工事中であることを表す. xi, yi は 1 ≤ xi, yi ≤ 16 をみたす.\n\nデータセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 太郎君の通学経路の個数 m を1行に出力する.\n\n入出力例\n\n入力例\n\n5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n\n出力例\n\n5\n5\n\n下図は a=5, b=4, n=3 で,工事中の交差点が (2,2), (2,3), (4,2) の場合を表している.\n\nこの場合,通学経路は m=5 通りある. 5通りの通学経路を全て図示すると,以下の通り.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 20, "memory_kb": 756}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s640004265", "group_id": "codeNet:p00447", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define INF_LL 9000000000000000000\n#define INF 2000000000\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\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair PII;\n\nclass Union_find{\nprivate:\n\tvector par;\n\tvector rank;\n\tint n;\n\npublic:\n\tUnion_find(int a){\n\t\tn = a;\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tpar.push_back(i);\n\t\t\trank.push_back(0);\n\t\t}\n\t}\n\n\tint find(int x){\n\t\tif(par[x] == x){\n\t\t\treturn x;\n\t\t}else{\n\t\t\treturn par[x] = find(par[x]);\n\t\t}\n\t}\n\n\tvoid unite(int x, int y){\n\t\tx = find(x);\n\t\ty = find(y);\n\t\tif(x == y) return;\n\n\t\tif(rank[x] < rank[y]){\n\t\t\tpar[x] = y;\n\t\t}else{\n\t\t\tpar[y] = x;\n\t\t\tif(rank[x] == rank[y]) rank[x]++;\n\t\t}\n\t}\n\n\tbool same(int x, int y){\n\t\treturn find(x) == find(y);\n\t}\n};\n\nstruct edge{int to, cost; };\n\nint main(void){\n\tint m;\n\twhile(cin >> m && m){\n\tint tx[200], ty[200];\n\tint n;\n\tmap > S;\n\tREP(i, m){\n\t\tcin >> tx[i] >> ty[i];\n\t}\n\tcin >> n;\n\tREP(i, n){\n\t\tint x, y;\n\t\tcin >> x >> y;\n\t\tS[x].push_back(y);\n\t}\n\tREP(i, 1000000){\n\t\tREP(j, S[i].size()){\n\t\t\tbool flag;\n\t\t\tint diff_x, diff_y;\n\t\t\tdiff_x = i-tx[0];\n\t\t\tdiff_y = S[i][j]-ty[0];\n\t\t\tFOR(k, 1, m){\n\t\t\t\tflag = false;\n\t\t\t\tREP(l, S[tx[k]+diff_x].size()){\n\t\t\t\t\tif(S[tx[k]+diff_x][l] == ty[k]+diff_y){\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!flag){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag){\n\t\t\t\tcout << diff_x << \" \" << diff_y << endl;\n\t\t\t\tj = S[i].size();\n\t\t\t\ti = 1000000;\n\t\t\t}\n\t\t}\n\t}\n\t}\n\n}", "language": "C++", "metadata": {"date": 1480342496, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p00447.html", "problem_id": "p00447", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00447/input.txt", "sample_output_relpath": "derived/input_output/data/p00447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00447/C++/s640004265.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s640004265", "user_id": "u379956761"}, "prompt_components": {"gold_output": "2 -3\n-384281 179674\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define INF_LL 9000000000000000000\n#define INF 2000000000\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\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair PII;\n\nclass Union_find{\nprivate:\n\tvector par;\n\tvector rank;\n\tint n;\n\npublic:\n\tUnion_find(int a){\n\t\tn = a;\n\t\tfor(int i = 0;i < n;i++){\n\t\t\tpar.push_back(i);\n\t\t\trank.push_back(0);\n\t\t}\n\t}\n\n\tint find(int x){\n\t\tif(par[x] == x){\n\t\t\treturn x;\n\t\t}else{\n\t\t\treturn par[x] = find(par[x]);\n\t\t}\n\t}\n\n\tvoid unite(int x, int y){\n\t\tx = find(x);\n\t\ty = find(y);\n\t\tif(x == y) return;\n\n\t\tif(rank[x] < rank[y]){\n\t\t\tpar[x] = y;\n\t\t}else{\n\t\t\tpar[y] = x;\n\t\t\tif(rank[x] == rank[y]) rank[x]++;\n\t\t}\n\t}\n\n\tbool same(int x, int y){\n\t\treturn find(x) == find(y);\n\t}\n};\n\nstruct edge{int to, cost; };\n\nint main(void){\n\tint m;\n\twhile(cin >> m && m){\n\tint tx[200], ty[200];\n\tint n;\n\tmap > S;\n\tREP(i, m){\n\t\tcin >> tx[i] >> ty[i];\n\t}\n\tcin >> n;\n\tREP(i, n){\n\t\tint x, y;\n\t\tcin >> x >> y;\n\t\tS[x].push_back(y);\n\t}\n\tREP(i, 1000000){\n\t\tREP(j, S[i].size()){\n\t\t\tbool flag;\n\t\t\tint diff_x, diff_y;\n\t\t\tdiff_x = i-tx[0];\n\t\t\tdiff_y = S[i][j]-ty[0];\n\t\t\tFOR(k, 1, m){\n\t\t\t\tflag = false;\n\t\t\t\tREP(l, S[tx[k]+diff_x].size()){\n\t\t\t\t\tif(S[tx[k]+diff_x][l] == ty[k]+diff_y){\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!flag){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag){\n\t\t\t\tcout << diff_x << \" \" << diff_y << endl;\n\t\t\t\tj = S[i].size();\n\t\t\t\ti = 1000000;\n\t\t\t}\n\t\t}\n\t}\n\t}\n\n}", "problem_context": "星座探し\n\n問題\n\nあなたは星空の写真の中から星座を探している.写真には必ず,探したい星座と同じ形・向き・大きさの図形がちょうど一つ含まれている.ただし,写真の中には星座を構成する星以外に余分な星が写っている可能性がある.\n\n例えば,図 1 の星座は図 2 の写真に含まれている(丸で囲んで示した).与えられた星座��星の座標を x 方向に 2, y 方向に −3 だけ平行移動すると写真の中の位置になる.\n\n探したい星座の形と写真に写っている星の位置が与えられたとき,星座の座標を写真の中の座標に変換するために平行移動するべき量を答えるプログラムを書け.\n\n図 1: 探したい星座\n\n図 2: 星空の写真\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の 1 行目には探したい星座を構成する星の個数 m が書かれている.続く m 行には探したい星座を構成する m 個の星の x 座標と y 座標を示す整数が空白区切りで書かれている. m+2 行目には写真に写っている星の個数 n が書かれている.続く n 行には写真に写っている n 個の星の x 座標と y 座標を示す整数が空白区切りで書かれている.\n\n星座を構成する m 個の星の位置はすべて異なる.また,写真に写っている n 個の星の位置はすべて異なる. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000 である.星の x 座標と y 座標はすべて 0 以上 1000000 以下である.\n\nm が 0 のとき入力の終わりを示す. データセットの数は 5 を超えない.\n\n出力\n\n各データセットの出力は 1 行からなり, 2 個の整数を空白区切りで書く.これらは探したい星座の座標をどれだけ平行移動すれば写真の中の座標になるかを表す.最初の整数が x 方向に平行移動する量,次の整数が y 方向に平行移動する量である.\n\n入出力例\n\n入力例\n\n5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 541942\n0\n\n出力例\n\n2 -3\n-384281 179674\n\n入出力例の1つ目は上の図に対応している.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 541942\n0\n"}, "reference_outputs": ["2 -3\n-384281 179674\n"], "source_document_id": "p00447", "source_text": "星座探し\n\n問題\n\nあなたは星空の写真の中から星座を探している.写真には必ず,探したい星座と同じ形・向き・大きさの図形がちょうど一つ含まれている.ただし,写真の中には星座を構成する星以外に余分な星が写っている可能性がある.\n\n例えば,図 1 の星座は図 2 の写真に含まれている(丸で囲んで示した).与えられた星座の星の座標を x 方向に 2, y 方向に −3 だけ平行移動すると写真の中の位置になる.\n\n探したい星座の形と写真に写っている星の位置が与えられたとき,星座の座標を写真の中の座標に変換するために平行移動するべき量を答えるプログラムを書け.\n\n図 1: 探したい星座\n\n図 2: 星空の写真\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の 1 行目には探したい星座を構成する星の個数 m が書かれている.続く m 行には探したい星座を構成する m 個の星の x 座標と y 座標を示す整数が空白区切りで書かれている. m+2 行目には写真に写っている星の個数 n が書かれている.続く n 行には写真に写っている n 個の星の x 座標と y 座標を示す整数が空白区切りで書かれている.\n\n星座を構成する m 個の星の位置はすべて異なる.また,写真に写っている n 個の星の位置はすべて異なる. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000 である.星の x 座標と y 座標はすべて 0 以上 1000000 以下である.\n\nm が 0 のとき入力の終わりを示す. データセットの数は 5 を超えない.\n\n出力\n\n各データセットの出力は 1 行からなり, 2 個の整数を空白区切りで書く.これらは探したい星座の座標をどれだけ平行移動すれば写真の中の座標になるかを表す.最初の整数が x 方向に平行移動する量,次の整数が y 方向に平行移動する量である.\n\n入出力例\n\n入力例\n\n5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n50795 541942\n0\n\n出力例\n\n2 -3\n-384281 179674\n\n入出力例の1つ目は上の図に対応している.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1625, "cpu_time_ms": 220, "memory_kb": 57728}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s781731732", "group_id": "codeNet:p00451", "input_text": "//JOI 0528 Common Sub-String\n#include \n#include \n#include \nusing namespace std;\nint main() {\n\tstring s, t;\n\tfor(int o=0;o<4;o++){\n cin>>s>>t;\n\t\tint roop1=0, save=0, ans = 0;\n\tfor (int i = 0; i\n#include \n#include \nusing namespace std;\nint main() {\n\tstring s, t;\n\tfor(int o=0;o<4;o++){\n cin>>s>>t;\n\t\tint roop1=0, save=0, ans = 0;\n\tfor (int i = 0; i\nusing namespace std;\n#define ll long long\n#define M INT_MAX\nint dp[10002][5001][2];\nint main(void){\n\tint n,nn,ti[10001],i,j,k,t,mi;\n\tcin>>n;\n\tnn=n/2;\n\tfor(i=1;i>ti[i];\n\tti[n]=0;\n\tfor(i=0;i<=n;i++){\n\t\tfor(j=0;j<=nn;j++) dp[i][j][0]=M,dp[i][j][1]=M;\n\t}\n\tdp[1][1][0]=ti[1];\n\tfor(i=1;i\nusing namespace std;\n#define ll long long\n#define M INT_MAX\nint dp[10002][5001][2];\nint main(void){\n\tint n,nn,ti[10001],i,j,k,t,mi;\n\tcin>>n;\n\tnn=n/2;\n\tfor(i=1;i>ti[i];\n\tti[n]=0;\n\tfor(i=0;i<=n;i++){\n\t\tfor(j=0;j<=nn;j++) dp[i][j][0]=M,dp[i][j][1]=M;\n\t}\n\tdp[1][1][0]=ti[1];\n\tfor(i=1;i\nusing namespace std;\n\ninline string toString(int a){\n stringstream ss;\n ss << a;\n return ss.str();\n}\n\ninline int toInt(string s){\n stringstream ss(s);\n int res;\n ss >> res;\n return res;\n}\n\ninline bool is_prime(int 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\nint rec(int d, int n, string s, string c){\n if(n>4)return -1;\n if(d==n){\n string pal = s + c;\n reverse(s.begin(),s.end());\n pal += s;\n int p = toInt(pal);\n return is_prime(p)?p:-1;\n }\n\n int res = -1;\n for(int i=0;i<10;i++){\n if(d==0 && (i%2==0 || i%5==0))continue;\n res = max( res, rec(d+1, n, s + toString(i), c) );\n }\n return res;\n}\n\nint main(){\n int n,c;\n cin >> n >> c;\n string center = (c<0)?\"\":toString(c);\n int res = rec(0,n,\"\",center);\n\n if(res<0){\n for(int i=0;i\nusing namespace std;\n\ninline string toString(int a){\n stringstream ss;\n ss << a;\n return ss.str();\n}\n\ninline int toInt(string s){\n stringstream ss(s);\n int res;\n ss >> res;\n return res;\n}\n\ninline bool is_prime(int 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\nint rec(int d, int n, string s, string c){\n if(n>4)return -1;\n if(d==n){\n string pal = s + c;\n reverse(s.begin(),s.end());\n pal += s;\n int p = toInt(pal);\n return is_prime(p)?p:-1;\n }\n\n int res = -1;\n for(int i=0;i<10;i++){\n if(d==0 && (i%2==0 || i%5==0))continue;\n res = max( res, rec(d+1, n, s + toString(i), c) );\n }\n return res;\n}\n\nint main(){\n int n,c;\n cin >> n >> c;\n string center = (c<0)?\"\":toString(c);\n int res = rec(0,n,\"\",center);\n\n if(res<0){\n for(int i=0;i\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<(int)n;++i)\n#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define ALL(c) (c).begin(), (c).end()\nconst int INF = 1<<29;\n\nint main() {\n int n, U;\n while(cin>>n>>U, n||U) {\n int bitmask[n];\n int c[n];\n memset(bitmask,0,sizeof(bitmask));\n REP(i,n) {\n int k;\n cin >> c[i] >> k;\n REP(j,k) {\n int r;\n cin >> r;\n bitmask[i] |= 1<>i&1) {\n if (S&bitmask[i] != bitmask[i]) {\n dame = 1;\n break;\n }\n sum += c[i];\n }\n }\n if (!dame && sum >= U) {\n ok = 1;\n res = k;\n break;\n }\n int x = S&-S, y=S+x;\n S = ((S & ~y) / x >> 1) | y;\n }\n if (ok) break;\n }\n cout << res << endl;\n }\n}", "language": "C++", "metadata": {"date": 1312254351, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p00618.html", "problem_id": "p00618", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00618/input.txt", "sample_output_relpath": "derived/input_output/data/p00618/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00618/C++/s297424838.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s297424838", "user_id": "u505648358"}, "prompt_components": {"gold_output": "2\n3\n", "input_to_evaluate": "#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<(int)n;++i)\n#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define ALL(c) (c).begin(), (c).end()\nconst int INF = 1<<29;\n\nint main() {\n int n, U;\n while(cin>>n>>U, n||U) {\n int bitmask[n];\n int c[n];\n memset(bitmask,0,sizeof(bitmask));\n REP(i,n) {\n int k;\n cin >> c[i] >> k;\n REP(j,k) {\n int r;\n cin >> r;\n bitmask[i] |= 1<>i&1) {\n if (S&bitmask[i] != bitmask[i]) {\n dame = 1;\n break;\n }\n sum += c[i];\n }\n }\n if (!dame && sum >= U) {\n ok = 1;\n res = k;\n break;\n }\n int x = S&-S, y=S+x;\n S = ((S & ~y) / x >> 1) | y;\n }\n if (ok) break;\n }\n cout << res << endl;\n }\n}", "problem_context": "Problem D: Course Planning for Lazy Students\n\n会津大学では2009年度より、授業履修に関する新しい制度を開始した。新制度では必修科目を撤廃���、それぞれの進路を考慮して科目を自由に選択できるようになった。\n\nしかし、どの科目も無条件で履修できるわけではなく、特定の科目を履修するためには、先修条件を満たしている必要がある。下図に履修計画表の一部の例を示す:\n\n図の長方形が1つの科目を表し科目名と単位数を含んでいる。図の矢印が先修条件を表す。矢印の意味は、矢印の終点で指されている科目を履修するためには、その矢印の始点を示す科目を修得している必要がある。例えば、Linear Algebra II (線形代数2)を履修するためには、Linear Algebra I (線形代数1)を修得している必要がある。また、Applied Algebra (応用代数)を履修するためには、Linear Algebra I と Discrete Systems (離散系論)の両方を修得している必要がある。\n\nさて、履修登録計画において卒業に要する最低限の合計単位数 U を満たす履修科目の組み合わせは、怠慢な学生にとって興味深いものである。\n\nあなたの仕事は、与えられた履修計画表と U を読み込み、最低限の履修科目数を報告するプログラムを作成することである。これは計画であるため、履修登録した科目は必ず単位を修得できるものと仮定する。\n\nInput\n\n入力は複数のデータセットからなる。各データセットは以下の形式で与えられる:\n\nn U\n\nc0 k0 r01 r02 ... r0k0\n\nc1 k1 r11 r12 ... r1k1\n\n.\n\n.\n\ncn-1 kn-1 r(n-1)1 r(n-1)2 ... r(n-1)kn-1\n\nn (1 ≤ n ≤ 20) は履修計画表が含む科目の数を示す整数である。科目には 0 から n-1 までの番号が割り当てられているものとし、以下 i 番目の科目を科目 i と呼ぶことにする。\n\nU (1 ≤ U ≤ 100) は必要な合計単位数を表す整数である。\n\nci (1 ≤ ci ≤ 10)は科目 i の単位数を示す。次の ki (0 ≤ ki ≤ 5) は科目 i の先修科目の数を示す。それに続く ri1 ri2 ... riki は科目 i の先修科目の科目番号を示す。\n\nある科目から先修条件を表す矢印を1つ以上たどり、再びその科目に戻るような入力は与えられない。また、U を満たす科目の組み合わせが必ず存在すると仮定してよい。\n\nn と U がともに 0 のとき入力の終わりを示す。データセットの数は 100 を超えない。\n\nOutput\n\n各データセットについて、最低限必要な科目数を1行に出力せよ。\n\nSample Input\n\n4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 6\n1 0\n3 2 0 2\n2 0\n0 0\n\nOutput for the Sample Input\n\n2\n3", "sample_input": "4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 6\n1 0\n3 2 0 2\n2 0\n0 0\n"}, "reference_outputs": ["2\n3\n"], "source_document_id": "p00618", "source_text": "Problem D: Course Planning for Lazy Students\n\n会津大学では2009年度より、授業履修に関する新しい制度を開始した。新制度では必修科目を撤廃し、それぞれの進路を考慮して科目を自由に選択できるようになった。\n\nしかし、どの科目も無条件で履修できるわけではなく、特定の科目を履修するためには、先修条件を満たしている必要がある。下図に履修計画表の一部の例を示す:\n\n図の長方形が1つの科目を表し科目名と単位数を含んでいる。図の矢印が先修条件を表す。矢印の意味は、矢印の終点で指されている科目を履修するためには、その矢印の始点を示す科目を修得している必要がある。例えば、Linear Algebra II (線形代数2)を履修するためには、Linear Algebra I (線形代数1)を修得している必要がある。また、Applied Algebra (応用代数)を履修するためには、Linear Algebra I と Discrete Systems (離散系論)の両方を修得している必要がある。\n\nさて、履修登録計画において卒業に要する最低限の合計単位数 U を満たす履修科目の組み合わせは、怠慢な学生にとって興味深いものである。\n\nあなたの仕事は、与えられた履修計画表と U を読み込み、最低限の履修科目数を報告するプログラムを作成することである。これは計画であるため、履修登録した科目は必ず単位を修得できるものと仮定する。\n\nInput\n\n入力は複数のデータセットからなる。各データセットは以下の形式で与えられる:\n\nn U\n\nc0 k0 r01 r02 ... r0k0\n\nc1 k1 r11 r12 ... r1k1\n\n.\n\n.\n\ncn-1 kn-1 r(n-1)1 r(n-1)2 ... r(n-1)kn-1\n\nn (1 ≤ n ≤ 20) は履修計画表が含む科目の数を示す整数である。科目には 0 から n-1 までの番号が割り当てられているものとし、以下 i 番目の科目を科目 i と呼ぶことにする。\n\nU (1 ≤ U ≤ 100) は必要な合計単位数を表す整数である。\n\nci (1 ≤ ci ≤ 10)は科目 i の単位数��示す。次の ki (0 ≤ ki ≤ 5) は科目 i の先修科目の数を示す。それに続く ri1 ri2 ... riki は科目 i の先修科目の科目番号を示す。\n\nある科目から先修条件を表す矢印を1つ以上たどり、再びその科目に戻るような入力は与えられない。また、U を満たす科目の組み合わせが必ず存在すると仮定してよい。\n\nn と U がともに 0 のとき入力の終わりを示す。データセットの数は 100 を超えない。\n\nOutput\n\n各データセットについて、最低限必要な科目数を1行に出力せよ。\n\nSample Input\n\n4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 6\n1 0\n3 2 0 2\n2 0\n0 0\n\nOutput for the Sample Input\n\n2\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1395, "cpu_time_ms": 1700, "memory_kb": 864}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s213436257", "group_id": "codeNet:p00653", "input_text": "#include\nusing namespace std;\ntypedef vectorvi;\ntypedef vectorvvi;\n\nconst int B=80;\nint H,W,Q;\nvi *fld,*bucket;\n\nbool solve(){\n scanf(\"%d%d%d\",&H,&W,&Q);\n if(H==0&&W==0&&Q==0)return false;\n fld=new vi[H];\n bucket=new vi[H/B+1];\n fill_n(fld,H,vi(W));\n fill_n(bucket,H/B+1,vi(W/B+1,INT_MAX));\n vi latte(H/B+1,INT_MAX);\n vi malta(W/B+1,INT_MAX);\n for(int i=0;i\nusing namespace std;\ntypedef vectorvi;\ntypedef vectorvvi;\n\nconst int B=80;\nint H,W,Q;\nvi *fld,*bucket;\n\nbool solve(){\n scanf(\"%d%d%d\",&H,&W,&Q);\n if(H==0&&W==0&&Q==0)return false;\n fld=new vi[H];\n bucket=new vi[H/B+1];\n fill_n(fld,H,vi(W));\n fill_n(bucket,H/B+1,vi(W/B+1,INT_MAX));\n vi latte(H/B+1,INT_MAX);\n vi malta(W/B+1,INT_MAX);\n for(int i=0;i 250000, Input consists of only that case.\n\nOutput\n\nFor each query you should print the lowest value in the subgrid in a line.\n\nSample input\n\n3 3 4\n1 2 3\n4 2 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0\n\nSample output\n\n1\n1\n4\n2\n1\n1\n6\n5", "sample_input": "3 3 4\n1 2 3\n4 2 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0\n"}, "reference_outputs": ["1\n1\n4\n2\n1\n1\n6\n5\n"], "source_document_id": "p00653", "source_text": "Problem G: School of Killifish\n\nJon is the leader of killifish.\nJon have a problem in these days.\nJon has a plan to built new town in a pond.\nOf course new towns should have a school for children. But there are some natural enemies in a pond.\nJon thinks that the place of a school should be the safest place in a pond for children.\n\nJon has asked by some construction companies to make construction plans and Jon has q construction plans now.\nThe plan is selected by voting. But for each plan, the safest place for the school should be decided before voting.\n\nA pond is expressed by a 2D grid whose size is r*c.\nThe grid has r rows and c columns. The coordinate of the top-left cell is (0,0). The coordinate of the bottom-right cell is expressed as (r-1,c-1).\nEach cell has an integer which implies a dangerousness.\nThe lower value implies safer than the higher value.\nq plans are given by four integer r1 ,c1 ,r2 and c2 which represent the subgrid.\nThe top-left corner is (r1,c1) and the bottom-right corner is (r2,c2).\n\nYou have the r*c grid and q plans. Your task is to find the safest point for each plan.\nYou should find the lowest value in the subgrid.\n\nInput\n\nInput consists of multiple datasets.\n\nEach dataset is given in the following format.\n\nr c q\ngrid0,0 grid0,1 ... grid0,c-1\n...\ngridr-1,0 ... gridr-1,c-1\nr1 c1 r2 c2\n...\nr1 c1 r2 c2\n\nThe first line consists of 3 integers, r ,c , and q .\nNext r lines have c integers.\ngridi,j means a dangerousness of the grid.\nAnd you can assume 0 ≤ gridi,j ≤ 231-1.\nAfter that, q queries, r1, c1, r2 and c2, are given.\n\nThe dataset satisfies following constraints.\n\nr*c ≤ 106\n\nq ≤ 104\n\nFor each query, you can assume that r1≤ r2 and c1 ≤ c2 .\n\nIf r * c ≤ 250000, q ≤ 100 is assured.\nIf r * c > 250000, Input consists of only that case.\n\nOutput\n\nFor each query you should print the lowest value in the subgrid in a line.\n\nSample input\n\n3 3 4\n1 2 3\n4 2 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0\n\nSample output\n\n1\n1\n4\n2\n1\n1\n6\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2409, "cpu_time_ms": 19370, "memory_kb": 56632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s744124738", "group_id": "codeNet:p00660", "input_text": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint dicea[6],diceb[6];\nstring str[21];\nint mk_num(string *);\n\nvoid lr_hanten(string a[]){\n for(int i=0;i<7;i++)\n for(int j=0;j<7/2;j++) swap(a[i][j],a[i][6-j]);\n}\n\nvoid ud_hanten(string a[]){\n for(int i=0;i<7;i++) \n for(int j=0;j<7/2;j++) swap(a[j][i],a[6-j][i]);\n}\n\nvoid rol_90(string a[]){\n string b[7];\n for(int i=0;i<7;i++)\n for(int j=0;j<7;j++) {\n b[i] += a[j][6-i];\n if(b[i][j] == '-') b[i][j] = '|';\n else if(b[i][j] =='|') b[i][j] = '-';\n }\n for(int i=0;i<7;i++) a[i] = b[i];\n}\n\nvoid choice(string num[],int x,int y){\n for(int i=0;i<7;i++){\n num[i]=\"\";\n for(int j=0;j<7;j++) num[i]+=str[y+i][x+j];\n }\n}\n\nvoid mk_dice(){\n string num[2][7];\n //ue\n choice(num[0],7,0),choice(num[1],36,0);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[0] = mk_num(num[0]),diceb[0]=mk_num(num[1]);\n \n //hidari\n choice(num[0],0,7),choice(num[1],29,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n rol_90(num[0]),rol_90(num[1]);\n dicea[1] = mk_num(num[0]),diceb[1] = mk_num(num[1]);\n\n //mid_hidari\n choice(num[0],7,7),choice(num[1],36,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[2] = mk_num(num[0]),diceb[2] = mk_num(num[1]);\n\n //mid_migi\n choice(num[0],14,7),choice(num[1],43,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n for(int i=0;i<3;i++)rol_90(num[0]),rol_90(num[1]);\n dicea[3] = mk_num(num[0]),diceb[3] = mk_num(num[1]);\n\n //migi\n choice(num[0],21,7),choice(num[1],50,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[4] = mk_num(num[0]),diceb[4] = mk_num(num[1]);\n\n\n //sita\n choice(num[0],7,14),choice(num[1],36,14);\n ud_hanten(num[0]),ud_hanten(num[1]);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[5] = mk_num(num[0]),diceb[5] = mk_num(num[1]);\n}\n\nint main(){\n srand((unsigned)time(NULL));\n while(1) {\n for(int i=0;i<21;i++){\n cin >> str[i];\n if(str[i]==\"0\")break;\n }\n if(str[0]==\"0\")break;\n mk_dice();\n int a=0,b=0;\n for(int i=0;i<6;i++) assert(dicea[i]!=-1 && diceb[i]!=-1);\n\n int arr[6]={};\n for(int i=0;i<100000;i++){\n arr[rand()%6]++;\n if(dicea[rand()%6] > diceb[rand()%6]) a++;\n else if(dicea[rand()%6]b-500) cout<<\"HIGH\"<\n#include \n#include \n#include \n#include \nusing namespace std;\nint dicea[6],diceb[6];\nstring str[21];\nint mk_num(string *);\n\nvoid lr_hanten(string a[]){\n for(int i=0;i<7;i++)\n for(int j=0;j<7/2;j++) swap(a[i][j],a[i][6-j]);\n}\n\nvoid ud_hanten(string a[]){\n for(int i=0;i<7;i++) \n for(int j=0;j<7/2;j++) swap(a[j][i],a[6-j][i]);\n}\n\nvoid rol_90(string a[]){\n string b[7];\n for(int i=0;i<7;i++)\n for(int j=0;j<7;j++) {\n b[i] += a[j][6-i];\n if(b[i][j] == '-') b[i][j] = '|';\n else if(b[i][j] =='|') b[i][j] = '-';\n }\n for(int i=0;i<7;i++) a[i] = b[i];\n}\n\nvoid choice(string num[],int x,int y){\n for(int i=0;i<7;i++){\n num[i]=\"\";\n for(int j=0;j<7;j++) num[i]+=str[y+i][x+j];\n }\n}\n\nvoid mk_dice(){\n string num[2][7];\n //ue\n choice(num[0],7,0),choice(num[1],36,0);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[0] = mk_num(num[0]),diceb[0]=mk_num(num[1]);\n \n //hidari\n choice(num[0],0,7),choice(num[1],29,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n rol_90(num[0]),rol_90(num[1]);\n dicea[1] = mk_num(num[0]),diceb[1] = mk_num(num[1]);\n\n //mid_hidari\n choice(num[0],7,7),choice(num[1],36,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[2] = mk_num(num[0]),diceb[2] = mk_num(num[1]);\n\n //mid_migi\n choice(num[0],14,7),choice(num[1],43,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n for(int i=0;i<3;i++)rol_90(num[0]),rol_90(num[1]);\n dicea[3] = mk_num(num[0]),diceb[3] = mk_num(num[1]);\n\n //migi\n choice(num[0],21,7),choice(num[1],50,7);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[4] = mk_num(num[0]),diceb[4] = mk_num(num[1]);\n\n\n //sita\n choice(num[0],7,14),choice(num[1],36,14);\n ud_hanten(num[0]),ud_hanten(num[1]);\n lr_hanten(num[0]),lr_hanten(num[1]);\n dicea[5] = mk_num(num[0]),diceb[5] = mk_num(num[1]);\n}\n\nint main(){\n srand((unsigned)time(NULL));\n while(1) {\n for(int i=0;i<21;i++){\n cin >> str[i];\n if(str[i]==\"0\")break;\n }\n if(str[0]==\"0\")break;\n mk_dice();\n int a=0,b=0;\n for(int i=0;i<6;i++) assert(dicea[i]!=-1 && diceb[i]!=-1);\n\n int arr[6]={};\n for(int i=0;i<100000;i++){\n arr[rand()%6]++;\n if(dicea[rand()%6] > diceb[rand()%6]) a++;\n else if(dicea[rand()%6]b-500) cout<<\"HIGH\"<\nusing namespace std;\n\n#define rep(i,x,y) for(int i=(x);i<(y);++i)\n#define debug(x) #x << \"=\" << (x)\n\n#ifdef DEBUG\n#define _GLIBCXX_DEBUG\n#define dump(x) std::cerr << debug(x) << \" (L:\" << __LINE__ << \")\" << std::endl\n#else\n#define dump(x)\n#endif\n\ntypedef long long int ll;\ntypedef pair pii;\n//template using vec=std::vector;\n\nconst int inf=1<<30;\nconst long long int infll=1LL<<58;\nconst double eps=1e-9;\nconst int dx[]={1,0,-1,0},dy[]={0,1,0,-1};\n\ntemplate ostream &operator<<(ostream &os, const vector &vec){\n\tos << \"[\";\n\tfor (const auto &v : vec) {\n\t\tos << v << \",\";\n\t}\n\tos << \"]\";\n\treturn os;\n}\n\nint p,q,a,n;\n\nint dfs(int denom,int numer,int prev,int product,int num){\n {\n int tmp1=denom*prev,tmp2=numer*prev+denom*num;\n if((double)tmp2/tmp1+eps<(double)p/q) return 0;\n }\n if((double)numer/denom-eps>(double)p/q) return 0;\n\n int res=0;\n if((double)p/q-eps<=(double)numer/denom and (double)numer/denom<=(double)p/q+eps) ++res;\n if(num==0) return res;\n\n int x=prev;\n while(true){\n if(product*x>a) break;\n res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);\n ++x;\n }\n return res;\n}\n\nvoid solve(){\n while(cin >> p >> q >> a >> n){\n if(p==0 and q==0 and a==0 and n==0) break;\n cout << dfs(1,0,1,1,n) << endl;\n }\n}\n\nint main(){\n\tstd::ios::sync_with_stdio(false);\n\tstd::cin.tie(0);\n\tsolve();\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1448088137, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p00712.html", "problem_id": "p00712", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00712/input.txt", "sample_output_relpath": "derived/input_output/data/p00712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00712/C++/s097037505.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s097037505", "user_id": "u313705878"}, "prompt_components": {"gold_output": "4\n7\n6\n2\n42\n1\n0\n9\n3\n", "input_to_evaluate": "#include \nusing namespace std;\n\n#define rep(i,x,y) for(int i=(x);i<(y);++i)\n#define debug(x) #x << \"=\" << (x)\n\n#ifdef DEBUG\n#define _GLIBCXX_DEBUG\n#define dump(x) std::cerr << debug(x) << \" (L:\" << __LINE__ << \")\" << std::endl\n#else\n#define dump(x)\n#endif\n\ntypedef long long int ll;\ntypedef pair pii;\n//template using vec=std::vector;\n\nconst int inf=1<<30;\nconst long long int infll=1LL<<58;\nconst double eps=1e-9;\nconst int dx[]={1,0,-1,0},dy[]={0,1,0,-1};\n\ntemplate ostream &operator<<(ostream &os, const vector &vec){\n\tos << \"[\";\n\tfor (const auto &v : vec) {\n\t\tos << v << \",\";\n\t}\n\tos << \"]\";\n\treturn os;\n}\n\nint p,q,a,n;\n\nint dfs(int denom,int numer,int prev,int product,int num){\n {\n int tmp1=denom*prev,tmp2=numer*prev+denom*num;\n if((double)tmp2/tmp1+eps<(double)p/q) return 0;\n }\n if((double)numer/denom-eps>(double)p/q) return 0;\n\n int res=0;\n if((double)p/q-eps<=(double)numer/denom and (double)numer/denom<=(double)p/q+eps) ++res;\n if(num==0) return res;\n\n int x=prev;\n while(true){\n if(product*x>a) break;\n res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);\n ++x;\n }\n return res;\n}\n\nvoid solve(){\n while(cin >> p >> q >> a >> n){\n if(p==0 and q==0 and a==0 and n==0) break;\n cout << dfs(1,0,1,1,n) << endl;\n }\n}\n\nint main(){\n\tstd::ios::sync_with_stdio(false);\n\tstd::cin.tie(0);\n\tsolve();\n\treturn 0;\n}", "problem_context": "Problem C: Unit Fraction Partition\n\nA fraction whose numerator is 1\nand whose denominator is a positive integer\nis called a unit fraction.\nA representation of a positive rational number\np/q\nas the sum of finitely many unit fractions is called a partition of\np/q\ninto unit fractions.\nFor example,\n1/2 + 1/6\nis a partition of\n2/3\ninto unit fractions.\nThe difference in the order of addition is disregarded.\nFor example, we do not distinguish\n1/6 + 1/2\nfrom\n1/2 + 1/6.\n\nFor given four positive integers\np,\nq,\na, and\nn,\ncount the number\nof partitions of\np/q\ninto unit fractions satisfying the following two conditions.\n\nThe partition is the sum of at most\nn\nmany unit fractions.\n\nThe product of the denominators of the unit fractions in the\npartition is less than or equal to\na.\n\nFor example, if\n(p,q,a,n) = (2,3,120,3),\nyou should report 4 since\n\nenumerates all of the valid partitions.\n\nInput\n\nThe input is a sequence of at most 1000 data sets followed by a terminator.\n\nA data set is a line containing four positive integers\np,\nq,\na, and\nn\nsatisfying\np,q <= 800,\na <= 12000\nand\nn <= 7.\nThe integers are separated by a space.\n\nThe terminator is composed of just one line\nwhich contains four zeros separated by a space.\nIt is not a part of the input data but a mark for the end of the input.\n\nOutput\n\nThe output should be composed of lines\neach of which contains a single integer.\nNo other characters should appear in the output.\n\nThe output integer corresponding to a data set\np,\nq,\na,\nn\nshould be the number of all partitions of\np/q\ninto at most\nn\nmany unit fractions such that the product of the denominators of the\nunit fractions is less than or equal to\na.\n\nSample Input\n\n2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 795 12000 7\n2 3 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0\n\nOutput for the Sample Input\n\n4\n7\n6\n2\n42\n1\n0\n9\n3", "sample_input": "2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 795 12000 7\n2 3 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0\n"}, "reference_outputs": ["4\n7\n6\n2\n42\n1\n0\n9\n3\n"], "source_document_id": "p00712", "source_text": "Problem C: Unit Fraction Partition\n\nA fraction whose numerator is 1\nand whose denominator is a positive integer\nis called a unit fraction.\nA representation of a positive rational number\np/q\nas the sum of finitely many unit fractions is called a partition of\np/q\ninto unit fractions.\nFor example,\n1/2 + 1/6\nis a partition of\n2/3\ninto unit fractions.\nThe difference in the order of addition is disregarded.\nFor example, we do not distinguish\n1/6 + 1/2\nfrom\n1/2 + 1/6.\n\nFor given four positive integers\np,\nq,\na, and\nn,\ncount the number\nof partitions of\np/q\ninto unit fractions satisfying the following two conditions.\n\nThe partition is the sum of at most\nn\nmany unit fractions.\n\nThe product of the denominators of the unit fractions in the\npartition is less than or equal to\na.\n\nFor example, if\n(p,q,a,n) = (2,3,120,3),\nyou should report 4 since\n\nenumerates all of the valid partitions.\n\nInput\n\nThe input is a sequence of at most 1000 data sets followed by a terminator.\n\nA data set is a line containing four positive integers\np,\nq,\na, and\nn\nsatisfying\np,q <= 800,\na <= 12000\nand\nn <= 7.\nThe integers are separated by a space.\n\nThe terminator is composed of just one line\nwhich contains four zeros separated by a space.\nIt is not a part of the input data but a mark for the end of the input.\n\nOutput\n\nThe output should be composed of lines\neach of which contains a single integer.\nNo other characters should appear in the output.\n\nThe output integer corresponding to a data set\np,\nq,\na,\nn\nshould be the number of all partitions of\np/q\ninto at most\nn\nmany unit fractions such that the product of the denominators of the\nunit fractions is less than or equal to\na.\n\nSample Input\n\n2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 795 12000 7\n2 3 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0\n\nOutput for the Sample Input\n\n4\n7\n6\n2\n42\n1\n0\n9\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1451, "cpu_time_ms": 140, "memory_kb": 3084}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s936896487", "group_id": "codeNet:p00712", "input_text": "#include\nusing namespace std;\nconst double eps=1e-9;\ndouble p,q,a;\nint n;\nint ans=0;\nvoid dfs(double pq,int s,int depth,int seki){\n if(pq>=-eps&&pq<=eps){\n ans++;\n return;\n }\n for(int i=s;i<=a/2;i++){\n if(seki*i>a)\n break;\n if((pq-(1.0/i))>=-eps&&depth+1<=n){\n dfs((pq-(1.0/i)),i,depth+1,seki*i);\n }\n }\n}\nint main(){\n while(cin>>p>>q>>a>>n,p+q+a+n){\n ans=0;\n for(int i=1;i<=a/2;i++){\n if((p/q)-(1.0/i)>=-eps)\n\tdfs((p/q)-(1.0/i),i,1,i);\n }\n cout<\nusing namespace std;\nconst double eps=1e-9;\ndouble p,q,a;\nint n;\nint ans=0;\nvoid dfs(double pq,int s,int depth,int seki){\n if(pq>=-eps&&pq<=eps){\n ans++;\n return;\n }\n for(int i=s;i<=a/2;i++){\n if(seki*i>a)\n break;\n if((pq-(1.0/i))>=-eps&&depth+1<=n){\n dfs((pq-(1.0/i)),i,depth+1,seki*i);\n }\n }\n}\nint main(){\n while(cin>>p>>q>>a>>n,p+q+a+n){\n ans=0;\n for(int i=1;i<=a/2;i++){\n if((p/q)-(1.0/i)>=-eps)\n\tdfs((p/q)-(1.0/i),i,1,i);\n }\n cout<\n#include \n#include \n\nstruct Action {\n\tsize_t x;\n\tsize_t y;\n\tsize_t cost;\n\tbool left_foot_on;\n};\n\nbool operator>(Action lhs, Action rhs) {\n\treturn lhs.cost > rhs.cost;\n}\n\nbool operator==(Action lhs, Action rhs) {\n\treturn lhs.x == rhs.x && lhs.y == rhs.y && lhs.left_foot_on == rhs.left_foot_on;\n}\n\nnamespace std {\n\ttemplate <>\n\tstruct hash {\n\t\tusing result_type = size_t;\n\n\t\tresult_type operator()(const Action& act) const {\n\t\t\treturn act.x * 31 + act.y * 12 + act.left_foot_on * 7;\n\t\t}\n\t};\n}\n\nclass Climber {\nprivate:\n\tusing candidates_t = std::priority_queue, std::greater>;\n\n\tsize_t _width;\n\tsize_t _height;\n\tstd::string* _cliff;\n\tcandidates_t _candidates;\n\tstd::unordered_set _traversed;\n\n\tchar get(size_t x, size_t y);\n\tvoid try_put_candidate(const Action& now, size_t x, size_t y);\n\tvoid put_candidate(size_t x, size_t y, size_t cost, bool left_foot_on);\npublic:\n\tClimber(size_t width, size_t height);\n\tvoid load();\n\tint climb();\n};\n\nClimber::Climber(size_t width, size_t height) : _width(width), _height(height) { }\n\nvoid Climber::load() {\n\t_cliff = new std::string[_height];\n\tfor (size_t y = 0; y < _height; ++y) {\n\t\tstd::string line;\n\t\tfor (size_t x = 0; x < _width; ++x) {\n\t\t\tchar a;\n\t\t\tstd::cin >> a;\n\t\t\tline += a;\n\t\t}\n\t\t_cliff[y] = line;\n\t}\n}\n\nint Climber::climb() {\n\t// ??????????????????S????????????????¶????????¶???????????????????????????????\n\tfor (size_t y = 0; y < _height; ++y) {\n\t\tfor (size_t x = 0; x < _width; ++x) {\n\t\t\tif (get(x, y) == 'S') {\n\t\t\t\tput_candidate(x, y, 0, false);\n\t\t\t\tput_candidate(x, y, 0, true);\n\t\t\t}\n\t\t}\n\t}\n\t// ???????°???????????????????????????????????????????????????????????????????\n\twhile (!_candidates.empty()) {\n\t\tconst Action now = _candidates.top();\n\t\tif (get(now.x, now.y) == 'T') {\n\t\t\treturn now.cost;\n\t\t}\n\t\t_candidates.pop();\n#ifdef _DEBUG\n\t\t//std::cerr << \"(\" << now.x << \",\" << now.y << \")->\" << now.cost << \" [\" << now.left_foot_on << \"]\\n\";\n#endif\n\t\tif (now.left_foot_on) {\n\t\t\ttry_put_candidate(now, now.x + 1, now.y - 2);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y + 2);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x + 3, now.y);\n\t\t} else {\n\t\t\ttry_put_candidate(now, now.x - 1, now.y - 2);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y + 2);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x - 3, now.y);\n\t\t}\n\t}\n\t// ????????????????????£???\n\treturn -1;\n}\n\nvoid Climber::try_put_candidate(const Action& now, size_t x, size_t y) {\n\tchar type = get(x, y);\n\tif (type == 'S' || type == 'X' || type == '\\0') {\n\t\treturn; // type==S??????????????????????????????????????????????§????????????????????????????????????????????????????\n\t}\n\tint additionalCost;\n\tif (type == 'T') {\n\t\tadditionalCost = 0; // ????????§??????????????????\n\t} else {\n\t\tadditionalCost = type - '0';\n\t}\n\tput_candidate(x, y, now.cost + additionalCost, !now.left_foot_on);\n}\n\nchar Climber::get(size_t x, size_t y) {\n\tif (x >= _width || y >= _height) {\n\t\treturn '\\0'; // invalid range\n\t}\n\treturn _cliff[y][x];\n}\n\nvoid Climber::put_candidate(size_t x, size_t y, size_t cost, bool left_foot_on) {\n\tAction a{x, y, cost, left_foot_on};\n\tauto alreadyTraversed = _traversed.find(a);\n\tif (alreadyTraversed == _traversed.end() || alreadyTraversed->cost > cost) {\n\t\t_traversed.emplace(a);\n\t\t_candidates.emplace(std::move(a));\n\t}\n}\n\nint main() {\n\tsize_t width, height;\n\twhile (true) {\n\t\tstd::cin >> width >> height;\n\t\tif (width == 0 || height == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tClimber climber(width, height);\n\t\tclimber.load();\n\t\tstd::cout << climber.climb() << std::endl;\n\t}\n}", "language": "C++", "metadata": {"date": 1465817622, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p00731.html", "problem_id": "p00731", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00731/input.txt", "sample_output_relpath": "derived/input_output/data/p00731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00731/C++/s986413849.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s986413849", "user_id": "u319242829"}, "prompt_components": {"gold_output": "12\n5\n-1\n22\n12\n", "input_to_evaluate": "#include \n#include \n#include \n\nstruct Action {\n\tsize_t x;\n\tsize_t y;\n\tsize_t cost;\n\tbool left_foot_on;\n};\n\nbool operator>(Action lhs, Action rhs) {\n\treturn lhs.cost > rhs.cost;\n}\n\nbool operator==(Action lhs, Action rhs) {\n\treturn lhs.x == rhs.x && lhs.y == rhs.y && lhs.left_foot_on == rhs.left_foot_on;\n}\n\nnamespace std {\n\ttemplate <>\n\tstruct hash {\n\t\tusing result_type = size_t;\n\n\t\tresult_type operator()(const Action& act) const {\n\t\t\treturn act.x * 31 + act.y * 12 + act.left_foot_on * 7;\n\t\t}\n\t};\n}\n\nclass Climber {\nprivate:\n\tusing candidates_t = std::priority_queue, std::greater>;\n\n\tsize_t _width;\n\tsize_t _height;\n\tstd::string* _cliff;\n\tcandidates_t _candidates;\n\tstd::unordered_set _traversed;\n\n\tchar get(size_t x, size_t y);\n\tvoid try_put_candidate(const Action& now, size_t x, size_t y);\n\tvoid put_candidate(size_t x, size_t y, size_t cost, bool left_foot_on);\npublic:\n\tClimber(size_t width, size_t height);\n\tvoid load();\n\tint climb();\n};\n\nClimber::Climber(size_t width, size_t height) : _width(width), _height(height) { }\n\nvoid Climber::load() {\n\t_cliff = new std::string[_height];\n\tfor (size_t y = 0; y < _height; ++y) {\n\t\tstd::string line;\n\t\tfor (size_t x = 0; x < _width; ++x) {\n\t\t\tchar a;\n\t\t\tstd::cin >> a;\n\t\t\tline += a;\n\t\t}\n\t\t_cliff[y] = line;\n\t}\n}\n\nint Climber::climb() {\n\t// ??????????????????S????????????????¶????????¶???????????????????????????????\n\tfor (size_t y = 0; y < _height; ++y) {\n\t\tfor (size_t x = 0; x < _width; ++x) {\n\t\t\tif (get(x, y) == 'S') {\n\t\t\t\tput_candidate(x, y, 0, false);\n\t\t\t\tput_candidate(x, y, 0, true);\n\t\t\t}\n\t\t}\n\t}\n\t// ???????°???????????????????????????????????????????????????????????????????\n\twhile (!_candidates.empty()) {\n\t\tconst Action now = _candidates.top();\n\t\tif (get(now.x, now.y) == 'T') {\n\t\t\treturn now.cost;\n\t\t}\n\t\t_candidates.pop();\n#ifdef _DEBUG\n\t\t//std::cerr << \"(\" << now.x << \",\" << now.y << \")->\" << now.cost << \" [\" << now.left_foot_on << \"]\\n\";\n#endif\n\t\tif (now.left_foot_on) {\n\t\t\ttry_put_candidate(now, now.x + 1, now.y - 2);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x + 1, now.y + 2);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y);\n\t\t\ttry_put_candidate(now, now.x + 2, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x + 3, now.y);\n\t\t} else {\n\t\t\ttry_put_candidate(now, now.x - 1, now.y - 2);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x - 1, now.y + 2);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y - 1);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y);\n\t\t\ttry_put_candidate(now, now.x - 2, now.y + 1);\n\t\t\ttry_put_candidate(now, now.x - 3, now.y);\n\t\t}\n\t}\n\t// ????????????????????£???\n\treturn -1;\n}\n\nvoid Climber::try_put_candidate(const Action& now, size_t x, size_t y) {\n\tchar type = get(x, y);\n\tif (type == 'S' || type == 'X' || type == '\\0') {\n\t\treturn; // type==S??????????????????????????????????????????????§????????????????????????????????????????????????????\n\t}\n\tint additionalCost;\n\tif (type == 'T') {\n\t\tadditionalCost = 0; // ????????§??????????????????\n\t} else {\n\t\tadditionalCost = type - '0';\n\t}\n\tput_candidate(x, y, now.cost + additionalCost, !now.left_foot_on);\n}\n\nchar Climber::get(size_t x, size_t y) {\n\tif (x >= _width || y >= _height) {\n\t\treturn '\\0'; // invalid range\n\t}\n\treturn _cliff[y][x];\n}\n\nvoid Climber::put_candidate(size_t x, size_t y, size_t cost, bool left_foot_on) {\n\tAction a{x, y, cost, left_foot_on};\n\tauto alreadyTraversed = _traversed.find(a);\n\tif (alreadyTraversed == _traversed.end() || alreadyTraversed->cost > cost) {\n\t\t_traversed.emplace(a);\n\t\t_candidates.emplace(std::move(a));\n\t}\n}\n\nint main() {\n\tsize_t width, height;\n\twhile (true) {\n\t\tstd::cin >> width >> height;\n\t\tif (width == 0 || height == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tClimber climber(width, height);\n\t\tclimber.load();\n\t\tstd::cout << climber.climb() << std::endl;\n\t}\n}", "problem_context": "Problem D: Cliff Climbing\n\nAt 17:00, special agent Jack starts to escape from the enemy camp.\nThere is a cliff in between the camp and the nearest safety zone.\nJack has to climb the almost vertical cliff\nby stepping his feet on the blocks that cover the cliff.\nThe cliff has slippery blocks where Jack has to\nspend time to take each step.\nHe also has to bypass some blocks that are too loose to support his weight.\nYour mission is to write a program that calculates the minimum time to complete climbing.\n\nFigure D-1 shows an example of cliff data that you will\nreceive.\nThe cliff is covered with square blocks.\nJack starts cliff climbing from the ground under the cliff,\nby stepping his left or right foot on one of the blocks marked with\n'S' at the bottom row.\nThe numbers on the blocks are the \"slippery levels\". It takes\nt time units for him to safely put his foot on a\nblock marked with t, where 1 ≤ t ≤ 9.\nHe cannot put his feet on blocks marked with 'X'.\nHe completes the climbing when he puts\neither of his feet on one of the blocks marked with 'T' at the top row.\n\nFigure D-1: Example of Cliff Data\n\nJack's movement must meet the following constraints.\nAfter putting his left (or right) foot on a block, he can only move\nhis right (or left, respectively) foot.\nHis left foot position (lx, ly) and his right foot position\n(rx, ry) should satisfy\nlx < rx\nand | lx - rx | + | ly - ry | ≤ 3\n.\nThis implies that, given a position of his left foot in Figure D-2 (a), he has to\nplace his right foot on one of the nine blocks marked with blue color.\nSimilarly, given a position of his right foot in Figure D-2 (b),\nhe has to place his\nleft foot on one of the nine blocks marked with blue color.\n\nFigure D-2: Possible Placements of Feet\n\nInput\n\nThe input is a sequence of datasets.\nThe end of the input is indicated by a line containing two zeros separated by a space.\nEach dataset is formatted as follows:\n\nw h\n\ns(1,1) ... s(1,w)\n\ns(2,1) ... s(2,w)\n\n...\n\ns(h,1) ... s(h,w)\n\nThe integers w and h are the width and the height of\nthe matrix data of the cliff. You may assume 2 ≤ w ≤ 30 and 5 ≤ h ≤ 60.\nEach of the following h lines consists of w characters\ndelimited by a space.\nThe character s(y, x) represents the state of the block at\nposition\n(x, y) as follows:\n\n'S': Jack can start cliff climbing from this block.\n\n'T': Jack finishes climbing when he reaches this block.\n\n'X': Jack cannot put his feet on this block.\n\n'1' - '9' (= t): Jack has to spend t time units\nto put either of his feet on this block.\n\nYou can assume that it takes no time to put a foot on a block marked with 'S' or 'T'.\n\nOutput\n\nFor each dataset, print a line only having a decimal integer indicating\nthe minimum time required for the cliff climbing,\nwhen Jack can complete it.\nOtherwise, print a line only having \"-1\" for the dataset.\nEach line should not have any characters other than these numbers.\n\nSample Input\n\n6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X 5 X 5\n8 9 9 9 6 X X 5 X 5\n8 6 5 4 6 8 X 5 X 5\n8 9 3 9 6 8 X 5 X 5\n8 3 9 9 6 X X X 5 X\nS S S S S S S S S S\n10 7\n2 3 2 3 2 3 2 3 T T\n1 2 3 2 3 2 3 2 3 2\n3 2 3 2 3 2 3 2 3 4\n3 2 3 2 3 2 3 2 3 5\n3 2 3 1 3 2 3 2 3 5\n2 2 3 2 4 2 3 2 3 5\nS S 2 3 2 1 2 3 2 3\n0 0\n\nOutput for the Sample Input\n\n12\n5\n-1\n22\n12", "sample_input": "6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X 5 X 5\n8 9 9 9 6 X X 5 X 5\n8 6 5 4 6 8 X 5 X 5\n8 9 3 9 6 8 X 5 X 5\n8 3 9 9 6 X X X 5 X\nS S S S S S S S S S\n10 7\n2 3 2 3 2 3 2 3 T T\n1 2 3 2 3 2 3 2 3 2\n3 2 3 2 3 2 3 2 3 4\n3 2 3 2 3 2 3 2 3 5\n3 2 3 1 3 2 3 2 3 5\n2 2 3 2 4 2 3 2 3 5\nS S 2 3 2 1 2 3 2 3\n0 0\n"}, "reference_outputs": ["12\n5\n-1\n22\n12\n"], "source_document_id": "p00731", "source_text": "Problem D: Cliff Climbing\n\nAt 17:00, special agent Jack starts to escape from the enemy camp.\nThere is a cliff in between the camp and the nearest safety zone.\nJack has to climb the almost vertical cliff\nby stepping his feet on the blocks that cover the cliff.\nThe cliff has slippery blocks where Jack has to\nspend time to take each step.\nHe also has to bypass some blocks that are too loose to support his weight.\nYour mission is to write a program that calculates the minimum time to complete climbing.\n\nFigure D-1 shows an example of cliff data that you will\nreceive.\nThe cliff is covered with square blocks.\nJack starts cliff climbing from the ground under the cliff,\nby stepping his left or right foot on one of the blocks marked with\n'S' at the bottom row.\nThe numbers on the blocks are the \"slippery levels\". It takes\nt time units for him to safely put his foot on a\nblock marked with t, where 1 ≤ t ≤ 9.\nHe cannot put his feet on blocks marked with 'X'.\nHe completes the climbing when he puts\neither of his feet on one of the blocks marked with 'T' at the top row.\n\nFigure D-1: Example of Cliff Data\n\nJack's movement must meet the following constraints.\nAfter putting his left (or right) foot on a block, he can only move\nhis right (or left, respectively) foot.\nHis left foot position (lx, ly) and his right foot position\n(rx, ry) should satisfy\nlx < rx\nand | lx - rx | + | ly - ry | ≤ 3\n.\nThis implies that, given a position of his left foot in Figure D-2 (a), he has to\nplace his right foot on one of the nine blocks marked with blue color.\nSimilarly, given a position of his right foot in Figure D-2 (b),\nhe has to place his\nleft foot on one of the nine blocks marked with blue color.\n\nFigure D-2: Possible Placements of Feet\n\nInput\n\nThe input is a sequence of datasets.\nThe end of the input is indicated by a line containing two zeros separated by a space.\nEach dataset is formatted as follows:\n\nw h\n\ns(1,1) ... s(1,w)\n\ns(2,1) ... s(2,w)\n\n...\n\ns(h,1) ... s(h,w)\n\nThe integers w and h are the width and the height of\nthe matrix data of the cliff. You may assume 2 ≤ w ≤ 30 and 5 ≤ h ≤ 60.\nEach of the following h lines consists of w characters\ndelimited by a space.\nThe character s(y, x) represents the state of the block at\nposition\n(x, y) as follows:\n\n'S': Jack can start cliff climbing from this block.\n\n'T': Jack finishes climbing when he reaches this block.\n\n'X': Jack cannot put his feet on this block.\n\n'1' - '9' (= t): Jack has to spend t time units\nto put either of his feet on this block.\n\nYou can assume that it takes no time to put a foot on a block marked with 'S' or 'T'.\n\nOutput\n\nFor each dataset, print a line only having a decimal integer indicating\nthe minimum time required for the cliff climbing,\nwhen Jack can complete it.\nOtherwise, print a line only having \"-1\" for the dataset.\nEach line should not have any characters other than these numbers.\n\nSample Input\n\n6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X 5 X 5\n8 9 9 9 6 X X 5 X 5\n8 6 5 4 6 8 X 5 X 5\n8 9 3 9 6 8 X 5 X 5\n8 3 9 9 6 X X X 5 X\nS S S S S S S S S S\n10 7\n2 3 2 3 2 3 2 3 T T\n1 2 3 2 3 2 3 2 3 2\n3 2 3 2 3 2 3 2 3 4\n3 2 3 2 3 2 3 2 3 5\n3 2 3 1 3 2 3 2 3 5\n2 2 3 2 4 2 3 2 3 5\nS S 2 3 2 1 2 3 2 3\n0 0\n\nOutput for the Sample Input\n\n12\n5\n-1\n22\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4109, "cpu_time_ms": 40, "memory_kb": 3600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s474866800", "group_id": "codeNet:p00744", "input_text": "#define _CRT_SECURE_NO_WARNINGS\n// #define _GLIBCXX_DEBUG\n#include \nusing namespace std;\ntypedef long long ll;\n// #define int ll\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair pii;\n#define all(c) begin(c), end(c)\n#define range(i,a,b) for(ll i=a; i ostream & operator << (ostream &os, vector const &);\ntemplate\ntypename enable_if<(n>=sizeof...(T))>::type\n_ot(ostream &, tuple const &){}\ntemplate\ntypename enable_if<(n< sizeof...(T))>::type\n_ot(ostream &os, tuple const &t){\n os << (n==0?\"\":\" \") << get(t); _ot(os, t);\n}\ntemplate\nostream & operator << (ostream &os, tuple const &t){\n _ot<0>(os, t); return os;\n}\ntemplate\nostream & operator<<(ostream &os, pair const &p){\n return os << \"(\" << p.first << \", \" << p.second << \") \";\n}\ntemplate\nostream & operator<<(ostream &os, vector const &v){\n rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?\"\":\" \"); return os;\n}\n#ifdef DEBUG\n#define dump(...) (cerr << #__VA_ARGS__ << \" = \" << mt(__VA_ARGS__) \\\n << \" [\" << __LINE__ << \"]\" << endl)\n#else\n#define dump(...)\n#endif\nvoid fastios(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n#define endl '\\n'\n}\ntemplate\nsize_t uniq(vector &v){\n sort(v.begin(), v.end());\n v.erase(unique(v.begin(), v.end()), v.end());\n return v.size();\n}\ntemplate\nsize_t uniq(T *l, size_t n){\n sort(l,l+n);\n return unique(l,l+n) - l;\n}\n#define mems(arr,val) memset(arr,val,sizeof(arr));\nint const mod = 1000000007;\nint const inf = numeric_limits::max()/8;\n\ntypedef int Capacity;\nstruct Edge {\n int src, dst;\n Capacity cap;\n Edge(int src_, int dst_, Capacity cap_) :\n src(src_), dst(dst_), cap(cap_) { }\n};\ntypedef vector Edges;\ntypedef vector Graph;\n\nstruct Dinic {\n int n, s, t;\n vector level, iter;\n vector> cap, flow;\n vector> g;\n Capacity inf;\n Dinic(int n)\n : n(n), cap(n, vector(n)), flow(n, vector(n)),\n g(n, vector()), inf(numeric_limits::max()/8){}\n Dinic(const Graph &graph){\n *this = Dinic(graph.size());\n rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);\n }\n void addEdge(int u, int v, Capacity c){\n cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;\n g[u].push_back(v); g[v].push_back(u);\n }\n inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }\n Capacity solve(int s, int t){\n this->t = t, this->s = s;\n Capacity res = 0, aug = 1;\n while(aug > 0){\n levelize();\n iter.assign(n, 0);\n aug = augment(s, inf);\n res += aug;\n }\n return res;\n }\n void levelize(){\n level.assign(n, inf); level[s] = 0;\n queue q; q.emplace(s);\n while(q.size()){\n int v = q.front(); q.pop();\n for(const int &d : g[v]){\n if(level[d] <= level[v] + 1 || residue(v,d) == 0) continue;\n level[d] = level[v] + 1; q.emplace(d);\n }\n }\n }\n Capacity augment(int v, Capacity lim){\n Capacity res = 0;\n if(v == t) return lim;\n for(int &i = iter[v]; i < (int)g[v].size(); i++){\n const int &d = g[v][i];\n if(residue(v,d) == 0 || level[v] + 1 != level[d]) continue;\n Capacity aug = augment(d, min(lim, residue(v,d)));\n if(aug > 0){\n flow[v][d] += aug; flow[d][v] -= aug;\n res += aug; lim -= aug;\n if(lim == 0) return res;\n }\n }\n return res;\n }\n};\n\nint main(){\n fastios();\n int n,m;\n while(cin >> n >> m && n|m){\n vector a(n), b(m);\n rep(i,n) cin >> a[i];\n rep(i,m) cin >> b[i];\n Dinic d(n+m+2);\n int s = n+m, t = n+m+1;\n rep(i,m) d.addEdge(i+n,t,1);\n rep(i,n){\n d.addEdge(s,i,1);\n rep(j,m) if(__gcd(a[i],b[j]) != 1) d.addEdge(i,n+j,1);\n }\n rep(i,n)rep(j,m){\n if(d.flow[i][j+n]) dump(i,j, d.flow[i][j+m]);\n }\n cout << d.solve(s,t) << endl;\n }\n}\n\n// int main(){\n// int N,M;\n// cin >> N >> M;\n// Graph g(N);\n// rep(i,M){\n// int a,b,c;\n// cin >> a >> b >> c;\n// g[a].emplace_back(a,b,c);\n// }\n// Dinic dinic(g);\n// cout << dinic.solve(0,N-1) << endl;\n// }", "language": "C++", "metadata": {"date": 1444922255, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p00744.html", "problem_id": "p00744", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p00744/input.txt", "sample_output_relpath": "derived/input_output/data/p00744/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00744/C++/s474866800.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474866800", "user_id": "u553881259"}, "prompt_components": {"gold_output": "3\n1\n0\n4\n9\n18\n85\n", "input_to_evaluate": "#define _CRT_SECURE_NO_WARNINGS\n// #define _GLIBCXX_DEBUG\n#include \nusing namespace std;\ntypedef long long ll;\n// #define int ll\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair pii;\n#define all(c) begin(c), end(c)\n#define range(i,a,b) for(ll i=a; i ostream & operator << (ostream &os, vector const &);\ntemplate\ntypename enable_if<(n>=sizeof...(T))>::type\n_ot(ostream &, tuple const &){}\ntemplate\ntypename enable_if<(n< sizeof...(T))>::type\n_ot(ostream &os, tuple const &t){\n os << (n==0?\"\":\" \") << get(t); _ot(os, t);\n}\ntemplate\nostream & operator << (ostream &os, tuple const &t){\n _ot<0>(os, t); return os;\n}\ntemplate\nostream & operator<<(ostream &os, pair const &p){\n return os << \"(\" << p.first << \", \" << p.second << \") \";\n}\ntemplate\nostream & operator<<(ostream &os, vector const &v){\n rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?\"\":\" \"); return os;\n}\n#ifdef DEBUG\n#define dump(...) (cerr << #__VA_ARGS__ << \" = \" << mt(__VA_ARGS__) \\\n << \" [\" << __LINE__ << \"]\" << endl)\n#else\n#define dump(...)\n#endif\nvoid fastios(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n#define endl '\\n'\n}\ntemplate\nsize_t uniq(vector &v){\n sort(v.begin(), v.end());\n v.erase(unique(v.begin(), v.end()), v.end());\n return v.size();\n}\ntemplate\nsize_t uniq(T *l, size_t n){\n sort(l,l+n);\n return unique(l,l+n) - l;\n}\n#define mems(arr,val) memset(arr,val,sizeof(arr));\nint const mod = 1000000007;\nint const inf = numeric_limits::max()/8;\n\ntypedef int Capacity;\nstruct Edge {\n int src, dst;\n Capacity cap;\n Edge(int src_, int dst_, Capacity cap_) :\n src(src_), dst(dst_), cap(cap_) { }\n};\ntypedef vector Edges;\ntypedef vector Graph;\n\nstruct Dinic {\n int n, s, t;\n vector level, iter;\n vector> cap, flow;\n vector> g;\n Capacity inf;\n Dinic(int n)\n : n(n), cap(n, vector(n)), flow(n, vector(n)),\n g(n, vector()), inf(numeric_limits::max()/8){}\n Dinic(const Graph &graph){\n *this = Dinic(graph.size());\n rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);\n }\n void addEdge(int u, int v, Capacity c){\n cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;\n g[u].push_back(v); g[v].push_back(u);\n }\n inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }\n Capacity solve(int s, int t){\n this->t = t, this->s = s;\n Capacity res = 0, aug = 1;\n while(aug > 0){\n levelize();\n iter.assign(n, 0);\n aug = augment(s, inf);\n res += aug;\n }\n return res;\n }\n void levelize(){\n level.assign(n, inf); level[s] = 0;\n queue q; q.emplace(s);\n while(q.size()){\n int v = q.front(); q.pop();\n for(const int &d : g[v]){\n if(level[d] <= level[v] + 1 || residue(v,d) == 0) continue;\n level[d] = level[v] + 1; q.emplace(d);\n }\n }\n }\n Capacity augment(int v, Capacity lim){\n Capacity res = 0;\n if(v == t) return lim;\n for(int &i = iter[v]; i < (int)g[v].size(); i++){\n const int &d = g[v][i];\n if(residue(v,d) == 0 || level[v] + 1 != level[d]) continue;\n Capacity aug = augment(d, min(lim, residue(v,d)));\n if(aug > 0){\n flow[v][d] += aug; flow[d][v] -= aug;\n res += aug; lim -= aug;\n if(lim == 0) return res;\n }\n }\n return res;\n }\n};\n\nint main(){\n fastios();\n int n,m;\n while(cin >> n >> m && n|m){\n vector a(n), b(m);\n rep(i,n) cin >> a[i];\n rep(i,m) cin >> b[i];\n Dinic d(n+m+2);\n int s = n+m, t = n+m+1;\n rep(i,m) d.addEdge(i+n,t,1);\n rep(i,n){\n d.addEdge(s,i,1);\n rep(j,m) if(__gcd(a[i],b[j]) != 1) d.addEdge(i,n+j,1);\n }\n rep(i,n)rep(j,m){\n if(d.flow[i][j+n]) dump(i,j, d.flow[i][j+m]);\n }\n cout << d.solve(s,t) << endl;\n }\n}\n\n// int main(){\n// int N,M;\n// cin >> N >> M;\n// Graph g(N);\n// rep(i,M){\n// int a,b,c;\n// cin >> a >> b >> c;\n// g[a].emplace_back(a,b,c);\n// }\n// Dinic dinic(g);\n// cout << dinic.solve(0,N-1) << endl;\n// }", "problem_context": "Problem E: Cards\n\nThere are many blue cards and red cards on the table.\nFor each card, an integer number greater than 1 is printed on its face.\nThe same number may be printed on several cards.\n\nA blue card and a red card can be paired when both of the numbers\nprinted on them have a common divisor greater than 1.\nThere may be more than one red card that can be paired with one blue card.\nAlso, there may be more than one blue card that can be paired with one red card.\nWhen a blue card and a red card are chosen and paired,\nthese two cards are removed from the whole cards on the table.\n\nFigure E-1: Four blue cards and three red cards\n\nFor example, in Figure E-1,\nthere are four blue cards and three red cards.\nNumbers 2, 6, 6 and 15 are printed on the faces of the four blue cards,\nand 2, 3 and 35 are printed on those of the three red cards.\nHere, you can make pairs of blue cards and red cards as follows.\nFirst,\nthe blue card with number 2 on it and the red card with 2 are paired and removed.\nSecond,\none of the two blue cards with 6 and the red card with 3 are paired and removed.\nFinally,\nthe blue card with 15 and the red card with 35 are paired and removed.\nThus the number of removed pairs is three.\n\nNote that the total number of the pairs depends on\nthe way of choosing cards to be paired.\nThe blue card with 15 and the red card with 3 might be paired\nand removed at the beginning.\nIn this case, there are only one more pair that can be removed\nand the total number of the removed pairs is two.\n\nYour job is to find the largest number of pairs that can be removed from the given set of cards on the table.\n\nInput\n\nThe input is a sequence of datasets.\nThe number of the datasets is less than or equal to 100.\nEach dataset is formatted as follows.\n\nm n\n\nb1 ... bk\n... bm\n\nr1 ... rk\n... rn\n\nThe integers m and n are the number of blue cards\nand that of red cards, respectively.\nYou may assume 1 ≤ m ≤ 500 and 1≤ n ≤ 500.\n\nbk (1 ≤ k ≤ m) and\nrk (1 ≤ k ≤ n) are\nnumbers printed on the blue cards and the red cards respectively,\nthat are integers greater than or equal to 2 and less than\n10000000 (=107).\nThe input integers are separated by a space or a newline.\nEach of bm and rn is\nfollowed by a newline.\nThere are no other characters in the dataset.\n\nThe end of the input is indicated by a line containing two zeros\nseparated by a space.\n\nOutput\n\nFor each dataset, output a line containing an integer that indicates\nthe maximum of the number of the pairs.\n\nSample Input\n\n4 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\nOutput for the Sample Input\n\n3\n1\n0\n4\n9\n18\n85", "sample_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"}, "reference_outputs": ["3\n1\n0\n4\n9\n18\n85\n"], "source_document_id": "p00744", "source_text": "Problem E: Cards\n\nThere are many blue cards and red cards on the table.\nFor each card, an integer number greater than 1 is printed on its face.\nThe same number may be printed on several cards.\n\nA blue card and a red card can be paired when both of the numbers\nprinted on them have a common divisor greater than 1.\nThere may be more than one red card that can be paired with one blue card.\nAlso, there may be more than one blue card that can be paired with one red card.\nWhen a blue card and a red card are chosen and paired,\nthese two cards are removed from the whole cards on the table.\n\nFigure E-1: Four blue cards and three red cards\n\nFor example, in Figure E-1,\nthere are four blue cards and three red cards.\nNumbers 2, 6, 6 and 15 are printed on the faces of the four blue cards,\nand 2, 3 and 35 are printed on those of the three red cards.\nHere, you can make pairs of blue cards and red cards as follows.\nFirst,\nthe blue card with number 2 on it and the red card with 2 are paired and removed.\nSecond,\none of the two blue cards with 6 and the red card with 3 are paired and removed.\nFinally,\nthe blue card with 15 and the red card with 35 are paired and removed.\nThus the number of removed pairs is three.\n\nNote that the total number of the pairs depends on\nthe way of choosing cards to be paired.\nThe blue card with 15 and the red card with 3 might be paired\nand removed at the beginning.\nIn this case, there are only one more pair that can be removed\nand the total number of the removed pairs is two.\n\nYour job is to find the largest number of pairs that can be removed from the given set of cards on the table.\n\nInput\n\nThe input is a sequence of datasets.\nThe number of the datasets is less than or equal to 100.\nEach dataset is formatted as follows.\n\nm n\n\nb1 ... bk\n... bm\n\nr1 ... rk\n... rn\n\nThe integers m and n are the number of blue cards\nand that of red cards, respectively.\nYou may assume 1 ≤ m ≤ 500 and 1≤ n ≤ 500.\n\nbk (1 ≤ k ≤ m) and\nrk (1 ≤ k ≤ n) are\nnumbers printed on the blue cards and the red cards respectively,\nthat are integers greater than or equal to 2 and less than\n10000000 (=107).\nThe input integers are separated by a space or a newline.\nEach of bm and rn is\nfollowed by a newline.\nThere are no other characters in the dataset.\n\nThe end of the input is indicated by a line containing two zeros\nseparated by a space.\n\nOutput\n\nFor each dataset, output a line containing an integer that indicates\nthe maximum of the number of the pairs.\n\nSample Input\n\n4 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\nOutput for the Sample Input\n\n3\n1\n0\n4\n9\n18\n85", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4750, "cpu_time_ms": 690, "memory_kb": 10612}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s292311924", "group_id": "codeNet:p00832", "input_text": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct dice{\n\tint val[6];\n\tvoid roti(){\n\t\tint t=val[5];\n\t\tval[5]=val[1];\n\t\tval[1]=val[4];\n\t\tval[4]=val[0];\n\t\tval[0]=t;\n\t}\n\tvoid rotj(){\n\t\tint t=val[3];\n\t\tval[3]=val[1];\n\t\tval[1]=val[2];\n\t\tval[2]=val[0];\n\t\tval[0]=t;\n\t}\n\tvoid rotk(){\n\t\tint t=val[3];\n\t\tval[3]=val[4];\n\t\tval[4]=val[2];\n\t\tval[2]=val[5];\n\t\tval[5]=t;\n\t}\n};\n\nint f[3][3],t[3][3];\ndice cube[3][3][3];\nint n;\nbool res[55];\n\nvoid rec(int cur){\n\tif(cur==27){\n\t\tint sum=0;\n\t\tfor(int i=0;i<3;i++){\n\t\t\tfor(int k=0;k<3;k++){\n\t\t\t\tsum+=cube[i][2][k].val[4];\n\t\t\t}\n\t\t}\n\t\tres[0]=false;\n\t\tres[sum]=true;\n\t\treturn;\n\t}\n\tint k=cur/9;\n\tint i=(cur/3)%3;\n\tint j=cur%3;\n\tdice d=(dice){2,5,6,1,3,4};\n\tfor(int r=0;r<24;r++){\n\t\td.rotk();\n\t\tif(r%4==0){\n\t\t\tif(r<16)d.rotj();\n\t\t\telse if(r==16)d.roti();\n\t\t\telse{\n\t\t\t\tfor(int l=0;l<2;l++){\n\t\t\t\t\td.roti();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(k==0 && t[i][j] && t[i][j]!=d.val[0])continue;\n\t\tif(i==2 && f[k][j] && f[k][j]!=d.val[2])continue;\n\t\tif(i && cube[i-1][j][k].val[2]+d.val[3]!=7)continue;\n\t\tif(j && cube[i][j-1][k].val[4]+d.val[5]!=7)continue;\n\t\tif(k && cube[i][j][k-1].val[1]+d.val[0]!=7)continue;\n\t\tcube[i][j][k]=d;\n\t\trec(cur+1);\n\t}\n}\n\nvoid solve(){\n\tmemset(res,false,sizeof(res));\n\tres[0]=true;\n\trec(0);\n\tif(res[0])printf(\"0\\n\");\n\telse{\n\t\tbool c=false;\n\t\tfor(int i=1;i<=54;i++){\n\t\t\tif(res[i]){\n\t\t\t\tif(c)printf(\" \");\n\t\t\t\tc=true;\n\t\t\t\tprintf(\"%d\",i);\n\t\t\t}\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n}\n\nint main(void){\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct dice{\n\tint val[6];\n\tvoid roti(){\n\t\tint t=val[5];\n\t\tval[5]=val[1];\n\t\tval[1]=val[4];\n\t\tval[4]=val[0];\n\t\tval[0]=t;\n\t}\n\tvoid rotj(){\n\t\tint t=val[3];\n\t\tval[3]=val[1];\n\t\tval[1]=val[2];\n\t\tval[2]=val[0];\n\t\tval[0]=t;\n\t}\n\tvoid rotk(){\n\t\tint t=val[3];\n\t\tval[3]=val[4];\n\t\tval[4]=val[2];\n\t\tval[2]=val[5];\n\t\tval[5]=t;\n\t}\n};\n\nint f[3][3],t[3][3];\ndice cube[3][3][3];\nint n;\nbool res[55];\n\nvoid rec(int cur){\n\tif(cur==27){\n\t\tint sum=0;\n\t\tfor(int i=0;i<3;i++){\n\t\t\tfor(int k=0;k<3;k++){\n\t\t\t\tsum+=cube[i][2][k].val[4];\n\t\t\t}\n\t\t}\n\t\tres[0]=false;\n\t\tres[sum]=true;\n\t\treturn;\n\t}\n\tint k=cur/9;\n\tint i=(cur/3)%3;\n\tint j=cur%3;\n\tdice d=(dice){2,5,6,1,3,4};\n\tfor(int r=0;r<24;r++){\n\t\td.rotk();\n\t\tif(r%4==0){\n\t\t\tif(r<16)d.rotj();\n\t\t\telse if(r==16)d.roti();\n\t\t\telse{\n\t\t\t\tfor(int l=0;l<2;l++){\n\t\t\t\t\td.roti();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(k==0 && t[i][j] && t[i][j]!=d.val[0])continue;\n\t\tif(i==2 && f[k][j] && f[k][j]!=d.val[2])continue;\n\t\tif(i && cube[i-1][j][k].val[2]+d.val[3]!=7)continue;\n\t\tif(j && cube[i][j-1][k].val[4]+d.val[5]!=7)continue;\n\t\tif(k && cube[i][j][k-1].val[1]+d.val[0]!=7)continue;\n\t\tcube[i][j][k]=d;\n\t\trec(cur+1);\n\t}\n}\n\nvoid solve(){\n\tmemset(res,false,sizeof(res));\n\tres[0]=true;\n\trec(0);\n\tif(res[0])printf(\"0\\n\");\n\telse{\n\t\tbool c=false;\n\t\tfor(int i=1;i<=54;i++){\n\t\t\tif(res[i]){\n\t\t\t\tif(c)printf(\" \");\n\t\t\t\tc=true;\n\t\t\t\tprintf(\"%d\",i);\n\t\t\t}\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n}\n\nint main(void){\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i\nusing namespace std;\nint main(){\n int sum=0;\n string s,t;\n cin>>s>>t;\nswap(s,t);\n vectorv[4001];\n for(int i=0;ip)r=mid;\n else l=mid+1;\n }\n \n }\n cout<\nusing namespace std;\nint main(){\n int sum=0;\n string s,t;\n cin>>s>>t;\nswap(s,t);\n vectorv[4001];\n for(int i=0;ip)r=mid;\n else l=mid+1;\n }\n \n }\n cout<

q;\n fill(dp,dp+(1<cost+1){\n\tdp[next]=cost+1;\n\tq.push(P(dp[next],next));\n }\n }\n }\n}\n\nint main(){\n cin>>n>>m>>k;\n for(int i=0;i>d[i]; d[i]--;\n to[d[i]]=i;\n }\n for(int i=0;i>G[i][j];\n G[i][j]--;\n }\n cout<\n#define INF (1e9)\n#define N 105\n#define M 16\nusing namespace std;\ntypedef pair P;\nint n,m,k,d[M],G[N][N],dp[(1< to;\n\nint bfs(){\n queue

q;\n fill(dp,dp+(1<cost+1){\n\tdp[next]=cost+1;\n\tq.push(P(dp[next],next));\n }\n }\n }\n}\n\nint main(){\n cin>>n>>m>>k;\n for(int i=0;i>d[i]; d[i]--;\n to[d[i]]=i;\n }\n for(int i=0;i>G[i][j];\n G[i][j]--;\n }\n cout<\nusing namespace std;\nstring t,p;\nchar c;\nint i,j,k,l,x;\nmain(){\n for(cin>>t>>p;i\nusing namespace std;\nstring t,p;\nchar c;\nint i,j,k,l,x;\nmain(){\n for(cin>>t>>p;i\n#define X first\n#define Y second\n#define pb push_back\n#define eb pb\n#define rep(X,Y) for(int X=0;X<(Y);++X)\n#define reps(X,O,Y) for(int X=O;X<(Y);++X)\n#define all(X) (X).begin(),(X).end()\n\nusing namespace std;\nusing ll=long long;\n\nconst int N=11234567;\nint prime[N];\n\nint main(){\n\tfill(prime,prime+N,1);\n\tprime[0]=prime[1]=0;\n\trep(i,N)if(prime[i])for(int j=i+i;j>n;\n\tif(n<=2){ cout<<0<\n#define X first\n#define Y second\n#define pb push_back\n#define eb pb\n#define rep(X,Y) for(int X=0;X<(Y);++X)\n#define reps(X,O,Y) for(int X=O;X<(Y);++X)\n#define all(X) (X).begin(),(X).end()\n\nusing namespace std;\nusing ll=long long;\n\nconst int N=11234567;\nint prime[N];\n\nint main(){\n\tfill(prime,prime+N,1);\n\tprime[0]=prime[1]=0;\n\trep(i,N)if(prime[i])for(int j=i+i;j>n;\n\tif(n<=2){ cout<<0<\n#include\nusing namespace std;\n \nint main(){\n long long int mi = 100000000000,ma = -100000000000,a,n;\n cin >> n;\n for(int i=0;i> a;\n ma = max(ma,a-mi);\n mi = min(mi,a);\n }\n cout<\n#include\nusing namespace std;\n \nint main(){\n long long int mi = 100000000000,ma = -100000000000,a,n;\n cin >> n;\n for(int i=0;i> a;\n ma = max(ma,a-mi);\n mi = min(mi,a);\n }\n cout< i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 50, "memory_kb": 3120}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s070595940", "group_id": "codeNet:p02274", "input_text": "#include \n#include\nusing namespace std;\n#define MAX 200000\n#define mm 10000000000\ntypedef long long ll;\nint L[MAX],R[MAX];\nll merge(int A[],int n,int left,int mid,int right)\n{\n\n int i,j,k;\n ll cnt=0;\n int n1=mid-left;\n int n2=right-mid;\n for(i=0; i\n#include\nusing namespace std;\n#define MAX 200000\n#define mm 10000000000\ntypedef long long ll;\nint L[MAX],R[MAX];\nll merge(int A[],int n,int left,int mid,int right)\n{\n\n int i,j,k;\n ll cnt=0;\n int n1=mid-left;\n int n2=right-mid;\n for(i=0; i a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "sample_input": "5\n3 5 2 1 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02274", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nThe Number of Inversions\n\nFor a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1085, "cpu_time_ms": 20, "memory_kb": 4716}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s507742532", "group_id": "codeNet:p02283", "input_text": "#include \n#include \n#pragma warning(disable : 4996)\nstruct Node {\n\tint key;\n\tNode *p, *l, *r;\n};\nNode *root, *NIL;\nvoid insert(int key_) {\n\tNode *x = root, *y = NIL, *z;\n\tz = (Node*)malloc(sizeof(Node));\n\tz->key = key_, z->l = NIL, z->r = NIL;\n\twhile (x != NIL) {\n\t\ty = x;\n\t\tx = (z->key < x->key) ? x->l : x->r;\n\t}\n\tz->p = y;\n\tif (y == NIL) root = z;\n\telse if (z->key < y->key) y->l = z;\n\telse y->r = z;\n}\nvoid walk1(Node *x) { if (x == NIL) return; walk1(x->l); printf(\" %d\", x->key); walk1(x->r); }\nvoid walk2(Node *x) { if (x == NIL) return; printf(\" %d\", x->key); walk2(x->l); walk2(x->r); }\nint n, v; char c[8];\nint main() {\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%s\", &c);\n\t\tif (c[0] == 'i') scanf(\"%d\", &v), insert(v);\n\t\telse walk1(root), printf(\"\\n\"), walk2(root), printf(\"\\n\");\n\t}\n}", "language": "C++", "metadata": {"date": 1463480465, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/C++/s507742532.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s507742532", "user_id": "u823513038"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "#include \n#include \n#pragma warning(disable : 4996)\nstruct Node {\n\tint key;\n\tNode *p, *l, *r;\n};\nNode *root, *NIL;\nvoid insert(int key_) {\n\tNode *x = root, *y = NIL, *z;\n\tz = (Node*)malloc(sizeof(Node));\n\tz->key = key_, z->l = NIL, z->r = NIL;\n\twhile (x != NIL) {\n\t\ty = x;\n\t\tx = (z->key < x->key) ? x->l : x->r;\n\t}\n\tz->p = y;\n\tif (y == NIL) root = z;\n\telse if (z->key < y->key) y->l = z;\n\telse y->r = z;\n}\nvoid walk1(Node *x) { if (x == NIL) return; walk1(x->l); printf(\" %d\", x->key); walk1(x->r); }\nvoid walk2(Node *x) { if (x == NIL) return; printf(\" %d\", x->key); walk2(x->l); walk2(x->r); }\nint n, v; char c[8];\nint main() {\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%s\", &c);\n\t\tif (c[0] == 'i') scanf(\"%d\", &v), insert(v);\n\t\telse walk1(root), printf(\"\\n\"), walk2(root), printf(\"\\n\");\n\t}\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 827, "cpu_time_ms": 330, "memory_kb": 26024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s219344991", "group_id": "codeNet:p02283", "input_text": "#include \n#include // next_permutation\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include //accumulate\n//#include //???????????\\??¢??°\n#include //ifstream, ofstream\n\n//#define NDEBUG //NDEBUG???#include ???????????????????????????????????´???assert?????????????????????????????????NDEBUG?????????????????????????????????????????????\n#include //assert\n\n\nusing namespace std;\n\n//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????\n#define TEST //*******************************************************************************************************************************************\n//?????????????????¨??§?????\\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????\n//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨??? ????????????????????????cerr????????£????????????????????????????????????\n#ifdef TEST\n#define dout cout\n#else\nstringstream dummy; //???????????°??????dout?????????????????????????????????\n#define dout dummy.str(\"\"); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????\n//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1\n#endif\n\n//?¨??????????????????????????????????????????????????????´??????OUTPUT2TEXTFILE????????????????????¬???????????????????????????????????¢????????????\n//#define OUTPUT2TEXTFILE //*******************************************************************************************************************************************\n#ifdef OUTPUT2TEXTFILE\n#define dout outputfile //??¨????????????TLE????????§?????????dout?????¨??¨??????????????¢????????????????????????????????????????????§????¨????????????´??????????????£??????????????????????¨?????????????????????????????????????????????§?????????????????????\n//TEST??????????????????????????¨???outputfile??????????????????????????????\n#define OUTPUTFILENAME \"output.txt\"\nofstream outputfile(OUTPUTFILENAME);\n#define OutputFilePath \"/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt\"\n#endif\n\n#define disp(A) dout << #A << \" = \" << (A) << endl\n#define disP(A) dout << setw(3) << (A) << \" \" // << setw(3) ??????????????\\????????????\n#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)\n\n#define dispAll(A,n) dout << #A << \" = \"; rep(j, 0, (n)) {disP(A[j]);} dout << endl\n\ntypedef pair pii;\ntypedef vector vi;\ntypedef unsigned long long ll;\n\nconst int INF = 1e9-1;\n\n\n\nclass Node {\npublic:\n Node(int value) {\n v = value;\n p = NULL;\n l = NULL;\n r = NULL;\n }\n \n \n int v;\n Node* p;\n Node* l;\n Node* r;\n};\n\n\n\nclass BinaryTree {\npublic:\n BinaryTree() {\n root = NULL;\n }\n \n \n Node* root;\n \n \n void insert(int value) {\n Node* x = new Node(value); //????????????????????????\n \n \n Node* ptr = root; //tree??°?????¨???????????????\n Node* ptr_parent = NULL;\n while( ptr!=NULL ) { //NULL????????????????????§?????????????????¨???ptr_parent????????????????????????\n ptr_parent = ptr;\n if( x->v < ptr->v ) ptr = ptr->l;\n else ptr = ptr->r;\n }\n \n \n if(ptr_parent==NULL) { //tree???????????£?????????????????¨????????????????????????\n root = x;\n return;\n }\n else if( x->v < ptr_parent->v) {\n ptr_parent->l = x;\n }\n else {\n ptr_parent->r = x;\n }\n }\n \n \n static void printInorder(Node* x) {\n if(x==NULL) return;\n \n printInorder(x->l);\n cout << \" \" << x->v;\n printInorder(x->r);\n }\n \n \n static void printPreorder(Node* x) {\n if(x==NULL) return;\n \n cout << \" \" << x->v;\n printPreorder(x->l);\n printPreorder(x->r);\n }\n \n \n};\n\n\nint main(){\n BinaryTree tree;\n \n int numOfQuery; cin >> numOfQuery;\n string command;\n int value;\n rep(i,0,numOfQuery) {\n cin >> command;\n if(command[0]=='i') {\n cin >> value;\n tree.insert(value);\n } else {\n BinaryTree::printInorder(tree.root);\n cout << endl;\n BinaryTree::printPreorder(tree.root);\n cout << endl;\n }\n }\n \n#ifdef OUTPUT2TEXTFILE\n outputfile.close();\n cout << \"\\\"\" << OutputFilePath << \"\\\"\" << endl;\n#endif\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1506403008, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/C++/s219344991.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s219344991", "user_id": "u713060520"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "#include \n#include // next_permutation\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include //accumulate\n//#include //???????????\\??¢??°\n#include //ifstream, ofstream\n\n//#define NDEBUG //NDEBUG???#include ???????????????????????????????????´???assert?????????????????????????????????NDEBUG?????????????????????????????????????????????\n#include //assert\n\n\nusing namespace std;\n\n//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????\n#define TEST //*******************************************************************************************************************************************\n//?????????????????¨??§?????\\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????\n//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨??? ????????????????????????cerr????????£????????????????????????????????????\n#ifdef TEST\n#define dout cout\n#else\nstringstream dummy; //???????????°??????dout?????????????????????????????????\n#define dout dummy.str(\"\"); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????\n//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1\n#endif\n\n//?¨??????????????????????????????????????????????????????´??????OUTPUT2TEXTFILE????????????????????¬???????????????????????????????????¢????????????\n//#define OUTPUT2TEXTFILE //*******************************************************************************************************************************************\n#ifdef OUTPUT2TEXTFILE\n#define dout outputfile //??¨????????????TLE????????§?????????dout?????¨??¨??????????????¢????????????????????????????????????????????§????¨????????????´??????????????£??????????????????????¨?????????????????????????????????????????????§?????????????????????\n//TEST??????????????????????????¨???outputfile??????????????????????????????\n#define OUTPUTFILENAME \"output.txt\"\nofstream outputfile(OUTPUTFILENAME);\n#define OutputFilePath \"/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt\"\n#endif\n\n#define disp(A) dout << #A << \" = \" << (A) << endl\n#define disP(A) dout << setw(3) << (A) << \" \" // << setw(3) ??????????????\\????????????\n#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)\n\n#define dispAll(A,n) dout << #A << \" = \"; rep(j, 0, (n)) {disP(A[j]);} dout << endl\n\ntypedef pair pii;\ntypedef vector vi;\ntypedef unsigned long long ll;\n\nconst int INF = 1e9-1;\n\n\n\nclass Node {\npublic:\n Node(int value) {\n v = value;\n p = NULL;\n l = NULL;\n r = NULL;\n }\n \n \n int v;\n Node* p;\n Node* l;\n Node* r;\n};\n\n\n\nclass BinaryTree {\npublic:\n BinaryTree() {\n root = NULL;\n }\n \n \n Node* root;\n \n \n void insert(int value) {\n Node* x = new Node(value); //????????????????????????\n \n \n Node* ptr = root; //tree??°?????¨???????????????\n Node* ptr_parent = NULL;\n while( ptr!=NULL ) { //NULL????????????????????§?????????????????¨???ptr_parent????????????????????????\n ptr_parent = ptr;\n if( x->v < ptr->v ) ptr = ptr->l;\n else ptr = ptr->r;\n }\n \n \n if(ptr_parent==NULL) { //tree???????????£?????????????????¨????????????????????????\n root = x;\n return;\n }\n else if( x->v < ptr_parent->v) {\n ptr_parent->l = x;\n }\n else {\n ptr_parent->r = x;\n }\n }\n \n \n static void printInorder(Node* x) {\n if(x==NULL) return;\n \n printInorder(x->l);\n cout << \" \" << x->v;\n printInorder(x->r);\n }\n \n \n static void printPreorder(Node* x) {\n if(x==NULL) return;\n \n cout << \" \" << x->v;\n printPreorder(x->l);\n printPreorder(x->r);\n }\n \n \n};\n\n\nint main(){\n BinaryTree tree;\n \n int numOfQuery; cin >> numOfQuery;\n string command;\n int value;\n rep(i,0,numOfQuery) {\n cin >> command;\n if(command[0]=='i') {\n cin >> value;\n tree.insert(value);\n } else {\n BinaryTree::printInorder(tree.root);\n cout << endl;\n BinaryTree::printPreorder(tree.root);\n cout << endl;\n }\n }\n \n#ifdef OUTPUT2TEXTFILE\n outputfile.close();\n cout << \"\\\"\" << OutputFilePath << \"\\\"\" << endl;\n#endif\n \n return 0;\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5003, "cpu_time_ms": 510, "memory_kb": 26636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s371486432", "group_id": "codeNet:p02289", "input_text": "#include\n#include\n#define MAX 2000000+5\nusing namespace std;\nint heap[MAX];\nint num;\nvoid maxheapify(int i){\n\tint largest;\n\tint left=i*2;int right=i*2+1;\n\tif(left<=num&&heap[left]>heap[i]){\n\t\tlargest=left;\n\t}else{\n\t\tlargest=i;\n\t}\n\tif(right<=num&&heap[largest]1&&heap[t/2]\n#include\n#define MAX 2000000+5\nusing namespace std;\nint heap[MAX];\nint num;\nvoid maxheapify(int i){\n\tint largest;\n\tint left=i*2;int right=i*2+1;\n\tif(left<=num&&heap[left]>heap[i]){\n\t\tlargest=left;\n\t}else{\n\t\tlargest=i;\n\t}\n\tif(right<=num&&heap[largest]1&&heap[t/2]\n#include \n#include \nusing namespace std;\nint main()\n{\n\tpriority_queue Q;\n\tstring S;\n\twhile(true)\n\t{\n\t\tcin >> S;\n\t\tif (S == \"end\")\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (S == \"insert\")\n\t\t\t{\n\t\t\t\tint a;\n\t\t\t\tcin >> a;\n\t\t\t\tQ.push(a);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << Q.top() << endl;\n\t\t\t\tQ.pop();\n\t\t\t}\n\t\t}\n\t}\n}\n", "language": "C++", "metadata": {"date": 1559874161, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/C++/s002643060.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s002643060", "user_id": "u202003995"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\nint main()\n{\n\tpriority_queue Q;\n\tstring S;\n\twhile(true)\n\t{\n\t\tcin >> S;\n\t\tif (S == \"end\")\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (S == \"insert\")\n\t\t\t{\n\t\t\t\tint a;\n\t\t\t\tcin >> a;\n\t\t\t\tQ.push(a);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << Q.top() << endl;\n\t\t\t\tQ.pop();\n\t\t\t}\n\t\t}\n\t}\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 343, "cpu_time_ms": 1290, "memory_kb": 7044}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s352316240", "group_id": "codeNet:p02328", "input_text": "#include \nusing namespace std;\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define rep(i,n) FOR(i,0,n)\n#define pb push_back\n#define mp make_pair\ntypedef long long ll;\ntypedef pair pint;\n\nstruct rect{int ht;int pos;};\nint tb[100001];\nint area_rect(int size,int buf[]){\n stack st;\n int mx=0;\n buf[size]=0;\n rep(i,size+1){\n rect r;\n r.ht=buf[i];\n r.pos=i;\n if(st.empty()) st.push(r);\n else{\n if(st.top().htr.ht){\n int ti=i;\n while(!st.empty()&&st.top().ht>=r.ht){\n rect pre=st.top();st.pop();\n int area=pre.ht*(i-pre.pos);\n mx=max(mx,area);\n ti=pre.pos;\n }\n r.pos = ti;\n st.push(r);\n }\n }\n }\n return mx;\n}\nint main(){\n int n;\n cin>>n;\n rep(i,n) cin>>tb[i];\n int mx=area_rect(n,tb);\n cout<\nusing namespace std;\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define rep(i,n) FOR(i,0,n)\n#define pb push_back\n#define mp make_pair\ntypedef long long ll;\ntypedef pair pint;\n\nstruct rect{int ht;int pos;};\nint tb[100001];\nint area_rect(int size,int buf[]){\n stack st;\n int mx=0;\n buf[size]=0;\n rep(i,size+1){\n rect r;\n r.ht=buf[i];\n r.pos=i;\n if(st.empty()) st.push(r);\n else{\n if(st.top().htr.ht){\n int ti=i;\n while(!st.empty()&&st.top().ht>=r.ht){\n rect pre=st.top();st.pop();\n int area=pre.ht*(i-pre.pos);\n mx=max(mx,area);\n ti=pre.pos;\n }\n r.pos = ti;\n st.push(r);\n }\n }\n }\n return mx;\n}\nint main(){\n int n;\n cin>>n;\n rep(i,n) cin>>tb[i];\n int mx=area_rect(n,tb);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n#define MOD 1000000007\nusing ll = long long;\n\nbool operator<(const pair& a, const pair& b) {\n\tif (a.first == b.first) {\n\t\treturn a.second < b.second;\n\t}\n\treturn a.first < b.first;\n}\n\nconst int INF = (1LL << 31) - 1;\nconst int sqrtN = 512;\n\nstruct SqrtDecomposition {\n\tint N, K;\n\tvector data; //内部の値, どのタイミングで変更したか\n\tvector bucketSum;\n\tvector bucketAdd;\n\tSqrtDecomposition(int n) : N(n) {\n\t\tK = (N + sqrtN - 1) / sqrtN;\n\t\tdata.assign(K*sqrtN, 0);\n\t\tbucketSum.assign(K, 0);\n\t\tbucketAdd.assign(K, 0);\n\t}\n\n\t// [s, t)\n\tvoid add(ll s, ll t, ll x) {\n\t\tfor (int k = 0; k < K; ++k) {\n\t\t\tll l = k * sqrtN, r = (k + 1) *sqrtN;\n\t\t\tif (r <= s || t <= l) continue;\n\t\t\tif (s <= l && r <= t) {\n\t\t\t\tbucketAdd[k] += x;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (int i = max(s, l); i < min(t, r); ++i) {\n\t\t\t\t\tdata[i] += x;\n\t\t\t\t\tbucketSum[k] += x;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//[x, y)\n\tll getSum(ll s, ll t) {\n\t\tll sum = 0;\n\t\tfor (int k = 0; k < K; ++k) {\n\t\t\tll l = k * sqrtN, r = (k + 1)*sqrtN;\n\t\t\tif (r <= s || t <= l) continue;\n\t\t\tif (s <= l && r <= t) {\n\t\t\t\tsum += bucketSum[k] + bucketAdd[k] * sqrtN;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (int i = max(s, l); i < min(t, r); ++i) {\n\t\t\t\t\tsum += data[i] + bucketAdd[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n};\nint main() {\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\t\n\tll n, q; cin >> n >> q;\n\tSqrtDecomposition sd(n);\n\n\tfor (int i = 0; i < q; ++i) {\n\t\tll com; cin >> com;\n\t\tif (com == 0) {\n\t\t\tll s, t, x; cin >> s >> t >> x;\n\t\t\tsd.add(s, t+1, x);\n\t\t}\n\t\telse {\n\t\t\tll x, y; cin >> x>> y;\n\t\t\tcout << sd.getSum(x, y+1) << endl;\n\t\t}\n\t}\n\tint a; cin >> a;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1554317979, "filename_ext": "cpp", "original_language": "C++11", "problem_description_relpath": "problem_descriptions/p02351.html", "problem_id": "p02351", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02351/input.txt", "sample_output_relpath": "derived/input_output/data/p02351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02351/C++/s860541717.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s860541717", "user_id": "u578258337"}, "prompt_components": {"gold_output": "4\n8\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n#define MOD 1000000007\nusing ll = long long;\n\nbool operator<(const pair& a, const pair& b) {\n\tif (a.first == b.first) {\n\t\treturn a.second < b.second;\n\t}\n\treturn a.first < b.first;\n}\n\nconst int INF = (1LL << 31) - 1;\nconst int sqrtN = 512;\n\nstruct SqrtDecomposition {\n\tint N, K;\n\tvector data; //内部の値, どのタイミングで変更したか\n\tvector bucketSum;\n\tvector bucketAdd;\n\tSqrtDecomposition(int n) : N(n) {\n\t\tK = (N + sqrtN - 1) / sqrtN;\n\t\tdata.assign(K*sqrtN, 0);\n\t\tbucketSum.assign(K, 0);\n\t\tbucketAdd.assign(K, 0);\n\t}\n\n\t// [s, t)\n\tvoid add(ll s, ll t, ll x) {\n\t\tfor (int k = 0; k < K; ++k) {\n\t\t\tll l = k * sqrtN, r = (k + 1) *sqrtN;\n\t\t\tif (r <= s || t <= l) continue;\n\t\t\tif (s <= l && r <= t) {\n\t\t\t\tbucketAdd[k] += x;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (int i = max(s, l); i < min(t, r); ++i) {\n\t\t\t\t\tdata[i] += x;\n\t\t\t\t\tbucketSum[k] += x;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//[x, y)\n\tll getSum(ll s, ll t) {\n\t\tll sum = 0;\n\t\tfor (int k = 0; k < K; ++k) {\n\t\t\tll l = k * sqrtN, r = (k + 1)*sqrtN;\n\t\t\tif (r <= s || t <= l) continue;\n\t\t\tif (s <= l && r <= t) {\n\t\t\t\tsum += bucketSum[k] + bucketAdd[k] * sqrtN;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (int i = max(s, l); i < min(t, r); ++i) {\n\t\t\t\t\tsum += data[i] + bucketAdd[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}\n};\nint main() {\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\t\n\tll n, q; cin >> n >> q;\n\tSqrtDecomposition sd(n);\n\n\tfor (int i = 0; i < q; ++i) {\n\t\tll com; cin >> com;\n\t\tif (com == 0) {\n\t\t\tll s, t, x; cin >> s >> t >> x;\n\t\t\tsd.add(s, t+1, x);\n\t\t}\n\t\telse {\n\t\t\tll x, y; cin >> x>> y;\n\t\t\tcout << sd.getSum(x, y+1) << endl;\n\t\t}\n\t}\n\tint a; cin >> a;\n\treturn 0;\n}\n", "problem_context": "RSQ and RAQ\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(s, t, x): add x to as, as+1, ..., at.\n\ngetSum(s, t): report the sum of as, as+1, ..., at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 s t\n\nThe first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes getSum(s, t).\n\nOutput\n\nFor each getSum operation, print the sum;\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n1 ≤ s ≤ t ≤ n\n\n0 ≤ x < 1000\n\nSample Input 1\n\n3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 1 2\n1 2 3\n\nSample Output 1\n\n4\n8\n\nSample Input 2\n\n4 3\n1 1 4\n0 1 4 1\n1 1 4\n\nSample Output 2\n\n0\n4", "sample_input": "3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 1 2\n1 2 3\n"}, "reference_outputs": ["4\n8\n"], "source_document_id": "p02351", "source_text": "RSQ and RAQ\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(s, t, x): add x to as, as+1, ..., at.\n\ngetSum(s, t): report the sum of as, as+1, ..., at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 s t\n\nThe first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes getSum(s, t).\n\nOutput\n\nFor each getSum operation, print the sum;\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n1 ≤ s ≤ t ≤ n\n\n0 ≤ x < 1000\n\nSample Input 1\n\n3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 1 2\n1 2 3\n\nSample Output 1\n\n4\n8\n\nSample Input 2\n\n4 3\n1 1 4\n0 1 4 1\n1 1 4\n\nSample Output 2\n\n0\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1817, "cpu_time_ms": 150, "memory_kb": 3608}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s806969933", "group_id": "codeNet:p02353", "input_text": "// clang-format off\n#include \nusing namespace std;\n#define int long long\n#define main signed main()\n#define loop(i, a, n) for (int i = (a); i < (n); i++)\n#define rep(i, n) loop(i, 0, n)\n#define all(v) (v).begin(), (v).end()\n#define rall(v) (v).rbegin(), (v).rend()\n#define prec(n) fixed << setprecision(n)\nconstexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;\nconstexpr int MOD = 1000000007;\nconstexpr double PI = 3.14159265358979;\ntemplate bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }\ntemplate bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }\nbool odd(const int &n) { return n & 1; }\nbool even(const int &n) { return ~n & 1; }\ntemplate T in() { T x; cin >> x; return x; }\ntemplate T in(T &&x) { T z(forward(x)); cin >> z; return z; }\ntemplate istream &operator>>(istream &is, vector &v) { for (T &x : v) is >> x; return is; }\ntemplate istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second; }\ntemplate ostream &operator<<(ostream &os, const vector> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? \"\" : \"\\n\"); return os; }\ntemplate ostream &operator<<(ostream &os, const vector &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? \"\" : \" \"); return os; }\ntemplate ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second; }\ntemplate auto vectors(const Head &head, const Value &v) { return vector(head, v); }\ntemplate auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector(x, inner); }\n// clang-format on\n\ntemplate class LazySegTree {\n using FoldMonoid = typename LSTTrait::FoldMonoid;\n using ActionMonoid = typename LSTTrait::ActionMonoid;\n using T = typename FoldMonoid::value_type;\n using Q = typename ActionMonoid::value_type;\n\n LSTTrait lstTrait; // apply :: (T, Q) -> T, pow :: (Q, int) -> Q\n FoldMonoid foldM;\n ActionMonoid actionM;\n int size = 1;\n vector tree; // 1-indexed\n vector lazy; // 1-indexed\n\n void push(int i) {\n stack> s;\n for (int d = 1; i /= 2; d *= 2) s.emplace(i, d);\n for (int x, d; s.size(); s.pop()) {\n tie(x, d) = s.top();\n update(x * 2, lazy[x], d);\n update(x * 2 + 1, lazy[x], d);\n lazy[x] = actionM.id();\n }\n }\n\n void update(const int &i, const Q &x, const int &d) {\n tree[i] = lstTrait.apply(tree[i], lstTrait.pow(x, d));\n if (i < size) lazy[i] = actionM(lazy[i], x);\n }\n\n void build(int i) {\n for (int d = 2; i /= 2; d *= 2) tree[i] = lstTrait.apply(foldM(tree[i * 2], tree[i * 2 + 1]), lstTrait.pow(lazy[i], d));\n }\n\npublic:\n LazySegTree(const int &n = 0) {\n while (size < n) size *= 2;\n tree.assign(size * 2, foldM.id());\n lazy.assign(size, actionM.id());\n }\n\n LazySegTree(const int &n, const T &x) {\n while (size < n) size *= 2;\n tree.assign(size * 2, x);\n lazy.assign(size, actionM.id());\n for (int i = size - 1; i >= 1; i--) tree[i] = foldM(tree[i * 2], tree[i * 2 + 1]);\n }\n\n template LazySegTree(InputIterator first, InputIterator last) {\n int n = distance(first, last);\n while (size < n) size *= 2;\n tree.resize(size * 2, foldM.id());\n lazy.assign(size, actionM.id());\n copy(first, last, tree.begin() + size);\n for (int i = size - 1; i >= 1; i--) tree[i] = foldM(tree[i * 2], tree[i * 2 + 1]);\n }\n\n void act(int l, int r, const Q &x) { // [l, r) += x\n int l0 = l += size, r0 = r += size;\n push(l0), push(r0 - 1);\n for (int d = 1; l < r; l /= 2, r /= 2, d *= 2) {\n if (l & 1) update(l++, x, d);\n if (r & 1) update(--r, x, d);\n }\n build(l0);\n build(r0 - 1);\n }\n\n T fold(int l, int r) { // [l, r)\n T accl = foldM.id(), accr = foldM.id();\n for (push(l += size), push((r += size) - 1); l < r; l /= 2, r /= 2) {\n if (l & 1) accl = foldM(accl, tree[l++]);\n if (r & 1) accr = foldM(tree[--r], accr);\n }\n return foldM(accl, accr);\n }\n};\n\ntemplate struct sumMonoid {\n using value_type = T;\n value_type id() { return 0; }\n value_type operator()(const value_type &a, const value_type &b) { return a + b; }\n};\n\ntemplate struct updateMonoid {\n using value_type = pair;\n value_type id() { return {false, T()}; }\n value_type operator()(const value_type &a, const value_type &b) { return b.first ? b : a; }\n};\n\ntemplate struct RSQ_RUQ_Trait {\n using FoldMonoid = sumMonoid;\n using ActionMonoid = updateMonoid;\n typename FoldMonoid::value_type apply(typename FoldMonoid::value_type t, typename ActionMonoid::value_type q) { return q.first ? q.second : t; }\n typename ActionMonoid::value_type pow(typename ActionMonoid::value_type q, const int &d) { return {q.first, q.second * d}; }\n};\n\nmain {\n int n, q;\n cin >> n >> q;\n LazySegTree> lst(n, 0);\n while (q--) {\n if (in()) {\n int s, t;\n cin >> s >> t;\n cout << lst.fold(s, t + 1) << endl;\n } else {\n int s, t, x;\n cin >> s >> t >> x;\n lst.act(s, t + 1, {true, x});\n }\n }\n}\n\n", "language": "C++", "metadata": {"date": 1527795299, "filename_ext": "cpp", "original_language": "C++14", "problem_description_relpath": "problem_descriptions/p02353.html", "problem_id": "p02353", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02353/input.txt", "sample_output_relpath": "derived/input_output/data/p02353/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02353/C++/s806969933.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806969933", "user_id": "u449960815"}, "prompt_components": {"gold_output": "-5\n1\n6\n8\n", "input_to_evaluate": "// clang-format off\n#include \nusing namespace std;\n#define int long long\n#define main signed main()\n#define loop(i, a, n) for (int i = (a); i < (n); i++)\n#define rep(i, n) loop(i, 0, n)\n#define all(v) (v).begin(), (v).end()\n#define rall(v) (v).rbegin(), (v).rend()\n#define prec(n) fixed << setprecision(n)\nconstexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;\nconstexpr int MOD = 1000000007;\nconstexpr double PI = 3.14159265358979;\ntemplate bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }\ntemplate bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }\nbool odd(const int &n) { return n & 1; }\nbool even(const int &n) { return ~n & 1; }\ntemplate T in() { T x; cin >> x; return x; }\ntemplate T in(T &&x) { T z(forward(x)); cin >> z; return z; }\ntemplate istream &operator>>(istream &is, vector &v) { for (T &x : v) is >> x; return is; }\ntemplate istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second; }\ntemplate ostream &operator<<(ostream &os, const vector> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? \"\" : \"\\n\"); return os; }\ntemplate ostream &operator<<(ostream &os, const vector &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? \"\" : \" \"); return os; }\ntemplate ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second; }\ntemplate auto vectors(const Head &head, const Value &v) { return vector(head, v); }\ntemplate auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector(x, inner); }\n// clang-format on\n\ntemplate class LazySegTree {\n using FoldMonoid = typename LSTTrait::FoldMonoid;\n using ActionMonoid = typename LSTTrait::ActionMonoid;\n using T = typename FoldMonoid::value_type;\n using Q = typename ActionMonoid::value_type;\n\n LSTTrait lstTrait; // apply :: (T, Q) -> T, pow :: (Q, int) -> Q\n FoldMonoid foldM;\n ActionMonoid actionM;\n int size = 1;\n vector tree; // 1-indexed\n vector lazy; // 1-indexed\n\n void push(int i) {\n stack> s;\n for (int d = 1; i /= 2; d *= 2) s.emplace(i, d);\n for (int x, d; s.size(); s.pop()) {\n tie(x, d) = s.top();\n update(x * 2, lazy[x], d);\n update(x * 2 + 1, lazy[x], d);\n lazy[x] = actionM.id();\n }\n }\n\n void update(const int &i, const Q &x, const int &d) {\n tree[i] = lstTrait.apply(tree[i], lstTrait.pow(x, d));\n if (i < size) lazy[i] = actionM(lazy[i], x);\n }\n\n void build(int i) {\n for (int d = 2; i /= 2; d *= 2) tree[i] = lstTrait.apply(foldM(tree[i * 2], tree[i * 2 + 1]), lstTrait.pow(lazy[i], d));\n }\n\npublic:\n LazySegTree(const int &n = 0) {\n while (size < n) size *= 2;\n tree.assign(size * 2, foldM.id());\n lazy.assign(size, actionM.id());\n }\n\n LazySegTree(const int &n, const T &x) {\n while (size < n) size *= 2;\n tree.assign(size * 2, x);\n lazy.assign(size, actionM.id());\n for (int i = size - 1; i >= 1; i--) tree[i] = foldM(tree[i * 2], tree[i * 2 + 1]);\n }\n\n template LazySegTree(InputIterator first, InputIterator last) {\n int n = distance(first, last);\n while (size < n) size *= 2;\n tree.resize(size * 2, foldM.id());\n lazy.assign(size, actionM.id());\n copy(first, last, tree.begin() + size);\n for (int i = size - 1; i >= 1; i--) tree[i] = foldM(tree[i * 2], tree[i * 2 + 1]);\n }\n\n void act(int l, int r, const Q &x) { // [l, r) += x\n int l0 = l += size, r0 = r += size;\n push(l0), push(r0 - 1);\n for (int d = 1; l < r; l /= 2, r /= 2, d *= 2) {\n if (l & 1) update(l++, x, d);\n if (r & 1) update(--r, x, d);\n }\n build(l0);\n build(r0 - 1);\n }\n\n T fold(int l, int r) { // [l, r)\n T accl = foldM.id(), accr = foldM.id();\n for (push(l += size), push((r += size) - 1); l < r; l /= 2, r /= 2) {\n if (l & 1) accl = foldM(accl, tree[l++]);\n if (r & 1) accr = foldM(tree[--r], accr);\n }\n return foldM(accl, accr);\n }\n};\n\ntemplate struct sumMonoid {\n using value_type = T;\n value_type id() { return 0; }\n value_type operator()(const value_type &a, const value_type &b) { return a + b; }\n};\n\ntemplate struct updateMonoid {\n using value_type = pair;\n value_type id() { return {false, T()}; }\n value_type operator()(const value_type &a, const value_type &b) { return b.first ? b : a; }\n};\n\ntemplate struct RSQ_RUQ_Trait {\n using FoldMonoid = sumMonoid;\n using ActionMonoid = updateMonoid;\n typename FoldMonoid::value_type apply(typename FoldMonoid::value_type t, typename ActionMonoid::value_type q) { return q.first ? q.second : t; }\n typename ActionMonoid::value_type pow(typename ActionMonoid::value_type q, const int &d) { return {q.first, q.second * d}; }\n};\n\nmain {\n int n, q;\n cin >> n >> q;\n LazySegTree> lst(n, 0);\n while (q--) {\n if (in()) {\n int s, t;\n cin >> s >> t;\n cout << lst.fold(s, t + 1) << endl;\n } else {\n int s, t, x;\n cin >> s >> t >> x;\n lst.act(s, t + 1, {true, x});\n }\n }\n}\n\n", "problem_context": "RSQ and RUQ\n\nWrite a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:\n\n$update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.\n\n$getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.\n\nNote that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.\n\nInput\n\n$n$ $q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nIn the first line, $n$ (the number of elements in $A$) and $q$ (the number of queries) are given. Then, $i$-th query $query_i$ is given in the following format:\n\n0 $s$ $t$ $x$\n\nor\n\n1 $s$ $t$\n\nThe first digit represents the type of the query. '0' denotes $update(s, t, x)$\nand '1' denotes $find(s, t)$.\n\nOutput\n\nFor each $getSum$ query, print the sum in a line.\n\nConstraints\n\n$1 ≤ n ≤ 100000$\n\n$1 ≤ q ≤ 100000$\n\n$0 ≤ s ≤ t < n$\n\n$-1000 ≤ x ≤ 1000$\n\nSample Input 1\n\n6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5\n\nSample Output 1\n\n-5\n1\n6\n8", "sample_input": "6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5\n"}, "reference_outputs": ["-5\n1\n6\n8\n"], "source_document_id": "p02353", "source_text": "RSQ and RUQ\n\nWrite a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:\n\n$update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.\n\n$getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.\n\nNote that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.\n\nInput\n\n$n$ $q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nIn the first line, $n$ (the number of elements in $A$) and $q$ (the number of queries) are given. Then, $i$-th query $query_i$ is given in the following format:\n\n0 $s$ $t$ $x$\n\nor\n\n1 $s$ $t$\n\nThe first digit represents the type of the query. '0' denotes $update(s, t, x)$\nand '1' denotes $find(s, t)$.\n\nOutput\n\nFor each $getSum$ query, print the sum in a line.\n\nConstraints\n\n$1 ≤ n ≤ 100000$\n\n$1 ≤ q ≤ 100000$\n\n$0 ≤ s ≤ t < n$\n\n$-1000 ≤ x ≤ 1000$\n\nSample Input 1\n\n6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5\n\nSample Output 1\n\n-5\n1\n6\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5378, "cpu_time_ms": 200, "memory_kb": 7008}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s619289085", "group_id": "codeNet:p02364", "input_text": "#include\n#include\n#include\n#include\n\nusing namespace std;\n\n\nstruct edge {int u,v,cost;};\nedge cookies[100000000];\n\nint V,E;\nint par[1000000],rank[10000000];\n\nvoid init(int n){\n for(int i=0;i\n#include\n#include\n#include\n\nusing namespace std;\n\n\nstruct edge {int u,v,cost;};\nedge cookies[100000000];\n\nint V,E;\nint par[1000000],rank[10000000];\n\nvoid init(int n){\n for(int i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef pair P;\nstatic const int INF = 1e9;\nstatic const int SIZE = 100001;\n\nstruct edge\n{\n\tint to, cost;\n};\n\nvector G[SIZE];\nint d[SIZE];\nint n;\n\nvoid bfs(int v)\n{\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\td[i] = INF;\n\t}\n\td[v] = 0;\n\tpriority_queue < P, vector

, greater

> pque;\n\tpque.push(P(0, v));\n\twhile (!pque.empty())\n\t{\n\t\tP p = pque.top();\n\t\tpque.pop();\n\t\tint vertex = p.second;\n\t\tfor (int i = 0; i < G[vertex].size(); ++i)\n\t\t{\n\t\t\tedge e = G[vertex][i];\n\t\t\tif (d[e.to] > d[vertex] + e.cost)\n\t\t\t{\n\t\t\t\td[e.to] = d[vertex] + e.cost;\n\t\t\t\tpque.push(P(d[e.to], e.to));\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid solve()\n{\n\tcin >> n;\n\tfor (int i = 0; i < n - 1; ++i)\n\t{\n\t\tint s, t, w;\n\t\tcin >> s >> t >> w;\n\t\tedge e1, e2;\n\t\te1.to = t;\n\t\te2.to = s;\n\t\te1.cost = e2.cost = w;\n\t\tG[s].push_back(e1);\n\t\tG[t].push_back(e2);\n\t}\n\tbfs(0);\n\tint maxDist = 0;\n\tint maxv = 0;\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\tif (maxDist < d[i])\n\t\t{\n\t\t\tmaxDist = d[i];\n\t\t\tmaxv = i;\n\t\t}\n\t}\n\tbfs(maxv);\n\tmaxDist = 0;\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tif (maxDist < d[i])\n\t\t{\n\t\t\tmaxDist = d[i];\n\t\t}\n\t}\n\tcout << maxDist << endl;\n}\n\nint main()\n{\n\tsolve();\n\treturn(0);\n}", "language": "C++", "metadata": {"date": 1462114414, "filename_ext": "cpp", "original_language": "C++", "problem_description_relpath": "problem_descriptions/p02371.html", "problem_id": "p02371", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02371/input.txt", "sample_output_relpath": "derived/input_output/data/p02371/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02371/C++/s066271753.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066271753", "user_id": "u285015144"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef pair P;\nstatic const int INF = 1e9;\nstatic const int SIZE = 100001;\n\nstruct edge\n{\n\tint to, cost;\n};\n\nvector G[SIZE];\nint d[SIZE];\nint n;\n\nvoid bfs(int v)\n{\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\td[i] = INF;\n\t}\n\td[v] = 0;\n\tpriority_queue < P, vector

, greater

> pque;\n\tpque.push(P(0, v));\n\twhile (!pque.empty())\n\t{\n\t\tP p = pque.top();\n\t\tpque.pop();\n\t\tint vertex = p.second;\n\t\tfor (int i = 0; i < G[vertex].size(); ++i)\n\t\t{\n\t\t\tedge e = G[vertex][i];\n\t\t\tif (d[e.to] > d[vertex] + e.cost)\n\t\t\t{\n\t\t\t\td[e.to] = d[vertex] + e.cost;\n\t\t\t\tpque.push(P(d[e.to], e.to));\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid solve()\n{\n\tcin >> n;\n\tfor (int i = 0; i < n - 1; ++i)\n\t{\n\t\tint s, t, w;\n\t\tcin >> s >> t >> w;\n\t\tedge e1, e2;\n\t\te1.to = t;\n\t\te2.to = s;\n\t\te1.cost = e2.cost = w;\n\t\tG[s].push_back(e1);\n\t\tG[t].push_back(e2);\n\t}\n\tbfs(0);\n\tint maxDist = 0;\n\tint maxv = 0;\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\tif (maxDist < d[i])\n\t\t{\n\t\t\tmaxDist = d[i];\n\t\t\tmaxv = i;\n\t\t}\n\t}\n\tbfs(maxv);\n\tmaxDist = 0;\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tif (maxDist < d[i])\n\t\t{\n\t\t\tmaxDist = d[i];\n\t\t}\n\t}\n\tcout << maxDist << endl;\n}\n\nint main()\n{\n\tsolve();\n\treturn(0);\n}", "problem_context": "Diameter of a Tree\n\nGiven a tree T with non-negative weight, find the diameter of the tree.\n\nThe diameter of a tree is the maximum distance between two nodes in a tree.\n\nInput\n\nn\ns1 t1 w1\ns2 t2 w2\n:\nsn-1 tn-1 wn-1\n\nThe first line consists of an integer n which represents the number of nodes in the tree. Every node has a unique ID from 0 to n-1 respectively.\n\nIn the following n-1 lines, edges of the tree are given.\n\nsi and ti represent end-points of the i-th edge (undirected) and wi represents the weight (distance) of the i-th edge.\n\nOutput\n\nPrint the diameter of the tree in a line.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ wi ≤ 1,000\n\nSample Input 1\n\n4\n0 1 2\n1 2 1\n1 3 3\n\nSample Output 1\n\n5\n\nSample Input 2\n\n4\n0 1 1\n1 2 2\n2 3 4\n\nSample Output 2\n\n7", "sample_input": "4\n0 1 2\n1 2 1\n1 3 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02371", "source_text": "Diameter of a Tree\n\nGiven a tree T with non-negative weight, find the diameter of the tree.\n\nThe diameter of a tree is the maximum distance between two nodes in a tree.\n\nInput\n\nn\ns1 t1 w1\ns2 t2 w2\n:\nsn-1 tn-1 wn-1\n\nThe first line consists of an integer n which represents the number of nodes in the tree. Every node has a unique ID from 0 to n-1 respectively.\n\nIn the following n-1 lines, edges of the tree are given.\n\nsi and ti represent end-points of the i-th edge (undirected) and wi represents the weight (distance) of the i-th edge.\n\nOutput\n\nPrint the diameter of the tree in a line.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ wi ≤ 1,000\n\nSample Input 1\n\n4\n0 1 2\n1 2 1\n1 3 3\n\nSample Output 1\n\n5\n\nSample Input 2\n\n4\n0 1 1\n1 2 2\n2 3 4\n\nSample Output 2\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1243, "cpu_time_ms": 110, "memory_kb": 7984}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s455919721", "group_id": "codeNet:p02396", "input_text": "#include\nusing namespace std;\nint main(){\n\tint x = 0;\n\tcin >> x;\n\tfor (int i = 0; i >= 0;i++){\n\t\tif (x != 0){\n\t\t\tcout << \"Case\" << \" \" << i << \"; \" <\nusing namespace std;\nint main(){\n\tint x = 0;\n\tcin >> x;\n\tfor (int i = 0; i >= 0;i++){\n\t\tif (x != 0){\n\t\t\tcout << \"Case\" << \" \" << i << \"; \" <\nusing namespace std;\nint main(){\n int n,m,l;\n cin>>n>>m>>l;\n \n int a[100][100];\n for(int i=0;i>a[i][j];\n \n int b[100][100];\n for(int i=0;i>b[i][j];\n \n long long c[100][100] = {};\n for(int i=0;i\nusing namespace std;\nint main(){\n int n,m,l;\n cin>>n>>m>>l;\n \n int a[100][100];\n for(int i=0;i>a[i][j];\n \n int b[100][100];\n for(int i=0;i>b[i][j];\n \n long long c[100][100] = {};\n for(int i=0;i& lhs,const pair& rhs){return lhs.c comp rhs.c;}\n\nusing namespace std;\nusing ll = long long;\n\nconstexpr ll atcoder_mod = 1e9+7;\n\ntemplate\nT in(){T x; cin >> x; return (x);}\ntemplate>\nC vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}\n\nvoid vout(){cout << endl;}\ntemplate\nvoid vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward(t)...);}\nvoid out(){cout << endl;}\ntemplate\nvoid out(Head&& h,Tail&&... t){cout << h;vout(forward(t)...);}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\t\n\tint Q=in();\n\tset S;\n\tREP(i,Q){\n\t\tint q=in();\n\t\tif(q==1){\n\t\t\tout(S.find(in())==S.end()?0:1);\n\t\t}\n\t\telse if(q==2){\n\t\t\tS.erase(in());\n\t\t}\n\t\telse{\n\t\t\tS.insert(in());\n\t\t\tout(S.size());\n\t\t}\n\t}\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1571062785, "filename_ext": "cpp", "original_language": "C++14", "problem_description_relpath": "problem_descriptions/p02456.html", "problem_id": "p02456", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02456/input.txt", "sample_output_relpath": "derived/input_output/data/p02456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02456/C++/s097422377.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s097422377", "user_id": "u442275619"}, "prompt_components": {"gold_output": "1\n2\n3\n1\n0\n1\n3\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n\n#define REP(i,num) for(int i=0;i<(num);++i)\n#define ALL(c) c.begin(),c.end()\n#define PRINTALL(c) for(auto& x:c){cout<& lhs,const pair& rhs){return lhs.c comp rhs.c;}\n\nusing namespace std;\nusing ll = long long;\n\nconstexpr ll atcoder_mod = 1e9+7;\n\ntemplate\nT in(){T x; cin >> x; return (x);}\ntemplate>\nC vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}\n\nvoid vout(){cout << endl;}\ntemplate\nvoid vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward(t)...);}\nvoid out(){cout << endl;}\ntemplate\nvoid out(Head&& h,Tail&&... t){cout << h;vout(forward(t)...);}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\t\n\tint Q=in();\n\tset S;\n\tREP(i,Q){\n\t\tint q=in();\n\t\tif(q==1){\n\t\t\tout(S.find(in())==S.end()?0:1);\n\t\t}\n\t\telse if(q==2){\n\t\t\tS.erase(in());\n\t\t}\n\t\telse{\n\t\t\tS.insert(in());\n\t\t\tout(S.size());\n\t\t}\n\t}\n\treturn 0;\n}\n", "problem_context": "Set: Delete\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.\n\ninsert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n\nfind($x$): Report the number of $x$ in $S$ (0 or 1).\n\ndelete($x$): Delete $x$ from $S$.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $x$\n\nor\n\n1 $x$\n\nor\n\n2 $x$\n\nwhere the first digits 0, 1 and 2 represent insert, find and delete operations respectively.\n\nOutput\n\nFor each insert operation, print the number of elements in $S$.\n\nFor each find operation, print the number of specified elements in $S$.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 2\n\nSample Output 1\n\n1\n2\n3\n1\n0\n1\n3", "sample_input": "8\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 2\n"}, "reference_outputs": ["1\n2\n3\n1\n0\n1\n3\n"], "source_document_id": "p02456", "source_text": "Set: Delete\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.\n\ninsert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n\nfind($x$): Report the number of $x$ in $S$ (0 or 1).\n\ndelete($x$): Delete $x$ from $S$.\n\nInput\n\nThe input is given in the following format.\n\n$q$\n$query_1$\n$query_2$\n:\n$query_q$\n\nEach query $query_i$ is given by\n\n0 $x$\n\nor\n\n1 $x$\n\nor\n\n2 $x$\n\nwhere the first digits 0, 1 and 2 represent insert, find and delete operations respectively.\n\nOutput\n\nFor each insert operation, print the number of elements in $S$.\n\nFor each find operation, print the number of specified elements in $S$.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 2\n\nSample Output 1\n\n1\n2\n3\n1\n0\n1\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1059, "cpu_time_ms": 220, "memory_kb": 12376}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s570591895", "group_id": "codeNet:p02536", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\n\nstruct UnionFind{\n\tvector par;\n\n\tUnionFind(int N){\n\t\tpar.resize(N,-1);\n\t}\n\n\tint root(int x){\n\t\tif(par[x] < 0) return x;\n\t\treturn par[x] = root(par[x]);\n\t}\n\n\tvoid unite(int x, int y){\n\t\tint rx = root(x);\n\t\tint ry = root(y);\n\t\tif(rx == ry) return;\n\t\tif(par[rx] < par[ry]){\n\t\t\tpar[rx] += par[ry];\n\t\t\tpar[ry] = rx;\n\t\t} else {\n\t\t\tpar[ry] += par[rx];\n\t\t\tpar[rx] = ry;\n\t\t}\n\t\t\n\t}\n\n\tbool same(int x, int y){\n\t\treturn par[x] == par[y];\n\t}\n\n};\n\nint main(){\n\tint N,M; cin >> N >> M;\n\tUnionFind uf(N);\n\tfor(int i=0; i> a >> b;\n\t\ta--; b--;\n\t\tuf.unite(a,b);\n\t}\n\tset s;\n\tfor(int i=0; i\nusing namespace std;\ntypedef long long ll;\n\nstruct UnionFind{\n\tvector par;\n\n\tUnionFind(int N){\n\t\tpar.resize(N,-1);\n\t}\n\n\tint root(int x){\n\t\tif(par[x] < 0) return x;\n\t\treturn par[x] = root(par[x]);\n\t}\n\n\tvoid unite(int x, int y){\n\t\tint rx = root(x);\n\t\tint ry = root(y);\n\t\tif(rx == ry) return;\n\t\tif(par[rx] < par[ry]){\n\t\t\tpar[rx] += par[ry];\n\t\t\tpar[ry] = rx;\n\t\t} else {\n\t\t\tpar[ry] += par[rx];\n\t\t\tpar[rx] = ry;\n\t\t}\n\t\t\n\t}\n\n\tbool same(int x, int y){\n\t\treturn par[x] == par[y];\n\t}\n\n};\n\nint main(){\n\tint N,M; cin >> N >> M;\n\tUnionFind uf(N);\n\tfor(int i=0; i> a >> b;\n\t\ta--; b--;\n\t\tuf.unite(a,b);\n\t}\n\tset s;\n\tfor(int i=0; i\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 all(x) (x).begin(),(x).end()\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n \nint dy4[4] = {-1, 0, +1, 0};\nint dx4[4] = {0, +1, 0, -1};\nint dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};\nint dx8[8] = {0, 1, 1, 1, 0, -1, -1, -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 \nll gcd(ll a, ll b){\n\tif (b == 0)return a;\n\treturn gcd(b, a % b);\n}\n \nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n\nll conbinationMemo[100][100];\n\nvoid cmemoInit(){\n rep(i, 100){\n rep(j, 100){\n conbinationMemo[i][j] = -1;\n }\n }\n}\n \nll nCr(ll n, ll r){\n if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];\n if(r == 0 || r == n){\n return 1;\n } else if(r == 1){\n return n;\n }\n return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));\n}\n \nll nPr(ll n, ll r){\n r = n - r;\n ll ret = 1;\n for (ll i = n; i >= r + 1; i--) ret *= i;\n return ret;\n}\n//-----------------------ここから-----------\nstruct UnionFind{\n vector parent;\n vector s;\n \n UnionFind(ll n){\n parent.resize(n);\n s.resize(n, 1);\n for(int i = 0; i < n; i++) parent[i] = i;\n }\n \n ll root(ll node){\n if(parent[node] == node){\n return node;\n } else {\n return parent[node] = root(parent[node]);\n }\n }\n \n void unite(ll x, ll y){\n ll rootx = root(x);\n ll rooty = root(y);\n if(rootx == rooty) return;\n if(s[rootx] < s[rooty]) swap(rootx, rooty);\n s[rootx] += s[rooty];\n parent[rooty] = rootx;\n }\n \n bool isSame(ll x, ll y){\n return root(x) == root(y);\n }\n \n ll size(ll x){\n return s[root(x)];\n }\n};\nint main(void){\n ll n;\n cin >> n;\n vector,ll>> vecx, vecy;\n rep(i, n){\n ll x, y;\n cin >> x >> y;\n vecx.push_back({{x, y}, i});\n }\n\n sort(all(vecx));\n\n UnionFind uf(n);\n vector> mi(200200, {INF, INF});\n set> rt;\n for(ll i = 0; i < n; i++){\n for(auto &j : rt){\n if(j.first < vecx[i].first.second){\n uf.unite(vecx[i].second, j.second);\n } else {\n break;\n }\n }\n ll root = uf.root(vecx[i].second);\n if(mi[root].first > vecx[i].first.second){\n rt.erase({mi[root].first, root});\n mi[root] = {vecx[i].first.second, vecx[i].second};\n rt.insert({mi[root].first, root});\n }\n }\n\n rep(i, n){\n cout << uf.size(i) << endl;\n }\n\n \n}\n\n", "language": "C++", "metadata": {"date": 1600693822, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02540.html", "problem_id": "p02540", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02540/input.txt", "sample_output_relpath": "derived/input_output/data/p02540/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02540/C++/s939345146.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s939345146", "user_id": "u845000384"}, "prompt_components": {"gold_output": "1\n1\n2\n2\n", "input_to_evaluate": "/*\nこれを入れて実行\ng++ code.cpp\n./a.out\n */\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\n#define all(x) (x).begin(),(x).end()\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n \nint dy4[4] = {-1, 0, +1, 0};\nint dx4[4] = {0, +1, 0, -1};\nint dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};\nint dx8[8] = {0, 1, 1, 1, 0, -1, -1, -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 \nll gcd(ll a, ll b){\n\tif (b == 0)return a;\n\treturn gcd(b, a % b);\n}\n \nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n\nll conbinationMemo[100][100];\n\nvoid cmemoInit(){\n rep(i, 100){\n rep(j, 100){\n conbinationMemo[i][j] = -1;\n }\n }\n}\n \nll nCr(ll n, ll r){\n if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];\n if(r == 0 || r == n){\n return 1;\n } else if(r == 1){\n return n;\n }\n return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));\n}\n \nll nPr(ll n, ll r){\n r = n - r;\n ll ret = 1;\n for (ll i = n; i >= r + 1; i--) ret *= i;\n return ret;\n}\n//-----------------------ここから-----------\nstruct UnionFind{\n vector parent;\n vector s;\n \n UnionFind(ll n){\n parent.resize(n);\n s.resize(n, 1);\n for(int i = 0; i < n; i++) parent[i] = i;\n }\n \n ll root(ll node){\n if(parent[node] == node){\n return node;\n } else {\n return parent[node] = root(parent[node]);\n }\n }\n \n void unite(ll x, ll y){\n ll rootx = root(x);\n ll rooty = root(y);\n if(rootx == rooty) return;\n if(s[rootx] < s[rooty]) swap(rootx, rooty);\n s[rootx] += s[rooty];\n parent[rooty] = rootx;\n }\n \n bool isSame(ll x, ll y){\n return root(x) == root(y);\n }\n \n ll size(ll x){\n return s[root(x)];\n }\n};\nint main(void){\n ll n;\n cin >> n;\n vector,ll>> vecx, vecy;\n rep(i, n){\n ll x, y;\n cin >> x >> y;\n vecx.push_back({{x, y}, i});\n }\n\n sort(all(vecx));\n\n UnionFind uf(n);\n vector> mi(200200, {INF, INF});\n set> rt;\n for(ll i = 0; i < n; i++){\n for(auto &j : rt){\n if(j.first < vecx[i].first.second){\n uf.unite(vecx[i].second, j.second);\n } else {\n break;\n }\n }\n ll root = uf.root(vecx[i].second);\n if(mi[root].first > vecx[i].first.second){\n rt.erase({mi[root].first, root});\n mi[root] = {vecx[i].first.second, vecx[i].second};\n rt.insert({mi[root].first, root});\n }\n }\n\n rep(i, n){\n cout << uf.size(i) << endl;\n }\n\n \n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "sample_input": "4\n1 4\n2 3\n3 1\n4 2\n"}, "reference_outputs": ["1\n1\n2\n2\n"], "source_document_id": "p02540", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k.\nRng can perform the following move arbitrarily many times:\n\nmove to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.\n\nHow many cities (including City k) are reachable from City k?\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n(x_1, x_2, \\dots, x_N) is a permutation of (1, 2, \\dots, N).\n\n(y_1, y_2, \\dots, y_N) is a permutation of (1, 2, \\dots, N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint N lines. In i-th line print the answer to the question when k = i.\n\nSample Input 1\n\n4\n1 4\n2 3\n3 1\n4 2\n\nSample Output 1\n\n1\n1\n2\n2\n\nRng can reach City 4 from City 3, or conversely City 3 from City 4.\n\nSample Input 2\n\n7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6\n\nSample Output 2\n\n3\n3\n1\n1\n2\n3\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3229, "cpu_time_ms": 393, "memory_kb": 19096}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s980028051", "group_id": "codeNet:p02546", "input_text": "#pragma GCC optimize(2)\n#include \n#include \n#include \n#include \n#include \n#define File(x) freopen(x\".in\",\"r\",stdin),freopen(x\".out\",\"w\",stdout);\n#define re register\n#define ri re int\n#define gtch() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)\n#define For(i,a,b) for(ri i=a;i<=b;++i) \n#define iFor(i,a,b) for(ri i=a;i>=b;--i) \nusing namespace std;\ntypedef long long ll;\nchar buf[1<<21],*p1=buf,*p2=buf;\ninline ll fr()\n{\n\tre char ch=getchar();re ll res=0;int bl=0;\n\twhile(!isdigit(ch)) bl=(ch=='-'),ch=getchar();\n\twhile(isdigit(ch)) res=(res<<1)+(res<<3)+ch-'0',ch=getchar();\n\treturn bl?-res:res;\n}\nconst int MAXN=100;\nconst int INF=9e8+5;\nstring s; \nsigned main()\n{\n//\tFile(\"temp\")\n\tcin>>s;\n\tcout< \n#include \n#include \n#include \n#include \n#define File(x) freopen(x\".in\",\"r\",stdin),freopen(x\".out\",\"w\",stdout);\n#define re register\n#define ri re int\n#define gtch() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)\n#define For(i,a,b) for(ri i=a;i<=b;++i) \n#define iFor(i,a,b) for(ri i=a;i>=b;--i) \nusing namespace std;\ntypedef long long ll;\nchar buf[1<<21],*p1=buf,*p2=buf;\ninline ll fr()\n{\n\tre char ch=getchar();re ll res=0;int bl=0;\n\twhile(!isdigit(ch)) bl=(ch=='-'),ch=getchar();\n\twhile(isdigit(ch)) res=(res<<1)+(res<<3)+ch-'0',ch=getchar();\n\treturn bl?-res:res;\n}\nconst int MAXN=100;\nconst int INF=9e8+5;\nstring s; \nsigned main()\n{\n//\tFile(\"temp\")\n\tcin>>s;\n\tcout<\n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n int n;\n cin >> n;\n int cnt = 0;\n rep(i, n) {\n int a, b;\n cin >> a >> b;\n if (a == b) {\n cnt++;\n if (cnt == 3) {\n cout << \"Yes\" << endl;\n return 0;\n }\n }\n else cnt = 0;\n }\n cout << \"No\" << endl;\n}", "language": "C++", "metadata": {"date": 1600542346, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/C++/s894285008.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894285008", "user_id": "u965602776"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "/*input\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n*/\n\n#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n int n;\n cin >> n;\n int cnt = 0;\n rep(i, n) {\n int a, b;\n cin >> a >> b;\n if (a == b) {\n cnt++;\n if (cnt == 3) {\n cout << \"Yes\" << endl;\n return 0;\n }\n }\n else cnt = 0;\n }\n cout << \"No\" << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 440, "cpu_time_ms": 6, "memory_kb": 3628}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s941211544", "group_id": "codeNet:p02547", "input_text": "// #pragma GCC optimize(\"Ofast\")\n// #pragma GCC target(\"avx,avx2,fma\")\n// #pragma GCC optimization (\"unroll-loops\")\n\n#include\n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\n\n#define fo(i,n) for(int i=0;i\n#define matrix(x) vector>\n#define sz(x) (int)x.size()\n#define mem(a,b) memset(a, b, sizeof a)\n#define vii vector>\n#define pii pair\n#define vi vector\n#define mii map\n#define uii unordered_map\n#define pqb priority_queue\n#define pqs priority_queue >\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define setbits(x) __builtin_popcountll(x)\n#define zrobits(x) __builtin_ctzll(x)\n#define mod 1000000007\n#define MOD 998244353\n#define inf 1e18\n#define ps(x,y) fixed<>x; while(x--)\n#define all(v) v.begin(),v.end()\n#define rep(i,begin,end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))\n#define len(s) s.length()\n\n#define watch(x) cout << #x << \" = \" << x << endl\n\n#define deb(...) cerr << \"[\" << #__VA_ARGS__ << \"] : [\", DBG(__VA_ARGS__)\nvoid DBG() { cerr << \"]\\n\";}\ntemplate void DBG(T first, Args... args)\n{cerr << first; if(sizeof...(args))cerr<<\", \"; DBG(args...); }\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> pbds; //for storing unique elements\ntypedef tree , rb_tree_tag , tree_order_statistics_node_update> ordered_set; //for repeating elements\n \nint power(int a,int b,int m=mod)\n{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}\nreturn ans;}\n\nvoid babuBhaiya()\n{\n\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n}\n\nstruct custom_hash {\n static uint64_t splitmix64(uint64_t x) {\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\n\nconst int N = 1e5+1;\nconst double pi = acos(-1);\n\n/*/-----------------------Modular Arithmetic---------------/*/\ninline int add(int x,int y){\n x+=y;\n if (x>=mod) return x-mod;\n return x;\n}\ninline int sub(int x,int y){\n x-=y;\n if (x<0) return x+mod;\n return x;\n}\ninline int mul(int x,int y){\n return (x*1ll*y)%mod;\n}\n/*/-----------------------------Code begins----------------------------------/*/\n\nvoid solve(){\n\n int n; cin>>n;\n vi v;\n fo(i,n){\n int a,b; cin>>a>>b;\n if(a == b) v.pb(i);\n }\n if(sz(v)<3){\n cout<<\"No\\n\";\n }\n else{\n bool flag = false;\n for(int i = 2;i>t;\n\n while(t--){\n solve();\n }\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1600542271, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02547.html", "problem_id": "p02547", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02547/input.txt", "sample_output_relpath": "derived/input_output/data/p02547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02547/C++/s941211544.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941211544", "user_id": "u774649089"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "// #pragma GCC optimize(\"Ofast\")\n// #pragma GCC target(\"avx,avx2,fma\")\n// #pragma GCC optimization (\"unroll-loops\")\n\n#include\n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\n\n#define fo(i,n) for(int i=0;i\n#define matrix(x) vector>\n#define sz(x) (int)x.size()\n#define mem(a,b) memset(a, b, sizeof a)\n#define vii vector>\n#define pii pair\n#define vi vector\n#define mii map\n#define uii unordered_map\n#define pqb priority_queue\n#define pqs priority_queue >\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define setbits(x) __builtin_popcountll(x)\n#define zrobits(x) __builtin_ctzll(x)\n#define mod 1000000007\n#define MOD 998244353\n#define inf 1e18\n#define ps(x,y) fixed<>x; while(x--)\n#define all(v) v.begin(),v.end()\n#define rep(i,begin,end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))\n#define len(s) s.length()\n\n#define watch(x) cout << #x << \" = \" << x << endl\n\n#define deb(...) cerr << \"[\" << #__VA_ARGS__ << \"] : [\", DBG(__VA_ARGS__)\nvoid DBG() { cerr << \"]\\n\";}\ntemplate void DBG(T first, Args... args)\n{cerr << first; if(sizeof...(args))cerr<<\", \"; DBG(args...); }\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> pbds; //for storing unique elements\ntypedef tree , rb_tree_tag , tree_order_statistics_node_update> ordered_set; //for repeating elements\n \nint power(int a,int b,int m=mod)\n{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}\nreturn ans;}\n\nvoid babuBhaiya()\n{\n\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n}\n\nstruct custom_hash {\n static uint64_t splitmix64(uint64_t x) {\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\n\nconst int N = 1e5+1;\nconst double pi = acos(-1);\n\n/*/-----------------------Modular Arithmetic---------------/*/\ninline int add(int x,int y){\n x+=y;\n if (x>=mod) return x-mod;\n return x;\n}\ninline int sub(int x,int y){\n x-=y;\n if (x<0) return x+mod;\n return x;\n}\ninline int mul(int x,int y){\n return (x*1ll*y)%mod;\n}\n/*/-----------------------------Code begins----------------------------------/*/\n\nvoid solve(){\n\n int n; cin>>n;\n vi v;\n fo(i,n){\n int a,b; cin>>a>>b;\n if(a == b) v.pb(i);\n }\n if(sz(v)<3){\n cout<<\"No\\n\";\n }\n else{\n bool flag = false;\n for(int i = 2;i>t;\n\n while(t--){\n solve();\n }\n \n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4007, "cpu_time_ms": 8, "memory_kb": 3656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s274538368", "group_id": "codeNet:p02548", "input_text": "#include \n\nusing namespace std;\nint counting(int x) {\n int ans = 0;\n for (int i=1; i * i <= x; i++) {\n if (x % i == 0) {\n if (i * i == x) ans++;\n else ans += 2;\n }\n }\n return ans;\n}\nint main() {\n int N;\n cin >> N;\n int ans = 0;\n for (int nc = 1; nc <= N-1; nc++) {\n ans += counting(nc);\n }\n cout << ans << endl;\n return 0;\n}\n\n", "language": "C++", "metadata": {"date": 1600542633, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02548/input.txt", "sample_output_relpath": "derived/input_output/data/p02548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02548/C++/s274538368.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s274538368", "user_id": "u721980697"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n\nusing namespace std;\nint counting(int x) {\n int ans = 0;\n for (int i=1; i * i <= x; i++) {\n if (x % i == 0) {\n if (i * i == x) ans++;\n else ans += 2;\n }\n }\n return ans;\n}\nint main() {\n int N;\n cin >> N;\n int ans = 0;\n for (int nc = 1; nc <= N-1; nc++) {\n ans += counting(nc);\n }\n cout << ans << endl;\n return 0;\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 1865, "memory_kb": 3652}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s807528182", "group_id": "codeNet:p02549", "input_text": "#include\ntypedef long long int lli;\n\n#define em emplace_back\n#define rep(i,j,n) for(lli i=j;in;--i)\nusing namespace std;\nlli m = 998244353;\n\nvoid solve(){\n\n lli n,k;\n cin>>n>>k;\n\n vector v;\n\n vector arrfront(n+1,0);\n\n unordered_map s;\n \n rep(i,0,k){\n lli a,b;\n cin>>a>>b;\n if(a==b){\n v.em(a);\n continue;\n }\n rep(j,a,b+1){\n v.em(j);\n }\n }\n\n vector arrback(n+1,0);\n sort(v.begin(), v.end());\n lli ans = 0;\n rep(i,1,n){\n\n if(arrfront[i]==0){\n if(i!=1){\n continue;\n }else{\n arrfront[i] = 1;\n }\n }\n\n rep(j,0,v.size()){\n if(i+v[j]>n){\n break;\n }\n arrfront[i+v[j]] = arrfront[i+v[j]]%m;\n arrfront[i+v[j]] = (arrfront[i+v[j]]%m + arrfront[i]%m)%m;\n arrfront[i+v[j]] = arrfront[i+v[j]]%m; \n \n }\n }\n\n cout<<(arrfront[n]%m);\n\n}\n \n \nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n solve();\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1600719186, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02549/input.txt", "sample_output_relpath": "derived/input_output/data/p02549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02549/C++/s807528182.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s807528182", "user_id": "u666281192"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include\ntypedef long long int lli;\n\n#define em emplace_back\n#define rep(i,j,n) for(lli i=j;in;--i)\nusing namespace std;\nlli m = 998244353;\n\nvoid solve(){\n\n lli n,k;\n cin>>n>>k;\n\n vector v;\n\n vector arrfront(n+1,0);\n\n unordered_map s;\n \n rep(i,0,k){\n lli a,b;\n cin>>a>>b;\n if(a==b){\n v.em(a);\n continue;\n }\n rep(j,a,b+1){\n v.em(j);\n }\n }\n\n vector arrback(n+1,0);\n sort(v.begin(), v.end());\n lli ans = 0;\n rep(i,1,n){\n\n if(arrfront[i]==0){\n if(i!=1){\n continue;\n }else{\n arrfront[i] = 1;\n }\n }\n\n rep(j,0,v.size()){\n if(i+v[j]>n){\n break;\n }\n arrfront[i+v[j]] = arrfront[i+v[j]]%m;\n arrfront[i+v[j]] = (arrfront[i+v[j]]%m + arrfront[i]%m)%m;\n arrfront[i+v[j]] = arrfront[i+v[j]]%m; \n \n }\n }\n\n cout<<(arrfront[n]%m);\n\n}\n \n \nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n solve();\n \n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "sample_input": "5 2\n1 1\n3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02549", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1241, "cpu_time_ms": 2205, "memory_kb": 8048}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s783213358", "group_id": "codeNet:p02549", "input_text": "#include\n#include\nusing LL = long long;\nusing namespace std;\nint mod = 998244353;\nint main() {\n\tLL N, K;\n\tcin >> N >> K;\n\tvector Li(K), Ri(K);\n\tvector S_has(N + 1, false);\n\tfor (int i = 0; i < K; i++) {\n\t\tcin >> Li[i] >> Ri[i];\n\t\tfor (int j = Li[i]; j <= Ri[i]; j++) {\n\t\t\tS_has[j] = true;\n\t\t}\n\t}\n\tvector Dp(N + 1, 0);\n\tDp[1] = 1;\n\n\tfor (int i = 2; i <= N; i++) {\n\t\tDp[i] += Dp[i - 1];\n\t\tfor (int k = 0; k < K; k++) {\n\t\t\tif (i - Li[k] > 0) {\n\t\t\t\tDp[i] += Dp[i - Li[k]];\n\t\t\t}\n\t\t\tif (i - Ri[k] - 1 > 0) {\n\t\t\t\tDp[i] -= Dp[i - Ri[k] - 1];\n\t\t\t}\n\t\t}\n\t\twhile (Dp[i] < 0) {\n\t\t\tDp[i] += mod;\n\t\t}\n\t\tDp[i] = Dp[i] % mod;\n\n\t}\n\tLL ans = Dp[N] - Dp[N - 1];\n\twhile (ans < 0) {\n\t\tans += mod;\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1600596600, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02549.html", "problem_id": "p02549", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02549/input.txt", "sample_output_relpath": "derived/input_output/data/p02549/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02549/C++/s783213358.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s783213358", "user_id": "u608654778"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include\n#include\nusing LL = long long;\nusing namespace std;\nint mod = 998244353;\nint main() {\n\tLL N, K;\n\tcin >> N >> K;\n\tvector Li(K), Ri(K);\n\tvector S_has(N + 1, false);\n\tfor (int i = 0; i < K; i++) {\n\t\tcin >> Li[i] >> Ri[i];\n\t\tfor (int j = Li[i]; j <= Ri[i]; j++) {\n\t\t\tS_has[j] = true;\n\t\t}\n\t}\n\tvector Dp(N + 1, 0);\n\tDp[1] = 1;\n\n\tfor (int i = 2; i <= N; i++) {\n\t\tDp[i] += Dp[i - 1];\n\t\tfor (int k = 0; k < K; k++) {\n\t\t\tif (i - Li[k] > 0) {\n\t\t\t\tDp[i] += Dp[i - Li[k]];\n\t\t\t}\n\t\t\tif (i - Ri[k] - 1 > 0) {\n\t\t\t\tDp[i] -= Dp[i - Ri[k] - 1];\n\t\t\t}\n\t\t}\n\t\twhile (Dp[i] < 0) {\n\t\t\tDp[i] += mod;\n\t\t}\n\t\tDp[i] = Dp[i] % mod;\n\n\t}\n\tLL ans = Dp[N] - Dp[N - 1];\n\twhile (ans < 0) {\n\t\tans += mod;\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "sample_input": "5 2\n1 1\n3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02549", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\n\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\n\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \\ldots, [L_K, R_K].\nLet S be the union of these K segments.\nHere, the segment [l, r] denotes the set consisting of all integers i that satisfy l \\leq i \\leq r.\n\n\bWhen you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.\n\nTo help Tak, find the number of ways to go to Cell N, modulo 998244353.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq \\min(N, 10)\n\n1 \\leq L_i \\leq R_i \\leq N\n\n[L_i, R_i] and [L_j, R_j] do not intersect (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nL_1 R_1\nL_2 R_2\n:\nL_K R_K\n\nOutput\n\nPrint the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.\n\nSample Input 1\n\n5 2\n1 1\n3 4\n\nSample Output 1\n\n4\n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore S = \\{ 1, 3, 4 \\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n1 \\to 2 \\to 3 \\to 4 \\to 5,\n\n1 \\to 2 \\to 5,\n\n1 \\to 4 \\to 5 and\n\n1 \\to 5.\n\nSample Input 2\n\n5 2\n3 3\n5 5\n\nSample Output 2\n\n0\n\nBecause S = \\{ 3, 5 \\} holds, you cannot reach to Cell 5.\nPrint 0.\n\nSample Input 3\n\n5 1\n1 2\n\nSample Output 3\n\n5\n\nSample Input 4\n\n60 3\n5 8\n1 3\n10 15\n\nSample Output 4\n\n221823067\n\nNote that you have to print the answer modulo 998244353.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 745, "cpu_time_ms": 18, "memory_kb": 4840}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s466928081", "group_id": "codeNet:p02550", "input_text": "#include \n#include \nusing namespace std;\nusing pii = pair;\nusing pll = pair;\nconst long long INF = 1<<29;\n\nconst int MOD = 1000000007;\nlong long ruizyou(long long m,long long n){\n if(m == 0)return 0;\n if(m == 1)return 1;\n long long ans = 1;\n long long tmp = m;\n for(int i=0;i<=30;i++){\n if(n & (1< par;\n vector> children;\n vector hukasa;\n vector kazu;\n unionfind(int n){\n par = vector(n);\n hukasa = vector(n,0);\n kazu = vector(n,1);\n for(int i=0;i= hukasa.at(ry)){\n par.at(ry) = rx;\n hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));\n kazu.at(rx) += kazu.at(ry);\n }\n else{\n par.at(rx) = ry;\n kazu.at(ry) += kazu.at(rx);\n }\n }\n void newkazu(){\n int n = kazu.size();\n for(int i=0;i> s,vector> table,int &ans,pii frm,int n,int m){\n int x,y;\n tie(x,y) = frm;\n set se;\n if(x-1 >= 0)se.insert(pii(x-1,y));\n if(x+1 < n)se.insert(pii(x+1,y));\n if(y-1 >= 0)se.insert(pii(x,y-1));\n if(y+1 < m)se.insert(pii(x,y+1));\n for(auto t:se){\n int tx,ty;\n tie(tx,ty) = t;\n if(s.at(tx).at(ty) && table.at(tx).at(ty) == -1){\n table.at(tx).at(ty) = table.at(x).at(y) + 1;\n ans = max(ans,table.at(tx).at(ty));\n hukasa(s,table,ans,t,n,m);\n table.at(tx).at(ty) = -1;\n }\n }\n}\nvoid daiku(int frm,vector> g,vector &cost,int n){\n priority_queue,greater> q;\n q.push(pii(cost.at(frm),frm));\n vector kakutei(n,false);\n while(!q.empty()){\n pii now = q.top();\n q.pop();\n int n1,n2;\n tie(n1,n2) = now;\n if(kakutei.at(n2))continue;\n kakutei.at(n2) = true;\n for(auto t:g.at(n2)){\n int tx,ty;\n tie(tx,ty) = t;\n if(cost.at(tx) > n1 + ty){\n cost.at(tx) = n1 + ty;\n q.push(pii(cost.at(tx),tx));\n }\n }\n }\n}\n\nint main(){\n long long n,x,m;\n cin >> n >> x >> m;\n long long a = 0;\n long long b = 0;\n int unko = n;\n int flag = 0;\n unordered_set se;\n while(unko){\n if(se.count(x)){\n flag = 1;\n break;\n }\n se.insert(x);\n unko--;\n b += x;\n a++;\n x *= x;\n x %= m;\n if(x == 0 || x == 1)break;\n }\n if(x == 0)cout << b << endl;\n else if(x == 1){\n //cout << 'n' << endl;\n cout << b + n - a << endl;\n }\n else if(flag == 1){\n long long ans = 0;\n ans += b * (n/a);\n n %= a;\n for(int i=0;i\n#include \nusing namespace std;\nusing pii = pair;\nusing pll = pair;\nconst long long INF = 1<<29;\n\nconst int MOD = 1000000007;\nlong long ruizyou(long long m,long long n){\n if(m == 0)return 0;\n if(m == 1)return 1;\n long long ans = 1;\n long long tmp = m;\n for(int i=0;i<=30;i++){\n if(n & (1< par;\n vector> children;\n vector hukasa;\n vector kazu;\n unionfind(int n){\n par = vector(n);\n hukasa = vector(n,0);\n kazu = vector(n,1);\n for(int i=0;i= hukasa.at(ry)){\n par.at(ry) = rx;\n hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));\n kazu.at(rx) += kazu.at(ry);\n }\n else{\n par.at(rx) = ry;\n kazu.at(ry) += kazu.at(rx);\n }\n }\n void newkazu(){\n int n = kazu.size();\n for(int i=0;i> s,vector> table,int &ans,pii frm,int n,int m){\n int x,y;\n tie(x,y) = frm;\n set se;\n if(x-1 >= 0)se.insert(pii(x-1,y));\n if(x+1 < n)se.insert(pii(x+1,y));\n if(y-1 >= 0)se.insert(pii(x,y-1));\n if(y+1 < m)se.insert(pii(x,y+1));\n for(auto t:se){\n int tx,ty;\n tie(tx,ty) = t;\n if(s.at(tx).at(ty) && table.at(tx).at(ty) == -1){\n table.at(tx).at(ty) = table.at(x).at(y) + 1;\n ans = max(ans,table.at(tx).at(ty));\n hukasa(s,table,ans,t,n,m);\n table.at(tx).at(ty) = -1;\n }\n }\n}\nvoid daiku(int frm,vector> g,vector &cost,int n){\n priority_queue,greater> q;\n q.push(pii(cost.at(frm),frm));\n vector kakutei(n,false);\n while(!q.empty()){\n pii now = q.top();\n q.pop();\n int n1,n2;\n tie(n1,n2) = now;\n if(kakutei.at(n2))continue;\n kakutei.at(n2) = true;\n for(auto t:g.at(n2)){\n int tx,ty;\n tie(tx,ty) = t;\n if(cost.at(tx) > n1 + ty){\n cost.at(tx) = n1 + ty;\n q.push(pii(cost.at(tx),tx));\n }\n }\n }\n}\n\nint main(){\n long long n,x,m;\n cin >> n >> x >> m;\n long long a = 0;\n long long b = 0;\n int unko = n;\n int flag = 0;\n unordered_set se;\n while(unko){\n if(se.count(x)){\n flag = 1;\n break;\n }\n se.insert(x);\n unko--;\n b += x;\n a++;\n x *= x;\n x %= m;\n if(x == 0 || x == 1)break;\n }\n if(x == 0)cout << b << endl;\n else if(x == 1){\n //cout << 'n' << endl;\n cout << b + n - a << endl;\n }\n else if(flag == 1){\n long long ans = 0;\n ans += b * (n/a);\n n %= a;\n for(int i=0;i\n#include \n#include \n#include \n#include \n \nusing namespace __gnu_pbds;\nusing namespace std;\n \n#define rep(i,n) for(int i=0;i<(n);++i)\n#define reps(i,n) for(int i=1;i<=(n);++i)\n#define all(x) begin(x),end(x)\n#define Fixed fixed << setprecision(12)\n#define int int_fast64_t\nusing pii = pair;\nconstexpr int INF = 0x3f3f3f3f;\nconstexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;\nconstexpr int mod1 = 1e9+7;\nconstexpr int mod2 = 998244353;\n \ntemplate \nclass FixPoint : Func {\npublic:\n explicit constexpr FixPoint(Func&& f) noexcept : Func(forward(f)) {}\n \n template \n constexpr decltype(auto) operator()(Args&&... args) const {\n return Func::operator()(*this, std::forward(args)...);\n }\n};\n \ntemplate \nstatic inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {\n return FixPoint{forward(f)};\n}\n \ntemplate inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }\ntemplate inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }\n \ntemplate using min_heap = priority_queue,greater >;\ntemplate using max_heap = priority_queue;\ntemplate using umap = unordered_map;\ntemplate using Set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using Umap = gp_hash_table;\nusing Trie = trie, pat_trie_tag, trie_prefix_search_node_update>;\n \ninline int square(int a){ return a * a;}\ninline int updiv(int a,int b){ return (a + b - 1) / b; }\n \nconstexpr int dx[] = {1,0,-1,0,1,1,-1,-1};\nconstexpr int dy[] = {0,-1,0,1,1,-1,-1,1};\n//}}}\n\nsigned main(){\n cin.tie(nullptr);\n ios_base::sync_with_stdio(false);\n cout.setf(ios_base::fixed);\n cout.precision(10);\n\n int x;\n cin >> x;\n\n if(x == 0){\n cout << 1 << '\\n';\n }else{\n cout << 0 << '\\n';\n }\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1600029740, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/C++/s333691271.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s333691271", "user_id": "u803754262"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "//header{{{\n#pragma GCC optimize(\"Ofast\")\n#include \n#include \n#include \n#include \n#include \n \nusing namespace __gnu_pbds;\nusing namespace std;\n \n#define rep(i,n) for(int i=0;i<(n);++i)\n#define reps(i,n) for(int i=1;i<=(n);++i)\n#define all(x) begin(x),end(x)\n#define Fixed fixed << setprecision(12)\n#define int int_fast64_t\nusing pii = pair;\nconstexpr int INF = 0x3f3f3f3f;\nconstexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;\nconstexpr int mod1 = 1e9+7;\nconstexpr int mod2 = 998244353;\n \ntemplate \nclass FixPoint : Func {\npublic:\n explicit constexpr FixPoint(Func&& f) noexcept : Func(forward(f)) {}\n \n template \n constexpr decltype(auto) operator()(Args&&... args) const {\n return Func::operator()(*this, std::forward(args)...);\n }\n};\n \ntemplate \nstatic inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {\n return FixPoint{forward(f)};\n}\n \ntemplate inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }\ntemplate inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }\n \ntemplate using min_heap = priority_queue,greater >;\ntemplate using max_heap = priority_queue;\ntemplate using umap = unordered_map;\ntemplate using Set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using Umap = gp_hash_table;\nusing Trie = trie, pat_trie_tag, trie_prefix_search_node_update>;\n \ninline int square(int a){ return a * a;}\ninline int updiv(int a,int b){ return (a + b - 1) / b; }\n \nconstexpr int dx[] = {1,0,-1,0,1,1,-1,-1};\nconstexpr int dy[] = {0,-1,0,1,1,-1,-1,1};\n//}}}\n\nsigned main(){\n cin.tie(nullptr);\n ios_base::sync_with_stdio(false);\n cout.setf(ios_base::fixed);\n cout.precision(10);\n\n int x;\n cin >> x;\n\n if(x == 0){\n cout << 1 << '\\n';\n }else{\n cout << 0 << '\\n';\n }\n\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2207, "cpu_time_ms": 9, "memory_kb": 3612}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s078749581", "group_id": "codeNet:p02552", "input_text": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main() {\n\tint x;\n\tcin >> x;\n\tif (x == 0) {\n\t\tcout << 1 << endl;\n\t}\n\telse cout << 0 << endl;\n\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1600023718, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/C++/s078749581.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s078749581", "user_id": "u813600655"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main() {\n\tint x;\n\tcin >> x;\n\tif (x == 0) {\n\t\tcout << 1 << endl;\n\t}\n\telse cout << 0 << endl;\n\n\treturn 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 8, "memory_kb": 3632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s612137662", "group_id": "codeNet:p02552", "input_text": "#define _GLIBCXX_DEBUG\n#include \nusing namespace std;\n\nint main() {\n int x;\n cin >> x;\n if (x==0) cout << 1 << endl;\n else cout << 0 << endl;\n}", "language": "C++", "metadata": {"date": 1600023703, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/C++/s612137662.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612137662", "user_id": "u042329722"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#define _GLIBCXX_DEBUG\n#include \nusing namespace std;\n\nint main() {\n int x;\n cin >> x;\n if (x==0) cout << 1 << endl;\n else cout << 0 << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 7, "memory_kb": 3628}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s326896175", "group_id": "codeNet:p02553", "input_text": "#include \n#define _GLIBCXX_DEBUG\n#define rep(i, n) for (int i = 0; i < (n); i++)\nusing ll = long long;\nusing namespace std;\n\nint main()\n{\n ll a, b, c, d;\n cin >> a >> b >> c >> d;\n\n cout << max(max((b*c),(b*d)),max((a*d),(a*c)))<< endl;\n\n}\n\n\n", "language": "C++", "metadata": {"date": 1600646195, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/C++/s326896175.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s326896175", "user_id": "u483065848"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define _GLIBCXX_DEBUG\n#define rep(i, n) for (int i = 0; i < (n); i++)\nusing ll = long long;\nusing namespace std;\n\nint main()\n{\n ll a, b, c, d;\n cin >> a >> b >> c >> d;\n\n cout << max(max((b*c),(b*d)),max((a*d),(a*c)))<< endl;\n\n}\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 264, "cpu_time_ms": 5, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s587209275", "group_id": "codeNet:p02553", "input_text": "#include \nusing namespace std;\n\nint main() {\n int64_t a, b, c, d;\n cin >> a >> b >> c >> d;\n \n if (a >= 0 && c >= 0) cout << b * d << endl;\n else if (b <= 0 && d <= 0) cout << a * c << endl;\n else if (a >= 0 && d <= 0) cout << a * d << endl;\n else if (b <= 0 && c >= 0) cout << b * c << endl;\n else if (a * b <= 0 && c * d <= 0) cout << max(a * c, b * d) << endl;\n else cout << b * d << endl;\n\n\n \n}\n", "language": "C++", "metadata": {"date": 1600025888, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/C++/s587209275.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s587209275", "user_id": "u614060232"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int64_t a, b, c, d;\n cin >> a >> b >> c >> d;\n \n if (a >= 0 && c >= 0) cout << b * d << endl;\n else if (b <= 0 && d <= 0) cout << a * c << endl;\n else if (a >= 0 && d <= 0) cout << a * d << endl;\n else if (b <= 0 && c >= 0) cout << b * c << endl;\n else if (a * b <= 0 && c * d <= 0) cout << max(a * c, b * d) << endl;\n else cout << b * d << endl;\n\n\n \n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 7, "memory_kb": 3672}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s376179033", "group_id": "codeNet:p02553", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\nint main(void){\n // Your code here!\n long x1,x2,y1,y2;\n cin>>x1>>x2>>y1>>y2;\n long answer=-1*pow(10,18);\n vector> vec={{x1,x2},{y1,y2}};\n for(int i=0;i<2;i++){\n for(int j=0;j<2;j++){\n if(vec[0][i]*vec[1][j]>answer){\n answer=vec[0][i]*vec[1][j];\n }\n }\n }\n cout<\n#include \n#include \n#include \nusing namespace std;\nint main(void){\n // Your code here!\n long x1,x2,y1,y2;\n cin>>x1>>x2>>y1>>y2;\n long answer=-1*pow(10,18);\n vector> vec={{x1,x2},{y1,y2}};\n for(int i=0;i<2;i++){\n for(int j=0;j<2;j++){\n if(vec[0][i]*vec[1][j]>answer){\n answer=vec[0][i]*vec[1][j];\n }\n }\n }\n cout<\n//#include \n//#pragma GCC optimize(\"Ofast\")\nusing namespace std;\n#define reps(i,s,n) for(int i = s; i < n; i++)\n#define rep(i,n) reps(i,0,n)\n#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)\n#define Rrep(i,n) Rreps(i,n,0)\n#define ALL(a) a.begin(), a.end()\n#define fi first\n#define se second\ntypedef long long ll;\ntypedef vector vec;\ntypedef vector mat;\n\nll N,M,H,W,Q,K,A,B;\nstring S;\ntypedef pair P;\nconst ll INF = (1LL<<60);\n\ntemplate class modint{\npublic:\n ll x;\n constexpr modint(){x = 0;}\n constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}\n constexpr modint operator-(){\n return x == 0 ? 0 : mod - x;\n }\n constexpr modint& operator+=(const modint& a){\n if((x += a.x) >= mod) x -= mod;\n return *this;\n }\n constexpr modint operator+(const modint& a) const{\n return modint(*this) += a;\n }\n constexpr modint& operator-=(const modint& a){\n if((x -= a.x) < 0) x += mod;\n return *this;\n }\n constexpr modint operator-(const modint& a) const{\n return modint(*this) -= a;\n }\n constexpr modint& operator*=(const modint& a){\n (x *= a.x)%=mod;\n return *this;\n }\n constexpr modint operator*(const modint& a) const{\n return modint(*this) *= a;\n }\n constexpr modint pow(unsigned long long pw) const{\n modint res(1), comp(*this);\n while(pw){\n if(pw&1) res *= comp;\n comp *= comp;\n pw >>= 1;\n }\n return res;\n }\n //以下、modが素数のときのみ\n constexpr modint inv() const{\n return modint(*this).pow(mod - 2);\n }\n constexpr modint& operator/=(const modint &a){\n (x *= a.inv().x)%=mod;\n return *this;\n }\n constexpr modint operator/(const modint &a) const{\n return modint(*this) /= a;\n }\n};\n#define mod2 1000000007\nusing mint = modint;\n\nostream& operator<<(ostream& os, const mint& a){\n os << a.x;\n return os;\n}\nusing vm = vector;\nint main() {\n cin>>N;\n mint res(10);\n res = res.pow(N);\n res -= mint(9).pow(N) * 2;\n res += mint(8).pow(N);\n cout<\n//#include \n//#pragma GCC optimize(\"Ofast\")\nusing namespace std;\n#define reps(i,s,n) for(int i = s; i < n; i++)\n#define rep(i,n) reps(i,0,n)\n#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)\n#define Rrep(i,n) Rreps(i,n,0)\n#define ALL(a) a.begin(), a.end()\n#define fi first\n#define se second\ntypedef long long ll;\ntypedef vector vec;\ntypedef vector mat;\n\nll N,M,H,W,Q,K,A,B;\nstring S;\ntypedef pair P;\nconst ll INF = (1LL<<60);\n\ntemplate class modint{\npublic:\n ll x;\n constexpr modint(){x = 0;}\n constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}\n constexpr modint operator-(){\n return x == 0 ? 0 : mod - x;\n }\n constexpr modint& operator+=(const modint& a){\n if((x += a.x) >= mod) x -= mod;\n return *this;\n }\n constexpr modint operator+(const modint& a) const{\n return modint(*this) += a;\n }\n constexpr modint& operator-=(const modint& a){\n if((x -= a.x) < 0) x += mod;\n return *this;\n }\n constexpr modint operator-(const modint& a) const{\n return modint(*this) -= a;\n }\n constexpr modint& operator*=(const modint& a){\n (x *= a.x)%=mod;\n return *this;\n }\n constexpr modint operator*(const modint& a) const{\n return modint(*this) *= a;\n }\n constexpr modint pow(unsigned long long pw) const{\n modint res(1), comp(*this);\n while(pw){\n if(pw&1) res *= comp;\n comp *= comp;\n pw >>= 1;\n }\n return res;\n }\n //以下、modが素数のときのみ\n constexpr modint inv() const{\n return modint(*this).pow(mod - 2);\n }\n constexpr modint& operator/=(const modint &a){\n (x *= a.inv().x)%=mod;\n return *this;\n }\n constexpr modint operator/(const modint &a) const{\n return modint(*this) /= a;\n }\n};\n#define mod2 1000000007\nusing mint = modint;\n\nostream& operator<<(ostream& os, const mint& a){\n os << a.x;\n return os;\n}\nusing vm = vector;\nint main() {\n cin>>N;\n mint res(10);\n res = res.pow(N);\n res -= mint(9).pow(N) * 2;\n res += mint(8).pow(N);\n cout<\nusing namespace std;\n\nint main(){\n int s;\n cin>>s;\n vector dp(s+1,0);\n long long max = pow(10,9)+7;\n \n dp[0] = 1;\n for(int i=3;i<=s;i++){\n dp[i] = (dp[i-1]+dp[i-3])%max;\n }\n cout<\nusing namespace std;\n\nint main(){\n int s;\n cin>>s;\n vector dp(s+1,0);\n long long max = pow(10,9)+7;\n \n dp[0] = 1;\n for(int i=3;i<=s;i++){\n dp[i] = (dp[i-1]+dp[i-3])%max;\n }\n cout<\n#define f first\n#define s second\n#define sym(s) s = \"#\" + s + \"#\";\n#define all(x) (x).begin(), (x).end()\n#define alll(x,n) x+1, x+n+1\n#define newl cout<<\"\\n\";\n#define foo(i,a,n) for(ll i = (a); i <= n; i++)\n#define deb1(a) cout<> n;\\\n ll mnx, mxx, mny, mxy;\n mnx = mny = INF;\n mxx = mxy = -INF;\n for(int i = 1; i <= n; i++){\n cin >> x[i] >> y[i];\n mnx = min(mnx, x[i]);\n mxx = max(mxx, x[i]);\n mny = min(mny, y[i]);\n mxy = max(mxy, y[i]);\n }\n\n set> points;\n ll tmn, tmx;\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(x[i] == mnx){\n tmn = min(tmn, y[i]);\n tmx = max(tmx, y[i]);\n }\n }\n points.insert({mnx,tmn});\n points.insert({mnx,tmx});\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(x[i] == mxx){\n tmn = min(tmn, y[i]);\n tmx = max(tmx, y[i]);\n }\n }\n points.insert({mxx,tmn});\n points.insert({mxx,tmx});\n\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(y[i] == mny){\n tmn = min(tmn, x[i]);\n tmx = max(tmx, x[i]);\n }\n }\n points.insert({tmn, mny});\n points.insert({tmx, mny});\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(y[i] == mxy){\n tmn = min(tmn, x[i]);\n tmx = max(tmx, x[i]);\n }\n }\n points.insert({tmn, mxy});\n points.insert({tmx, mxy});\n\n ll res = 0;\n for(auto [x1,y1]: points){\n for(auto [x2, y2]: points){\n res = max(res, abs(x1 - x2) + abs(y1 - y2));\n }\n }\n\n deb1(res);\n\n\n}\n\nint main(){\n ios:: sync_with_stdio(false); \n cin.tie(nullptr); cout.tie(nullptr);\n cout<>test_cases;\n for(int i = 1; i <= test_cases; i++){\n MAIN(i);\n }\n}", "language": "C++", "metadata": {"date": 1600026600, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02556.html", "problem_id": "p02556", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02556/input.txt", "sample_output_relpath": "derived/input_output/data/p02556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02556/C++/s428364969.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s428364969", "user_id": "u622748505"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#pragma optimization_level 3\n#include \n#define f first\n#define s second\n#define sym(s) s = \"#\" + s + \"#\";\n#define all(x) (x).begin(), (x).end()\n#define alll(x,n) x+1, x+n+1\n#define newl cout<<\"\\n\";\n#define foo(i,a,n) for(ll i = (a); i <= n; i++)\n#define deb1(a) cout<> n;\\\n ll mnx, mxx, mny, mxy;\n mnx = mny = INF;\n mxx = mxy = -INF;\n for(int i = 1; i <= n; i++){\n cin >> x[i] >> y[i];\n mnx = min(mnx, x[i]);\n mxx = max(mxx, x[i]);\n mny = min(mny, y[i]);\n mxy = max(mxy, y[i]);\n }\n\n set> points;\n ll tmn, tmx;\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(x[i] == mnx){\n tmn = min(tmn, y[i]);\n tmx = max(tmx, y[i]);\n }\n }\n points.insert({mnx,tmn});\n points.insert({mnx,tmx});\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(x[i] == mxx){\n tmn = min(tmn, y[i]);\n tmx = max(tmx, y[i]);\n }\n }\n points.insert({mxx,tmn});\n points.insert({mxx,tmx});\n\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(y[i] == mny){\n tmn = min(tmn, x[i]);\n tmx = max(tmx, x[i]);\n }\n }\n points.insert({tmn, mny});\n points.insert({tmx, mny});\n\n tmn = INF; tmx = -INF;\n for(int i = 1; i <= n; i++){\n if(y[i] == mxy){\n tmn = min(tmn, x[i]);\n tmx = max(tmx, x[i]);\n }\n }\n points.insert({tmn, mxy});\n points.insert({tmx, mxy});\n\n ll res = 0;\n for(auto [x1,y1]: points){\n for(auto [x2, y2]: points){\n res = max(res, abs(x1 - x2) + abs(y1 - y2));\n }\n }\n\n deb1(res);\n\n\n}\n\nint main(){\n ios:: sync_with_stdio(false); \n cin.tie(nullptr); cout.tie(nullptr);\n cout<>test_cases;\n for(int i = 1; i <= test_cases; i++){\n MAIN(i);\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "sample_input": "3\n1 1\n2 4\n3 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02556", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).\nThere can be multiple points that share the same coordinate.\nWhat is the maximum possible Manhattan distance between two distinct points?\n\nHere, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq x_i,y_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 1\n2 4\n3 2\n\nSample Output 1\n\n4\n\nThe Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.\n\nSample Input 2\n\n2\n1 1\n1 1\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2779, "cpu_time_ms": 49, "memory_kb": 6772}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s959314295", "group_id": "codeNet:p02557", "input_text": "#include \nusing namespace std;\n\nint n,i,j;\nint a[200000];\nint b[200000];\n\nint main(){\n\tcin >> n;\n\tfor(i = 0; i < n; i++){ cin >> a[i]; }\n\tfor(i = 0; i < n; i++){ cin >> b[i]; }\n\ti = 0; j = n-1;\n\twhile(i <= j){\n\t\tif(a[i] == b[i]){\n\t\t\t//cout << a[i] << \" \" << b[i] << endl;\n\t\t\tswap(a[i],a[j]);\n\t\t\t//cout << a[j] << \" \" << a[i] << endl;\n\t\t\tif(a[i] == b[i]) { cout << \"No\" << endl; return 0;}\n\t\t}\n\t\ti++; j--;\n\t}\n\tcout << \"Yes\" << endl;\n\tfor(i = 0; i < n; i++){cout << a[i] << \" \";}\n\tcout << endl;\n}\n", "language": "C++", "metadata": {"date": 1600028351, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02557.html", "problem_id": "p02557", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02557/input.txt", "sample_output_relpath": "derived/input_output/data/p02557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02557/C++/s959314295.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s959314295", "user_id": "u301041462"}, "prompt_components": {"gold_output": "Yes\n2 2 3 1 1 1\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint n,i,j;\nint a[200000];\nint b[200000];\n\nint main(){\n\tcin >> n;\n\tfor(i = 0; i < n; i++){ cin >> a[i]; }\n\tfor(i = 0; i < n; i++){ cin >> b[i]; }\n\ti = 0; j = n-1;\n\twhile(i <= j){\n\t\tif(a[i] == b[i]){\n\t\t\t//cout << a[i] << \" \" << b[i] << endl;\n\t\t\tswap(a[i],a[j]);\n\t\t\t//cout << a[j] << \" \" << a[i] << endl;\n\t\t\tif(a[i] == b[i]) { cout << \"No\" << endl; return 0;}\n\t\t}\n\t\ti++; j--;\n\t}\n\tcout << \"Yes\" << endl;\n\tfor(i = 0; i < n; i++){cout << a[i] << \" \";}\n\tcout << endl;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "sample_input": "6\n1 1 1 2 2 3\n1 1 1 2 2 3\n"}, "reference_outputs": ["Yes\n2 2 3 1 1 1\n"], "source_document_id": "p02557", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 510, "cpu_time_ms": 108, "memory_kb": 5184}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s568793342", "group_id": "codeNet:p02562", "input_text": "#include \n#include \nusing namespace std;\nusing namespace atcoder;\n\nusing ll=long long;\n#define rng(i,l,r) for(int i=int(l);i=int(l);i--)\n#define rrep(i,r) rrng(i,0,r)\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define mt make_tuple\n#define F first\n#define S second\n#define bg begin()\n#define ed end()\n#define all(x) x.bg,x.ed\n#define si(x) int(x.size())\n#define inf INT_MAX/2-100\n#define infl LLONG_MAX/3\n#ifdef LOCAL\n#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<bool chmax(t&a,u b){if(abool chmin(t&a,u b){if(busing vc=vector;\ntemplateusing vvc=vector>;\n\nusing pi=pair;\nusing pl=pair;\nusing vi=vc;\nusing vl=vc;\n\n\nll readl(void){\n\tll x;\n\tcin>>x;\n\treturn x;\n}\nint readi(void){\n\tint x;\n\tcin>>x;\n\treturn x;\n}\n\nstring readstr(){\n\tstring s;\n\tcin>>s;\n\treturn s;\n}\nvi readvi(int n,int off=0){\n\tvi v(n);\n\trep(i,n)v[i]=readi(),v[i]+=off;\n\treturn v;\n}\n\nvl readvl(int n,int off=0){\n\tvl v(n);\n\trep(i,n)v[i]=readl(),v[i]+=off;\n\treturn v;\n}\n\ntemplate\nvoid print(t x,int suc=1){\n\tcout<\nvoid print(const vc&v,int suc=1){\n\trep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);\n}\n\ntemplate\nbool inc(t a,t b,t c){\n\treturn !(c\nvoid compress(vc&v){\n\tsort(all(v));\n\tv.erase(unique(all(v)),v.ed);\n}\n\ntemplate\nint lwb(const vc&v,const t&a){\n\treturn lower_bound(all(v),a)-v.bg;\n}\n\ntemplate\nstruct Compress{\n\tvcv;\n\tCompress()=default;\n\tCompress(const vc&x){\n\t\tadd(x);\n\t}\n\tCompress(const initializer_list >&x){\n\t\tfor(auto &p:x)add(p);\n\t}\n\tvoid add(const t&x){\n\t\tv.eb(x);\n\t}\n\tvoid add(const vc&x){\n\t\tcopy(all(x),back_inserter(v));\n\t}\n\tvoid build(){\n\t\tcompress(v);\n\t}\n\tint get(const t&x)const{\n\t\treturn lwb(v,x);\n\t}\n\tvcget(const vc&x)const{\n\t\tvcres(x);\n\t\tfor(auto &p:res)p=get(p);\n\t\treturn res;\n\t}\n\tconst t &operator[](int x)const{\n\t\treturn v[x];\n\t}\n\tint size(){\n\t\treturn v.size();\n\t}\n};\nvoid Yes(bool ex=true){\n\tcout<<\"Yes\\n\";\n\tif(ex)exit(0);\n}\nvoid YES(bool ex=true){\n\tcout<<\"YES\\n\";\n\tif(ex)exit(0);\n}\nvoid No(bool ex=true){\n\tcout<<\"No\\n\";\n\tif(ex)exit(0);\n}\nvoid NO(bool ex=true){\n\tcout<<\"NO\\n\";\n\tif(ex)exit(0);\n}\nvoid orYes(bool x,bool ex=true){\n\tif(x)Yes(ex);\n\telse No(ex);\n}\nvoid orYES(bool x,bool ex=true){\n\tif(x)YES(ex);\n\telse NO(ex);\n}\nvoid Possible(bool ex=true){\n\tcout<<\"Possible\\n\";\n\tif(ex)exit(0);\n}\nvoid POSSIBLE(bool ex=true){\n\tcout<<\"POSSIBLE\\n\";\n\tif(ex)exit(0);\n}\nvoid Impossible(bool ex=true){\n\tcout<<\"Impossible\\n\";\n\tif(ex)exit(0);\n}\nvoid IMPOSSIBLE(bool ex=true){\n\tcout<<\"IMPOSSIBLE\\n\";\n\tif(ex)exit(0);\n}\nvoid orPossible(bool x,bool ex=true){\n\tif(x)Possible(ex);\n\telse Impossible(ex);\n}\nvoid orPOSSIBLE(bool x,bool ex=true){\n\tif(x)POSSIBLE(ex);\n\telse IMPOSSIBLE(ex);\n}\n\n\n\nll n,k,a[55][55];\nint main(void){\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\tcin>>n>>k;\n\trep(i,n)rep(j,n)cin>>a[i][j];\n\tmcf_graph g(n*2+2);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tg.add_edge(i,n+j,1,1e9-a[i][j]);\n\t\t}\n\t}\n\trep(i,n){\n\t\tg.add_edge(n*2,i,k,0);\n\t\tg.add_edge(n+i,n*2+1,k,0);\n\t}\n\tvcp=g.slope(n*2,n*2+1);\n\tfor(auto &i:p){\n\t\tswap(i.F,i.S);\n\t\ti.F=i.S*1e9-i.F;\n\t}\n\tsort(all(p));\n\tprint(p.back().F);\n\tmcf_graph ans(n*2+2);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tans.add_edge(i,n+j,1,1e9-a[i][j]);\n\t\t}\n\t}\n\trep(i,n){\n\t\tans.add_edge(n*2,i,k,0);\n\t\tans.add_edge(n+i,n*2+1,k,0);\n\t}\n\tans.flow(n*2,n*2+1,p.back().S);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tif(ans.get_edge(i*n+j).flow==1)cout<<'X';\n\t\t\telse cout<<'.';\n\t\t}\n\t\tcout<\n#include \nusing namespace std;\nusing namespace atcoder;\n\nusing ll=long long;\n#define rng(i,l,r) for(int i=int(l);i=int(l);i--)\n#define rrep(i,r) rrng(i,0,r)\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define mt make_tuple\n#define F first\n#define S second\n#define bg begin()\n#define ed end()\n#define all(x) x.bg,x.ed\n#define si(x) int(x.size())\n#define inf INT_MAX/2-100\n#define infl LLONG_MAX/3\n#ifdef LOCAL\n#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<bool chmax(t&a,u b){if(abool chmin(t&a,u b){if(busing vc=vector;\ntemplateusing vvc=vector>;\n\nusing pi=pair;\nusing pl=pair;\nusing vi=vc;\nusing vl=vc;\n\n\nll readl(void){\n\tll x;\n\tcin>>x;\n\treturn x;\n}\nint readi(void){\n\tint x;\n\tcin>>x;\n\treturn x;\n}\n\nstring readstr(){\n\tstring s;\n\tcin>>s;\n\treturn s;\n}\nvi readvi(int n,int off=0){\n\tvi v(n);\n\trep(i,n)v[i]=readi(),v[i]+=off;\n\treturn v;\n}\n\nvl readvl(int n,int off=0){\n\tvl v(n);\n\trep(i,n)v[i]=readl(),v[i]+=off;\n\treturn v;\n}\n\ntemplate\nvoid print(t x,int suc=1){\n\tcout<\nvoid print(const vc&v,int suc=1){\n\trep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);\n}\n\ntemplate\nbool inc(t a,t b,t c){\n\treturn !(c\nvoid compress(vc&v){\n\tsort(all(v));\n\tv.erase(unique(all(v)),v.ed);\n}\n\ntemplate\nint lwb(const vc&v,const t&a){\n\treturn lower_bound(all(v),a)-v.bg;\n}\n\ntemplate\nstruct Compress{\n\tvcv;\n\tCompress()=default;\n\tCompress(const vc&x){\n\t\tadd(x);\n\t}\n\tCompress(const initializer_list >&x){\n\t\tfor(auto &p:x)add(p);\n\t}\n\tvoid add(const t&x){\n\t\tv.eb(x);\n\t}\n\tvoid add(const vc&x){\n\t\tcopy(all(x),back_inserter(v));\n\t}\n\tvoid build(){\n\t\tcompress(v);\n\t}\n\tint get(const t&x)const{\n\t\treturn lwb(v,x);\n\t}\n\tvcget(const vc&x)const{\n\t\tvcres(x);\n\t\tfor(auto &p:res)p=get(p);\n\t\treturn res;\n\t}\n\tconst t &operator[](int x)const{\n\t\treturn v[x];\n\t}\n\tint size(){\n\t\treturn v.size();\n\t}\n};\nvoid Yes(bool ex=true){\n\tcout<<\"Yes\\n\";\n\tif(ex)exit(0);\n}\nvoid YES(bool ex=true){\n\tcout<<\"YES\\n\";\n\tif(ex)exit(0);\n}\nvoid No(bool ex=true){\n\tcout<<\"No\\n\";\n\tif(ex)exit(0);\n}\nvoid NO(bool ex=true){\n\tcout<<\"NO\\n\";\n\tif(ex)exit(0);\n}\nvoid orYes(bool x,bool ex=true){\n\tif(x)Yes(ex);\n\telse No(ex);\n}\nvoid orYES(bool x,bool ex=true){\n\tif(x)YES(ex);\n\telse NO(ex);\n}\nvoid Possible(bool ex=true){\n\tcout<<\"Possible\\n\";\n\tif(ex)exit(0);\n}\nvoid POSSIBLE(bool ex=true){\n\tcout<<\"POSSIBLE\\n\";\n\tif(ex)exit(0);\n}\nvoid Impossible(bool ex=true){\n\tcout<<\"Impossible\\n\";\n\tif(ex)exit(0);\n}\nvoid IMPOSSIBLE(bool ex=true){\n\tcout<<\"IMPOSSIBLE\\n\";\n\tif(ex)exit(0);\n}\nvoid orPossible(bool x,bool ex=true){\n\tif(x)Possible(ex);\n\telse Impossible(ex);\n}\nvoid orPOSSIBLE(bool x,bool ex=true){\n\tif(x)POSSIBLE(ex);\n\telse IMPOSSIBLE(ex);\n}\n\n\n\nll n,k,a[55][55];\nint main(void){\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\tcin>>n>>k;\n\trep(i,n)rep(j,n)cin>>a[i][j];\n\tmcf_graph g(n*2+2);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tg.add_edge(i,n+j,1,1e9-a[i][j]);\n\t\t}\n\t}\n\trep(i,n){\n\t\tg.add_edge(n*2,i,k,0);\n\t\tg.add_edge(n+i,n*2+1,k,0);\n\t}\n\tvcp=g.slope(n*2,n*2+1);\n\tfor(auto &i:p){\n\t\tswap(i.F,i.S);\n\t\ti.F=i.S*1e9-i.F;\n\t}\n\tsort(all(p));\n\tprint(p.back().F);\n\tmcf_graph ans(n*2+2);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tans.add_edge(i,n+j,1,1e9-a[i][j]);\n\t\t}\n\t}\n\trep(i,n){\n\t\tans.add_edge(n*2,i,k,0);\n\t\tans.add_edge(n+i,n*2+1,k,0);\n\t}\n\tans.flow(n*2,n*2+1,p.back().S);\n\trep(i,n){\n\t\trep(j,n){\n\t\t\tif(ans.get_edge(i*n+j).flow==1)cout<<'X';\n\t\t\telse cout<<'.';\n\t\t}\n\t\tcout<\nusing namespace std;\n\nint main(){\n long long d,t,s;\n cin >> d >> t >> s;\n if(d/s <= t){\n cout << \"Yes\" << endl;\n }else{\n cout << \"No\" << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1598732572, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/C++/s125326346.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s125326346", "user_id": "u497715246"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n long long d,t,s;\n cin >> d >> t >> s;\n if(d/s <= t){\n cout << \"Yes\" << endl;\n }else{\n cout << \"No\" << endl;\n }\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 7, "memory_kb": 3552}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s116165382", "group_id": "codeNet:p02570", "input_text": "#include \n#include \n\nusing namespace std;\n\nint main(){\n int d,t,s;\n cin >> d >> t >> s ;\n if(d > t * s) cout << 'Yes';\n else cout << 'No';\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1598728452, "filename_ext": "cpp", "original_language": "C++ (Clang 10.0.0)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02570/input.txt", "sample_output_relpath": "derived/input_output/data/p02570/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02570/C++/s116165382.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s116165382", "user_id": "u260228177"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#include \n\nusing namespace std;\n\nint main(){\n int d,t,s;\n cin >> d >> t >> s ;\n if(d > t * s) cout << 'Yes';\n else cout << 'No';\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 176, "cpu_time_ms": 9, "memory_kb": 3192}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s681491388", "group_id": "codeNet:p02571", "input_text": "#include\n#define Vsort(a) sort(a.begin(), a.end())\n#define rep(i,n) for(long long int i = 0; i < (n); i++)\n#define ll long long\n#define P pair\nusing namespace std;\n\nint main() {\n string s, t;\n cin >> s >> t;\n int count = s.size() - t.size();\n vector wa(count);\n int size = t.size();\n rep(i, count){\n rep(j, size){\n char S, T;\n S = s.at(i + j); T = t.at(j);\n if(S != T) wa[i]++;\n }\n }\n Vsort(wa);\n cout << wa[0] << endl;\n}\n", "language": "C++", "metadata": {"date": 1598734761, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/C++/s681491388.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s681491388", "user_id": "u424661377"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\n#define Vsort(a) sort(a.begin(), a.end())\n#define rep(i,n) for(long long int i = 0; i < (n); i++)\n#define ll long long\n#define P pair\nusing namespace std;\n\nint main() {\n string s, t;\n cin >> s >> t;\n int count = s.size() - t.size();\n vector wa(count);\n int size = t.size();\n rep(i, count){\n rep(j, size){\n char S, T;\n S = s.at(i + j); T = t.at(j);\n if(S != T) wa[i]++;\n }\n }\n Vsort(wa);\n cout << wa[0] << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 492, "cpu_time_ms": 103, "memory_kb": 3604}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s088790489", "group_id": "codeNet:p02571", "input_text": "#include\n#define ll long long int\nusing namespace std;\nint main()\n{\n string str,ptr;\n cin>>str>>ptr;\n int mx=0;\n for(int i=0; i\n#define ll long long int\nusing namespace std;\nint main()\n{\n string str,ptr;\n cin>>str>>ptr;\n int mx=0;\n for(int i=0; i\n#define all(v) v.begin(), v.end()\n#define x first\n#define y second\n#define PQ priority_queue\n#define pb push_back\n#define fu(i,a,j) for(int i=a;i=j;i--)\n#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)\n#define MOD 1000000007 \n#define MOD2 1000000021\n#define MAXN 2000000\n#define INF 1e9\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef double db;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vpii;\ntypedef vector vpll;\ntypedef vector vs;\n\n//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }\n\nll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }\nll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }\nll lcm(ll a, ll b) { return a * b / gcd(a, b); };\ndb dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }\nint dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };\nint dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };\n\nint n, m, k, t;\n\nstring ansok[2] = { \"NO\",\"YES\" };\n\npii a[200005];\nint par[200005];\nint sz[200005];\nint Find(int u) {\n\tif (par[u] < 0) { return u; }\n\treturn par[u] = Find(par[u]);\n}\nbool Union(int u, int v) {\n\tu = Find(u);\n\tv = Find(v);\n\tif (u == v)\n\t\treturn 0;\n\tpar[v] = u;\n\tsz[u] += sz[v];\n\treturn 1;\n}\nint main()\n{\n\tSYNC;\n\tmemset(par, -1, sizeof par);\n\tcin >> n >> m;\n\tfor (int i = 1; i <= n; i++)\n\t\tsz[i] = 1;\n\tfor (int i = 0; i < m; i++) {\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tUnion(u,v);\n\t}\n\tint mx = 0;\n\tfor (int i = 1; i <= n; i++) {\n\t\tmx = max(mx, sz[Find(i)]);\n\t}\n\tcout << mx << '\\n';\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1598728795, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02573/input.txt", "sample_output_relpath": "derived/input_output/data/p02573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02573/C++/s980446156.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980446156", "user_id": "u203081684"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#define all(v) v.begin(), v.end()\n#define x first\n#define y second\n#define PQ priority_queue\n#define pb push_back\n#define fu(i,a,j) for(int i=a;i=j;i--)\n#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)\n#define MOD 1000000007 \n#define MOD2 1000000021\n#define MAXN 2000000\n#define INF 1e9\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef double db;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vpii;\ntypedef vector vpll;\ntypedef vector vs;\n\n//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }\n\nll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }\nll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }\nll lcm(ll a, ll b) { return a * b / gcd(a, b); };\ndb dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }\nint dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };\nint dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };\n\nint n, m, k, t;\n\nstring ansok[2] = { \"NO\",\"YES\" };\n\npii a[200005];\nint par[200005];\nint sz[200005];\nint Find(int u) {\n\tif (par[u] < 0) { return u; }\n\treturn par[u] = Find(par[u]);\n}\nbool Union(int u, int v) {\n\tu = Find(u);\n\tv = Find(v);\n\tif (u == v)\n\t\treturn 0;\n\tpar[v] = u;\n\tsz[u] += sz[v];\n\treturn 1;\n}\nint main()\n{\n\tSYNC;\n\tmemset(par, -1, sizeof par);\n\tcin >> n >> m;\n\tfor (int i = 1; i <= n; i++)\n\t\tsz[i] = 1;\n\tfor (int i = 0; i < m; i++) {\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tUnion(u,v);\n\t}\n\tint mx = 0;\n\tfor (int i = 1; i <= n; i++) {\n\t\tmx = max(mx, sz[Find(i)]);\n\t}\n\tcout << mx << '\\n';\n\treturn 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "sample_input": "5 3\n1 2\n3 4\n5 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02573", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1731, "cpu_time_ms": 54, "memory_kb": 5732}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s030600402", "group_id": "codeNet:p02575", "input_text": "#include\n\n#define si(a) scanf(\"%d\",&a)\n#define sl(a) scanf(\"%lld\",&a)\n#define sd(a) scanf(\"%lf\",&a)\n#define sc(a) scahf(\"%c\",&a);\n#define ss(a) scanf(\"%s\",a)\n#define pi(a) printf(\"%d\\n\",a)\n#define pl(a) printf(\"%lld\\n\",a)\n#define pc(a) putchar(a)\n#define ms(a) memset(a,0,sizeof(a))\n#define repi(i, a, b) for(register int i=a;i<=b;++i)\n#define repd(i, a, b) for(register int i=a;i>=b;--i)\n#define reps(s) for(register int i=head[s];i;i=Next[i])\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define pii pair\n#define mii unordered_map\n#define msi unordered_map\n#define lowbit(x) ((x)&(-(x)))\n#define ce(i, r) i==r?'\\n':' '\n#define pb push_back\n#define fi first\n#define se second\n#define all(x) x.begin(),x.end()\n#define INF 0x3f3f3f3f\n#define pr(x) cout<<#x<<\": \"< '9') {\n if (c == '-')fu = -1;\n c = getchar();\n }\n while (c >= '0' && c <= '9') {\n f = (f << 3) + (f << 1) + c - 48;\n c = getchar();\n }\n return f * fu;\n}\n\n\nconst int N = 4e5 + 10;\n\nstruct Seg_Tree {\n struct T {\n int l, r, ans, add;\n } t[N * 4];\n\n void build(int p, int l, int r) {\n t[p].l = l, t[p].r = r, t[p].ans=INF, t[p].add = 0;\n if (l == r)return;\n int mid = (l + r) >> 1;\n build(p << 1, l, mid);\n build(p << 1 | 1, mid + 1, r);\n }\n\n void spread(int p) {\n if (t[p].add) {\n t[p << 1].ans = t[p].l - t[p].add;\n t[p << 1].add = t[p].add;\n t[p << 1 | 1].ans = ((t[p].l + t[p].r) >> 1) + 1 - t[p].add;\n t[p << 1 | 1].add = t[p].add;\n t[p].add = 0;\n }\n }\n\n void change(int p, int l, int r, int c) {\n //if (t[p].r < l || t[p].l > r)return;\n if (l <= t[p].l && t[p].r <= r) {\n t[p].ans = l - c, t[p].add = c;\n return;\n }\n spread(p);\n int mid = (t[p].l + t[p].r) >> 1;\n if (l <= mid)change(p << 1, l, r, c);\n if (r > mid)change(p << 1 | 1, l, r, c);\n t[p].ans = min(t[p << 1].ans, t[p << 1 | 1].ans);\n }\n\n int ask(int p, int x) {\n if (t[p].l == t[p].r)return x - t[p].ans;\n spread(p);\n int mid = (t[p].l + t[p].r) >> 1;\n return x <= mid ? ask(p >> 1, x) : ask(p << 1 | 1, x);\n }\n} tr;\n\nint n, m, now = 1;\n\nint main() {\n n = qr(), m = qr();\n tr.build(1, 1, m);\n repi(i, 1, n) {\n int l = qr(), r = qr();\n if (now >= l && now <= r)tr.change(1, now, r, -INF), now = r + 1;\n else if (now < l)tr.change(1, l, r, tr.ask(1, l - 1));\n if (now > m) {\n repi(j, i, n)puts(\"-1\");\n return 0;\n }\n pi(i + tr.t[1].ans);\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1598739313, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02575.html", "problem_id": "p02575", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02575/input.txt", "sample_output_relpath": "derived/input_output/data/p02575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02575/C++/s030600402.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s030600402", "user_id": "u593074754"}, "prompt_components": {"gold_output": "1\n3\n6\n-1\n", "input_to_evaluate": "#include\n\n#define si(a) scanf(\"%d\",&a)\n#define sl(a) scanf(\"%lld\",&a)\n#define sd(a) scanf(\"%lf\",&a)\n#define sc(a) scahf(\"%c\",&a);\n#define ss(a) scanf(\"%s\",a)\n#define pi(a) printf(\"%d\\n\",a)\n#define pl(a) printf(\"%lld\\n\",a)\n#define pc(a) putchar(a)\n#define ms(a) memset(a,0,sizeof(a))\n#define repi(i, a, b) for(register int i=a;i<=b;++i)\n#define repd(i, a, b) for(register int i=a;i>=b;--i)\n#define reps(s) for(register int i=head[s];i;i=Next[i])\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define pii pair\n#define mii unordered_map\n#define msi unordered_map\n#define lowbit(x) ((x)&(-(x)))\n#define ce(i, r) i==r?'\\n':' '\n#define pb push_back\n#define fi first\n#define se second\n#define all(x) x.begin(),x.end()\n#define INF 0x3f3f3f3f\n#define pr(x) cout<<#x<<\": \"< '9') {\n if (c == '-')fu = -1;\n c = getchar();\n }\n while (c >= '0' && c <= '9') {\n f = (f << 3) + (f << 1) + c - 48;\n c = getchar();\n }\n return f * fu;\n}\n\n\nconst int N = 4e5 + 10;\n\nstruct Seg_Tree {\n struct T {\n int l, r, ans, add;\n } t[N * 4];\n\n void build(int p, int l, int r) {\n t[p].l = l, t[p].r = r, t[p].ans=INF, t[p].add = 0;\n if (l == r)return;\n int mid = (l + r) >> 1;\n build(p << 1, l, mid);\n build(p << 1 | 1, mid + 1, r);\n }\n\n void spread(int p) {\n if (t[p].add) {\n t[p << 1].ans = t[p].l - t[p].add;\n t[p << 1].add = t[p].add;\n t[p << 1 | 1].ans = ((t[p].l + t[p].r) >> 1) + 1 - t[p].add;\n t[p << 1 | 1].add = t[p].add;\n t[p].add = 0;\n }\n }\n\n void change(int p, int l, int r, int c) {\n //if (t[p].r < l || t[p].l > r)return;\n if (l <= t[p].l && t[p].r <= r) {\n t[p].ans = l - c, t[p].add = c;\n return;\n }\n spread(p);\n int mid = (t[p].l + t[p].r) >> 1;\n if (l <= mid)change(p << 1, l, r, c);\n if (r > mid)change(p << 1 | 1, l, r, c);\n t[p].ans = min(t[p << 1].ans, t[p << 1 | 1].ans);\n }\n\n int ask(int p, int x) {\n if (t[p].l == t[p].r)return x - t[p].ans;\n spread(p);\n int mid = (t[p].l + t[p].r) >> 1;\n return x <= mid ? ask(p >> 1, x) : ask(p << 1 | 1, x);\n }\n} tr;\n\nint n, m, now = 1;\n\nint main() {\n n = qr(), m = qr();\n tr.build(1, 1, m);\n repi(i, 1, n) {\n int l = qr(), r = qr();\n if (now >= l && now <= r)tr.change(1, now, r, -INF), now = r + 1;\n else if (now < l)tr.change(1, l, r, tr.ask(1, l - 1));\n if (now > m) {\n repi(j, i, n)puts(\"-1\");\n return 0;\n }\n pi(i + tr.t[1].ans);\n }\n return 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "sample_input": "4 4\n2 4\n1 1\n2 3\n2 4\n"}, "reference_outputs": ["1\n3\n6\n-1\n"], "source_document_id": "p02575", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2839, "cpu_time_ms": 2206, "memory_kb": 11804}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s391437372", "group_id": "codeNet:p02576", "input_text": "#pragma GCC optimize(\"Ofast\")\n#include \nusing namespace std;\n#define out(x) cout << x << '\\n'\n#define lli long long int\n#define uli unsigned long long int\n#define rep(i, m, n) for (lli i = m; i < (n); i++)\n#define repe(i, m, n) for (lli i = m; i <= (n); i++)\n#define ALL(x) (x).begin(), (x).end()\n#define SIZE(x) ((lli)(x).size())\n#define MAX(x) *max_element(ALL(x))\n#define MIN(x) *min_element(ALL(x))\n#define _GLIBCXX_DEBUG\nconst lli INF = 2147483647;\nconst lli MINF = -2147483648;\nconst lli LINF = 9223372036854775807;\nconst lli MOD = 1000000007; //10^9+7\nconst double PI = acos(-1);\n#define SORT(n) sort(n.begin(), n.end())\n#define SORTR(n) sort(n.begin(), n.end(), greater())\n#define REV(n) reverse(n.begin(), n.end())\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\nusing vi = vector;\nusing vvi = vector;\nusing vvvi = vector;\nusing vlli = vector;\nusing vvli = vector;\nusing vs = vector;\nusing vvs = vector;\nusing vb = vector;\nusing vvb = vector;\nusing ll = long long;\n//---------------------------------------------------------------------------------------------------\n// vector入力\ntemplate \nistream &operator>>(istream &is, vector &vec)\n{\n for (T &x : vec)\n is >> x;\n return is;\n}\n// vector出力\ntemplate \nostream &operator<<(ostream &os, vector &vec)\n{\n // os << '{';\n for (int i = 0; i < vec.size(); i++)\n {\n os << vec[i] << (i + 1 == vec.size() ? \"\" : \"\");\n }\n // os << '}';\n return os;\n}\n// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)\ntemplate \nbool chmax(T &a, const T &b)\n{\n if (a < b)\n {\n a = b; // aをbで更新\n return true;\n }\n return false;\n}\n// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)\ntemplate \nbool chmin(T &a, const T &b)\n{\n if (a > b)\n {\n a = b; // aをbで更新\n return true;\n }\n return false;\n}\n//---------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------\nvoid solve()\n{\n lli a = 0, b = 0, c = 0, h = 0, n = 0, x, t, w = 0, ans = 0, count = 0;\n vector> pr;\n map ma;\n set st;\n\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cin >> n >> x >> t;\n while (n > count)\n {\n count += x;\n ans += t;\n }\n out(ans);\n // if ()\n // {\n // out(\"Yes\");\n // }\n // else\n // {\n // out(\"No\");\n // }\n}\n\n//---------------------------------------------------------------------------------------------------\nsigned main()\n{\n solve();\n}", "language": "C++", "metadata": {"date": 1598124249, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02576/input.txt", "sample_output_relpath": "derived/input_output/data/p02576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02576/C++/s391437372.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391437372", "user_id": "u363892646"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#pragma GCC optimize(\"Ofast\")\n#include \nusing namespace std;\n#define out(x) cout << x << '\\n'\n#define lli long long int\n#define uli unsigned long long int\n#define rep(i, m, n) for (lli i = m; i < (n); i++)\n#define repe(i, m, n) for (lli i = m; i <= (n); i++)\n#define ALL(x) (x).begin(), (x).end()\n#define SIZE(x) ((lli)(x).size())\n#define MAX(x) *max_element(ALL(x))\n#define MIN(x) *min_element(ALL(x))\n#define _GLIBCXX_DEBUG\nconst lli INF = 2147483647;\nconst lli MINF = -2147483648;\nconst lli LINF = 9223372036854775807;\nconst lli MOD = 1000000007; //10^9+7\nconst double PI = acos(-1);\n#define SORT(n) sort(n.begin(), n.end())\n#define SORTR(n) sort(n.begin(), n.end(), greater())\n#define REV(n) reverse(n.begin(), n.end())\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\nusing vi = vector;\nusing vvi = vector;\nusing vvvi = vector;\nusing vlli = vector;\nusing vvli = vector;\nusing vs = vector;\nusing vvs = vector;\nusing vb = vector;\nusing vvb = vector;\nusing ll = long long;\n//---------------------------------------------------------------------------------------------------\n// vector入力\ntemplate \nistream &operator>>(istream &is, vector &vec)\n{\n for (T &x : vec)\n is >> x;\n return is;\n}\n// vector出力\ntemplate \nostream &operator<<(ostream &os, vector &vec)\n{\n // os << '{';\n for (int i = 0; i < vec.size(); i++)\n {\n os << vec[i] << (i + 1 == vec.size() ? \"\" : \"\");\n }\n // os << '}';\n return os;\n}\n// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)\ntemplate \nbool chmax(T &a, const T &b)\n{\n if (a < b)\n {\n a = b; // aをbで更新\n return true;\n }\n return false;\n}\n// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)\ntemplate \nbool chmin(T &a, const T &b)\n{\n if (a > b)\n {\n a = b; // aをbで更新\n return true;\n }\n return false;\n}\n//---------------------------------------------------------------------------------------------------\n//---------------------------------------------------------------------------------------------------\nvoid solve()\n{\n lli a = 0, b = 0, c = 0, h = 0, n = 0, x, t, w = 0, ans = 0, count = 0;\n vector> pr;\n map ma;\n set st;\n\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cin >> n >> x >> t;\n while (n > count)\n {\n count += x;\n ans += t;\n }\n out(ans);\n // if ()\n // {\n // out(\"Yes\");\n // }\n // else\n // {\n // out(\"No\");\n // }\n}\n\n//---------------------------------------------------------------------------------------------------\nsigned main()\n{\n solve();\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2719, "cpu_time_ms": 7, "memory_kb": 3644}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s737260029", "group_id": "codeNet:p02576", "input_text": "#include \n#define ll long long\n#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n \nusing namespace std;\n \nint main()\n{\n the_flash;\n int n, x, t, sum = 0;\n cin >> n >> x >> t;\n \n if (x > 1)\n {\n while (x * t <= n)\n x += x;\n }\n else \n {\n cout << n * t << \"\\n\";\n return 0;\n }\n\n cout << x << \"\\n\"; \n return 0;\n}", "language": "C++", "metadata": {"date": 1598124070, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02576/input.txt", "sample_output_relpath": "derived/input_output/data/p02576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02576/C++/s737260029.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s737260029", "user_id": "u489075504"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \n#define ll long long\n#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n \nusing namespace std;\n \nint main()\n{\n the_flash;\n int n, x, t, sum = 0;\n cin >> n >> x >> t;\n \n if (x > 1)\n {\n while (x * t <= n)\n x += x;\n }\n else \n {\n cout << n * t << \"\\n\";\n return 0;\n }\n\n cout << x << \"\\n\"; \n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 9, "memory_kb": 3572}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s360486332", "group_id": "codeNet:p02576", "input_text": "#include \nusing namespace std;\n \nint main() {\n int N; cin >> N;\n int X; cin >> X;\n int T; cin >> T;\n int ans = 0;\n int tako = 0;\n\n while(true){\n ans += T;\n tako += X;\n if(tako >= N){\n break;\n }\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1598123067, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02576/input.txt", "sample_output_relpath": "derived/input_output/data/p02576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02576/C++/s360486332.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s360486332", "user_id": "u757672175"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \nusing namespace std;\n \nint main() {\n int N; cin >> N;\n int X; cin >> X;\n int T; cin >> T;\n int ans = 0;\n int tako = 0;\n\n while(true){\n ans += T;\n tako += X;\n if(tako >= N){\n break;\n }\n }\n cout << ans << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 3, "memory_kb": 3616}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s486166135", "group_id": "codeNet:p02578", "input_text": "#include\nint main()\n{\n long long int n,s=0,a,b,i,m;\n scanf(\"%lld\",&n);\n scanf(\"%lld\",&a);\n m=a;\n for(i=1;im)m=b;\n else if(b\nint main()\n{\n long long int n,s=0,a,b,i,m;\n scanf(\"%lld\",&n);\n scanf(\"%lld\",&a);\n m=a;\n for(i=1;im)m=b;\n else if(b\n\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define endl \"\\n\"\n\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst ll MOD = 1000000007LL; // = 10^9 + 7\nconst double PI = 3.14159265358979;\n\nint h, w;\nint seen[1010][1010];\n\nvector mp;\nint dx[4] = {0, -1, 0, 1};\nint dy[4] = {-1, 0, 1, 0};\n\nvoid bfs(queue

que, int lv)\n{\n if (que.empty()) return;\n queue

tmp;\n tmp.push(que.front());\n\n // 歩き\n while(!que.empty())\n {\n P tp = que.front();\n que.pop();\n for(int i = 0; i < 4; ++i)\n {\n int ny = tp.first + dy[i];\n int nx = tp.second + dx[i];\n\n if (ny < 0 || h <= ny) continue;\n if (nx < 0 || w <= nx) continue;\n\n if (seen[ny][nx] == 0 && mp[ny][nx] == '.')\n {\n seen[ny][nx] = lv;\n que.push(P(ny, nx));\n tmp.push(P(ny, nx));\n }\n }\n }\n\n // ワープ\n queue

next_que;\n while(!tmp.empty())\n {\n P tp = tmp.front();\n tmp.pop();\n for(int y = -2; y <= 2; ++y)\n {\n int ny = tp.first + y;\n if (ny < 0 || h <= ny) continue;\n\n for(int x = -2; x <= 2; ++x)\n {\n int nx = tp.second + x;\n if (nx < 0 || w <= nx) continue;\n\n if (seen[ny][nx] == 0 && mp[ny][nx] == '.')\n {\n seen[ny][nx] = lv + 1;\n next_que.push(P(ny, nx));\n }\n }\n }\n }\n bfs(next_que, lv + 1);\n}\n\nvoid solve()\n{\n int cy, cx;\n int dy, dx;\n\n cin >> h >> w;\n cin >> cy >> cx;\n cin >> dy >> dx;\n\n mp.resize(h);\n cx--; cy--;\n dx--; dy--;\n for(int i = 0; i < h; ++i)\n {\n cin >> mp[i];\n }\n\n queue

que;\n que.push(P(cy, cx));\n seen[cy][cx] = 1;\n\n bfs(que, 1);\n /*\n for(int ih = 0; ih < h; ++ih)\n {\n for(int iw = 0; iw < w; ++iw)\n {\n cout << seen[ih][iw];\n }\n cout << endl;\n }\n //*/\n cout << seen[dy][dx] - 1;\n\n}\n\nint main()\n{\n fastio;\n solve();\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1598613920, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/C++/s731106383.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s731106383", "user_id": "u866535689"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define endl \"\\n\"\n\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst ll MOD = 1000000007LL; // = 10^9 + 7\nconst double PI = 3.14159265358979;\n\nint h, w;\nint seen[1010][1010];\n\nvector mp;\nint dx[4] = {0, -1, 0, 1};\nint dy[4] = {-1, 0, 1, 0};\n\nvoid bfs(queue

que, int lv)\n{\n if (que.empty()) return;\n queue

tmp;\n tmp.push(que.front());\n\n // 歩き\n while(!que.empty())\n {\n P tp = que.front();\n que.pop();\n for(int i = 0; i < 4; ++i)\n {\n int ny = tp.first + dy[i];\n int nx = tp.second + dx[i];\n\n if (ny < 0 || h <= ny) continue;\n if (nx < 0 || w <= nx) continue;\n\n if (seen[ny][nx] == 0 && mp[ny][nx] == '.')\n {\n seen[ny][nx] = lv;\n que.push(P(ny, nx));\n tmp.push(P(ny, nx));\n }\n }\n }\n\n // ワープ\n queue

next_que;\n while(!tmp.empty())\n {\n P tp = tmp.front();\n tmp.pop();\n for(int y = -2; y <= 2; ++y)\n {\n int ny = tp.first + y;\n if (ny < 0 || h <= ny) continue;\n\n for(int x = -2; x <= 2; ++x)\n {\n int nx = tp.second + x;\n if (nx < 0 || w <= nx) continue;\n\n if (seen[ny][nx] == 0 && mp[ny][nx] == '.')\n {\n seen[ny][nx] = lv + 1;\n next_que.push(P(ny, nx));\n }\n }\n }\n }\n bfs(next_que, lv + 1);\n}\n\nvoid solve()\n{\n int cy, cx;\n int dy, dx;\n\n cin >> h >> w;\n cin >> cy >> cx;\n cin >> dy >> dx;\n\n mp.resize(h);\n cx--; cy--;\n dx--; dy--;\n for(int i = 0; i < h; ++i)\n {\n cin >> mp[i];\n }\n\n queue

que;\n que.push(P(cy, cx));\n seen[cy][cx] = 1;\n\n bfs(que, 1);\n /*\n for(int ih = 0; ih < h; ++ih)\n {\n for(int iw = 0; iw < w; ++iw)\n {\n cout << seen[ih][iw];\n }\n cout << endl;\n }\n //*/\n cout << seen[dy][dx] - 1;\n\n}\n\nint main()\n{\n fastio;\n solve();\n\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1918, "cpu_time_ms": 95, "memory_kb": 10380}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s314041453", "group_id": "codeNet:p02579", "input_text": "#include\nusing namespace std;\ntypedef long long int ll;\n\n#define F first\n#define S second\n#define pb push_back\n#define mp make_pair\n\nll gcd(ll a, ll b){\n\tif (a == 0) return b;\n\treturn gcd(b%a, a);\n}\n\nll lcm(ll a, ll b){\n\treturn (a/gcd(a, b))*b;\n}\n\nll ans = 1e10;\nll n,m,xi,yi , xf,yf;\nll a[1004][1004];\n\nbool check(ll x, ll y)\n{\n\treturn (x >= 0 && y >= 0 && x < n && y < m);\n}\n\nll b[] = {0 , 0 , 1, -1};\nll d[] = {-1 , 1 , 0 , 0};\n\n\nvoid solve(ll cx ,ll cy ,ll fx ,ll fy ,ll cnt)\n{\n\tif(cx == fx && cy == fy)\n\t{\n\t\tans = min(ans,cnt);\n\t}\n\n\ta[cx][cy] = 1;\n\n\tfor(ll i=0;i<4;i++)\n\t{\n\t\tll nx = cx + b[i];\n\t\tll ny = cy + d[i];\n\n\t\tif(check(nx,ny))\n\t\t{\n\t\t\tif(a[nx][ny] == 0)\n\t\t\t\tsolve(nx,ny,fx,fy,cnt);\n\t\t}\n\t}\n\n\n\tfor(ll i=-2;i<3;i++)\n\t{\n\t\tfor(ll j=-2;j<3;j++)\n\t\t{\n\t\t\tll nx = cx + i;\n\t\t\tll ny = cy + j;\n\t\t\tif(check(nx,ny))\n\t\t\t{\n\t\t\t\tif(a[nx][ny] == 0)\n\t\t\t\t{\n\t\t\t\t\tsolve(nx,ny,fx,fy,cnt+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\n\n\tcin >> n >> m >> xi >> yi >> xf >> yf;\n\tll i,j;\n\n\n\tfor(i=0;i> c;\n\n\t\t\tif(c == '.')\n\t\t\t\ta[i][j] = 0;\n\t\t\telse\n\t\t\t\ta[i][j] = 2;\n\t\t}\n\t}\n\n\tsolve(xi-1, yi - 1 , xf-1 , yf-1 ,0);\n\n\n\tif(ans == 1e10)\n\t\tcout << -1 << endl;\n\telse\n\t\tcout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1598131332, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02579.html", "problem_id": "p02579", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02579/input.txt", "sample_output_relpath": "derived/input_output/data/p02579/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02579/C++/s314041453.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s314041453", "user_id": "u705313695"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\nusing namespace std;\ntypedef long long int ll;\n\n#define F first\n#define S second\n#define pb push_back\n#define mp make_pair\n\nll gcd(ll a, ll b){\n\tif (a == 0) return b;\n\treturn gcd(b%a, a);\n}\n\nll lcm(ll a, ll b){\n\treturn (a/gcd(a, b))*b;\n}\n\nll ans = 1e10;\nll n,m,xi,yi , xf,yf;\nll a[1004][1004];\n\nbool check(ll x, ll y)\n{\n\treturn (x >= 0 && y >= 0 && x < n && y < m);\n}\n\nll b[] = {0 , 0 , 1, -1};\nll d[] = {-1 , 1 , 0 , 0};\n\n\nvoid solve(ll cx ,ll cy ,ll fx ,ll fy ,ll cnt)\n{\n\tif(cx == fx && cy == fy)\n\t{\n\t\tans = min(ans,cnt);\n\t}\n\n\ta[cx][cy] = 1;\n\n\tfor(ll i=0;i<4;i++)\n\t{\n\t\tll nx = cx + b[i];\n\t\tll ny = cy + d[i];\n\n\t\tif(check(nx,ny))\n\t\t{\n\t\t\tif(a[nx][ny] == 0)\n\t\t\t\tsolve(nx,ny,fx,fy,cnt);\n\t\t}\n\t}\n\n\n\tfor(ll i=-2;i<3;i++)\n\t{\n\t\tfor(ll j=-2;j<3;j++)\n\t\t{\n\t\t\tll nx = cx + i;\n\t\t\tll ny = cy + j;\n\t\t\tif(check(nx,ny))\n\t\t\t{\n\t\t\t\tif(a[nx][ny] == 0)\n\t\t\t\t{\n\t\t\t\t\tsolve(nx,ny,fx,fy,cnt+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\n\n\tcin >> n >> m >> xi >> yi >> xf >> yf;\n\tll i,j;\n\n\n\tfor(i=0;i> c;\n\n\t\t\tif(c == '.')\n\t\t\t\ta[i][j] = 0;\n\t\t\telse\n\t\t\t\ta[i][j] = 2;\n\t\t}\n\t}\n\n\tsolve(xi-1, yi - 1 , xf-1 , yf-1 ,0);\n\n\n\tif(ans == 1e10)\n\t\tcout << -1 << endl;\n\telse\n\t\tcout << ans << endl;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1293, "cpu_time_ms": 91, "memory_kb": 50644}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s772403893", "group_id": "codeNet:p02584", "input_text": "// https://atcoder.jp/contests/abc175/tasks/abc175_c\n#include \n#include \n#include \n#include \n#include \n#include // std::back_inserter\n\nusing namespace std;\n\nint main()\n{\n long long x, k, d;\n cin >> x >> k >> d;\n long long mod = x % d;\n long long div = x / d;\n if (d * k < x)\n {\n cout << x - d * k << endl;\n exit(0);\n }\n long long a = (x / d) * d;\n if ((k - div) % 2 == 0)\n {\n cout << x - a << endl;\n }\n else\n {\n cout << d - (x - a) << endl;\n }\n}\n", "language": "C++", "metadata": {"date": 1598472700, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/C++/s772403893.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s772403893", "user_id": "u904912386"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "// https://atcoder.jp/contests/abc175/tasks/abc175_c\n#include \n#include \n#include \n#include \n#include \n#include // std::back_inserter\n\nusing namespace std;\n\nint main()\n{\n long long x, k, d;\n cin >> x >> k >> d;\n long long mod = x % d;\n long long div = x / d;\n if (d * k < x)\n {\n cout << x - d * k << endl;\n exit(0);\n }\n long long a = (x / d) * d;\n if ((k - div) % 2 == 0)\n {\n cout << x - a << endl;\n }\n else\n {\n cout << d - (x - a) << endl;\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 9, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s515783394", "group_id": "codeNet:p02584", "input_text": "#include\nusing namespace std;\n\nint main(){\n long long x,k,d;\n cin >> x >> k >> d;\n //xは現在の座標\n //kは移動回数\n //dは一回の移動距離\n \n while(abs(x)>abs(d)){\n if(x>=0){\n x-=d;\n k--;\n }\n else{\n x+=d;\n k--;\n }\n if(k==0) break;\n }\n if(k%2==0){\n cout << abs(x) << endl;\n return 0;}\n else{\n if(x>=0)x-=d;\n else x+=d;\n }\n cout << abs(x) << endl;\n return 0;\n }", "language": "C++", "metadata": {"date": 1597836197, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/C++/s515783394.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s515783394", "user_id": "u461563687"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\n long long x,k,d;\n cin >> x >> k >> d;\n //xは現在の座標\n //kは移動回数\n //dは一回の移動距離\n \n while(abs(x)>abs(d)){\n if(x>=0){\n x-=d;\n k--;\n }\n else{\n x+=d;\n k--;\n }\n if(k==0) break;\n }\n if(k%2==0){\n cout << abs(x) << endl;\n return 0;}\n else{\n if(x>=0)x-=d;\n else x+=d;\n }\n cout << abs(x) << endl;\n return 0;\n }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 470, "cpu_time_ms": 2205, "memory_kb": 3564}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s979826880", "group_id": "codeNet:p02584", "input_text": "/****************************************\n\n\t\t\tLostMartian\n\n****************************************/\n#pragma GCC target(\"avx,avx2,fma\") \n#pragma GCC optimize(\"Ofast\") \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 \nusing namespace std;\ntypedef long long ll;\n\ntemplate \nvoid pn(Arg1&& arg1) {\n\tcout << arg1 << \"\\n\";\n}\ntemplate \nvoid pn(Arg1&& arg1, Args&&... args) { \n\tcout << arg1 << \" \"; \n\tpn(args...); \n}\ntemplate \nvoid ps(Arg1&& arg1) { \n\tcout << arg1 << \" \";\n}\ntemplate \nvoid ps(Arg1&& arg1, Args&&... args) { \n\tcout << arg1 << \" \"; \n\tps(args...); \n}\ntemplate \nvoid read(Arg1&& arg1) {\n\tcin >> arg1; \n}\ntemplate \nvoid read(Arg1&& arg1, Args&&... args) { \n\tcin >> arg1; \n\tread(args...); \n}\n\n#define rep(i,m,n) for(ll i=m; i=n; i--)\n#define vll vector\n#define vvl vector >\n#define pi pair\n#define vpi vector\n#define umap unordered_map\n#define pb push_back\n#define mk make_pair\n#define sz size()\n#define fi first\n#define se second\n#define all(x) x.begin(), x.end()\n#define test ll t; cin>>t; while(t--)\n#define ini(a, x) memset(a, x, sizeof(a))\n#define d(x) cout<<\"Value of \"#x\" = \"<>x>>k>>d;\n\tll m=abs(x)/d;\n\tif(m>=k) {\n\t\tif(x<0) {\n\t\t\tpn(-x-d*k);\n\t\t\treturn 0;\n\t\t}\n\t\telse {\n\t\t\tpn(x-d*k);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif(x<0) {\n\t\tx+=m*d;\n\t\tk-=m;\n\t\tif(!(k&1)) {\n\t\t\tpn(min(-x,x+d));\n\t\t}\n\t\telse {\n\t\t\tpn(min(abs(d-x), abs(-x-d)));\n\t\t}\n\t} \n\telse {\n\t\tx-=m*d;\n\t\tk-=m;\n\t\tif(!(k&1)) {\n\t\t\tpn(min(x, d-x));\n\t\t}\n\t\telse {\n\t\t\tpn(min(abs(d+x), abs(x-d)));\n\t\t}\n\n\t}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tdebug(\"Total Time: %.7f\\n\", (double)(clock() - z) / CLOCKS_PER_SEC);\n\treturn 0;\n}\nvoid LOCAL() {\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\t#endif\n}\n", "language": "C++", "metadata": {"date": 1597521680, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/C++/s979826880.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979826880", "user_id": "u764177390"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/****************************************\n\n\t\t\tLostMartian\n\n****************************************/\n#pragma GCC target(\"avx,avx2,fma\") \n#pragma GCC optimize(\"Ofast\") \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 \nusing namespace std;\ntypedef long long ll;\n\ntemplate \nvoid pn(Arg1&& arg1) {\n\tcout << arg1 << \"\\n\";\n}\ntemplate \nvoid pn(Arg1&& arg1, Args&&... args) { \n\tcout << arg1 << \" \"; \n\tpn(args...); \n}\ntemplate \nvoid ps(Arg1&& arg1) { \n\tcout << arg1 << \" \";\n}\ntemplate \nvoid ps(Arg1&& arg1, Args&&... args) { \n\tcout << arg1 << \" \"; \n\tps(args...); \n}\ntemplate \nvoid read(Arg1&& arg1) {\n\tcin >> arg1; \n}\ntemplate \nvoid read(Arg1&& arg1, Args&&... args) { \n\tcin >> arg1; \n\tread(args...); \n}\n\n#define rep(i,m,n) for(ll i=m; i=n; i--)\n#define vll vector\n#define vvl vector >\n#define pi pair\n#define vpi vector\n#define umap unordered_map\n#define pb push_back\n#define mk make_pair\n#define sz size()\n#define fi first\n#define se second\n#define all(x) x.begin(), x.end()\n#define test ll t; cin>>t; while(t--)\n#define ini(a, x) memset(a, x, sizeof(a))\n#define d(x) cout<<\"Value of \"#x\" = \"<>x>>k>>d;\n\tll m=abs(x)/d;\n\tif(m>=k) {\n\t\tif(x<0) {\n\t\t\tpn(-x-d*k);\n\t\t\treturn 0;\n\t\t}\n\t\telse {\n\t\t\tpn(x-d*k);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif(x<0) {\n\t\tx+=m*d;\n\t\tk-=m;\n\t\tif(!(k&1)) {\n\t\t\tpn(min(-x,x+d));\n\t\t}\n\t\telse {\n\t\t\tpn(min(abs(d-x), abs(-x-d)));\n\t\t}\n\t} \n\telse {\n\t\tx-=m*d;\n\t\tk-=m;\n\t\tif(!(k&1)) {\n\t\t\tpn(min(x, d-x));\n\t\t}\n\t\telse {\n\t\t\tpn(min(abs(d+x), abs(x-d)));\n\t\t}\n\n\t}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\tdebug(\"Total Time: %.7f\\n\", (double)(clock() - z) / CLOCKS_PER_SEC);\n\treturn 0;\n}\nvoid LOCAL() {\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\t#endif\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2518, "cpu_time_ms": 9, "memory_kb": 3796}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s872371763", "group_id": "codeNet:p02584", "input_text": "#include\nusing namespace std;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define PI acos(-1)\ntypedef long long ll;\nll gcd(ll x,ll y){\n if(y==0) return x;\n else return gcd(y,x%y);\n}\nll lcm(ll x,ll y){\n return x/gcd(x,y)*y;\n}\n\nint main(){\n ll x,k,d;\n cin>>x>>k>>d;\n ll ans=10000000000000000;\n ll a=-x/(2*d)+k/2;\n\n for(ll i=a-10000;i\nusing namespace std;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define PI acos(-1)\ntypedef long long ll;\nll gcd(ll x,ll y){\n if(y==0) return x;\n else return gcd(y,x%y);\n}\nll lcm(ll x,ll y){\n return x/gcd(x,y)*y;\n}\n\nint main(){\n ll x,k,d;\n cin>>x>>k>>d;\n ll ans=10000000000000000;\n ll a=-x/(2*d)+k/2;\n\n for(ll i=a-10000;i\n#include \n#include \n#include \n\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n\nusing std::cin;\nusing std::cout;\nusing std::endl;\nusing std::string;\nusing std::vector;\n\nint main()\n{\n long long X, K, D;\n cin >> X >> K >> D;\n\n if (X >= K * D)\n {\n cout << X - K * D << endl;\n }\n else\n {\n int div = X / D;\n K -= div;\n X -= div * D;\n if (K % 2 == 0)\n {\n cout << X << endl;\n }\n else\n {\n cout << std::abs(X - D) << endl;\n }\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1597519359, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02584/input.txt", "sample_output_relpath": "derived/input_output/data/p02584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02584/C++/s231732408.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231732408", "user_id": "u320027541"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n\nusing std::cin;\nusing std::cout;\nusing std::endl;\nusing std::string;\nusing std::vector;\n\nint main()\n{\n long long X, K, D;\n cin >> X >> K >> D;\n\n if (X >= K * D)\n {\n cout << X - K * D << endl;\n }\n else\n {\n int div = X / D;\n K -= div;\n X -= div * D;\n if (K % 2 == 0)\n {\n cout << X << endl;\n }\n else\n {\n cout << std::abs(X - D) << endl;\n }\n }\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 526, "cpu_time_ms": 6, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s272725638", "group_id": "codeNet:p02585", "input_text": "\n#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define INF 1e9\n#define PI 3.14159265359\n#define MOD 1000000007\n#define ALL(v) v.begin(),v.end()\n#define ALLR(v) v.rbegin(),v.rend()\n#define F first\n#define S second\ntypedef long long ll;\nconst int dx[4] = {1,0,-1,0};\nconst int dy[4] = {0,1,0,-1};\n//isPrime\n//modpow modinv\n//getDigit\ntemplate inline bool chmin(T& a, T b) {\n if (a > b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate inline bool chmax(T& a, T b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\nint main() {\n cout << fixed << setprecision(10);\n int n,k;\n cin >> n >> k;\n vector p(n),c(n);\n rep(i,n) cin >> p[i];\n rep(i,n) p[i]--;\n rep(i,n) cin >> c[i];\n vector> a;\n map mp;\n rep(i,n){\n if(mp[i]!=0)continue;\n mp[i]++;\n int q = i;\n vector b;\n rep(j,n){\n b.push_back(c[q]);\n q=p[q];\n if(mp[q]!=0){\n break;\n }\n mp[q]++;\n }\n a.push_back(b);\n }\n ll t = -1e18;\n for(auto b:a){\n int m = b.size();\n vector d(2*m+1);\n rep(i,m){\n d[i+1]=d[i]+b[i];\n }\n rep(i,m){\n d[i+m+1]=d[i+m]+b[i];\n }\n ll res = 0;\n if((d[m]-d[0])>=0){\n if(k%m==0&&k>=m){\n res+=(k/m-1)*(d[m]-d[0]);\n }else{\n res += (k/m)*(d[m]-d[0]);\n }\n }else{\n res = 0;\n }\n\n\n int k1;\n if(k%m==0&&k>=m){\n k1=m;\n }else{\n k1=k%m;\n }\n ll ans = -1e18;\n for(int add=1; add<=k1; add++){\n for(int i=0; i+add<2*m+1; i++){\n ans = max(ans,d[i+add]-d[i]);\n }\n }\n t = max(t,ans+res);\n }\n cout << t << endl;\n\n}\n", "language": "C++", "metadata": {"date": 1597546704, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02585/input.txt", "sample_output_relpath": "derived/input_output/data/p02585/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02585/C++/s272725638.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s272725638", "user_id": "u474760662"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "\n#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define INF 1e9\n#define PI 3.14159265359\n#define MOD 1000000007\n#define ALL(v) v.begin(),v.end()\n#define ALLR(v) v.rbegin(),v.rend()\n#define F first\n#define S second\ntypedef long long ll;\nconst int dx[4] = {1,0,-1,0};\nconst int dy[4] = {0,1,0,-1};\n//isPrime\n//modpow modinv\n//getDigit\ntemplate inline bool chmin(T& a, T b) {\n if (a > b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate inline bool chmax(T& a, T b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\nint main() {\n cout << fixed << setprecision(10);\n int n,k;\n cin >> n >> k;\n vector p(n),c(n);\n rep(i,n) cin >> p[i];\n rep(i,n) p[i]--;\n rep(i,n) cin >> c[i];\n vector> a;\n map mp;\n rep(i,n){\n if(mp[i]!=0)continue;\n mp[i]++;\n int q = i;\n vector b;\n rep(j,n){\n b.push_back(c[q]);\n q=p[q];\n if(mp[q]!=0){\n break;\n }\n mp[q]++;\n }\n a.push_back(b);\n }\n ll t = -1e18;\n for(auto b:a){\n int m = b.size();\n vector d(2*m+1);\n rep(i,m){\n d[i+1]=d[i]+b[i];\n }\n rep(i,m){\n d[i+m+1]=d[i+m]+b[i];\n }\n ll res = 0;\n if((d[m]-d[0])>=0){\n if(k%m==0&&k>=m){\n res+=(k/m-1)*(d[m]-d[0]);\n }else{\n res += (k/m)*(d[m]-d[0]);\n }\n }else{\n res = 0;\n }\n\n\n int k1;\n if(k%m==0&&k>=m){\n k1=m;\n }else{\n k1=k%m;\n }\n ll ans = -1e18;\n for(int add=1; add<=k1; add++){\n for(int i=0; i+add<2*m+1; i++){\n ans = max(ans,d[i+add]-d[i]);\n }\n }\n t = max(t,ans+res);\n }\n cout << t << endl;\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "sample_input": "5 2\n2 4 5 1 3\n3 4 -10 -8 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02585", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1686, "cpu_time_ms": 48, "memory_kb": 4032}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s590837510", "group_id": "codeNet:p02586", "input_text": "#include \n#define int long long\nusing namespace std;\n\nconst int Sz = 3e3 + 3;\nusing ii = pair;\n\nint n, m, k;\nint x, y, z;\nint val = 0;\nint f[Sz][Sz][4];\nint a[Sz][Sz];\nint dp(int row, int col, int cnt){\n if(row > n || col > m) return 0;\n int &res = f[row][col][cnt];\n if(res != -1) return res;\n res = dp(row + 1, col, 0);\n if(cnt < 3) res += a[row][col];\n if(cnt < 3){\n if(a[row][col] != 0)\n res = max(res, dp(row, col + 1, cnt + 1) + a[row][col]);\n res = max(res, dp(row, col + 1, cnt));\n }\n //cout << row << \" \" << col << \" \" << res << '\\n';\n return res;\n}\nvoid trace(int row, int col, int cnt){\n if(row > n || col > m) return ;\n if(f[row][col][cnt] == f[row + 1][col][0]) return trace(row + 1, col, 0);\n if(f[row][col][cnt] == f[row][col + 1][cnt]) return trace(row, col + 1, cnt);\n cout << row << \" \" << col << '\\n';\n return trace(row, col + 1, cnt + 1);\n}\nint32_t main()\n{\n //freopen(\"inp.txt\" , \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n memset(f, -1, sizeof f);\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n cin >> n >> m >> k;\n while(k--){\n cin >> x >> y >> z;\n a[x][y] = z;\n }\n cout << dp(1, 1, 0);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1598390347, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02586/input.txt", "sample_output_relpath": "derived/input_output/data/p02586/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02586/C++/s590837510.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590837510", "user_id": "u179794617"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#include \n#define int long long\nusing namespace std;\n\nconst int Sz = 3e3 + 3;\nusing ii = pair;\n\nint n, m, k;\nint x, y, z;\nint val = 0;\nint f[Sz][Sz][4];\nint a[Sz][Sz];\nint dp(int row, int col, int cnt){\n if(row > n || col > m) return 0;\n int &res = f[row][col][cnt];\n if(res != -1) return res;\n res = dp(row + 1, col, 0);\n if(cnt < 3) res += a[row][col];\n if(cnt < 3){\n if(a[row][col] != 0)\n res = max(res, dp(row, col + 1, cnt + 1) + a[row][col]);\n res = max(res, dp(row, col + 1, cnt));\n }\n //cout << row << \" \" << col << \" \" << res << '\\n';\n return res;\n}\nvoid trace(int row, int col, int cnt){\n if(row > n || col > m) return ;\n if(f[row][col][cnt] == f[row + 1][col][0]) return trace(row + 1, col, 0);\n if(f[row][col][cnt] == f[row][col + 1][cnt]) return trace(row, col + 1, cnt);\n cout << row << \" \" << col << '\\n';\n return trace(row, col + 1, cnt + 1);\n}\nint32_t main()\n{\n //freopen(\"inp.txt\" , \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n memset(f, -1, sizeof f);\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n cin >> n >> m >> k;\n while(k--){\n cin >> x >> y >> z;\n a[x][y] = z;\n }\n cout << dp(1, 1, 0);\n return 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1266, "cpu_time_ms": 562, "memory_kb": 356228}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s428022761", "group_id": "codeNet:p02587", "input_text": "#include \n\nusing namespace std;\n\nint n;\nstring s[54];\nlong long c[54];\nlong long dist[54][2][24];\npriority_queue>>> pq;\nvector ans;\n\nvoid solve(){\n cin>>n;\n memset(dist, -1, sizeof(dist));\n for(int i = 0; i < n; i++){\n cin>>s[i]>>c[i];\n dist[i][0][s[i].length()] = c[i];\n pq.push({-c[i], {i, {0, s[i].length()}}});\n }\n while(!pq.empty()){\n pair>> now = pq.top();\n pq.pop();\n long long cost = -now.first;\n int idx = now.second.first;\n int dir = now.second.second.first;\n int rem = now.second.second.second;\n if(cost > dist[idx][dir][rem]) continue;\n if(dir == 0){\n for(int nextIdx = 0; nextIdx < n; nextIdx++){\n const int L = s[idx].length();\n const int R = s[nextIdx].length();\n bool can = true;\n int lRem = rem, rRem = R;\n while(lRem && rRem){\n if(s[idx][L-lRem] != s[nextIdx][rRem-1]) can = false;\n lRem--;\n rRem--;\n }\n if(!can) continue;\n long long nextCost = cost + c[nextIdx];\n if(lRem + rRem <= 1){\n ans.push_back(nextCost);\n continue;\n }\n if(lRem && (dist[idx][0][lRem] > nextCost || dist[idx][0][lRem] == -1)){\n dist[idx][0][lRem] = nextCost;\n pq.push({-nextCost, {idx, {0, lRem}}});\n }\n if(rRem && (dist[nextIdx][1][rRem] > nextCost || dist[nextIdx][1][rRem] == -1)){\n dist[nextIdx][1][rRem] = nextCost;\n pq.push({-nextCost, {nextIdx, {1, rRem}}});\n }\n }\n }\n else {\n for(int nextIdx = 0; nextIdx < n; nextIdx++){\n const int L = s[nextIdx].length();\n const int R = s[idx].length();\n bool can = true;\n int lRem = L, rRem = rem;\n while(lRem && rRem){\n if(s[nextIdx][L-lRem] != s[idx][rRem-1]) can = false;\n lRem--;\n rRem--;\n }\n if(!can) continue;\n long long nextCost = cost + c[nextIdx];\n if(lRem + rRem <= 1){\n ans.push_back(nextCost);\n continue;\n }\n if(lRem && (dist[nextIdx][0][lRem] > nextCost || dist[nextIdx][0][lRem] == -1)){\n dist[nextIdx][0][lRem] = nextCost;\n pq.push({-nextCost, {nextIdx, {0, lRem}}});\n }\n if(rRem && (dist[idx][1][rRem] > nextCost || dist[idx][1][rRem] == -1)){\n dist[idx][1][rRem] = nextCost;\n pq.push({-nextCost, {idx, {1, rRem}}});\n }\n }\n }\n }\n if(ans.size() == 0) cout<<-1<>TC;\n TC=1;\n while(TC--){\n solve();\n }\n}", "language": "C++", "metadata": {"date": 1597544766, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02587.html", "problem_id": "p02587", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02587/input.txt", "sample_output_relpath": "derived/input_output/data/p02587/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02587/C++/s428022761.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s428022761", "user_id": "u541786453"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint n;\nstring s[54];\nlong long c[54];\nlong long dist[54][2][24];\npriority_queue>>> pq;\nvector ans;\n\nvoid solve(){\n cin>>n;\n memset(dist, -1, sizeof(dist));\n for(int i = 0; i < n; i++){\n cin>>s[i]>>c[i];\n dist[i][0][s[i].length()] = c[i];\n pq.push({-c[i], {i, {0, s[i].length()}}});\n }\n while(!pq.empty()){\n pair>> now = pq.top();\n pq.pop();\n long long cost = -now.first;\n int idx = now.second.first;\n int dir = now.second.second.first;\n int rem = now.second.second.second;\n if(cost > dist[idx][dir][rem]) continue;\n if(dir == 0){\n for(int nextIdx = 0; nextIdx < n; nextIdx++){\n const int L = s[idx].length();\n const int R = s[nextIdx].length();\n bool can = true;\n int lRem = rem, rRem = R;\n while(lRem && rRem){\n if(s[idx][L-lRem] != s[nextIdx][rRem-1]) can = false;\n lRem--;\n rRem--;\n }\n if(!can) continue;\n long long nextCost = cost + c[nextIdx];\n if(lRem + rRem <= 1){\n ans.push_back(nextCost);\n continue;\n }\n if(lRem && (dist[idx][0][lRem] > nextCost || dist[idx][0][lRem] == -1)){\n dist[idx][0][lRem] = nextCost;\n pq.push({-nextCost, {idx, {0, lRem}}});\n }\n if(rRem && (dist[nextIdx][1][rRem] > nextCost || dist[nextIdx][1][rRem] == -1)){\n dist[nextIdx][1][rRem] = nextCost;\n pq.push({-nextCost, {nextIdx, {1, rRem}}});\n }\n }\n }\n else {\n for(int nextIdx = 0; nextIdx < n; nextIdx++){\n const int L = s[nextIdx].length();\n const int R = s[idx].length();\n bool can = true;\n int lRem = L, rRem = rem;\n while(lRem && rRem){\n if(s[nextIdx][L-lRem] != s[idx][rRem-1]) can = false;\n lRem--;\n rRem--;\n }\n if(!can) continue;\n long long nextCost = cost + c[nextIdx];\n if(lRem + rRem <= 1){\n ans.push_back(nextCost);\n continue;\n }\n if(lRem && (dist[nextIdx][0][lRem] > nextCost || dist[nextIdx][0][lRem] == -1)){\n dist[nextIdx][0][lRem] = nextCost;\n pq.push({-nextCost, {nextIdx, {0, lRem}}});\n }\n if(rRem && (dist[idx][1][rRem] > nextCost || dist[idx][1][rRem] == -1)){\n dist[idx][1][rRem] = nextCost;\n pq.push({-nextCost, {idx, {1, rRem}}});\n }\n }\n }\n }\n if(ans.size() == 0) cout<<-1<>TC;\n TC=1;\n while(TC--){\n solve();\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have N strings of lowercase English letters: S_1, S_2, \\cdots, S_N.\n\nTakahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - and concatenating them in some order of his choice.\n\nThe cost of using the string S_i once is C_i, and the cost of using it multiple times is C_i multiplied by that number of times.\n\nFind the minimum total cost needed to choose strings so that Takahashi can make a palindrome.\n\nIf there is no choice of strings in which he can make a palindrome, print -1.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq |S_i| \\leq 20\n\nS_i consists of lowercase English letters.\n\n1 \\leq C_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 C_1\nS_2 C_2\n:\nS_N C_N\n\nOutput\n\nPrint the minimum total cost needed to choose strings so that Takahashi can make a palindrome, or -1 if there is no such choice.\n\nSample Input 1\n\n3\nba 3\nabc 4\ncbaa 5\n\nSample Output 1\n\n7\n\nWe have ba, abc, and cbaa.\n\nFor example, we can use ba once and abc once for a cost of 7, then concatenate them in the order abc, ba to make a palindrome.\nAlso, we can use abc once and cbaa once for a cost of 9, then concatenate them in the order cbaa, abc to make a palindrome.\n\nWe cannot make a palindrome for a cost less than 7, so we should print 7.\n\nSample Input 2\n\n2\nabcab 5\ncba 3\n\nSample Output 2\n\n11\n\nWe can choose abcab once and cba twice, then concatenate them in the order abcab, cba, cba to make a palindrome for a cost of 11.\n\nSample Input 3\n\n4\nab 5\ncba 3\na 12\nab 10\n\nSample Output 3\n\n8\n\nWe can choose a once, which is already a palindrome, but it is cheaper to concatenate ab and cba.\n\nSample Input 4\n\n2\nabc 1\nab 2\n\nSample Output 4\n\n-1\n\nWe cannot make a palindrome, so we should print -1.", "sample_input": "3\nba 3\nabc 4\ncbaa 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02587", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have N strings of lowercase English letters: S_1, S_2, \\cdots, S_N.\n\nTakahashi wants to make a string that is a palindrome by choosing one or more of these strings - the same string can be chosen more than once - and concatenating them in some order of his choice.\n\nThe cost of using the string S_i once is C_i, and the cost of using it multiple times is C_i multiplied by that number of times.\n\nFind the minimum total cost needed to choose strings so that Takahashi can make a palindrome.\n\nIf there is no choice of strings in which he can make a palindrome, print -1.\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq |S_i| \\leq 20\n\nS_i consists of lowercase English letters.\n\n1 \\leq C_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 C_1\nS_2 C_2\n:\nS_N C_N\n\nOutput\n\nPrint the minimum total cost needed to choose strings so that Takahashi can make a palindrome, or -1 if there is no such choice.\n\nSample Input 1\n\n3\nba 3\nabc 4\ncbaa 5\n\nSample Output 1\n\n7\n\nWe have ba, abc, and cbaa.\n\nFor example, we can use ba once and abc once for a cost of 7, then concatenate them in the order abc, ba to make a palindrome.\nAlso, we can use abc once and cbaa once for a cost of 9, then concatenate them in the order cbaa, abc to make a palindrome.\n\nWe cannot make a palindrome for a cost less than 7, so we should print 7.\n\nSample Input 2\n\n2\nabcab 5\ncba 3\n\nSample Output 2\n\n11\n\nWe can choose abcab once and cba twice, then concatenate them in the order abcab, cba, cba to make a palindrome for a cost of 11.\n\nSample Input 3\n\n4\nab 5\ncba 3\na 12\nab 10\n\nSample Output 3\n\n8\n\nWe can choose a once, which is already a palindrome, but it is cheaper to concatenate ab and cba.\n\nSample Input 4\n\n2\nabc 1\nab 2\n\nSample Output 4\n\n-1\n\nWe cannot make a palindrome, so we should print -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3293, "cpu_time_ms": 6, "memory_kb": 3696}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s869263256", "group_id": "codeNet:p02588", "input_text": "#include \"bits/stdc++.h\"\n \nusing namespace std;\ntypedef long long ll;\ntypedef vector vll;\n#define int ll\ntypedef pair pii;\n#define fi first\n#define se second\n#define Sort(a) sort(a.begin(),a.end())\n#define rep(i,n) for(int i = 0;i < (n) ; i++) \n#define REP(i,n) for(int i = 0;i < (n) ; i++) \n#define MP(a,b) make_pair(a,b)\n#define pb(a) push_back(a)\n#define INF LLONG_MAX/4\n#define INTINF INT_MAX/2\n#define all(x) (x).begin(),(x).end()\n#define debug(x) cerr<<#x<<\": \"< inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}\ntemplate inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}\n/*----------------------------------------------------------------*/\n// const int MOD = 998244353;\n// const int MOD = 1000000007;\nvector p;\n/*----------------------------------------------------------------*/\nsigned main(){\n\t\n\tint n;\n\tcin >> n;\n\tint cnt[300][300] = {};\n\trep(i,n){\n\t\tstring a;\n\t\tcin >> a;\n\t\t// cerr << a << endl;\n\t\tint m = a.size();\n\t\tint z = 0;\n\t\tint f = 0;\n\t\tint x2 = 0;\n\t\tint x5 = 0;\n\n\t\trep(j,m){\n\t\t\tif(a[m-1-j] == '.'){\n\t\t\t\tf = 1;\n\t\t\t\ta.erase(m-1-j,1);\n\t\t\t\tbreak;\n\t\t\t}else{\n\t\t\t\tz++;\n\t\t\t}\n\t\t}\n\t\tif(f==0)z = 0;\n\t\t\n\t\tx2 = -z;\n\t\tx5 = -z;\n\t\tcerr << a << endl;\n\t\tint A = stoll(a);\n\t\twhile(A%2 == 0){\n\t\t\tA /= 2;\n\t\t\tx2++;\n\t\t}\n\t\twhile(A%5 == 0){\n\t\t\tA /= 5;\n\t\t\tx5++;\n\t\t}\n\t\tp.push_back(MP(x2,x5));\n\t\t// cerr << x2 <<\" \" << x5 << endl;\n\t\tcnt[x2+150][x5+150]++;\n\t}\n\n\tint s[310][310] = {};\n\trep(i,301)rep(j,301)s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + cnt[i][j];\n\n\tint ans = 0;\n\trep(i,n){\n\t\tint x2 = p[i].first;\n\t\tint x5 = p[i].second;\n\t\t// cerr << x2 << \" \" << x5 << endl;\n\t\tint y2 = 150-x2;\n\t\tint y5 = 150-x5;\n\t\tint pl = s[300][300]-s[y2][300]-s[300][y5]+s[y2][y5];\n\t\tif(x2>=0&&x5>=0)pl--;\n\t\tans += pl;\n\t\t// cerr << x2 <<\" \" << x5 << \" : \" << pl << endl;\n\t}\n\tcout << ans/2 << endl;\n\t\n\n\n\t\n\n\n\treturn 0;\n}\n/*----------------------------------------------------------------*/\n\n// g++ -std=gnu++17 code1.cpp\n// sudo pip3 install --upgrade online-judge-tools\n// rm -r -f test;oj dl https://abc174.contest.atcoder.jp/tasks/abc174_b\n// rm -r -f test;oj d https://atcoder.jp/contests/agc047/tasks/agc047_a", "language": "C++", "metadata": {"date": 1597024604, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02588.html", "problem_id": "p02588", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02588/input.txt", "sample_output_relpath": "derived/input_output/data/p02588/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02588/C++/s869263256.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s869263256", "user_id": "u548768105"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n \nusing namespace std;\ntypedef long long ll;\ntypedef vector vll;\n#define int ll\ntypedef pair pii;\n#define fi first\n#define se second\n#define Sort(a) sort(a.begin(),a.end())\n#define rep(i,n) for(int i = 0;i < (n) ; i++) \n#define REP(i,n) for(int i = 0;i < (n) ; i++) \n#define MP(a,b) make_pair(a,b)\n#define pb(a) push_back(a)\n#define INF LLONG_MAX/4\n#define INTINF INT_MAX/2\n#define all(x) (x).begin(),(x).end()\n#define debug(x) cerr<<#x<<\": \"< inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}\ntemplate inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}\n/*----------------------------------------------------------------*/\n// const int MOD = 998244353;\n// const int MOD = 1000000007;\nvector p;\n/*----------------------------------------------------------------*/\nsigned main(){\n\t\n\tint n;\n\tcin >> n;\n\tint cnt[300][300] = {};\n\trep(i,n){\n\t\tstring a;\n\t\tcin >> a;\n\t\t// cerr << a << endl;\n\t\tint m = a.size();\n\t\tint z = 0;\n\t\tint f = 0;\n\t\tint x2 = 0;\n\t\tint x5 = 0;\n\n\t\trep(j,m){\n\t\t\tif(a[m-1-j] == '.'){\n\t\t\t\tf = 1;\n\t\t\t\ta.erase(m-1-j,1);\n\t\t\t\tbreak;\n\t\t\t}else{\n\t\t\t\tz++;\n\t\t\t}\n\t\t}\n\t\tif(f==0)z = 0;\n\t\t\n\t\tx2 = -z;\n\t\tx5 = -z;\n\t\tcerr << a << endl;\n\t\tint A = stoll(a);\n\t\twhile(A%2 == 0){\n\t\t\tA /= 2;\n\t\t\tx2++;\n\t\t}\n\t\twhile(A%5 == 0){\n\t\t\tA /= 5;\n\t\t\tx5++;\n\t\t}\n\t\tp.push_back(MP(x2,x5));\n\t\t// cerr << x2 <<\" \" << x5 << endl;\n\t\tcnt[x2+150][x5+150]++;\n\t}\n\n\tint s[310][310] = {};\n\trep(i,301)rep(j,301)s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + cnt[i][j];\n\n\tint ans = 0;\n\trep(i,n){\n\t\tint x2 = p[i].first;\n\t\tint x5 = p[i].second;\n\t\t// cerr << x2 << \" \" << x5 << endl;\n\t\tint y2 = 150-x2;\n\t\tint y5 = 150-x5;\n\t\tint pl = s[300][300]-s[y2][300]-s[300][y5]+s[y2][y5];\n\t\tif(x2>=0&&x5>=0)pl--;\n\t\tans += pl;\n\t\t// cerr << x2 <<\" \" << x5 << \" : \" << pl << endl;\n\t}\n\tcout << ans/2 << endl;\n\t\n\n\n\t\n\n\n\treturn 0;\n}\n/*----------------------------------------------------------------*/\n\n// g++ -std=gnu++17 code1.cpp\n// sudo pip3 install --upgrade online-judge-tools\n// rm -r -f test;oj dl https://abc174.contest.atcoder.jp/tasks/abc174_b\n// rm -r -f test;oj d https://atcoder.jp/contests/agc047/tasks/agc047_a", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "sample_input": "5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02588", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N real values A_1, A_2, \\ldots, A_N.\nCompute the number of pairs of indices (i, j)\nsuch that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n2 \\leq N \\leq 200\\,000\n\n0 < A_i < 10^4\n\nA_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is given from Standard Input in the following format.\n\nN\nA_1\nA_2\n\\vdots\nA_N\n\nOutput\n\nPrint the number of pairs with integer product A_i \\cdot A_j (and i < j).\n\nSample Input 1\n\n5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n\nSample Output 1\n\n3\n\nThere are 3 pairs with integer product:\n\n7.5 \\cdot 2.4 = 18\n\n7.5 \\cdot 16 = 120\n\n17 \\cdot 16 = 272\n\nSample Input 2\n\n11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n\nSample Output 2\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2265, "cpu_time_ms": 618, "memory_kb": 8184}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s696102540", "group_id": "codeNet:p02594", "input_text": "#include\nusing namespace std;\ntypedef long long int ll;\ntypedef long double lld;\nll MOD = (1e9)+7;\nconst int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};\nconst int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};\nconst int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};\nconst int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};\n//#pragma GCC target (\"avx2\")\n//#pragma GCC optimization (\"O3\")\n//#pragma GCC optimization (\"unroll-loops\")\ninline void fastIO(){\n ios_base::sync_with_stdio(0);cin.tie(0);\n}\ntemplate ostream& operator<<(ostream &os, const vector &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = \", \"; return os << '}'; }\ntemplate ostream& operator<<(ostream &os, const array &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = \", \"; return os << '}'; }\ntemplate ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\n\nvoid debug_out() { cerr << endl; }\ntemplate void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }\n\n#ifdef LOCAL\n#define debug(...) cerr << \"(\" << #__VA_ARGS__ << \"):\", debug_out(__VA_ARGS__)\n#else\n#define debug(...) 47\n#endif\nconst ll MAXN=5050;\n\nint main(){\n fastIO();\n int x;\n cin>>x;\n if(x>=30){\n cout<<\"Yes\"<\nusing namespace std;\ntypedef long long int ll;\ntypedef long double lld;\nll MOD = (1e9)+7;\nconst int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};\nconst int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};\nconst int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};\nconst int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};\n//#pragma GCC target (\"avx2\")\n//#pragma GCC optimization (\"O3\")\n//#pragma GCC optimization (\"unroll-loops\")\ninline void fastIO(){\n ios_base::sync_with_stdio(0);cin.tie(0);\n}\ntemplate ostream& operator<<(ostream &os, const vector &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = \", \"; return os << '}'; }\ntemplate ostream& operator<<(ostream &os, const array &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = \", \"; return os << '}'; }\ntemplate ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\n\nvoid debug_out() { cerr << endl; }\ntemplate void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }\n\n#ifdef LOCAL\n#define debug(...) cerr << \"(\" << #__VA_ARGS__ << \"):\", debug_out(__VA_ARGS__)\n#else\n#define debug(...) 47\n#endif\nconst ll MAXN=5050;\n\nint main(){\n fastIO();\n int x;\n cin>>x;\n if(x>=30){\n cout<<\"Yes\"<\nusing namespace std;\n\nint main()\n{\n\tint X;\n\tcin >> X;\n\tif (X < 30) {\n\t\tcout << \"Yes\" << endl;\n\t}\n\telse cout << \"No\" << endl;\n\n}\n", "language": "C++", "metadata": {"date": 1597953543, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02594/input.txt", "sample_output_relpath": "derived/input_output/data/p02594/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02594/C++/s715818352.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s715818352", "user_id": "u046198295"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main()\n{\n\tint X;\n\tcin >> X;\n\tif (X < 30) {\n\t\tcout << \"Yes\" << endl;\n\t}\n\telse cout << \"No\" << endl;\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "sample_input": "25\n"}, "reference_outputs": ["No\n"], "source_document_id": "p02594", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\n\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\nConstraints\n\n-40 \\leq X \\leq 40\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint Yes if you will turn on the air conditioner; print No otherwise.\n\nSample Input 1\n\n25\n\nSample Output 1\n\nNo\n\nSample Input 2\n\n30\n\nSample Output 2\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 6, "memory_kb": 3620}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s382061014", "group_id": "codeNet:p02594", "input_text": "#include\nusing namespace std;\n#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define int long long\n#define pb push_back\n#define ff first\n#define ss second\n\nbool isvalid(int x,int y,int n,int m)\n{\n return (x>=0 && x=0 && y>t;\n\twhile(t--)\n\t{\n\t int n;\n\t cin>>n;\n\t if(n>=30)\n\t cout<<\"YES\"<\nusing namespace std;\n#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define int long long\n#define pb push_back\n#define ff first\n#define ss second\n\nbool isvalid(int x,int y,int n,int m)\n{\n return (x>=0 && x=0 && y>t;\n\twhile(t--)\n\t{\n\t int n;\n\t cin>>n;\n\t if(n>=30)\n\t cout<<\"YES\"<\nusing namespace std;\nconst int BUF = 200005;\n\n\nint N, D;\nint pt[BUF][2];\n\nvoid read() {\n cin >> N >> D;\n for (int i = 0; i < N; ++i) {\n cin >> pt[i][0] >> pt[i][1];\n }\n}\n\n\nvoid work() {\n int cnt = 0;\n for (int i = 0; i < N; ++i) {\n cnt += 1LL * pt[i][0] * pt[i][0] + 1LL * pt[i][1] * pt[i][1] <= 1LL * D * D;\n }\n cout << cnt << endl;\n}\n\n\nint main() {\n read();\n work();\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1596517630, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/C++/s318813841.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318813841", "user_id": "u052873655"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\nusing namespace std;\nconst int BUF = 200005;\n\n\nint N, D;\nint pt[BUF][2];\n\nvoid read() {\n cin >> N >> D;\n for (int i = 0; i < N; ++i) {\n cin >> pt[i][0] >> pt[i][1];\n }\n}\n\n\nvoid work() {\n int cnt = 0;\n for (int i = 0; i < N; ++i) {\n cnt += 1LL * pt[i][0] * pt[i][0] + 1LL * pt[i][1] * pt[i][1] <= 1LL * D * D;\n }\n cout << cnt << endl;\n}\n\n\nint main() {\n read();\n work();\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 445, "cpu_time_ms": 101, "memory_kb": 5160}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s948771299", "group_id": "codeNet:p02595", "input_text": "#include\nusing namespace std;\n//#pragma gcc optimize(\"O3\")\n//#pragma gcc optimize(\"unroll-loops\")\n#ifdef EVAH\n #define _WIN32_WINNT 0x0500\n #include\n#endif\n#define openFile(n) ShellExecute(nullptr,\"open\",n,nullptr,nullptr,SW_SHOWNORMAL);\n#define closeP(n) system((string(\"taskkill /im \")+n+\" /f\").c_str());\n#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);\n#define opf \"output.txt\"\n#define ipf \"input.txt\"\n#define mem(n,x) memset(n,x,sizeof(n));\n#define sf scanf\n#define pf printf\n#define ff first\n#define ss second\n#define pb push_back\n#define PII pair\n#define For(x,n) for(int i=x; i> n >> d;\n while(n-- > 0) {\n cin >> x >> y;\n if(sqrt(x*x+y*y)<=d) cnt++;\n }\n cout << cnt << \"\\n\";\n\n #ifdef EVAH\n //openFile(opf);\n //Sleep(3000);\n //closeP(\"notepad.exe\");\n //closeConsole;\n #endif\n}\n", "language": "C++", "metadata": {"date": 1596416732, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/C++/s948771299.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948771299", "user_id": "u709944434"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\nusing namespace std;\n//#pragma gcc optimize(\"O3\")\n//#pragma gcc optimize(\"unroll-loops\")\n#ifdef EVAH\n #define _WIN32_WINNT 0x0500\n #include\n#endif\n#define openFile(n) ShellExecute(nullptr,\"open\",n,nullptr,nullptr,SW_SHOWNORMAL);\n#define closeP(n) system((string(\"taskkill /im \")+n+\" /f\").c_str());\n#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);\n#define opf \"output.txt\"\n#define ipf \"input.txt\"\n#define mem(n,x) memset(n,x,sizeof(n));\n#define sf scanf\n#define pf printf\n#define ff first\n#define ss second\n#define pb push_back\n#define PII pair\n#define For(x,n) for(int i=x; i> n >> d;\n while(n-- > 0) {\n cin >> x >> y;\n if(sqrt(x*x+y*y)<=d) cnt++;\n }\n cout << cnt << \"\\n\";\n\n #ifdef EVAH\n //openFile(opf);\n //Sleep(3000);\n //closeP(\"notepad.exe\");\n //closeConsole;\n #endif\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1276, "cpu_time_ms": 51, "memory_kb": 3664}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s440725386", "group_id": "codeNet:p02596", "input_text": "#include \nusing namespace std;\n\nint main() {\n int k;\n cin >> k;\n \n if (k%2==0 || k%5==0 || k%17==0 || k%19==0 || k%23==0 || k%29==0 || k%31==0) {\n cout << -1 << endl;\n return 0;\n }\n else {\n long long s = 7, o = 10, ans = 1;\n while (1) {\n if (s%k == 0) {\n cout << ans << endl;\n break;\n }\n s += o*7;\n o *= 10;\n ans++;\n }\n }\n}", "language": "C++", "metadata": {"date": 1600392029, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/C++/s440725386.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s440725386", "user_id": "u528258842"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int k;\n cin >> k;\n \n if (k%2==0 || k%5==0 || k%17==0 || k%19==0 || k%23==0 || k%29==0 || k%31==0) {\n cout << -1 << endl;\n return 0;\n }\n else {\n long long s = 7, o = 10, ans = 1;\n while (1) {\n if (s%k == 0) {\n cout << ans << endl;\n break;\n }\n s += o*7;\n o *= 10;\n ans++;\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 479, "cpu_time_ms": 2205, "memory_kb": 3608}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s726797086", "group_id": "codeNet:p02600", "input_text": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include //cout << fixed << setprecision(15) << x << endl;\n\nusing namespace std;\ntypedef long long ll;\nconst ll INF = 1e9 + 8;\nconst ll MOD = 1e9 + 7;\nconst ll LLINF = 1e18;\n#define Pint pair\n#define rng(i,a,b) for(int i=int(a);i=int(b);i--)\n#define rep(i,b) rng(i,0,b)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n/* -- template -- */\n\nint main() {\n int x; cin >> x;\n for(int i = 0; i < 8; ++i) {\n if(x < 600 + 200 * i) {\n cout << 8 - i << endl;\n return 0;\n }\n }\n}\n", "language": "C++", "metadata": {"date": 1595980378, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02600.html", "problem_id": "p02600", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02600/input.txt", "sample_output_relpath": "derived/input_output/data/p02600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02600/C++/s726797086.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726797086", "user_id": "u275488634"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include //cout << fixed << setprecision(15) << x << endl;\n\nusing namespace std;\ntypedef long long ll;\nconst ll INF = 1e9 + 8;\nconst ll MOD = 1e9 + 7;\nconst ll LLINF = 1e18;\n#define Pint pair\n#define rng(i,a,b) for(int i=int(a);i=int(b);i--)\n#define rep(i,b) rng(i,0,b)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n/* -- template -- */\n\nint main() {\n int x; cin >> x;\n for(int i = 0; i < 8; ++i) {\n if(x < 600 + 200 * i) {\n cout << 8 - i << endl;\n return 0;\n }\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "sample_input": "725\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02600", "source_text": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 806, "cpu_time_ms": 8, "memory_kb": 3592}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s983068999", "group_id": "codeNet:p02604", "input_text": "#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\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair P;\ntypedef pair Q;\ntypedef complex C;\n#define cx real()\n#define cy imag()\nconst ll INF = 1LL << 60;\nconst double DINF = 1e30;\nconst ll mod = 1000000007;\nconst ll dx[4] = {1, 0, -1, 0};\nconst ll dy[4] = {0, -1, 0, 1};\nconst C I = C(0, 1);\nconst double EPS = 1e-10;\nconst ll NCK_MAX = 510000;\n\nll gcd(ll a, ll b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\n\nll extgcd(ll a, ll b, ll& x, ll& y) {\n if (b == 0) {\n x = 1, y = 0; return a;\n }\n ll q = a/b, g = extgcd(b, a - q*b, x, y);\n ll z = x - q * y;\n x = y;\n y = z;\n return g;\n}\n\nll invmod (ll a, ll m) { // a^-1 mod m\n ll x, y;\n extgcd(a, m, x, y);\n x %= m;\n if (x < 0) x += m;\n return x;\n}\n\nll *fac, *finv, *inv;\n\nvoid nCk_init(ll mod) {\n fac = new ll[NCK_MAX];\n finv = new ll[NCK_MAX];\n inv = new ll[NCK_MAX];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (ll i = 2; i < NCK_MAX; 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 nCk(ll n, ll k, ll mod) {\n if (fac == NULL) nCk_init(mod);\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\ntemplate \nclass Zip {\n vector d;\n bool flag;\n void init() {\n sort(d.begin(), d.end());\n d.erase(unique(d.begin(), d.end()), d.end());\n flag = false;\n }\npublic:\n Zip() {\n flag = false;\n }\n void add(T x) {\n d.push_back(x);\n flag = true;\n }\n ll getNum(T x) {\n if (flag) init();\n return lower_bound(d.begin(), d.end(), x) - d.begin();\n }\n ll size() {\n if (flag) init();\n return (ll)d.size();\n }\n};\n\nclass UnionFind {\n vector par, rank; // par > 0: number, par < 0: -par\npublic:\n UnionFind(ll n) : par(n, 1), rank(n, 0) {}\n ll getSize(ll x) {\n return par[find(x)];\n }\n ll find(ll x) {\n if (par[x] > 0) return x;\n return -(par[x] = -find(-par[x]));\n }\n void merge(ll x, ll y) {\n x = find(x);\n y = find(y);\n if (x == y) return;\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = -y;\n } else {\n par[x] += par[y];\n par[y] = -x;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n bool isSame(ll x, ll y) {\n return find(x) == find(y);\n }\n};\n\n\ntemplate \nclass SegmentTree {\n ll n;\n vector node;\n function fun, fun2;\n bool customChange;\n T outValue, initValue;\npublic:\n void init(ll num, function resultFunction, T init, T out, function changeFunction = NULL) {\n // changeFunction: (input, beforevalue) => newvalue\n fun = resultFunction;\n fun2 = changeFunction;\n customChange = changeFunction != NULL;\n n = 1;\n while (n < num) n *= 2;\n node.resize(2 * n - 1);\n fill(node.begin(), node.end(), init);\n outValue = out;\n initValue = init;\n }\n void valueChange(ll num, T value) {\n num += n-1;\n if (customChange) node[num] = fun2(value, node[num]);\n else node[num] = value;\n while (num > 0) num = (num - 1) / 2, node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);\n }\n T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)\n if (r == -1) r = n;\n if (a <= l && r <= b) return node[k];\n if (b <= l || r <= a) return outValue;\n ll mid = (l + r) / 2;\n return fun(rangeQuery(a, b, l, mid, 2*k+1), rangeQuery(a, b, mid, r, 2*k+2));\n }\n};\n\ntemplate \nclass Graph {\n struct edge { ll to; T cost; };\n struct edge_data { ll from, to; T cost; };\n\n ll v;\n vector> e, re;\n vector ed;\n vector used;\n vector vs, cmp;\n bool isDirected, isMinasEdge;\npublic:\n Graph(ll _v, bool _isDirected = true, ll range_add = 0) {\n // range_add 0:no / 1:in / 2:out / 3:in+ut\n //_v++;\n v = _v, isDirected = _isDirected; isMinasEdge = false;\n e.resize(v), re.resize(v);\n }\n void add_edge(ll s, ll t, T cost = 1) {\n e[s].push_back((edge){t, cost});\n if (!isDirected) e[t].push_back((edge){s, cost});\n else re[t].push_back((edge){s, cost});\n ed.push_back((edge_data){s, t, cost});\n if (cost < 0) isMinasEdge = true;\n }\n vector dijkstra(ll s) {\n vector d(v, INF);\n d[s] = 0;\n auto edge_cmp = [](const edge& a, const edge& b) { return a.cost > b.cost; };\n priority_queue, decltype(edge_cmp)> pq(edge_cmp);\n pq.push((edge){s, 0});\n while (!pq.empty()) {\n edge temp = pq.top(); pq.pop();\n if (d[temp.to] < temp.cost) continue;\n for (const edge& next : e[temp.to]) {\n T cost = temp.cost + next.cost;\n if (d[next.to] > cost) {\n d[next.to] = cost;\n pq.push((edge){next.to, cost});\n }\n }\n }\n return d;\n }\n vector bellmanford(ll s) {\n vector d(v, INF);\n d[s] = 0;\n for (ll i = 0; i < v; i++) {\n for (const edge_data& temp : ed) {\n if (d[temp.from] != INF && d[temp.to] > d[temp.from] + temp.cost) d[temp.to] = d[temp.from] + temp.cost;\n if (!isDirected && d[temp.to] != INF && d[temp.from] > d[temp.to] + temp.cost) d[temp.from] = d[temp.to] + temp.cost;\n }\n }\n for (ll i = 0; i < v; i++) {\n for (const edge_data& temp : ed) {\n if (d[temp.from] != INF && d[temp.to] > d[temp.from] + temp.cost) d[temp.to] = -INF;\n if (!isDirected && d[temp.to] != INF && d[temp.from] > d[temp.to] + temp.cost) d[temp.from] = -INF;\n }\n }\n return d;\n }\n vector shortest_path(ll s) {\n if (isMinasEdge) return bellmanford(s);\n else return dijkstra(s);\n }\n T kruskal() {\n // if (isDirected)\n UnionFind uf(v);\n auto edge_data_cmp = [](const edge_data& a, const edge_data& b) { return a.cost < b.cost; };\n sort(ed.begin(), ed.end(), edge_data_cmp);\n T ans = 0;\n for (const edge_data& temp : ed) {\n if (uf.isSame(temp.from, temp.to)) continue;\n uf.merge(temp.from, temp.to);\n ans += temp.cost;\n }\n return ans;\n }\n void scc_dfs(ll s) {\n used[s] = true;\n for (const edge& i : e[s]) if (!used[i.to]) scc_dfs(i.to);\n vs.push_back(s);\n }\n void scc_rdfs(ll s, ll k) {\n used[s] = true;\n cmp[s] = k;\n for (const edge& i : re[s]) if (!used[i.to]) scc_rdfs(i.to, k);\n }\n vector scc() {\n used.resize(v);\n fill(used.begin(), used.end(), false);\n cmp.resize(v);\n vs.clear();\n for (ll i = 0; i < v; i++) if (!used[i]) scc_dfs(i);\n used.resize(v);\n fill(used.begin(), used.end(), false);\n ll k = 0;\n for (ll i = vs.size() - 1; i >= 0; i--) if (!used[vs[i]]) scc_rdfs(vs[i], k++);\n return cmp;\n }\n};\n\nclass RollingHash {\n int base;\n vector<__int128> hash;\n vector<__int128> pw;\n const __int128 hashmod = (1ull << 61) - 1;\npublic:\n RollingHash(string s, int base = 10007) : base(base), hash(s.length()+1, 0), pw(s.length()+1, 1) {\n for (int i = 0; i < (int)s.length(); i++) {\n hash[i+1] = (hash[i] * base + s[i]) % hashmod;\n pw[i+1] = pw[i] * base % hashmod;\n }\n }\n ll get(ll a, ll b) { // [a, b)\n __int128 tmp = hashmod + hash[b] - hash[a] * pw[b-a] % hashmod;\n if (tmp >= hashmod) tmp -= hashmod;\n return (ll)tmp;\n }\n};\n\nll n, x[15], y[15], p[15], ans[16], dir[15];\n\nvoid check() {\n vector vx, vy;\n vx.push_back(0);\n vy.push_back(0);\n ll counter = 0;\n for (ll i = 0; i < n; i++) {\n if (dir[i] == 1) vx.push_back(x[i]), counter++;\n if (dir[i] == 2) vy.push_back(y[i]), counter++;\n }\n ll tmp = 0;\n for (ll i = 0; i < n; i++) {\n ll mn = INF;\n for (ll j : vx) mn = min(mn, abs(x[i] - j));\n for (ll j : vy) mn = min(mn, abs(y[i] - j));\n tmp += mn * p[i];\n }\n ans[counter] = min(ans[counter], tmp);\n}\n\nint main() {\n scanf(\"%lld\", &n);\n for (ll i = 0; i < n; i++) scanf(\"%lld%lld%lld\", &x[i], &y[i], &p[i]);\n for (ll i = 0; i <= n; i++) ans[i] = INF;\n check();\n for (ll i = 0; i < 10000000; i++) {\n ll tmp = rand() % n;\n dir[tmp]++;\n if (dir[tmp] == 3) dir[tmp] = 0;\n check();\n }\n for (ll i = 1; i <= n; i++) ans[i] = min(ans[i], ans[i-1]);\n for (ll i = 0; i <= n; i++) printf(\"%lld\\n\", ans[i]);\n}\n", "language": "C++", "metadata": {"date": 1595731181, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02604/input.txt", "sample_output_relpath": "derived/input_output/data/p02604/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02604/C++/s983068999.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s983068999", "user_id": "u820262277"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "#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\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair P;\ntypedef pair Q;\ntypedef complex C;\n#define cx real()\n#define cy imag()\nconst ll INF = 1LL << 60;\nconst double DINF = 1e30;\nconst ll mod = 1000000007;\nconst ll dx[4] = {1, 0, -1, 0};\nconst ll dy[4] = {0, -1, 0, 1};\nconst C I = C(0, 1);\nconst double EPS = 1e-10;\nconst ll NCK_MAX = 510000;\n\nll gcd(ll a, ll b) {\n if (b == 0) return a;\n return gcd(b, a % b);\n}\n\nll extgcd(ll a, ll b, ll& x, ll& y) {\n if (b == 0) {\n x = 1, y = 0; return a;\n }\n ll q = a/b, g = extgcd(b, a - q*b, x, y);\n ll z = x - q * y;\n x = y;\n y = z;\n return g;\n}\n\nll invmod (ll a, ll m) { // a^-1 mod m\n ll x, y;\n extgcd(a, m, x, y);\n x %= m;\n if (x < 0) x += m;\n return x;\n}\n\nll *fac, *finv, *inv;\n\nvoid nCk_init(ll mod) {\n fac = new ll[NCK_MAX];\n finv = new ll[NCK_MAX];\n inv = new ll[NCK_MAX];\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (ll i = 2; i < NCK_MAX; 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 nCk(ll n, ll k, ll mod) {\n if (fac == NULL) nCk_init(mod);\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\ntemplate \nclass Zip {\n vector d;\n bool flag;\n void init() {\n sort(d.begin(), d.end());\n d.erase(unique(d.begin(), d.end()), d.end());\n flag = false;\n }\npublic:\n Zip() {\n flag = false;\n }\n void add(T x) {\n d.push_back(x);\n flag = true;\n }\n ll getNum(T x) {\n if (flag) init();\n return lower_bound(d.begin(), d.end(), x) - d.begin();\n }\n ll size() {\n if (flag) init();\n return (ll)d.size();\n }\n};\n\nclass UnionFind {\n vector par, rank; // par > 0: number, par < 0: -par\npublic:\n UnionFind(ll n) : par(n, 1), rank(n, 0) {}\n ll getSize(ll x) {\n return par[find(x)];\n }\n ll find(ll x) {\n if (par[x] > 0) return x;\n return -(par[x] = -find(-par[x]));\n }\n void merge(ll x, ll y) {\n x = find(x);\n y = find(y);\n if (x == y) return;\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = -y;\n } else {\n par[x] += par[y];\n par[y] = -x;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n bool isSame(ll x, ll y) {\n return find(x) == find(y);\n }\n};\n\n\ntemplate \nclass SegmentTree {\n ll n;\n vector node;\n function fun, fun2;\n bool customChange;\n T outValue, initValue;\npublic:\n void init(ll num, function resultFunction, T init, T out, function changeFunction = NULL) {\n // changeFunction: (input, beforevalue) => newvalue\n fun = resultFunction;\n fun2 = changeFunction;\n customChange = changeFunction != NULL;\n n = 1;\n while (n < num) n *= 2;\n node.resize(2 * n - 1);\n fill(node.begin(), node.end(), init);\n outValue = out;\n initValue = init;\n }\n void valueChange(ll num, T value) {\n num += n-1;\n if (customChange) node[num] = fun2(value, node[num]);\n else node[num] = value;\n while (num > 0) num = (num - 1) / 2, node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);\n }\n T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)\n if (r == -1) r = n;\n if (a <= l && r <= b) return node[k];\n if (b <= l || r <= a) return outValue;\n ll mid = (l + r) / 2;\n return fun(rangeQuery(a, b, l, mid, 2*k+1), rangeQuery(a, b, mid, r, 2*k+2));\n }\n};\n\ntemplate \nclass Graph {\n struct edge { ll to; T cost; };\n struct edge_data { ll from, to; T cost; };\n\n ll v;\n vector> e, re;\n vector ed;\n vector used;\n vector vs, cmp;\n bool isDirected, isMinasEdge;\npublic:\n Graph(ll _v, bool _isDirected = true, ll range_add = 0) {\n // range_add 0:no / 1:in / 2:out / 3:in+ut\n //_v++;\n v = _v, isDirected = _isDirected; isMinasEdge = false;\n e.resize(v), re.resize(v);\n }\n void add_edge(ll s, ll t, T cost = 1) {\n e[s].push_back((edge){t, cost});\n if (!isDirected) e[t].push_back((edge){s, cost});\n else re[t].push_back((edge){s, cost});\n ed.push_back((edge_data){s, t, cost});\n if (cost < 0) isMinasEdge = true;\n }\n vector dijkstra(ll s) {\n vector d(v, INF);\n d[s] = 0;\n auto edge_cmp = [](const edge& a, const edge& b) { return a.cost > b.cost; };\n priority_queue, decltype(edge_cmp)> pq(edge_cmp);\n pq.push((edge){s, 0});\n while (!pq.empty()) {\n edge temp = pq.top(); pq.pop();\n if (d[temp.to] < temp.cost) continue;\n for (const edge& next : e[temp.to]) {\n T cost = temp.cost + next.cost;\n if (d[next.to] > cost) {\n d[next.to] = cost;\n pq.push((edge){next.to, cost});\n }\n }\n }\n return d;\n }\n vector bellmanford(ll s) {\n vector d(v, INF);\n d[s] = 0;\n for (ll i = 0; i < v; i++) {\n for (const edge_data& temp : ed) {\n if (d[temp.from] != INF && d[temp.to] > d[temp.from] + temp.cost) d[temp.to] = d[temp.from] + temp.cost;\n if (!isDirected && d[temp.to] != INF && d[temp.from] > d[temp.to] + temp.cost) d[temp.from] = d[temp.to] + temp.cost;\n }\n }\n for (ll i = 0; i < v; i++) {\n for (const edge_data& temp : ed) {\n if (d[temp.from] != INF && d[temp.to] > d[temp.from] + temp.cost) d[temp.to] = -INF;\n if (!isDirected && d[temp.to] != INF && d[temp.from] > d[temp.to] + temp.cost) d[temp.from] = -INF;\n }\n }\n return d;\n }\n vector shortest_path(ll s) {\n if (isMinasEdge) return bellmanford(s);\n else return dijkstra(s);\n }\n T kruskal() {\n // if (isDirected)\n UnionFind uf(v);\n auto edge_data_cmp = [](const edge_data& a, const edge_data& b) { return a.cost < b.cost; };\n sort(ed.begin(), ed.end(), edge_data_cmp);\n T ans = 0;\n for (const edge_data& temp : ed) {\n if (uf.isSame(temp.from, temp.to)) continue;\n uf.merge(temp.from, temp.to);\n ans += temp.cost;\n }\n return ans;\n }\n void scc_dfs(ll s) {\n used[s] = true;\n for (const edge& i : e[s]) if (!used[i.to]) scc_dfs(i.to);\n vs.push_back(s);\n }\n void scc_rdfs(ll s, ll k) {\n used[s] = true;\n cmp[s] = k;\n for (const edge& i : re[s]) if (!used[i.to]) scc_rdfs(i.to, k);\n }\n vector scc() {\n used.resize(v);\n fill(used.begin(), used.end(), false);\n cmp.resize(v);\n vs.clear();\n for (ll i = 0; i < v; i++) if (!used[i]) scc_dfs(i);\n used.resize(v);\n fill(used.begin(), used.end(), false);\n ll k = 0;\n for (ll i = vs.size() - 1; i >= 0; i--) if (!used[vs[i]]) scc_rdfs(vs[i], k++);\n return cmp;\n }\n};\n\nclass RollingHash {\n int base;\n vector<__int128> hash;\n vector<__int128> pw;\n const __int128 hashmod = (1ull << 61) - 1;\npublic:\n RollingHash(string s, int base = 10007) : base(base), hash(s.length()+1, 0), pw(s.length()+1, 1) {\n for (int i = 0; i < (int)s.length(); i++) {\n hash[i+1] = (hash[i] * base + s[i]) % hashmod;\n pw[i+1] = pw[i] * base % hashmod;\n }\n }\n ll get(ll a, ll b) { // [a, b)\n __int128 tmp = hashmod + hash[b] - hash[a] * pw[b-a] % hashmod;\n if (tmp >= hashmod) tmp -= hashmod;\n return (ll)tmp;\n }\n};\n\nll n, x[15], y[15], p[15], ans[16], dir[15];\n\nvoid check() {\n vector vx, vy;\n vx.push_back(0);\n vy.push_back(0);\n ll counter = 0;\n for (ll i = 0; i < n; i++) {\n if (dir[i] == 1) vx.push_back(x[i]), counter++;\n if (dir[i] == 2) vy.push_back(y[i]), counter++;\n }\n ll tmp = 0;\n for (ll i = 0; i < n; i++) {\n ll mn = INF;\n for (ll j : vx) mn = min(mn, abs(x[i] - j));\n for (ll j : vy) mn = min(mn, abs(y[i] - j));\n tmp += mn * p[i];\n }\n ans[counter] = min(ans[counter], tmp);\n}\n\nint main() {\n scanf(\"%lld\", &n);\n for (ll i = 0; i < n; i++) scanf(\"%lld%lld%lld\", &x[i], &y[i], &p[i]);\n for (ll i = 0; i <= n; i++) ans[i] = INF;\n check();\n for (ll i = 0; i < 10000000; i++) {\n ll tmp = rand() % n;\n dir[tmp]++;\n if (dir[tmp] == 3) dir[tmp] = 0;\n check();\n }\n for (ll i = 1; i <= n; i++) ans[i] = min(ans[i], ans[i-1]);\n for (ll i = 0; i <= n; i++) printf(\"%lld\\n\", ans[i]);\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "sample_input": "3\n1 2 300\n3 3 600\n1 4 800\n"}, "reference_outputs": ["2900\n900\n0\n0\n"], "source_document_id": "p02604", "source_text": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8369, "cpu_time_ms": 3308, "memory_kb": 3772}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s425131249", "group_id": "codeNet:p02605", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define syosu(x) fixed< P;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef vector vl;\ntypedef vector vvl;\ntypedef vector vs;\ntypedef vector

vp;\ntypedef vector vvp;\ntypedef vector vpll;\ntypedef pair pip;\ntypedef vector vip;\nconst int inf=1<<28;\nconst ll INF=1ll<<60;\nconst double pi=acos(-1);\nconst double eps=1e-8;\nconst ll mod=998244353;\nconst int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};\n\nconst int M=500001;\nint n;\nvi x,y,a;\nmap mp={\n\t{'U',0},\n\t{'R',1},\n\t{'D',2},\n\t{'L',3},\n};\n\nint main(){\n\tcin>>n;\n\tint res=inf;\n\tx=y=a=vi(n);\n\tfor(int i=0;i>x[i]>>y[i]>>c;\n\t\ta[i]=mp[c];\n\t}\n\tvvp b(M);\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define syosu(x) fixed< P;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef vector vl;\ntypedef vector vvl;\ntypedef vector vs;\ntypedef vector

vp;\ntypedef vector vvp;\ntypedef vector vpll;\ntypedef pair pip;\ntypedef vector vip;\nconst int inf=1<<28;\nconst ll INF=1ll<<60;\nconst double pi=acos(-1);\nconst double eps=1e-8;\nconst ll mod=998244353;\nconst int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};\n\nconst int M=500001;\nint n;\nvi x,y,a;\nmap mp={\n\t{'U',0},\n\t{'R',1},\n\t{'D',2},\n\t{'L',3},\n};\n\nint main(){\n\tcin>>n;\n\tint res=inf;\n\tx=y=a=vi(n);\n\tfor(int i=0;i>x[i]>>y[i]>>c;\n\t\ta[i]=mp[c];\n\t}\n\tvvp b(M);\n\tfor(int i=0;i\nusing namespace std;\nint main(){\n int l,r,d,result=0;\n cin >> l >> r >> d;\n for(;l<=r;l++){\n if(l%d==0) result++;\n }\n cout << result << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1594526620, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02606.html", "problem_id": "p02606", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02606/input.txt", "sample_output_relpath": "derived/input_output/data/p02606/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02606/C++/s486612593.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s486612593", "user_id": "u091870478"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\nint main(){\n int l,r,d,result=0;\n cin >> l >> r >> d;\n for(;l<=r;l++){\n if(l%d==0) result++;\n }\n cout << result << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "sample_input": "5 10 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02606", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 7, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s891867279", "group_id": "codeNet:p02606", "input_text": "#include \n\n#ifdef NON_SUBMIT\n#define TEST(n) (n)\n#define tout cerr\n#else\n#define TEST(n) ((void)0)\n#define tout cin\n#endif\n\nusing namespace std;\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL); cout.tie(NULL);\n\tTEST(freopen(\"input.txt\",\"r\",stdin));\n\tTEST(freopen(\"output.txt\",\"w\",stdout));\n\tTEST(freopen(\"debug.txt\",\"w\",stderr));\n\tint L, R, D;\n\tcin>>L>>R>>D;\n\tcout<\n\n#ifdef NON_SUBMIT\n#define TEST(n) (n)\n#define tout cerr\n#else\n#define TEST(n) ((void)0)\n#define tout cin\n#endif\n\nusing namespace std;\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL); cout.tie(NULL);\n\tTEST(freopen(\"input.txt\",\"r\",stdin));\n\tTEST(freopen(\"output.txt\",\"w\",stdout));\n\tTEST(freopen(\"debug.txt\",\"w\",stderr));\n\tint L, R, D;\n\tcin>>L>>R>>D;\n\tcout<\n#define ll long long\n#define ld long double\n#define ull unsigned long long\n#define mp make_pair\n#define pb(x) push_back(x)\n#define vi vector\n#define vs vector\n#define vll vector\n#define vc vector\n#define vs vector\n#define pii pair\n#define pll pair\n#define pil pair\n#define pli pair\n#define pcc pair\n#define pdd pair\n#define mll map\n#define gcd __gcd\nusing namespace std;\nint main()\n{\n\tll n;\n\tll a[100];\n\tll ct=0;\n\tcin>>n;\n\tfor(ll i=0;i>a[i];\n\t}\n\tfor(ll i=0; i\n#define ll long long\n#define ld long double\n#define ull unsigned long long\n#define mp make_pair\n#define pb(x) push_back(x)\n#define vi vector\n#define vs vector\n#define vll vector\n#define vc vector\n#define vs vector\n#define pii pair\n#define pll pair\n#define pil pair\n#define pli pair\n#define pcc pair\n#define pdd pair\n#define mll map\n#define gcd __gcd\nusing namespace std;\nint main()\n{\n\tll n;\n\tll a[100];\n\tll ct=0;\n\tcin>>n;\n\tfor(ll i=0;i>a[i];\n\t}\n\tfor(ll i=0; i\nusing namespace std;\nint main()\n{\n int cnt = 0, val, n;\n cin >> n;\n for (int i = 1; i <= n; i++)\n {\n cin >> val;\n if ((i % 2) == 1 && (val % 2) == 1)\n cnt++;\n }\n cout << cnt << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1594516139, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/C++/s717178011.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s717178011", "user_id": "u124676202"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\nint main()\n{\n int cnt = 0, val, n;\n cin >> n;\n for (int i = 1; i <= n; i++)\n {\n cin >> val;\n if ((i % 2) == 1 && (val % 2) == 1)\n cnt++;\n }\n cout << cnt << endl;\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 7, "memory_kb": 3588}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s500254213", "group_id": "codeNet:p02607", "input_text": "#include \nusing namespace std;\n\nint main() {\n int N;\n cin >> N;\n int ans = 0;\n for (int i = 1; i <= N; i++) {\n int A;\n cin >> A;\n if (i % 2 == 1 && A % 2 == 1) ans++;\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1594515804, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/C++/s500254213.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s500254213", "user_id": "u658901072"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int N;\n cin >> N;\n int ans = 0;\n for (int i = 1; i <= N; i++) {\n int A;\n cin >> A;\n if (i % 2 == 1 && A % 2 == 1) ans++;\n }\n cout << ans << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 247, "cpu_time_ms": 7, "memory_kb": 3592}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s337381529", "group_id": "codeNet:p02608", "input_text": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n int arr[10001] = {0};\n int m = min(n,99);\n for(int i = 1 ; i <= m ; i++)\n {\n for(int j = 1 ; j <= m ;j++)\n {\n for(int z = 1 ; z <= m ;z++)\n {\n if(i*i+j*j+z*z+i*j+i*z+j*z <= 10000)\n arr[i*i+j*j+z*z+i*j+i*z+j*z]++;\n }\n }\n }\n for(int i = 1 ; i <= n ; i++)\n {\n cout<\n\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n int arr[10001] = {0};\n int m = min(n,99);\n for(int i = 1 ; i <= m ; i++)\n {\n for(int j = 1 ; j <= m ;j++)\n {\n for(int z = 1 ; z <= m ;z++)\n {\n if(i*i+j*j+z*z+i*j+i*z+j*z <= 10000)\n arr[i*i+j*j+z*z+i*j+i*z+j*z]++;\n }\n }\n }\n for(int i = 1 ; i <= n ; i++)\n {\n cout<\nusing namespace std;\n\nint func(int A){\n int count=0;\n for(int i=1;i<55;i++){\n for(int j=1;j<55;j++){\n for(int k=1;k<55;k++){\n int B=i*i+j*j+k*k+i*j+j*k+k*i;\n if(A==B){\n count++;\n }\n }\n }\n }\n return count;\n}\n \nint main(){\n int N;\n cin >> N;\n for(int i=0;i\nusing namespace std;\n\nint func(int A){\n int count=0;\n for(int i=1;i<55;i++){\n for(int j=1;j<55;j++){\n for(int k=1;k<55;k++){\n int B=i*i+j*j+k*k+i*j+j*k+k*i;\n if(A==B){\n count++;\n }\n }\n }\n }\n return count;\n}\n \nint main(){\n int N;\n cin >> N;\n for(int i=0;i\nusing namespace std;\nint main()\n{\n long long int n,m,i,j,k,l,p,b,t;\n cin>>n;\n t=0;\n for(i=1; i<=n; i++)\n {\n p = sqrt(i/2);\n t=0;\n for(j=1; j<=p; j++)\n {\n for(k=1; k<=p; k++)\n {\n for(l=1; l<=p; l++)\n {\n b = j*j+k*k+l*l+j*k+k*l+j*l;\n if(b==i)\n {\n t++;\n break;\n }\n }\n }\n }\n cout<\nusing namespace std;\nint main()\n{\n long long int n,m,i,j,k,l,p,b,t;\n cin>>n;\n t=0;\n for(i=1; i<=n; i++)\n {\n p = sqrt(i/2);\n t=0;\n for(j=1; j<=p; j++)\n {\n for(k=1; k<=p; k++)\n {\n for(l=1; l<=p; l++)\n {\n b = j*j+k*k+l*l+j*k+k*l+j*l;\n if(b==i)\n {\n t++;\n break;\n }\n }\n }\n }\n cout<\n#endif\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// C++\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#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#if __cplusplus >= 201103L\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#endif\n#pragma endregion\n\nusing namespace std;\n#pragma region Macros\n#define CHOOSE(a) CHOOSE2 a\n#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x\n#define debug_1(x1) cout << #x1 << \": \" << x1 << endl\n#define debug_2(x1, x2) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << endl\n#define debug_3(x1, x2, x3) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << endl\n#define debug_4(x1, x2, x3, x4) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << \", \" #x4 << \": \" << x4 << endl\n#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << \", \" #x4 << \": \" << x4 << \", \" #x5 << \": \" << x5 << endl\n#ifdef _DEBUG\n#define debug(...) \\\n CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \\\n (__VA_ARGS__)\n#else\n#define debug(...)\n#endif\n#pragma region end\n\n#pragma region Libraries\ntemplate \nstring to_string(T o)\n{\n stringstream s;\n s << o;\n return s.str();\n}\n\ntemplate \nstring to_string(vector v)\n{\n stringstream s;\n s << \"[\";\n for (auto i = 0; i < v.size(); i++)\n {\n s << to_string(v.at(i));\n if (i != v.size() - 1)\n {\n s << \", \";\n }\n }\n s << \"]\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const vector &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(vector> m)\n{\n stringstream s;\n s << \"[\" << endl;\n for (auto i = 0; i < m.size(); i++)\n {\n auto v = m[i];\n s << \" \"\n << \"#\" << i << \":\"\n << \" \" << to_string(v);\n s << \", \" << endl;\n }\n s << \"]\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const vector> &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(pair p)\n{\n stringstream s;\n s << \"pair(\" << to_string(p.first) << \", \" << to_string(p.second) << \")\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const pair &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(map m)\n{\n stringstream s;\n s << \"{\" << endl;\n for (const auto &p : m)\n {\n s << \" \" << to_string(p.first) << \": \" << to_string(p.second) << \",\" << endl;\n }\n s << \"}\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const map &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(set ss)\n{\n stringstream s;\n s << \"set\"\n << \"{\";\n for (auto itr = ss.begin(); itr != ss.end(); itr++)\n {\n s << to_string(*itr);\n if (next(itr, 1) != ss.end())\n {\n s << \", \";\n }\n }\n s << \"}\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const set &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(queue q)\n{\n auto temp = queue{};\n stringstream s;\n s << \"queue{\";\n while (!q.empty())\n {\n auto top = q.front();\n s << to_string(top) << \", \";\n q.pop();\n temp.push(top);\n }\n s << \"}\";\n\n while (!temp.empty())\n {\n auto top = temp.front();\n temp.pop();\n q.push(top);\n }\n\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const queue &obj)\n{\n o << to_string(obj);\n return o;\n}\n#pragma endregion\n\ntypedef long long ll;\n\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n std::cout << std::setprecision(20);\n\n ll n;\n cin >> n;\n map cnt;\n\n for (int x = 1; x <= 100; x++)\n {\n for (int y = 1; y <= 100; y++)\n {\n for (int z = 1; z <= 100; z++)\n {\n ll val = x * x + y * y + z * z + x * y + y * z + z * x;\n if (val >= 1 && val <= 10000)\n {\n cnt[val]++;\n }\n }\n }\n }\n\n for (auto i = 1; i <= n; i++)\n {\n cout << cnt[i] << endl;\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1594517436, "filename_ext": "cpp", "original_language": "C++ (Clang 10.0.0)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02608/input.txt", "sample_output_relpath": "derived/input_output/data/p02608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02608/C++/s554866027.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554866027", "user_id": "u734834944"}, "prompt_components": {"gold_output": "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n", "input_to_evaluate": "#pragma region Headers\n#ifndef _GLIBCXX_NO_ASSERT\n#include \n#endif\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// C++\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#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#if __cplusplus >= 201103L\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#endif\n#pragma endregion\n\nusing namespace std;\n#pragma region Macros\n#define CHOOSE(a) CHOOSE2 a\n#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x\n#define debug_1(x1) cout << #x1 << \": \" << x1 << endl\n#define debug_2(x1, x2) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << endl\n#define debug_3(x1, x2, x3) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << endl\n#define debug_4(x1, x2, x3, x4) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << \", \" #x4 << \": \" << x4 << endl\n#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << \": \" << x1 << \", \" #x2 << \": \" << x2 << \", \" #x3 << \": \" << x3 << \", \" #x4 << \": \" << x4 << \", \" #x5 << \": \" << x5 << endl\n#ifdef _DEBUG\n#define debug(...) \\\n CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \\\n (__VA_ARGS__)\n#else\n#define debug(...)\n#endif\n#pragma region end\n\n#pragma region Libraries\ntemplate \nstring to_string(T o)\n{\n stringstream s;\n s << o;\n return s.str();\n}\n\ntemplate \nstring to_string(vector v)\n{\n stringstream s;\n s << \"[\";\n for (auto i = 0; i < v.size(); i++)\n {\n s << to_string(v.at(i));\n if (i != v.size() - 1)\n {\n s << \", \";\n }\n }\n s << \"]\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const vector &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(vector> m)\n{\n stringstream s;\n s << \"[\" << endl;\n for (auto i = 0; i < m.size(); i++)\n {\n auto v = m[i];\n s << \" \"\n << \"#\" << i << \":\"\n << \" \" << to_string(v);\n s << \", \" << endl;\n }\n s << \"]\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const vector> &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(pair p)\n{\n stringstream s;\n s << \"pair(\" << to_string(p.first) << \", \" << to_string(p.second) << \")\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const pair &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(map m)\n{\n stringstream s;\n s << \"{\" << endl;\n for (const auto &p : m)\n {\n s << \" \" << to_string(p.first) << \": \" << to_string(p.second) << \",\" << endl;\n }\n s << \"}\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const map &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(set ss)\n{\n stringstream s;\n s << \"set\"\n << \"{\";\n for (auto itr = ss.begin(); itr != ss.end(); itr++)\n {\n s << to_string(*itr);\n if (next(itr, 1) != ss.end())\n {\n s << \", \";\n }\n }\n s << \"}\";\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const set &obj)\n{\n o << to_string(obj);\n return o;\n}\n\ntemplate \nstring to_string(queue q)\n{\n auto temp = queue{};\n stringstream s;\n s << \"queue{\";\n while (!q.empty())\n {\n auto top = q.front();\n s << to_string(top) << \", \";\n q.pop();\n temp.push(top);\n }\n s << \"}\";\n\n while (!temp.empty())\n {\n auto top = temp.front();\n temp.pop();\n q.push(top);\n }\n\n return s.str();\n}\n\ntemplate \nostream &operator<<(ostream &o, const queue &obj)\n{\n o << to_string(obj);\n return o;\n}\n#pragma endregion\n\ntypedef long long ll;\n\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n std::cout << std::setprecision(20);\n\n ll n;\n cin >> n;\n map cnt;\n\n for (int x = 1; x <= 100; x++)\n {\n for (int y = 1; y <= 100; y++)\n {\n for (int z = 1; z <= 100; z++)\n {\n ll val = x * x + y * y + z * z + x * y + y * z + z * x;\n if (val >= 1 && val <= 10000)\n {\n cnt[val]++;\n }\n }\n }\n }\n\n for (auto i = 1; i <= n; i++)\n {\n cout << cnt[i] << endl;\n }\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5391, "cpu_time_ms": 58, "memory_kb": 3764}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s115318534", "group_id": "codeNet:p02609", "input_text": "#include \"bits/stdc++.h\"\n\n#define MOD 1000000007\n#define rep(i, n) for(ll i=0; i < (n); i++)\n#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)\n#define ALL(v) v.begin(),v.end()\n#define rALL(v) v.rbegin(),v.rend()\n#define FOR(i, j, k) for(ll i=j;i llvec;\ntypedef vector dvec;\ntypedef pair P;\ntypedef long double ld;\nstruct edge{ll x, c;};\n\nll mod(ll a, ll mod){\n ll res = a%mod;\n while(res<0){\n res=res + mod;\n }\n return res;\n}\n\nll modpow(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 modinv(ll a, ll mod){\n return modpow(a, mod-2, mod);\n}\n\nll gcd(ll a, ll b){\n ll r = a%b;\n if(r==0) return b;\n else return gcd(b, a%b);\n}\n\nbool is_prime(ll n){\n ll i = 2;\n if(n==1)return false;\n if(n==2)return true;\n bool res = true;\n while(i*i bt.first){\n swap(at, bt);\n swap(a, b);\n }\n p[at.second] = bt.second;\n cnt[bt.second]+=cnt[at.second];\n p[a]=bt.second;\n }\n }\n\n P root(ll a){\n ll atmp = a;\n ll c=0;\n while(atmp!=p[atmp]){\n atmp = p[atmp];\n c++;\n }\n p[a] = atmp;\n return {c, atmp};\n }\n\n bool is_con(ll a, ll b){\n P at=root(a);\n P bt=root(b);\n return at.second == bt.second;\n }\n \n};\n\nstruct dijkstra{\n ll N;\n llvec d;\n vector> e;\n dijkstra(ll n){\n N = n;\n //d = llvec(N, 1e18);\n e = vector>(N);\n }\n\n void add_edge(ll from, ll to, ll cost){\n e[from].push_back({to, cost});\n }\n\n void run(ll start){\n priority_queue, greater

> que;\n que.push({0, start});\n d = llvec(N, 1e18);\n d[start]=0;\n while(!que.empty()){\n P q = que.top();que.pop();\n ll dc = q.first;\n ll x = q.second;\n if(dc>d[x]){\n continue;\n }else{\n for(auto ip: e[x]){\n if(d[ip.x]<=d[x]+ip.c){\n continue;\n }else{\n d[ip.x]= d[x]+ip.c;\n que.push({d[ip.x], ip.x});\n }\n }\n }\n }\n } \n};\n\nll dp[5000000];\nll func2(ll n, ll s){\n if(n==0)return s;\n ll cnt = 0;\n rep(i, 20){\n if(n>>i&1)cnt++;\n }\n ll ans = 0;\n rep(i, 20){\n if(n>>i&1){\n ans = mod(ans + modpow(2, i, cnt), cnt);\n }\n }\n return func2(ans, s+1);\n}\n\n\n/**************************************\n** A main function starts from here **\n***************************************/\nint main(){\n ll N;\n cin >> N;\n string X;\n cin >> X;\n ll cnt=0;\n rep(i, N){\n if(X[i]=='1')cnt++;\n }\n ll cnt_m1=0;\n ll cnt_p1=0;\n rep(i, N){\n if(X[i]=='1'){\n if(cnt>0)cnt_m1 = mod(cnt_m1+modpow(2, N-i-1, cnt-1), cnt-1);\n cnt_p1 = mod(cnt_p1+modpow(2, N-i-1, cnt+1), cnt+1);\n }\n }\n /*\n rep(i, N+1){\n dp[i] = func2(i, 0);\n }\n */\n rep(i, N){\n if(X[i]=='0'){\n ll tmp = mod(cnt_p1+modpow(2, N-i-1, cnt+1), cnt+1);\n cout << func2(tmp, 1)<=0; i--)\n#define ALL(v) v.begin(),v.end()\n#define rALL(v) v.rbegin(),v.rend()\n#define FOR(i, j, k) for(ll i=j;i llvec;\ntypedef vector dvec;\ntypedef pair P;\ntypedef long double ld;\nstruct edge{ll x, c;};\n\nll mod(ll a, ll mod){\n ll res = a%mod;\n while(res<0){\n res=res + mod;\n }\n return res;\n}\n\nll modpow(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 modinv(ll a, ll mod){\n return modpow(a, mod-2, mod);\n}\n\nll gcd(ll a, ll b){\n ll r = a%b;\n if(r==0) return b;\n else return gcd(b, a%b);\n}\n\nbool is_prime(ll n){\n ll i = 2;\n if(n==1)return false;\n if(n==2)return true;\n bool res = true;\n while(i*i bt.first){\n swap(at, bt);\n swap(a, b);\n }\n p[at.second] = bt.second;\n cnt[bt.second]+=cnt[at.second];\n p[a]=bt.second;\n }\n }\n\n P root(ll a){\n ll atmp = a;\n ll c=0;\n while(atmp!=p[atmp]){\n atmp = p[atmp];\n c++;\n }\n p[a] = atmp;\n return {c, atmp};\n }\n\n bool is_con(ll a, ll b){\n P at=root(a);\n P bt=root(b);\n return at.second == bt.second;\n }\n \n};\n\nstruct dijkstra{\n ll N;\n llvec d;\n vector> e;\n dijkstra(ll n){\n N = n;\n //d = llvec(N, 1e18);\n e = vector>(N);\n }\n\n void add_edge(ll from, ll to, ll cost){\n e[from].push_back({to, cost});\n }\n\n void run(ll start){\n priority_queue, greater

> que;\n que.push({0, start});\n d = llvec(N, 1e18);\n d[start]=0;\n while(!que.empty()){\n P q = que.top();que.pop();\n ll dc = q.first;\n ll x = q.second;\n if(dc>d[x]){\n continue;\n }else{\n for(auto ip: e[x]){\n if(d[ip.x]<=d[x]+ip.c){\n continue;\n }else{\n d[ip.x]= d[x]+ip.c;\n que.push({d[ip.x], ip.x});\n }\n }\n }\n }\n } \n};\n\nll dp[5000000];\nll func2(ll n, ll s){\n if(n==0)return s;\n ll cnt = 0;\n rep(i, 20){\n if(n>>i&1)cnt++;\n }\n ll ans = 0;\n rep(i, 20){\n if(n>>i&1){\n ans = mod(ans + modpow(2, i, cnt), cnt);\n }\n }\n return func2(ans, s+1);\n}\n\n\n/**************************************\n** A main function starts from here **\n***************************************/\nint main(){\n ll N;\n cin >> N;\n string X;\n cin >> X;\n ll cnt=0;\n rep(i, N){\n if(X[i]=='1')cnt++;\n }\n ll cnt_m1=0;\n ll cnt_p1=0;\n rep(i, N){\n if(X[i]=='1'){\n if(cnt>0)cnt_m1 = mod(cnt_m1+modpow(2, N-i-1, cnt-1), cnt-1);\n cnt_p1 = mod(cnt_p1+modpow(2, N-i-1, cnt+1), cnt+1);\n }\n }\n /*\n rep(i, N+1){\n dp[i] = func2(i, 0);\n }\n */\n rep(i, N){\n if(X[i]=='0'){\n ll tmp = mod(cnt_p1+modpow(2, N-i-1, cnt+1), cnt+1);\n cout << func2(tmp, 1)<\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 int ll;\nusing ull = unsigned long long;\n\nll solve(vector> v){\n int n=v.size();\n for(int i=0;i> s(n+1);\n for(int i=0;i q;\n for(int i=n;i>=1;i--){\n for(int x:s[i]){q.push(x);}\n if(q.size()){\n res+=q.top();\n q.pop();\n }\n }\n return res;\n}\n\nint main(){\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n int q; cin >> q;\n while(q--){\n int n; cin >> n;\n vector> pl,pr;\n ll res=0;\n for(int i=0;i> k >> l >> r;\n int m=min(l,r);\n res+=m;\n l-=m,r-=m;\n if(l>0)pl.push_back({k,l});\n else pr.push_back({n-k,r});\n }\n res+=solve(pl);\n res+=solve(pr);\n printf(\"%lld\\n\",res );\n }\n}", "language": "C++", "metadata": {"date": 1594755900, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02610.html", "problem_id": "p02610", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02610/input.txt", "sample_output_relpath": "derived/input_output/data/p02610/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02610/C++/s913567047.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s913567047", "user_id": "u928536113"}, "prompt_components": {"gold_output": "25\n221\n1354\n", "input_to_evaluate": "#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 int ll;\nusing ull = unsigned long long;\n\nll solve(vector> v){\n int n=v.size();\n for(int i=0;i> s(n+1);\n for(int i=0;i q;\n for(int i=n;i>=1;i--){\n for(int x:s[i]){q.push(x);}\n if(q.size()){\n res+=q.top();\n q.pop();\n }\n }\n return res;\n}\n\nint main(){\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n int q; cin >> q;\n while(q--){\n int n; cin >> n;\n vector> pl,pr;\n ll res=0;\n for(int i=0;i> k >> l >> r;\n int m=min(l,r);\n res+=m;\n l-=m,r-=m;\n if(l>0)pl.push_back({k,l});\n else pr.push_back({n-k,r});\n }\n res+=solve(pl);\n res+=solve(pr);\n printf(\"%lld\\n\",res );\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N camels numbered 1,2,\\ldots,N.\nSnuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel.\n\nSolve this problem for each of the T test cases given.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 10^5\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq K_i \\leq N\n\n1 \\leq L_i, R_i \\leq 10^9\n\nThe sum of values of N in each input file is at most 2 \\times 10^5.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\\mathrm{case}_1\n\\vdots\n\\mathrm{case}_T\n\nEach case is given in the following format:\n\nN\nK_1 L_1 R_1\n\\vdots\nK_N L_N R_N\n\nOutput\n\nPrint T lines. The i-th line should contain the answer to the i-th test case.\n\nSample Input 1\n\n3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n\nSample Output 1\n\n25\n221\n1354\n\nIn the first test case, it is optimal to line up the camels in the order 2, 1.\n\nCamel 1 is not the frontmost camel, so its happiness will be 10.\n\nCamel 2 is among the two frontmost camels, so its happiness will be 15.\n\nIn the second test case, it is optimal to line up the camels in the order 2, 1, 3.\n\nCamel 1 is among the two frontmost camels, so its happiness will be 93.\n\nCamel 2 is the frontmost camel, so its happiness will be 71.\n\nCamel 3 is among the three frontmost camels, so its happiness will be 57.", "sample_input": "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n"}, "reference_outputs": ["25\n221\n1354\n"], "source_document_id": "p02610", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N camels numbered 1,2,\\ldots,N.\nSnuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel.\n\nSolve this problem for each of the T test cases given.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 10^5\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq K_i \\leq N\n\n1 \\leq L_i, R_i \\leq 10^9\n\nThe sum of values of N in each input file is at most 2 \\times 10^5.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\\mathrm{case}_1\n\\vdots\n\\mathrm{case}_T\n\nEach case is given in the following format:\n\nN\nK_1 L_1 R_1\n\\vdots\nK_N L_N R_N\n\nOutput\n\nPrint T lines. The i-th line should contain the answer to the i-th test case.\n\nSample Input 1\n\n3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n\nSample Output 1\n\n25\n221\n1354\n\nIn the first test case, it is optimal to line up the camels in the order 2, 1.\n\nCamel 1 is not the frontmost camel, so its happiness will be 10.\n\nCamel 2 is among the two frontmost camels, so its happiness will be 15.\n\nIn the second test case, it is optimal to line up the camels in the order 2, 1, 3.\n\nCamel 1 is among the two frontmost camels, so its happiness will be 93.\n\nCamel 2 is the frontmost camel, so its happiness will be 71.\n\nCamel 3 is among the three frontmost camels, so its happiness will be 57.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1242, "cpu_time_ms": 84, "memory_kb": 11108}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s277819194", "group_id": "codeNet:p02610", "input_text": "#include \nusing namespace std;\n#define m_p make_pair\n#define all(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define fi first\n#define se second\ntypedef long long ll;\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\nmt19937 rnf(2106);\nconst int N = 200005;\nstruct ban\n{\n int k, l, r;\n};\nbool operator<(const ban& a, const ban& b)\n{\n return abs(a.l - a.r) < abs(b.l - b.r);\n}\n\nint n;\nban a[N];\n\nvoid ubd(int tl, int tr, int x, int y, int pos, vector& s, vector& p)\n{\n if (tl == tr)\n {\n s[pos] += y;\n p[pos] = min(p[pos], 0);\n return;\n }\n int m = (tl + tr) / 2;\n if (x <= m)\n ubd(tl, m, x, y, pos * 2, s, p);\n else\n ubd(m + 1, tr, x, y, pos * 2 + 1, s, p);\n s[pos] = s[pos * 2] + s[pos * 2 + 1];\n p[pos] = min(p[pos * 2], s[pos * 2] + p[pos * 2 + 1]);\n}\n\nvoid solv()\n{\n scanf(\"%d\", &n);\n for (int i = 1; i <= n; ++i)\n scanf(\"%d%d%d\", &a[i].k, &a[i].l, &a[i].r);\n sort(a + 1, a + n + 1);\n reverse(a + 1, a + n + 1);\n\n vector sl, pl, sr, pr;\n sl.assign(n * 4 + 5, 0);\n pl.assign(n * 4 + 5, 0);\n sr.assign(n * 4 + 5, 0);\n pr.assign(n * 4 + 5, 0);\n\n for (int i = 1; i <= n; ++i)\n {\n ubd(1, n, i, 1, 1, sl, pl);\n ubd(1, n, i, 1, 1, sr, pr);\n }\n\n ll ans = 0;\n for (int i = 1; i <= n; ++i)\n {\n if (a[i].l > a[i].r)\n {\n ubd(1, n, a[i].k, -1, 1, sl, pl);\n if (pl[1] < 0)\n {\n ubd(1, n, a[i].k, 1, 1, sl, pl);\n ans += a[i].r;\n }\n else\n ans += a[i].l;\n }\n else\n {\n if (n - a[i].k == 0)\n {\n ans += a[i].l;\n continue;\n }\n ubd(1, n, n - a[i].k, -1, 1, sr, pr);\n if (pr[1] < 0)\n {\n ubd(1, n, n - a[i].k, 1, 1, sr, pr);\n ans += a[i].l;\n }\n else\n ans += a[i].r;\n }\n //ubd(1, n, n, -2, 1, sl, pl);\n //ubd(1, n, 1, -2, 1, sr, pr);\n }\n printf(\"%lld\\n\", ans);\n}\n\nint main()\n{\n #ifdef SOMETHING\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n #endif // SOMETHING\n int tt;\n scanf(\"%d\", &tt);\n while (tt--)\n solv();\n return 0;\n}\n\n//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}\n", "language": "C++", "metadata": {"date": 1594520004, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02610.html", "problem_id": "p02610", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02610/input.txt", "sample_output_relpath": "derived/input_output/data/p02610/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02610/C++/s277819194.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277819194", "user_id": "u742977643"}, "prompt_components": {"gold_output": "25\n221\n1354\n", "input_to_evaluate": "#include \nusing namespace std;\n#define m_p make_pair\n#define all(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define fi first\n#define se second\ntypedef long long ll;\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\nmt19937 rnf(2106);\nconst int N = 200005;\nstruct ban\n{\n int k, l, r;\n};\nbool operator<(const ban& a, const ban& b)\n{\n return abs(a.l - a.r) < abs(b.l - b.r);\n}\n\nint n;\nban a[N];\n\nvoid ubd(int tl, int tr, int x, int y, int pos, vector& s, vector& p)\n{\n if (tl == tr)\n {\n s[pos] += y;\n p[pos] = min(p[pos], 0);\n return;\n }\n int m = (tl + tr) / 2;\n if (x <= m)\n ubd(tl, m, x, y, pos * 2, s, p);\n else\n ubd(m + 1, tr, x, y, pos * 2 + 1, s, p);\n s[pos] = s[pos * 2] + s[pos * 2 + 1];\n p[pos] = min(p[pos * 2], s[pos * 2] + p[pos * 2 + 1]);\n}\n\nvoid solv()\n{\n scanf(\"%d\", &n);\n for (int i = 1; i <= n; ++i)\n scanf(\"%d%d%d\", &a[i].k, &a[i].l, &a[i].r);\n sort(a + 1, a + n + 1);\n reverse(a + 1, a + n + 1);\n\n vector sl, pl, sr, pr;\n sl.assign(n * 4 + 5, 0);\n pl.assign(n * 4 + 5, 0);\n sr.assign(n * 4 + 5, 0);\n pr.assign(n * 4 + 5, 0);\n\n for (int i = 1; i <= n; ++i)\n {\n ubd(1, n, i, 1, 1, sl, pl);\n ubd(1, n, i, 1, 1, sr, pr);\n }\n\n ll ans = 0;\n for (int i = 1; i <= n; ++i)\n {\n if (a[i].l > a[i].r)\n {\n ubd(1, n, a[i].k, -1, 1, sl, pl);\n if (pl[1] < 0)\n {\n ubd(1, n, a[i].k, 1, 1, sl, pl);\n ans += a[i].r;\n }\n else\n ans += a[i].l;\n }\n else\n {\n if (n - a[i].k == 0)\n {\n ans += a[i].l;\n continue;\n }\n ubd(1, n, n - a[i].k, -1, 1, sr, pr);\n if (pr[1] < 0)\n {\n ubd(1, n, n - a[i].k, 1, 1, sr, pr);\n ans += a[i].l;\n }\n else\n ans += a[i].r;\n }\n //ubd(1, n, n, -2, 1, sl, pl);\n //ubd(1, n, 1, -2, 1, sr, pr);\n }\n printf(\"%lld\\n\", ans);\n}\n\nint main()\n{\n #ifdef SOMETHING\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n #endif // SOMETHING\n int tt;\n scanf(\"%d\", &tt);\n while (tt--)\n solv();\n return 0;\n}\n\n//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N camels numbered 1,2,\\ldots,N.\nSnuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel.\n\nSolve this problem for each of the T test cases given.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 10^5\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq K_i \\leq N\n\n1 \\leq L_i, R_i \\leq 10^9\n\nThe sum of values of N in each input file is at most 2 \\times 10^5.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\\mathrm{case}_1\n\\vdots\n\\mathrm{case}_T\n\nEach case is given in the following format:\n\nN\nK_1 L_1 R_1\n\\vdots\nK_N L_N R_N\n\nOutput\n\nPrint T lines. The i-th line should contain the answer to the i-th test case.\n\nSample Input 1\n\n3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n\nSample Output 1\n\n25\n221\n1354\n\nIn the first test case, it is optimal to line up the camels in the order 2, 1.\n\nCamel 1 is not the frontmost camel, so its happiness will be 10.\n\nCamel 2 is among the two frontmost camels, so its happiness will be 15.\n\nIn the second test case, it is optimal to line up the camels in the order 2, 1, 3.\n\nCamel 1 is among the two frontmost camels, so its happiness will be 93.\n\nCamel 2 is the frontmost camel, so its happiness will be 71.\n\nCamel 3 is among the three frontmost camels, so its happiness will be 57.", "sample_input": "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n"}, "reference_outputs": ["25\n221\n1354\n"], "source_document_id": "p02610", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N camels numbered 1,2,\\ldots,N.\nSnuke has decided to make them line up in a row.\n\nThe happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.\n\nSnuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel.\n\nSolve this problem for each of the T test cases given.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq T \\leq 10^5\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n1 \\leq K_i \\leq N\n\n1 \\leq L_i, R_i \\leq 10^9\n\nThe sum of values of N in each input file is at most 2 \\times 10^5.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\\mathrm{case}_1\n\\vdots\n\\mathrm{case}_T\n\nEach case is given in the following format:\n\nN\nK_1 L_1 R_1\n\\vdots\nK_N L_N R_N\n\nOutput\n\nPrint T lines. The i-th line should contain the answer to the i-th test case.\n\nSample Input 1\n\n3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34\n\nSample Output 1\n\n25\n221\n1354\n\nIn the first test case, it is optimal to line up the camels in the order 2, 1.\n\nCamel 1 is not the frontmost camel, so its happiness will be 10.\n\nCamel 2 is among the two frontmost camels, so its happiness will be 15.\n\nIn the second test case, it is optimal to line up the camels in the order 2, 1, 3.\n\nCamel 1 is among the two frontmost camels, so its happiness will be 93.\n\nCamel 2 is the frontmost camel, so its happiness will be 71.\n\nCamel 3 is among the three frontmost camels, so its happiness will be 57.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2431, "cpu_time_ms": 185, "memory_kb": 18004}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s538790818", "group_id": "codeNet:p02613", "input_text": "#include \n#define rep(i,n) for (int i=0; i< int (n); i++)\nusing namespace std;\ntypedef long long ll;\n\nint main(){\n\nint n;\ncin >> n;\nvector s(100010);\nint a=0, w=0, t=0, r=0;\nrep(i,n) {\n cin >> s[i];\n if(s[i]==\"AC\") a++;\n if(s[i]==\"WA\") w++;\n if(s[i]==\"TLE\") t++;\n if(s[i]==\"RE\") r++;\n}\ncout << \"AC x \" << a << endl;\ncout << \"WA x \" << w << endl;\ncout << \"TLE x \" << t << endl;\ncout << \"RE x \" << r << endl;\n\n}", "language": "C++", "metadata": {"date": 1593997690, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02613/input.txt", "sample_output_relpath": "derived/input_output/data/p02613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02613/C++/s538790818.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538790818", "user_id": "u778605027"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "#include \n#define rep(i,n) for (int i=0; i< int (n); i++)\nusing namespace std;\ntypedef long long ll;\n\nint main(){\n\nint n;\ncin >> n;\nvector s(100010);\nint a=0, w=0, t=0, r=0;\nrep(i,n) {\n cin >> s[i];\n if(s[i]==\"AC\") a++;\n if(s[i]==\"WA\") w++;\n if(s[i]==\"TLE\") t++;\n if(s[i]==\"RE\") r++;\n}\ncout << \"AC x \" << a << endl;\ncout << \"WA x \" << w << endl;\ncout << \"TLE x \" << t << endl;\ncout << \"RE x \" << r << endl;\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 33, "memory_kb": 6424}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s963844331", "group_id": "codeNet:p02614", "input_text": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nint H,W,K;\n\nint main(){\n cin >> H >> W >> K;\n vector > c(H,vector(W));\n int all =0;\n for(int i=0;i> a;\n if(a=='#') {\n\tall++;\n\tc[i][j]=1;\n }\n else c[i][j]=0;\n }\n }\n int ans =0;\n for(int bith = 0;bith<(1<\n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nint H,W,K;\n\nint main(){\n cin >> H >> W >> K;\n vector > c(H,vector(W));\n int all =0;\n for(int i=0;i> a;\n if(a=='#') {\n\tall++;\n\tc[i][j]=1;\n }\n else c[i][j]=0;\n }\n }\n int ans =0;\n for(int bith = 0;bith<(1<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing pll = pair ;\nusing vs = vector;\nusing vb = vector;\nusing vll = vector;\nusing vvll = vector>;\n#define PI 3.1415926535\n#define rep(i, k, n) for(ll i = k; i < n; i++)\n\nint main(){\n ll h, w, k;\n cin >> h >> w >> k;\n \n vector> block(h,vector(w));\n \n rep(i, 0, h){\n rep(j, 0, w){\n cin >> block[i][j];\n }\n }\n \n ll ans = 0;\n for(ll bit = 0; bit < (1<<(h+w)); bit ++){\n \n vector> painted(h,vector(w));\n rep(i, 0, h){\n rep(j, 0, w){\n painted[i][j] = block[i][j];\n }\n }\n \n rep(i, 0, h+w){\n if(bit & (1 << i)){\n if(i < h){\n rep(j, 0, w){painted[i][j] = 'R';}\n }\n else{\n rep(j, 0, h){painted[j][i-h] = 'R';}\n }\n }\n }\n\t\n ll cnt = 0;\n rep(i, 0, h){\n rep(j, 0, w){\n if(painted[i][j] == '#'){cnt++;}\n }\n }\n \n if(cnt == k){ans++;}\n }\n \n cout << ans << endl;\n \n}\n\n\n\n\n", "language": "C++", "metadata": {"date": 1595960473, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/C++/s923763823.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923763823", "user_id": "u108843155"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing pll = pair ;\nusing vs = vector;\nusing vb = vector;\nusing vll = vector;\nusing vvll = vector>;\n#define PI 3.1415926535\n#define rep(i, k, n) for(ll i = k; i < n; i++)\n\nint main(){\n ll h, w, k;\n cin >> h >> w >> k;\n \n vector> block(h,vector(w));\n \n rep(i, 0, h){\n rep(j, 0, w){\n cin >> block[i][j];\n }\n }\n \n ll ans = 0;\n for(ll bit = 0; bit < (1<<(h+w)); bit ++){\n \n vector> painted(h,vector(w));\n rep(i, 0, h){\n rep(j, 0, w){\n painted[i][j] = block[i][j];\n }\n }\n \n rep(i, 0, h+w){\n if(bit & (1 << i)){\n if(i < h){\n rep(j, 0, w){painted[i][j] = 'R';}\n }\n else{\n rep(j, 0, h){painted[j][i-h] = 'R';}\n }\n }\n }\n\t\n ll cnt = 0;\n rep(i, 0, h){\n rep(j, 0, w){\n if(painted[i][j] == '#'){cnt++;}\n }\n }\n \n if(cnt == k){ans++;}\n }\n \n cout << ans << endl;\n \n}\n\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1187, "cpu_time_ms": 8, "memory_kb": 3640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s073989855", "group_id": "codeNet:p02614", "input_text": "#include\n// #define int long long\n#define rep(i, n) for(int i = 0; i < (int)n; i++)\n#define repa(i, s, n) for(int i = s; i < (int)n; i++)\nusing namespace std;\nusing ll = long long;\ntypedef vector vi;\n\nsigned main() {\n int h, w, k;\n cin >> h >> w >> k;\n vector s(h);\n int ans = 0;\n rep(i, h) cin >> s[i];\n\n rep(is, 1<>i & 1) continue;\n if(js>>i & 1) continue;\n if(s[i][j] == '#') cnt++;\n }\n if(cnt == k) ans++;\n }\n\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1594080398, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/C++/s073989855.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s073989855", "user_id": "u510749912"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include\n// #define int long long\n#define rep(i, n) for(int i = 0; i < (int)n; i++)\n#define repa(i, s, n) for(int i = s; i < (int)n; i++)\nusing namespace std;\nusing ll = long long;\ntypedef vector vi;\n\nsigned main() {\n int h, w, k;\n cin >> h >> w >> k;\n vector s(h);\n int ans = 0;\n rep(i, h) cin >> s[i];\n\n rep(is, 1<>i & 1) continue;\n if(js>>i & 1) continue;\n if(s[i][j] == '#') cnt++;\n }\n if(cnt == k) ans++;\n }\n\n cout << ans << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 7, "memory_kb": 3552}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s807447364", "group_id": "codeNet:p02614", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i,n) for(int i=0;i<(int)(n);i++)\nconst double PI=3.1415926535897932;\nusing namespace std;\ntypedef long long ll;\n\nint main(void){\n ll h,w,q;\n cin>>h>>w>>q;\n int a[h][w];\n rep(i,h){\n rep(j,w){\n char c;\n cin>>c;\n if(c=='.')a[i][j]=1;\n else a[i][j]=0;\n }\n }\n int ans=0;\n for(int bit=0;bit<(1<ex;\n for(int i=0;i ew;\n for(int j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i,n) for(int i=0;i<(int)(n);i++)\nconst double PI=3.1415926535897932;\nusing namespace std;\ntypedef long long ll;\n\nint main(void){\n ll h,w,q;\n cin>>h>>w>>q;\n int a[h][w];\n rep(i,h){\n rep(j,w){\n char c;\n cin>>c;\n if(c=='.')a[i][j]=1;\n else a[i][j]=0;\n }\n }\n int ans=0;\n for(int bit=0;bit<(1<ex;\n for(int i=0;i ew;\n for(int j=0;j\n#define pb push_back\n#define mp make_pair\n#define forn(i,a,b) for(int i =a;i\ntypename enable_if::value, Ostream&>::type operator<<(Ostream& os, const Cont& v){\n\tos<<\"[\";\n\tfor(auto& x:v){os<\nOstream& operator<<(Ostream& os, const pair& p){\n\treturn os<<\"{\"< vi;\ntypedef pair pii;\ntypedef pair pll;\n\n\nvoid solve(){\n\tint n;\n\tcin >> n;\n\tll a[n];\n\tforn(i,0,n) cin >> a[i];\n\tsort(a,a+n);\n\treverse(a,a+n);\n\tlong long int ans = 0;\n\tans+=a[0];\n\tfor(int i=0;i<((n-1)/2 - 1);i++){\n\t\tans+=(2*a[i+1]);\n\t\t// cout << ans << endl;\n\t}\n\tif(n%2){\n\t\tans+=a[(n-1)/2];\n\t}\n\telse{\n\t\tans+=2*a[(n-1)/2];\n\t}\n\tcout << ans << endl;\n}\n\nint main(){\n\tfast;\n\t#ifndef ONLINE_JUDGE\n\t\tfreopen(\"input.txt\",\"r\",stdin);\n\t\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\n\t// int t;cin >> t;while(t--)\n\t\tsolve();\n}\n", "language": "C++", "metadata": {"date": 1593999954, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02615/input.txt", "sample_output_relpath": "derived/input_output/data/p02615/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02615/C++/s632810778.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632810778", "user_id": "u768225950"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include\n#define pb push_back\n#define mp make_pair\n#define forn(i,a,b) for(int i =a;i\ntypename enable_if::value, Ostream&>::type operator<<(Ostream& os, const Cont& v){\n\tos<<\"[\";\n\tfor(auto& x:v){os<\nOstream& operator<<(Ostream& os, const pair& p){\n\treturn os<<\"{\"< vi;\ntypedef pair pii;\ntypedef pair pll;\n\n\nvoid solve(){\n\tint n;\n\tcin >> n;\n\tll a[n];\n\tforn(i,0,n) cin >> a[i];\n\tsort(a,a+n);\n\treverse(a,a+n);\n\tlong long int ans = 0;\n\tans+=a[0];\n\tfor(int i=0;i<((n-1)/2 - 1);i++){\n\t\tans+=(2*a[i+1]);\n\t\t// cout << ans << endl;\n\t}\n\tif(n%2){\n\t\tans+=a[(n-1)/2];\n\t}\n\telse{\n\t\tans+=2*a[(n-1)/2];\n\t}\n\tcout << ans << endl;\n}\n\nint main(){\n\tfast;\n\t#ifndef ONLINE_JUDGE\n\t\tfreopen(\"input.txt\",\"r\",stdin);\n\t\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\n\t// int t;cin >> t;while(t--)\n\t\tsolve();\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "sample_input": "4\n2 2 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02615", "source_text": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1470, "cpu_time_ms": 51, "memory_kb": 5208}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s379690414", "group_id": "codeNet:p02616", "input_text": "#define _USE_MATH_DEFINES\n#include \nusing namespace std;\n\n//template\n#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)\n#define ALL(v) (v).begin(),(v).end()\ntypedef long long int ll;\nconst int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;\ntemplateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}\n//end\n\ntemplatestruct fp {\n int v; static unsigned get_mod(){return mod;}\n int inv() const{\n int tmp,a=v,b=mod,x=1,y=0;\n while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);\n if(x<0){x+=mod;} return x;\n }\n fp():v(0){}\n fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}\n fp operator-()const{return fp(-v);}\n fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}\n fp& operator+=(const fp& x){if((v+=x.v)>=(int)mod)v-=mod; return *this;}\n fp& operator-=(const fp& x){if((v+=mod-x.v)>=(int)mod)v-=mod; return *this;}\n fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}\n fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}\n fp operator+(const fp& x)const{return fp(*this)+=x;}\n fp operator-(const fp& x)const{return fp(*this)-=x;}\n fp operator*(const fp& x)const{return fp(*this)*=x;}\n fp operator/(const fp& x)const{return fp(*this)/=x;}\n bool operator==(const fp& x)const{return v==x.v;}\n bool operator!=(const fp& x)const{return v!=x.v;}\n}; using Fp=fp<>;\n\nint main(){\n int n,k; cin>>n>>k;\n vector a(n);\n rep(i,0,n)cin>>a[i];\n sort(ALL(a));\n if(a.back()<0 and k%2==1){\n Fp res=1;\n rep(i,n-k,n)res*=a[i];\n cout< pos,neg;\n rep(i,0,n){\n if(a[i]>=0)pos.push_back(a[i]);\n else neg.push_back(-a[i]);\n }\n sort(ALL(pos),greater());\n sort(ALL(neg),greater());\n Fp res=1;\n int pi=0,ni=0;\n while(k){\n if(k==1){\n res*=pos[pi]; k--;\n continue;\n }\n if(neg.size()-ni<=1){\n res*=1LL*pos[pi]*pos[pi+1];\n pi+=2; k-=2;\n }\n else if(pos.size()-pi==0){\n res*=1LL*neg[ni]*neg[ni+1];\n ni+=2; k-=2;\n }\n else{\n ll P=1LL*pos[pi]*pos[pi+1];\n ll Q=1LL*neg[ni]*neg[ni+1];\n if(P\nusing namespace std;\n\n//template\n#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)\n#define ALL(v) (v).begin(),(v).end()\ntypedef long long int ll;\nconst int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;\ntemplateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}\n//end\n\ntemplatestruct fp {\n int v; static unsigned get_mod(){return mod;}\n int inv() const{\n int tmp,a=v,b=mod,x=1,y=0;\n while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);\n if(x<0){x+=mod;} return x;\n }\n fp():v(0){}\n fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}\n fp operator-()const{return fp(-v);}\n fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}\n fp& operator+=(const fp& x){if((v+=x.v)>=(int)mod)v-=mod; return *this;}\n fp& operator-=(const fp& x){if((v+=mod-x.v)>=(int)mod)v-=mod; return *this;}\n fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}\n fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}\n fp operator+(const fp& x)const{return fp(*this)+=x;}\n fp operator-(const fp& x)const{return fp(*this)-=x;}\n fp operator*(const fp& x)const{return fp(*this)*=x;}\n fp operator/(const fp& x)const{return fp(*this)/=x;}\n bool operator==(const fp& x)const{return v==x.v;}\n bool operator!=(const fp& x)const{return v!=x.v;}\n}; using Fp=fp<>;\n\nint main(){\n int n,k; cin>>n>>k;\n vector a(n);\n rep(i,0,n)cin>>a[i];\n sort(ALL(a));\n if(a.back()<0 and k%2==1){\n Fp res=1;\n rep(i,n-k,n)res*=a[i];\n cout< pos,neg;\n rep(i,0,n){\n if(a[i]>=0)pos.push_back(a[i]);\n else neg.push_back(-a[i]);\n }\n sort(ALL(pos),greater());\n sort(ALL(neg),greater());\n Fp res=1;\n int pi=0,ni=0;\n while(k){\n if(k==1){\n res*=pos[pi]; k--;\n continue;\n }\n if(neg.size()-ni<=1){\n res*=1LL*pos[pi]*pos[pi+1];\n pi+=2; k-=2;\n }\n else if(pos.size()-pi==0){\n res*=1LL*neg[ni]*neg[ni+1];\n ni+=2; k-=2;\n }\n else{\n ll P=1LL*pos[pi]*pos[pi+1];\n ll Q=1LL*neg[ni]*neg[ni+1];\n if(P\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\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing uint = unsigned int;\nusing ldouble = long double;\n\n\n//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun\n\n#define REP(i,a,b) for(int i = a; i < b; ++i)\n#define PRI(s) cout << s << endl\n#define PRIY PRI(\"Yes\")\n#define PRIN PRI(\"No\")\n\nll N, K;\nvector a;\nvector ap;\nvector am;\nll MOD = 1000000007;\n\nll mod(ll x) { return (x%MOD + MOD) % MOD; }\nint main() {\n\tcin >> N >> K;\n\ta.resize(N);\n\tREP(i,0, N) {\n\t\tcin >> a[i];\n\t\tif (a[i] >= 0)ap.push_back(a[i]);\n\t\telse am.push_back(a[i]);\n\t}\n\n\tbool minus = false;\n\tint ccc = 0;\n\twhile (ccc + 2 <= K && ccc + 2 <= am.size()) ccc += 2;\n\tif (ccc + ap.size() < K) minus = true;\n\tif (minus) {\n\t\tsort(a.begin(), a.end(), [](ll x, ll y) {return abs(x) < abs(y); });\n\t\tll ret = 1;\n\t\tREP(i, 0, K) ret = mod(ret * a[i]);\n\t\tPRI(ret);\n\t\treturn 0;\n\t}\n\tsort(ap.begin(), ap.end(), greater());\n\tsort(am.begin(), am.end(), less());\n\tvector pick(K);\n\tREP(i, 0, K) pick[i] = i < a.size() ? ap[i] : 0;\n\tsort(pick.begin(), pick.end(), less());\n\tfor (int i = 0; i + 1 < K && i + 1 < am.size(); i += 2) {\n\t\tif (pick[i] * pick[i + 1] < am[i] * am[i + 1]) {\n\t\t\tpick[i] = am[i];\n\t\t\tpick[i + 1] = am[i + 1];\n\t\t}\n\t\telse break;\n\t}\n\tll ret = 1;\n\tREP(i, 0, K) ret = mod(ret * pick[i]);\n\tPRI(ret);\n\treturn 0;\n}\n\n\n", "language": "C++", "metadata": {"date": 1598548810, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/C++/s069864174.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s069864174", "user_id": "u539145601"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#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\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing uint = unsigned int;\nusing ldouble = long double;\n\n\n//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun\n\n#define REP(i,a,b) for(int i = a; i < b; ++i)\n#define PRI(s) cout << s << endl\n#define PRIY PRI(\"Yes\")\n#define PRIN PRI(\"No\")\n\nll N, K;\nvector a;\nvector ap;\nvector am;\nll MOD = 1000000007;\n\nll mod(ll x) { return (x%MOD + MOD) % MOD; }\nint main() {\n\tcin >> N >> K;\n\ta.resize(N);\n\tREP(i,0, N) {\n\t\tcin >> a[i];\n\t\tif (a[i] >= 0)ap.push_back(a[i]);\n\t\telse am.push_back(a[i]);\n\t}\n\n\tbool minus = false;\n\tint ccc = 0;\n\twhile (ccc + 2 <= K && ccc + 2 <= am.size()) ccc += 2;\n\tif (ccc + ap.size() < K) minus = true;\n\tif (minus) {\n\t\tsort(a.begin(), a.end(), [](ll x, ll y) {return abs(x) < abs(y); });\n\t\tll ret = 1;\n\t\tREP(i, 0, K) ret = mod(ret * a[i]);\n\t\tPRI(ret);\n\t\treturn 0;\n\t}\n\tsort(ap.begin(), ap.end(), greater());\n\tsort(am.begin(), am.end(), less());\n\tvector pick(K);\n\tREP(i, 0, K) pick[i] = i < a.size() ? ap[i] : 0;\n\tsort(pick.begin(), pick.end(), less());\n\tfor (int i = 0; i + 1 < K && i + 1 < am.size(); i += 2) {\n\t\tif (pick[i] * pick[i + 1] < am[i] * am[i + 1]) {\n\t\t\tpick[i] = am[i];\n\t\t\tpick[i + 1] = am[i + 1];\n\t\t}\n\t\telse break;\n\t}\n\tll ret = 1;\n\tREP(i, 0, K) ret = mod(ret * pick[i]);\n\tPRI(ret);\n\treturn 0;\n}\n\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1817, "cpu_time_ms": 174, "memory_kb": 8240}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s544015197", "group_id": "codeNet:p02616", "input_text": "#include\nusing namespace std;\nint a[100005];\nint zheng[100005];\nint ffu[100005];\nconst long long mod=1e9+7;\nbool cmp(int a,int b){\n return abs(a)>abs(b);\n}\n\nint n,k;\nint main()\n{\n scanf(\"%d%d\",&n,&k);\n int s1=0,s2=0,kk=k;\n for(int i=0;i0){\n zheng[s1]=a[i];s1++;\n\t\t }\n if(a[i]<0){\n ffu[s2]=a[i];s2++;\n\t\t }\n }\n sort(zheng,zheng+s1,cmp);\n sort(ffu,ffu+s2,cmp);\n long long ans=1;\n int ss1=0,ss2=0;\n while(true)\n\t{\n if(k==0)\n break;\n if(abs(zheng[ss1])>abs(ffu[ss2]))\n\t\t{\n ans=(ans*zheng[ss1])%mod;\n ss1++;\n k--;\n }\n else\n\t\t{\n ans=(ans*ffu[ss2])%mod;\n ss2++;\n k--;\n }\n }\n if(ans>0){\n printf(\"%lld\\n\",ans%mod);\n return 0;\n }\n if(ans>0){\n printf(\"%lld\\n\",ans%mod);\n return 0;\n }\n if(ans<0&&s1>0)\n\t{\n long long ans1=1;\n if(ss1=0;i--)\n ans2=(ffu[i]*ans2%mod);\n printf(\"%lld\",ans2%mod);\n }\n return 0;\n}\n\n ", "language": "C++", "metadata": {"date": 1594993018, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/C++/s544015197.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s544015197", "user_id": "u018679195"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include\nusing namespace std;\nint a[100005];\nint zheng[100005];\nint ffu[100005];\nconst long long mod=1e9+7;\nbool cmp(int a,int b){\n return abs(a)>abs(b);\n}\n\nint n,k;\nint main()\n{\n scanf(\"%d%d\",&n,&k);\n int s1=0,s2=0,kk=k;\n for(int i=0;i0){\n zheng[s1]=a[i];s1++;\n\t\t }\n if(a[i]<0){\n ffu[s2]=a[i];s2++;\n\t\t }\n }\n sort(zheng,zheng+s1,cmp);\n sort(ffu,ffu+s2,cmp);\n long long ans=1;\n int ss1=0,ss2=0;\n while(true)\n\t{\n if(k==0)\n break;\n if(abs(zheng[ss1])>abs(ffu[ss2]))\n\t\t{\n ans=(ans*zheng[ss1])%mod;\n ss1++;\n k--;\n }\n else\n\t\t{\n ans=(ans*ffu[ss2])%mod;\n ss2++;\n k--;\n }\n }\n if(ans>0){\n printf(\"%lld\\n\",ans%mod);\n return 0;\n }\n if(ans>0){\n printf(\"%lld\\n\",ans%mod);\n return 0;\n }\n if(ans<0&&s1>0)\n\t{\n long long ans1=1;\n if(ss1=0;i--)\n ans2=(ffu[i]*ans2%mod);\n printf(\"%lld\",ans2%mod);\n }\n return 0;\n}\n\n ", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1387, "cpu_time_ms": 120, "memory_kb": 4544}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s900963243", "group_id": "codeNet:p02616", "input_text": "#include \nusing namespace std;\nusing LL = long long;\nusing LD = long double;\nusing PII = pair;\nusing PLI = pair;\nusing PLL = pair;\nusing TI = tuple;\nmt19937 mrand(random_device{}());\nint rnd(int x) { return mrand() % x; }\ntemplate ostream& operator <<(ostream& out, const pair &p) {\n return out << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate \nostream& operator <<(ostream& out, const array& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const vector& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const deque& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const set& a) {\n out << \"{\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"}\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const unordered_set& a) {\n out << \"{\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"}\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const map& a) {\n out << \"{\"; bool first = true;\n for (auto& p : a) { out << (first ? \"\" : \", \"); out << p.first << \":\" << p.second; first = 0;} out << \"}\";\n return out;\n}\ntemplate inline void YES(T condition) { \n if(condition) cout << \"YES\" << '\\n';\n else cout << \"NO\" << '\\n';\n}\ntemplate inline void Yes(T condition) {\n if(condition) cout << \"Yes\" << '\\n';\n else cout << \"No\" << '\\n';\n}\ntemplate T gcd(T a, T b) {\n while (b) {\n T tmp = b;\n b = a % b;\n a = tmp;\n }\n return a;\n}\ntemplate T lcm(T a, T b){\n return a / gcd(a, b) * b;\n}\n\n#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n cerr << name << \": \" << arg1 << endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');\n cerr.write(names, comma - names) << \": \" << arg1 << \" |\";\n __f(comma + 1, args...);\n}\n\nlong long qpow(long long a, long long b, int MOD) {\n if (b == 0) return 1;\n long long res = 1;\n while (b) {\n if (b & 1) res = (res * a) % MOD;\n a = (a * a) % MOD;\n b >>= 1;\n }\n return res;\n}\n\nconst int MOD = 1e9 + 7;\nconst int maxn = 2e6;\nint fac[maxn + 5];\nint invfac[maxn + 5];\nvoid init() {\n fac[0] = 1;\n for (int i = 1; i <= maxn; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;\n invfac[maxn] = (int)(qpow(fac[maxn], MOD - 2, MOD));\n for (int i = maxn - 1; i >= 0; i--) invfac[i] = 1LL * invfac[i + 1] * (i + 1) % MOD;\n}\nint C(int n, int k) {\n assert(0 <= k && n >= k);\n int tmp = (int)(1LL * invfac[k] * invfac[n - k] % MOD);\n return (int)(1LL * fac[n] * tmp % MOD);\n}\n\nint main() {\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n\n int n, k;\n cin >> n >> k;\n vector a(n), pos, zero, neg;\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n if (a[i] > 0) {\n pos.push_back(a[i]);\n } else if (a[i] == 0) {\n zero.push_back(a[i]);\n } else {\n neg.push_back(a[i]);\n }\n }\n sort(pos.begin(), pos.end());\n sort(neg.begin(), neg.end());\n reverse(neg.begin(), neg.end());\n int pcnt = pos.size(), zcnt = zero.size(), ncnt = neg.size();\n LL ALL = 1;\n for (auto& v: a) ALL = (ALL * v) % MOD;\n ALL = (ALL + MOD) % MOD;\n if (k == 1) {\n LL ans = *max_element(a.begin(), a.end()) % MOD;\n cout << (ans + MOD) % MOD << '\\n';\n return 0;\n }\n if (k == pcnt + zcnt + ncnt) {\n cout << ALL << '\\n';\n return 0;\n }\n if (k > pcnt + ncnt) {\n cout << 0 << '\\n';\n return 0;\n } else if (pcnt == 0) {\n if (k & 1) {\n if (zcnt) { cout << 0 << '\\n'; return 0; }\n LL now = 1;\n for (int i = 0; i < k; i++) now = (now * neg[i]) % MOD;\n cout << (now + MOD) % MOD << '\\n';\n return 0;\n } else {\n if (k > ncnt) { cout << 0 << '\\n'; return 0; }\n LL now = 1;\n for (int i = ncnt - 1; i; i--) now = (now * neg[i]) % MOD;\n cout << (now + MOD) % MOD << '\\n';\n return 0;\n }\n } else {\n LL now = 1;\n int i = pos.size() - 1, j = neg.size() - 1;\n for (; k; ) {\n if (k == 1) {\n if (i >= 0) now = now * pos[i--] % MOD;\n else if (j >= 1) {\n now = now * qpow(a[0], MOD - 2, MOD) % MOD;\n now = now * abs(neg[j--]) % MOD;\n now = now * abs(neg[j--]) % MOD;\n } else {\n now = now * a[j] % MOD;\n }\n k--;\n } else {\n LL P = 0, N = 0;\n if (i >= 1) P = pos[i] * pos[i - 1];\n else if (i == 0) P = pos[i];\n if (j >= 1) N = neg[j] * neg[j - 1];\n else if (j == 0) N = neg[j];\n if (P > N) {\n now = now * (P % MOD) % MOD;\n k -= 1 + (i > 0);\n i -= 1 + (i > 0);\n } else {\n now = now * (N % MOD) % MOD;\n k -= 1 + (j > 0);\n j -= 1 + (j > 0);\n }\n }\n }\n\n cout << (now + MOD) % MOD << '\\n';\n }\n\n\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1594307358, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02616/input.txt", "sample_output_relpath": "derived/input_output/data/p02616/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02616/C++/s900963243.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s900963243", "user_id": "u283661333"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \nusing namespace std;\nusing LL = long long;\nusing LD = long double;\nusing PII = pair;\nusing PLI = pair;\nusing PLL = pair;\nusing TI = tuple;\nmt19937 mrand(random_device{}());\nint rnd(int x) { return mrand() % x; }\ntemplate ostream& operator <<(ostream& out, const pair &p) {\n return out << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate \nostream& operator <<(ostream& out, const array& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const vector& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const deque& a) {\n out << \"[\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"]\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const set& a) {\n out << \"{\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"}\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const unordered_set& a) {\n out << \"{\"; bool first = true;\n for (auto& v : a) { out << (first ? \"\" : \", \"); out << v; first = 0;} out << \"}\";\n return out;\n}\ntemplate \nostream& operator <<(ostream& out, const map& a) {\n out << \"{\"; bool first = true;\n for (auto& p : a) { out << (first ? \"\" : \", \"); out << p.first << \":\" << p.second; first = 0;} out << \"}\";\n return out;\n}\ntemplate inline void YES(T condition) { \n if(condition) cout << \"YES\" << '\\n';\n else cout << \"NO\" << '\\n';\n}\ntemplate inline void Yes(T condition) {\n if(condition) cout << \"Yes\" << '\\n';\n else cout << \"No\" << '\\n';\n}\ntemplate T gcd(T a, T b) {\n while (b) {\n T tmp = b;\n b = a % b;\n a = tmp;\n }\n return a;\n}\ntemplate T lcm(T a, T b){\n return a / gcd(a, b) * b;\n}\n\n#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n cerr << name << \": \" << arg1 << endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');\n cerr.write(names, comma - names) << \": \" << arg1 << \" |\";\n __f(comma + 1, args...);\n}\n\nlong long qpow(long long a, long long b, int MOD) {\n if (b == 0) return 1;\n long long res = 1;\n while (b) {\n if (b & 1) res = (res * a) % MOD;\n a = (a * a) % MOD;\n b >>= 1;\n }\n return res;\n}\n\nconst int MOD = 1e9 + 7;\nconst int maxn = 2e6;\nint fac[maxn + 5];\nint invfac[maxn + 5];\nvoid init() {\n fac[0] = 1;\n for (int i = 1; i <= maxn; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;\n invfac[maxn] = (int)(qpow(fac[maxn], MOD - 2, MOD));\n for (int i = maxn - 1; i >= 0; i--) invfac[i] = 1LL * invfac[i + 1] * (i + 1) % MOD;\n}\nint C(int n, int k) {\n assert(0 <= k && n >= k);\n int tmp = (int)(1LL * invfac[k] * invfac[n - k] % MOD);\n return (int)(1LL * fac[n] * tmp % MOD);\n}\n\nint main() {\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n\n int n, k;\n cin >> n >> k;\n vector a(n), pos, zero, neg;\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n if (a[i] > 0) {\n pos.push_back(a[i]);\n } else if (a[i] == 0) {\n zero.push_back(a[i]);\n } else {\n neg.push_back(a[i]);\n }\n }\n sort(pos.begin(), pos.end());\n sort(neg.begin(), neg.end());\n reverse(neg.begin(), neg.end());\n int pcnt = pos.size(), zcnt = zero.size(), ncnt = neg.size();\n LL ALL = 1;\n for (auto& v: a) ALL = (ALL * v) % MOD;\n ALL = (ALL + MOD) % MOD;\n if (k == 1) {\n LL ans = *max_element(a.begin(), a.end()) % MOD;\n cout << (ans + MOD) % MOD << '\\n';\n return 0;\n }\n if (k == pcnt + zcnt + ncnt) {\n cout << ALL << '\\n';\n return 0;\n }\n if (k > pcnt + ncnt) {\n cout << 0 << '\\n';\n return 0;\n } else if (pcnt == 0) {\n if (k & 1) {\n if (zcnt) { cout << 0 << '\\n'; return 0; }\n LL now = 1;\n for (int i = 0; i < k; i++) now = (now * neg[i]) % MOD;\n cout << (now + MOD) % MOD << '\\n';\n return 0;\n } else {\n if (k > ncnt) { cout << 0 << '\\n'; return 0; }\n LL now = 1;\n for (int i = ncnt - 1; i; i--) now = (now * neg[i]) % MOD;\n cout << (now + MOD) % MOD << '\\n';\n return 0;\n }\n } else {\n LL now = 1;\n int i = pos.size() - 1, j = neg.size() - 1;\n for (; k; ) {\n if (k == 1) {\n if (i >= 0) now = now * pos[i--] % MOD;\n else if (j >= 1) {\n now = now * qpow(a[0], MOD - 2, MOD) % MOD;\n now = now * abs(neg[j--]) % MOD;\n now = now * abs(neg[j--]) % MOD;\n } else {\n now = now * a[j] % MOD;\n }\n k--;\n } else {\n LL P = 0, N = 0;\n if (i >= 1) P = pos[i] * pos[i - 1];\n else if (i == 0) P = pos[i];\n if (j >= 1) N = neg[j] * neg[j - 1];\n else if (j == 0) N = neg[j];\n if (P > N) {\n now = now * (P % MOD) % MOD;\n k -= 1 + (i > 0);\n i -= 1 + (i > 0);\n } else {\n now = now * (N % MOD) % MOD;\n k -= 1 + (j > 0);\n j -= 1 + (j > 0);\n }\n }\n }\n\n cout << (now + MOD) % MOD << '\\n';\n }\n\n\n\n return 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6040, "cpu_time_ms": 48, "memory_kb": 6920}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s772204069", "group_id": "codeNet:p02617", "input_text": "/*\n* welcome to my code!\n* ------------------------------------------\n* author : lynmisakura(twitter : @andoreiji11)\n*/\n\n#include\nusing namespace std;\n\nusing ll = long long;\n\n#define REP(i,n) for(int i = 0;i < n;i++)\n#define all(x) x.begin(),x.end()\n#define dup(x,y) (x + y - 1)/y\n#define sz(v) (int)v.size()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\ntemplate bool chmin(T& a,T b){if(a>b){a=b;return 1;}else return false;}\ntemplate bool chmax(T& a,T b){if(a> N;\n\n ll ans = 0;\n for(ll i = 0;i <= N - 1;i++){\n ans += (i + 1) * (N - i);\n }\n\n REP(i,N - 1){\n\n int u,v;cin >> u >> v;\n if(u > v)swap(u,v);\n\n ans -= u * (N + 1 - v);\n\n }\n\n cout << ans << '\\n';\n\n}\n", "language": "C++", "metadata": {"date": 1594058134, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02617.html", "problem_id": "p02617", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02617/input.txt", "sample_output_relpath": "derived/input_output/data/p02617/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02617/C++/s772204069.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s772204069", "user_id": "u426397594"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "/*\n* welcome to my code!\n* ------------------------------------------\n* author : lynmisakura(twitter : @andoreiji11)\n*/\n\n#include\nusing namespace std;\n\nusing ll = long long;\n\n#define REP(i,n) for(int i = 0;i < n;i++)\n#define all(x) x.begin(),x.end()\n#define dup(x,y) (x + y - 1)/y\n#define sz(v) (int)v.size()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\ntemplate bool chmin(T& a,T b){if(a>b){a=b;return 1;}else return false;}\ntemplate bool chmax(T& a,T b){if(a> N;\n\n ll ans = 0;\n for(ll i = 0;i <= N - 1;i++){\n ans += (i + 1) * (N - i);\n }\n\n REP(i,N - 1){\n\n int u,v;cin >> u >> v;\n if(u > v)swap(u,v);\n\n ans -= u * (N + 1 - v);\n\n }\n\n cout << ans << '\\n';\n\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "sample_input": "3\n1 3\n2 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02617", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\\cdots, N and 1, 2, \\cdots, N-1. Edge i connects Vertex u_i and v_i.\n\nFor integers L, R (1 \\leq L \\leq R \\leq N), let us define a function f(L, R) as follows:\n\nLet S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S.\n\nCompute \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq u_i, v_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint \\sum_{L=1}^{N} \\sum_{R=L}^{N} f(L, R).\n\nSample Input 1\n\n3\n1 3\n2 3\n\nSample Output 1\n\n7\n\nWe have six possible pairs (L, R) as follows:\n\nFor L = 1, R = 1, S = \\{1\\} and we have 1 connected component.\n\nFor L = 1, R = 2, S = \\{1, 2\\} and we have 2 connected components.\n\nFor L = 1, R = 3, S = \\{1, 2, 3\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n\nFor L = 2, R = 2, S = \\{2\\} and we have 1 connected component.\n\nFor L = 2, R = 3, S = \\{2, 3\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n\nFor L = 3, R = 3, S = \\{3\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n3\n\nSample Input 3\n\n10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n\nSample Output 3\n\n113", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 916, "cpu_time_ms": 43, "memory_kb": 3544}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s226277304", "group_id": "codeNet:p02621", "input_text": "#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n cout<\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n cout<\nusing namespace std;\nusing ll = long long;\n\nint main() {\n int a;\n cin >> a;\n int ans = a;\n ans += a * a;\n ans += a * a * a;\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1593306050, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02621/input.txt", "sample_output_relpath": "derived/input_output/data/p02621/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02621/C++/s684851336.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s684851336", "user_id": "u902387200"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\n\nint main() {\n int a;\n cin >> a;\n int ans = a;\n ans += a * a;\n ans += a * a * a;\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 7, "memory_kb": 3632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s336426749", "group_id": "codeNet:p02622", "input_text": "#include\n\n#define all(n) n.begin(),n.end()\n#define ll long long\n\n#define pb push_back\n#define eb emplace_back\n#define endl \"\\n\"\n#define pll pair\n\n#define ff first\n#define ss second\n\nusing namespace std;\nconst ll maxn=1e6+2;\nconst ll maxx=1e16;\nconst ll mod=998244353;\nconst ll mod1=998244353;\n\nvector ans[maxn];\npll a[maxn];\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n if (fopen(\"TEAMS.INP\",\"r\"))\n {\n freopen(\"TEAMS.INP\", \"r\", stdin);\n freopen(\"TEAMS.OUT\", \"w\", stdout);\n }\n string s;\n string t;\n cin>>s>>t;\n ll ans=0;\n for (int i=0;i\n\n#define all(n) n.begin(),n.end()\n#define ll long long\n\n#define pb push_back\n#define eb emplace_back\n#define endl \"\\n\"\n#define pll pair\n\n#define ff first\n#define ss second\n\nusing namespace std;\nconst ll maxn=1e6+2;\nconst ll maxx=1e16;\nconst ll mod=998244353;\nconst ll mod1=998244353;\n\nvector ans[maxn];\npll a[maxn];\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n if (fopen(\"TEAMS.INP\",\"r\"))\n {\n freopen(\"TEAMS.INP\", \"r\", stdin);\n freopen(\"TEAMS.OUT\", \"w\", stdout);\n }\n string s;\n string t;\n cin>>s>>t;\n ll ans=0;\n for (int i=0;i\nusing namespace std;\nint main()\n{\n char c;\n cin>>c;\n int d=(int)c;\n if(d>=65 && d<=90)\n {\n cout << 'A'<<'\\n';\n }\n if(d>=97 && d<=122)\n {\n cout << 'a'<<'\\n';\n }\n}\n", "language": "C++", "metadata": {"date": 1592788664, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/C++/s910287338.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910287338", "user_id": "u552937692"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "#include\nusing namespace std;\nint main()\n{\n char c;\n cin>>c;\n int d=(int)c;\n if(d>=65 && d<=90)\n {\n cout << 'A'<<'\\n';\n }\n if(d>=97 && d<=122)\n {\n cout << 'a'<<'\\n';\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 8, "memory_kb": 3616}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s897910011", "group_id": "codeNet:p02627", "input_text": "#include \nusing namespace std;\n#define ll long long\n\nint main() {\n char c;\n cin >> c;\n if (c >= 'A' && c <= 'Z') cout << 'A' << endl;\n else cout << 'a' << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592787656, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02627/input.txt", "sample_output_relpath": "derived/input_output/data/p02627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02627/C++/s897910011.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897910011", "user_id": "u548834738"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "#include \nusing namespace std;\n#define ll long long\n\nint main() {\n char c;\n cin >> c;\n if (c >= 'A' && c <= 'Z') cout << 'A' << endl;\n else cout << 'a' << endl;\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 7, "memory_kb": 3632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s591150165", "group_id": "codeNet:p02628", "input_text": "#include \nusing namespace std;\n\nint main () {\n int n, k;\n while (scanf(\"%d %d\", &n, &k) == 2) {\n vector p(n, 0);\n for (int i = 0; i < n; i++) scanf(\"%d\", &p[i]);\n sort(p.begin(), p.end());\n long long s = 0;\n for (int i = 0; i < n && i < k; i++) s += p[i];\n printf(\"%lld\\n\", s);\n }\n}\n\n", "language": "C++", "metadata": {"date": 1592787839, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/C++/s591150165.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s591150165", "user_id": "u143746002"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main () {\n int n, k;\n while (scanf(\"%d %d\", &n, &k) == 2) {\n vector p(n, 0);\n for (int i = 0; i < n; i++) scanf(\"%d\", &p[i]);\n sort(p.begin(), p.end());\n long long s = 0;\n for (int i = 0; i < n && i < k; i++) s += p[i];\n printf(\"%lld\\n\", s);\n }\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 355, "cpu_time_ms": 6, "memory_kb": 3792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s029963050", "group_id": "codeNet:p02629", "input_text": "#include \nusing namespace std;\n\nusing ll = long long;\nusing pii = pair;\n\n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n#define all(x) (x).begin(),(x).end()\n#define x first\n#define y second\n\nconst int MOD = 1e9 + 7;\n\nvoid setIO() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n}\n\n//ctrl q is comment\n//ctrl b is run\n//ctrl s is compile\n//shift r is search & replace\n//shift d is delete a line\n\nbool comp(pii a, pii b){\n return a.x == b.x ? a.y < b.y : a.x < b.x;\n}\nint main(){\n setIO();\n ll n; cin >> n;\n int p26 = 0;\n ll mult = 26;\n int temp = n;\n while(temp > mult){\n temp -= mult;\n mult *= 26;\n ++p26;\n }\n mult = 1;\n for(int i = 0; i < p26; ++i){\n mult *= 26;\n }\n string ans = \"\";\n for(int i = p26; i >= 0; --i){\n if(n % mult == 0 && mult != 1){\n ans += (char)(n / mult - 2 + 'a');\n n %= mult;\n n += mult;\n }\n else{\n ans += (char)(n / mult - 1 + 'a');\n n %= mult;\n }\n mult /= 26;\n }\n cout << ans << \"\\n\";\n}\n\n", "language": "C++", "metadata": {"date": 1592788760, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/C++/s029963050.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s029963050", "user_id": "u816600238"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "#include \nusing namespace std;\n\nusing ll = long long;\nusing pii = pair;\n\n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n#define all(x) (x).begin(),(x).end()\n#define x first\n#define y second\n\nconst int MOD = 1e9 + 7;\n\nvoid setIO() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n}\n\n//ctrl q is comment\n//ctrl b is run\n//ctrl s is compile\n//shift r is search & replace\n//shift d is delete a line\n\nbool comp(pii a, pii b){\n return a.x == b.x ? a.y < b.y : a.x < b.x;\n}\nint main(){\n setIO();\n ll n; cin >> n;\n int p26 = 0;\n ll mult = 26;\n int temp = n;\n while(temp > mult){\n temp -= mult;\n mult *= 26;\n ++p26;\n }\n mult = 1;\n for(int i = 0; i < p26; ++i){\n mult *= 26;\n }\n string ans = \"\";\n for(int i = p26; i >= 0; --i){\n if(n % mult == 0 && mult != 1){\n ans += (char)(n / mult - 2 + 'a');\n n %= mult;\n n += mult;\n }\n else{\n ans += (char)(n / mult - 1 + 'a');\n n %= mult;\n }\n mult /= 26;\n }\n cout << ans << \"\\n\";\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1117, "cpu_time_ms": 6, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s086966410", "group_id": "codeNet:p02633", "input_text": "#include \n\nint main()\n{\n \n int x;\n scanf(\"%d\",&x);\n int result=360/x;\n if(x*result==360)\n \tprintf(\"%d\",result);\n \telse\n \tprintf(\"%d\",result+1);\n}", "language": "C++", "metadata": {"date": 1592975877, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02633.html", "problem_id": "p02633", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02633/input.txt", "sample_output_relpath": "derived/input_output/data/p02633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02633/C++/s086966410.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s086966410", "user_id": "u885060644"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \n\nint main()\n{\n \n int x;\n scanf(\"%d\",&x);\n int result=360/x;\n if(x*result==360)\n \tprintf(\"%d\",result);\n \telse\n \tprintf(\"%d\",result+1);\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "sample_input": "90\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02633", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 6, "memory_kb": 1656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s053625603", "group_id": "codeNet:p02633", "input_text": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long \n#define ld long double\n#define pb push_back\n#define rep(i,n) for(i=0;i& v,ld n)\n{\n\tld i,io;\n\trep(i,n)\n\t{\n\t\tcin>>io;\n\t\tv.pb(io);\n\t}\n}*/\nint main()\n{\n\tfastio;\n\tint n;\n\tcin>>n;\n\tcout<<(360)/n<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long \n#define ld long double\n#define pb push_back\n#define rep(i,n) for(i=0;i& v,ld n)\n{\n\tld i,io;\n\trep(i,n)\n\t{\n\t\tcin>>io;\n\t\tv.pb(io);\n\t}\n}*/\nint main()\n{\n\tfastio;\n\tint n;\n\tcin>>n;\n\tcout<<(360)/n<\n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nconst int INF = INT32_MAX;\nconst ll INFL = INT64_MAX;\nconst int mod = 1e9 + 7;\n\ntemplate \nvoid print_vec(vector v) {\n for (T i : v) cout << i << \" \";\n cout << endl;\n}\n\nint main() {\n int ans = 0;\n rep(i, 5) {\n int x;\n cin >> x;\n if (x == 0) ans = i + 1;\n }\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1592182922, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02639/input.txt", "sample_output_relpath": "derived/input_output/data/p02639/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02639/C++/s490504407.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s490504407", "user_id": "u894496005"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nconst int INF = INT32_MAX;\nconst ll INFL = INT64_MAX;\nconst int mod = 1e9 + 7;\n\ntemplate \nvoid print_vec(vector v) {\n for (T i : v) cout << i << \" \";\n cout << endl;\n}\n\nint main() {\n int ans = 0;\n rep(i, 5) {\n int x;\n cin >> x;\n if (x == 0) ans = i + 1;\n }\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 463, "cpu_time_ms": 2, "memory_kb": 3584}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s139291902", "group_id": "codeNet:p02640", "input_text": "#include\nusing namespace std;\nint main(){int m,n;if(m<=n&&n<=2*m&&n%2==0)cout<<\"Yes\"<\nusing namespace std;\nint main(){int m,n;if(m<=n&&n<=2*m&&n%2==0)cout<<\"Yes\"<\n#include \n#include \nusing namespace std;\n\nint main() {\n\nint x,n, r{101};\nvectorv{};\ncin>>x>>n;\nif(!n)\n cout << x;\nelse\n{\n\n int c;\n for(int i = 0; i < n; i++)\n {\n cin >> c;\n v.push_back(abs(c));\n }\n\n sort(v.begin(), v.end());\n auto it = find(v.begin(),v.end(), x);\n \n if (it == v.end()){\n cout << x;\n exit(0);\n }\n \n \n \n int z = 1;\n while(true)\n {\n if(*(it-z) != x-z)\n {\n z = x-z;\n break;\n }\n else if (*(it+z) != x+z)\n {\n z = x+z;\n break;\n }\n z++;\n \n }\n cout << z;\n \n\n\n\n}\nreturn 0;\n}", "language": "C++", "metadata": {"date": 1601042084, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/C++/s155329689.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s155329689", "user_id": "u629482802"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\nint x,n, r{101};\nvectorv{};\ncin>>x>>n;\nif(!n)\n cout << x;\nelse\n{\n\n int c;\n for(int i = 0; i < n; i++)\n {\n cin >> c;\n v.push_back(abs(c));\n }\n\n sort(v.begin(), v.end());\n auto it = find(v.begin(),v.end(), x);\n \n if (it == v.end()){\n cout << x;\n exit(0);\n }\n \n \n \n int z = 1;\n while(true)\n {\n if(*(it-z) != x-z)\n {\n z = x-z;\n break;\n }\n else if (*(it+z) != x+z)\n {\n z = x+z;\n break;\n }\n z++;\n \n }\n cout << z;\n \n\n\n\n}\nreturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 8, "memory_kb": 3548}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s977135282", "group_id": "codeNet:p02641", "input_text": "#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#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define int long long\n#define ld long double\n#define all(x) x.begin(),x.end()\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\n#define vi vector\n#define vstr vector\n#define vbool vector\n#define vvi vector >\n#define mii map\n#define pb push_back\n#define pii pair\n#define vpair vector \n#define mkp make_pair\n#define scan(a,n) for(int i =0 ; i>a[i]\n#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<>x>>n;\n\tif(n==0)\n\t\tcout< ans(101,false);\n\t\tvi arr(n);\n\t\tloop(i,0,n)\n\t\t{\n\t\t\tcin>>arr[i];\n\t\t\tans[arr[i]] = true;\n\t\t}\n\t\tsort(all(arr));\n\t\tloop(i,x,101)\n\t\t{\n\t\t\tif(ans[i]==false)\n\t\t\t\t{\n\t\t\t\t\tp = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tfor(int i = x;i>0;i--)\n\t\t{\n\t\t\tif(ans[i]==false)\n\t\t\t\t{\n\t\t\t\t\tq = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tif(abs(x-p)>t;\n\twhile(t--)\n\t\tsolve();\n\treturn 0;\n} ", "language": "C++", "metadata": {"date": 1592189120, "filename_ext": "cpp", "original_language": "C++ (Clang 10.0.0)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/C++/s977135282.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s977135282", "user_id": "u860952176"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#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#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define int long long\n#define ld long double\n#define all(x) x.begin(),x.end()\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\n#define vi vector\n#define vstr vector\n#define vbool vector\n#define vvi vector >\n#define mii map\n#define pb push_back\n#define pii pair\n#define vpair vector \n#define mkp make_pair\n#define scan(a,n) for(int i =0 ; i>a[i]\n#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<>x>>n;\n\tif(n==0)\n\t\tcout< ans(101,false);\n\t\tvi arr(n);\n\t\tloop(i,0,n)\n\t\t{\n\t\t\tcin>>arr[i];\n\t\t\tans[arr[i]] = true;\n\t\t}\n\t\tsort(all(arr));\n\t\tloop(i,x,101)\n\t\t{\n\t\t\tif(ans[i]==false)\n\t\t\t\t{\n\t\t\t\t\tp = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tfor(int i = x;i>0;i--)\n\t\t{\n\t\t\tif(ans[i]==false)\n\t\t\t\t{\n\t\t\t\t\tq = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tif(abs(x-p)>t;\n\twhile(t--)\n\t\tsolve();\n\treturn 0;\n} ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2117, "cpu_time_ms": 4, "memory_kb": 3196}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s351696386", "group_id": "codeNet:p02641", "input_text": "// clang-format off\n#pragma GCC optimize(\"Ofast\")\n#include \nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing G = vector>;\n#define G(i, j) i, vector(j)\n#define Gv(i, j, k) i, vector(j, k)\n#define rep(i,n) for(ll i=0, i##_len=(n); i=0; --i)\n#define rrep1(i,n) for(ll i=n; i>0; --i)\n#define all(x) (x).begin(),(x).end()\n#define SORT(x) sort(all(x))\n#define SORT_DESC(x) sort((x).rbegin(),(x).rend())\n#define pb push_back\n#define mp make_pair\n#define coutl cout<inline bool chmax(T &a, const T &b){if (ainline bool chmin(T &a, const T &b){if (b p) {\n ll a, s = INF;\n rep(i, 102) {\n if (find(all(p), i) != p.end())\n continue;\n ll d = abs(X - i);\n if (d < s) {\n a = i;\n s = d;\n }\n }\n ANS(a);\n}\n\n// clang-format off\nint main() {\n long long X;\n scanf(\"%lld\",&X);\n long long N;\n scanf(\"%lld\",&N);\n std::vector p(N);\n for(int i = 0 ; i < N ; i++){\n scanf(\"%lld\",&p[i]);\n }\n solve(X, N, std::move(p));\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592185337, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02641.html", "problem_id": "p02641", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02641/input.txt", "sample_output_relpath": "derived/input_output/data/p02641/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02641/C++/s351696386.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s351696386", "user_id": "u891692185"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "// clang-format off\n#pragma GCC optimize(\"Ofast\")\n#include \nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing G = vector>;\n#define G(i, j) i, vector(j)\n#define Gv(i, j, k) i, vector(j, k)\n#define rep(i,n) for(ll i=0, i##_len=(n); i=0; --i)\n#define rrep1(i,n) for(ll i=n; i>0; --i)\n#define all(x) (x).begin(),(x).end()\n#define SORT(x) sort(all(x))\n#define SORT_DESC(x) sort((x).rbegin(),(x).rend())\n#define pb push_back\n#define mp make_pair\n#define coutl cout<inline bool chmax(T &a, const T &b){if (ainline bool chmin(T &a, const T &b){if (b p) {\n ll a, s = INF;\n rep(i, 102) {\n if (find(all(p), i) != p.end())\n continue;\n ll d = abs(X - i);\n if (d < s) {\n a = i;\n s = d;\n }\n }\n ANS(a);\n}\n\n// clang-format off\nint main() {\n long long X;\n scanf(\"%lld\",&X);\n long long N;\n scanf(\"%lld\",&N);\n std::vector p(N);\n for(int i = 0 ; i < N ; i++){\n scanf(\"%lld\",&p[i]);\n }\n solve(X, N, std::move(p));\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1452, "cpu_time_ms": 7, "memory_kb": 3692}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s642314164", "group_id": "codeNet:p02644", "input_text": "#include \nusing namespace std;\n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n\nusing ll = long long;\nusing ld = long double;\nll INF = LLONG_MAX;\n\nusing vi = vector;\nusing vll = vector;\nusing pii = pair;\n\nnamespace output {\n\tvoid pr(int x) { cout << x; }\n\tvoid pr(long x) { cout << x; }\n\tvoid pr(ll x) { cout << x; }\n\tvoid pr(unsigned x) { cout << x; }\n\tvoid pr(unsigned long x) { cout << x; }\n\tvoid pr(unsigned long long x) { cout << x; }\n\tvoid pr(float x) { cout << x; }\n\tvoid pr(double x) { cout << x; }\n\tvoid pr(ld x) { cout << x; }\n\tvoid pr(char x) { cout << x; }\n\tvoid pr(const char* x) { cout << x; }\n\tvoid pr(const string& x) { cout << x; }\n\tvoid pr(bool x) { pr(x ? \"true\" : \"false\"); }\n\ttemplate void pr(const complex& x) { cout << x; }\n\t\n\ttemplate void pr(const pair& x);\n\ttemplate void pr(const T& x);\n\t\n\ttemplate void pr(const T& t, const Ts&... ts) { \n\t\tpr(t); pr(ts...); \n\t}\n\ttemplate void pr(const pair& x) { \n\t\tpr(\"{\",x.f,\", \",x.s,\"}\"); \n\t}\n\ttemplate void pr(const T& x) { \n\t\tpr(\"{\"); // const iterator needed for vector\n\t\tbool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; \n\t\tpr(\"}\");\n\t}\n\t\n\tvoid print() { pr(\"\\n\"); } // print w/ spaces\n\ttemplate void print(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\" \"); print(ts...); \n\t}\n}\n\nusing namespace output;\n\nusing state = tuple;\n\nvi DX = {-1, 1, 0, 0};\nvi DY = {0, 0, -1, 1};\n\nint main() {\n\t// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\t\n\tint H, W, K; cin >> H >> W >> K;\n\tint X1, Y1, X2, Y2; cin >> X1 >> Y1 >> X2 >> Y2; --X1; --Y1; --X2; --Y2;\n\tswap(X1, Y1);\n\tswap(X2, Y2);\n\n\tvector> grid (H, vector (W));\n\tF0R(i, H) {\n\t\tF0R(j, W) {\n\t\t\tchar c; cin >> c;\n\t\t\tgrid[i][j] = c == '@';\n\t\t}\n\t}\n\n\tvector>>> dist (H, vector>> (W, vector> (4, vector (K + 1, 1e7))));\n\t\n\tdeque q;\n\tF0R(i, 4) {\n\t\tq.push_front(make_tuple(X1, Y1, i, K));\n\t\tdist[Y1][X1][i][K] = 1;\n\t}\n\t\n\twhile (!q.empty()) {\n\t\tstate v = q.front();\n\t\tq.pop_front();\n\n\n\t\tint x = get<0>(v);\n\t\tint y = get<1>(v);\n\t\tint d = get<2>(v);\n\t\tint r = get<3>(v);\n\t\t\t\t\n\t\tint dis = dist[y][x][d][r];\n\n\t\t// print(\"SEARCHING\", x, y, d, r);\n\n\t\tF0R(i, 4) {\n\t\t\tif (dis + 1 < dist[y][x][i][K]) {\n\t\t\t\tdist[y][x][i][K] = dis + 1;\n\t\t\t\tq.push_back(make_tuple(x, y, i, K));\n\t\t\t}\n\t\t}\n\n\t\tif (r > 0) {\n\t\t\tint nx = x + DX[d];\n\t\t\tint ny = y + DY[d];\n\t\t\tif (0 <= nx && nx < W && 0 <= ny && ny < H && !grid[ny][nx]) {\n\t\t\t\tif (dis < dist[ny][nx][d][r-1]) {\n\t\t\t\t\tdist[ny][nx][d][r-1] = dis;\n\t\t\t\t\tq.push_front(make_tuple(nx, ny, d, r - 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tint ans = 1e7;\n\tF0R(i, 4) F0R(k, K+1) ans = min(ans, dist[Y2][X2][i][k]);\n\tprint((ans < 1e7) ? ans : -1); \n}", "language": "C++", "metadata": {"date": 1592272430, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02644/input.txt", "sample_output_relpath": "derived/input_output/data/p02644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02644/C++/s642314164.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s642314164", "user_id": "u148425972"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n\nusing ll = long long;\nusing ld = long double;\nll INF = LLONG_MAX;\n\nusing vi = vector;\nusing vll = vector;\nusing pii = pair;\n\nnamespace output {\n\tvoid pr(int x) { cout << x; }\n\tvoid pr(long x) { cout << x; }\n\tvoid pr(ll x) { cout << x; }\n\tvoid pr(unsigned x) { cout << x; }\n\tvoid pr(unsigned long x) { cout << x; }\n\tvoid pr(unsigned long long x) { cout << x; }\n\tvoid pr(float x) { cout << x; }\n\tvoid pr(double x) { cout << x; }\n\tvoid pr(ld x) { cout << x; }\n\tvoid pr(char x) { cout << x; }\n\tvoid pr(const char* x) { cout << x; }\n\tvoid pr(const string& x) { cout << x; }\n\tvoid pr(bool x) { pr(x ? \"true\" : \"false\"); }\n\ttemplate void pr(const complex& x) { cout << x; }\n\t\n\ttemplate void pr(const pair& x);\n\ttemplate void pr(const T& x);\n\t\n\ttemplate void pr(const T& t, const Ts&... ts) { \n\t\tpr(t); pr(ts...); \n\t}\n\ttemplate void pr(const pair& x) { \n\t\tpr(\"{\",x.f,\", \",x.s,\"}\"); \n\t}\n\ttemplate void pr(const T& x) { \n\t\tpr(\"{\"); // const iterator needed for vector\n\t\tbool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; \n\t\tpr(\"}\");\n\t}\n\t\n\tvoid print() { pr(\"\\n\"); } // print w/ spaces\n\ttemplate void print(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\" \"); print(ts...); \n\t}\n}\n\nusing namespace output;\n\nusing state = tuple;\n\nvi DX = {-1, 1, 0, 0};\nvi DY = {0, 0, -1, 1};\n\nint main() {\n\t// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\t\n\tint H, W, K; cin >> H >> W >> K;\n\tint X1, Y1, X2, Y2; cin >> X1 >> Y1 >> X2 >> Y2; --X1; --Y1; --X2; --Y2;\n\tswap(X1, Y1);\n\tswap(X2, Y2);\n\n\tvector> grid (H, vector (W));\n\tF0R(i, H) {\n\t\tF0R(j, W) {\n\t\t\tchar c; cin >> c;\n\t\t\tgrid[i][j] = c == '@';\n\t\t}\n\t}\n\n\tvector>>> dist (H, vector>> (W, vector> (4, vector (K + 1, 1e7))));\n\t\n\tdeque q;\n\tF0R(i, 4) {\n\t\tq.push_front(make_tuple(X1, Y1, i, K));\n\t\tdist[Y1][X1][i][K] = 1;\n\t}\n\t\n\twhile (!q.empty()) {\n\t\tstate v = q.front();\n\t\tq.pop_front();\n\n\n\t\tint x = get<0>(v);\n\t\tint y = get<1>(v);\n\t\tint d = get<2>(v);\n\t\tint r = get<3>(v);\n\t\t\t\t\n\t\tint dis = dist[y][x][d][r];\n\n\t\t// print(\"SEARCHING\", x, y, d, r);\n\n\t\tF0R(i, 4) {\n\t\t\tif (dis + 1 < dist[y][x][i][K]) {\n\t\t\t\tdist[y][x][i][K] = dis + 1;\n\t\t\t\tq.push_back(make_tuple(x, y, i, K));\n\t\t\t}\n\t\t}\n\n\t\tif (r > 0) {\n\t\t\tint nx = x + DX[d];\n\t\t\tint ny = y + DY[d];\n\t\t\tif (0 <= nx && nx < W && 0 <= ny && ny < H && !grid[ny][nx]) {\n\t\t\t\tif (dis < dist[ny][nx][d][r-1]) {\n\t\t\t\t\tdist[ny][nx][d][r-1] = dis;\n\t\t\t\t\tq.push_front(make_tuple(nx, ny, d, r - 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tint ans = 1e7;\n\tF0R(i, 4) F0R(k, K+1) ans = min(ans, dist[Y2][X2][i][k]);\n\tprint((ans < 1e7) ? ans : -1); \n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "sample_input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02644", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2984, "cpu_time_ms": 3335, "memory_kb": 3557680}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s334577794", "group_id": "codeNet:p02646", "input_text": "#include\nusing namespace std;\nint main() {\n int a,v;\n cin >> a >> v;\n int b,w;\n cin >> b >> w;\n int t;\n cin >> t;\n bool fg = false;\n for (int i = 1; i <= t; i++) {\n if (a > b) {\n a = a - v;\n b = b - w;\n if (a == b) {\n fg = true;\n }\n }\n if (a < b) {\n a = a + v;\n b = b + w;\n if (a == b) {\n fg = true;\n }\n }\n }\n if (fg) {\n cout << \"YES\" << endl;\n } else {\n cout << \"NO\" << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1592103135, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02646/input.txt", "sample_output_relpath": "derived/input_output/data/p02646/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02646/C++/s334577794.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s334577794", "user_id": "u583232278"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "#include\nusing namespace std;\nint main() {\n int a,v;\n cin >> a >> v;\n int b,w;\n cin >> b >> w;\n int t;\n cin >> t;\n bool fg = false;\n for (int i = 1; i <= t; i++) {\n if (a > b) {\n a = a - v;\n b = b - w;\n if (a == b) {\n fg = true;\n }\n }\n if (a < b) {\n a = a + v;\n b = b + w;\n if (a == b) {\n fg = true;\n }\n }\n }\n if (fg) {\n cout << \"YES\" << endl;\n } else {\n cout << \"NO\" << endl;\n }\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "sample_input": "1 2\n3 1\n3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02646", "source_text": "Score : 200 points\n\nProblem Statement\n\nTwo children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second.\nThe other child is now at coordinate B, and she can travel the distance of W per second.\n\nHe can catch her when his coordinate is the same as hers.\nDetermine whether he can catch her within T seconds (including exactly T seconds later).\nWe assume that both children move optimally.\n\nConstraints\n\n-10^9 \\leq A,B \\leq 10^9\n\n1 \\leq V,W \\leq 10^9\n\n1 \\leq T \\leq 10^9\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA V\nB W\nT\n\nOutput\n\nIf \"it\" can catch the other child, print YES; otherwise, print NO.\n\nSample Input 1\n\n1 2\n3 1\n3\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n1 2\n3 2\n3\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n1 2\n3 3\n3\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 492, "cpu_time_ms": 968, "memory_kb": 3628}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s919710448", "group_id": "codeNet:p02647", "input_text": "#include \n#include \n#include \n#include \n#include \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#include \n\n#define rep(i, x) for (int i = 0; i < (int)(x); i++)\n#define FOR(i, a, done) for (int i = (a); i < (done); ++i)\n#define all(a) (a).begin(), (a).end()\n#define x first\n#define y second\n#define debug(a) cout << (a) << endl\nnamespace mp = boost::multiprecision;\nusing cpp_int = mp::cpp_int;\nusing ll = long long;\nusing namespace std;\ntemplate \nbool chmax(T &a, const T &b)\n{\n\tif (a < b)\n\t{\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\ntemplate \nbool chmin(T &a, const T &b)\n{\n\tif (a > b)\n\t{\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nll M = 1000000007;\n\nvoid solve()\n{\n\tint n,k;\n\tcin>>n>>k;\n\tvectora(n);\n\tvector>imos(k+2,vector(n+2,0));\n\trep(i,n){\n\t\tcin>>a[i];\n\t\tint mi=max(i-a[i],0);\n\t\tint ma=min(n-1,i+a[i]);\n\t\timos[0][mi]++;\n\t\timos[0][ma+1]--;\n\t\t\n\t}\n\tif((ll)n*k>=(ll)1e6 or n<=k){\n\t\trep(i,n){\n\t\t\tcout<\n#include \n#include \n#include \n#include \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#include \n\n#define rep(i, x) for (int i = 0; i < (int)(x); i++)\n#define FOR(i, a, done) for (int i = (a); i < (done); ++i)\n#define all(a) (a).begin(), (a).end()\n#define x first\n#define y second\n#define debug(a) cout << (a) << endl\nnamespace mp = boost::multiprecision;\nusing cpp_int = mp::cpp_int;\nusing ll = long long;\nusing namespace std;\ntemplate \nbool chmax(T &a, const T &b)\n{\n\tif (a < b)\n\t{\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\ntemplate \nbool chmin(T &a, const T &b)\n{\n\tif (a > b)\n\t{\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nll M = 1000000007;\n\nvoid solve()\n{\n\tint n,k;\n\tcin>>n>>k;\n\tvectora(n);\n\tvector>imos(k+2,vector(n+2,0));\n\trep(i,n){\n\t\tcin>>a[i];\n\t\tint mi=max(i-a[i],0);\n\t\tint ma=min(n-1,i+a[i]);\n\t\timos[0][mi]++;\n\t\timos[0][ma+1]--;\n\t\t\n\t}\n\tif((ll)n*k>=(ll)1e6 or n<=k){\n\t\trep(i,n){\n\t\t\tcout<\nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ll N, K; cin >> N >> K;\n vector A(N); for (int i = 0; i < N; i++) cin >> A[i];\n\n while (K--) {\n vector inout(N+1, 0);\n for (int i = 0; i < N; i++) {\n inout[max((ll)0, i - A[i])]++;\n inout[min(N, i+A[i]+1)]--;\n }\n A[0] = inout[0];\n for (int i = 1; i < N; i++) {\n A[i] = A[i-1] + inout[i];\n }\n bool f = true;\n for (int i = 0; i < N; i++) {\n f = f && (A[i] == N);\n }\n if (f) break;\n }\n for (int i = 0; i < N; i++) {\n cout << A[i] << ' ';\n }\n cout << endl;\n}", "language": "C++", "metadata": {"date": 1592098837, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02647.html", "problem_id": "p02647", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02647/input.txt", "sample_output_relpath": "derived/input_output/data/p02647/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02647/C++/s359053831.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s359053831", "user_id": "u858575800"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ll N, K; cin >> N >> K;\n vector A(N); for (int i = 0; i < N; i++) cin >> A[i];\n\n while (K--) {\n vector inout(N+1, 0);\n for (int i = 0; i < N; i++) {\n inout[max((ll)0, i - A[i])]++;\n inout[min(N, i+A[i]+1)]--;\n }\n A[0] = inout[0];\n for (int i = 1; i < N; i++) {\n A[i] = A[i-1] + inout[i];\n }\n bool f = true;\n for (int i = 0; i < N; i++) {\n f = f && (A[i] == N);\n }\n if (f) break;\n }\n for (int i = 0; i < N; i++) {\n cout << A[i] << ' ';\n }\n cout << endl;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "sample_input": "5 1\n1 0 0 1 0\n"}, "reference_outputs": ["1 2 2 1 2\n"], "source_document_id": "p02647", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N bulbs arranged on a number line, numbered 1 to N from left to right.\nBulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity.\nWhen there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5.\nInitially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:\n\nFor each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.\n\nFind the intensity of each bulb after the K operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the intensity A{'}_i of each bulb i after the K operations to Standard Output in the following format:\n\nA{'}_1 A{'}_2 \\ldots A{'}_N\n\nSample Input 1\n\n5 1\n1 0 0 1 0\n\nSample Output 1\n\n1 2 2 1 2\n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1 becomes 1 after the operation.\nSimilarly, the bulbs initially illuminating coordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\nSample Input 2\n\n5 2\n1 0 0 1 0\n\nSample Output 2\n\n3 3 4 4 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 687, "cpu_time_ms": 81, "memory_kb": 6376}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s937100166", "group_id": "codeNet:p02648", "input_text": "#include \ntypedef long long LL;\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define REP(i,n) FOR(i,0,n)\n\nusing namespace std;\n\nint main(void)\n{\n int n;\n cin >> n;\n vector value(1<<18), weight(1<<18);\n FOR(i,1,n+1) cin >> value[i] >> weight[i];\n vector>> hanzen(1<<11); // weight, value\n hanzen[0].emplace_back(0,0);\n FOR(bits,1,1<<11) {\n for(pair p:hanzen[bits/2]) {\n pair added = make_pair(p.first+weight[bits], p.second+value[bits]);\n hanzen[bits].push_back(p);\n hanzen[bits].push_back(added);\n }\n vector> tmp(hanzen[bits].begin(),hanzen[bits].end());\n sort(tmp.begin(),tmp.end());\n hanzen[bits].clear();\n hanzen[bits].emplace_back(0,0);\n for(pair p:tmp) {\n if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);\n }\n }\n int q;\n cin >> q;\n while(q--) {\n LL v, l;\n cin >> v >> l;\n vector> comb;\n comb.emplace_back(0,0);\n while(v>=(1<<11)) {\n vector> tmp(comb.begin(), comb.end());\n for(pair p:tmp) {\n pair added = make_pair(p.first+weight[v], p.second+value[v]);\n comb.push_back(added);\n }\n v/=2;\n }\n LL answer = 0;\n for(pair p: comb) {\n LL cw,cv;\n tie(cw,cv) = p;\n if(cw>l) continue;\n auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));\n --ite;\n answer=max(answer, cv+ite->second);\n }\n cout << answer << endl;\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592114167, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02648.html", "problem_id": "p02648", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02648/input.txt", "sample_output_relpath": "derived/input_output/data/p02648/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02648/C++/s937100166.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s937100166", "user_id": "u633757735"}, "prompt_components": {"gold_output": "0\n3\n3\n", "input_to_evaluate": "#include \ntypedef long long LL;\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define REP(i,n) FOR(i,0,n)\n\nusing namespace std;\n\nint main(void)\n{\n int n;\n cin >> n;\n vector value(1<<18), weight(1<<18);\n FOR(i,1,n+1) cin >> value[i] >> weight[i];\n vector>> hanzen(1<<11); // weight, value\n hanzen[0].emplace_back(0,0);\n FOR(bits,1,1<<11) {\n for(pair p:hanzen[bits/2]) {\n pair added = make_pair(p.first+weight[bits], p.second+value[bits]);\n hanzen[bits].push_back(p);\n hanzen[bits].push_back(added);\n }\n vector> tmp(hanzen[bits].begin(),hanzen[bits].end());\n sort(tmp.begin(),tmp.end());\n hanzen[bits].clear();\n hanzen[bits].emplace_back(0,0);\n for(pair p:tmp) {\n if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);\n }\n }\n int q;\n cin >> q;\n while(q--) {\n LL v, l;\n cin >> v >> l;\n vector> comb;\n comb.emplace_back(0,0);\n while(v>=(1<<11)) {\n vector> tmp(comb.begin(), comb.end());\n for(pair p:tmp) {\n pair added = make_pair(p.first+weight[v], p.second+value[v]);\n comb.push_back(added);\n }\n v/=2;\n }\n LL answer = 0;\n for(pair p: comb) {\n LL cw,cv;\n tie(cw,cv) = p;\n if(cw>l) continue;\n auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));\n --ite;\n answer=max(answer, cv+ite->second);\n }\n cout << answer << endl;\n }\n\n return 0;\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "sample_input": "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n"}, "reference_outputs": ["0\n3\n3\n"], "source_document_id": "p02648", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1540, "cpu_time_ms": 1266, "memory_kb": 51104}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s714032417", "group_id": "codeNet:p02648", "input_text": "#include\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pa;\n\n#define fst first\n#define snd second\n#define pb push_back\n\nconst int maxn=500005,maxm=512;\nconst double pi=acos(-1.0);\n//const ll mod=1000000007;\nconst ll mod=998244353;\nconst double eps=1e-8;\n\nint dig(int xx)\n{\n for(int i=0;;i++)\n {\n if(xx>>i&1) return i;\n }\n}\n\n\nstruct dat\n{\n int sta;\n ll v,w;\n dat(ll v=0,ll w=0):sta(sta),v(v),w(w){}\n};\n\nint n,q;\nint v[maxn]={0},w[maxn]={0};\n\nll ve[maxm][maxm][2]={0};\n\nvector ans1[maxm];\n\nvector tmp;\n\nll cl2(int vv,int ww)\n{\n int lb=0,ub=ans1[vv].size();\n while(ub-lb>1)\n {\n int mid=(ub+lb)/2;\n if(ans1[vv][mid].fst<=ww) lb=mid;\n else ub=mid;\n }\n return ans1[vv][lb].snd;\n}\n\n\nvoid solve(int vv,int L)\n{\n int i,j;\n if(vv<512)\n {\n for(j=0;;j++) {if((vv<=maxm/2&&(vv<=maxm/2&&vv>(8-dig(j))];\n ve[i][j][1]=ve[i][jj][1]+w[i>>(8-dig(j))];\n }\n }\n for(i=maxm/2;i\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pa;\n\n#define fst first\n#define snd second\n#define pb push_back\n\nconst int maxn=500005,maxm=512;\nconst double pi=acos(-1.0);\n//const ll mod=1000000007;\nconst ll mod=998244353;\nconst double eps=1e-8;\n\nint dig(int xx)\n{\n for(int i=0;;i++)\n {\n if(xx>>i&1) return i;\n }\n}\n\n\nstruct dat\n{\n int sta;\n ll v,w;\n dat(ll v=0,ll w=0):sta(sta),v(v),w(w){}\n};\n\nint n,q;\nint v[maxn]={0},w[maxn]={0};\n\nll ve[maxm][maxm][2]={0};\n\nvector ans1[maxm];\n\nvector tmp;\n\nll cl2(int vv,int ww)\n{\n int lb=0,ub=ans1[vv].size();\n while(ub-lb>1)\n {\n int mid=(ub+lb)/2;\n if(ans1[vv][mid].fst<=ww) lb=mid;\n else ub=mid;\n }\n return ans1[vv][lb].snd;\n}\n\n\nvoid solve(int vv,int L)\n{\n int i,j;\n if(vv<512)\n {\n for(j=0;;j++) {if((vv<=maxm/2&&(vv<=maxm/2&&vv>(8-dig(j))];\n ve[i][j][1]=ve[i][jj][1]+w[i>>(8-dig(j))];\n }\n }\n for(i=maxm/2;i\nusing namespace std;\nusing ll = long long;\nint main() {\nll Z=0;\nstring s;\ncin>>s;\nll rui=0;\nll a=0;\nll f=0;\nll s1=s.size();\nll b[s1+1];\nll c[s1+1];\nfor (ll i=0;i=0;i--){\nb[i]=max(b[i],b[i+1]);}\nfor (ll i=0;i\nusing namespace std;\nusing ll = long long;\nint main() {\nll Z=0;\nstring s;\ncin>>s;\nll rui=0;\nll a=0;\nll f=0;\nll s1=s.size();\nll b[s1+1];\nll c[s1+1];\nfor (ll i=0;i=0;i--){\nb[i]=max(b[i],b[i+1]);}\nfor (ll i=0;i\nusing namespace std;\n\nconst int maxn = 5010, P = 1000000007;\nint n, A, B, ans, pw[maxn], f[maxn][maxn][2], pre[maxn][maxn][2], h[maxn];\n\nint main() {\n scanf(\"%d %d %d\", &n, &A, &B);\n if (A < B) swap(A, B);\n pw[0] = pw[1] = 1;\n for (int i = 2; i <= n; i++) {\n pw[i] = (pw[i - 1] + pw[i - 1]) % P;\n }\n f[0][0][0] = f[0][0][1] = 1, h[0] = 1;\n pre[0][0][0] = pre[0][0][1] = 1;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= i; j++) {\n (f[i][j][0] += pre[i - 1][i - j][1]) %= P;\n (f[i][j][1] += pre[i - B][i - j][0]) %= P;\n }\n for (int j = max(0, i - B + 1); j < i; j++) {\n (f[i][0][1] += h[j]) %= P;\n }\n for (int j = A; j <= i; j++) {\n int s = 1LL * (f[i][j][0] + f[i][j][1]) * pw[n - i] % P;\n (ans += s) %= P, f[i][j][0] = f[i][j][1] = 0;\n }\n for (int j = 0; j <= i; j++) {\n (h[i] += f[i][j][0]) %= P;\n pre[i][i - j][0] = (pre[i - 1][i - j][0] + f[i][j][0]) % P;\n pre[i][i - j][1] = (pre[i - 1][i - j][1] + f[i][j][1]) % P;\n }\n }\n printf(\"%d\\n\", (ans + P) % P);\n return 0;\n}", "language": "C++", "metadata": {"date": 1591857700, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02653.html", "problem_id": "p02653", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02653/input.txt", "sample_output_relpath": "derived/input_output/data/p02653/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02653/C++/s413711993.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s413711993", "user_id": "u813182415"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "#include \nusing namespace std;\n\nconst int maxn = 5010, P = 1000000007;\nint n, A, B, ans, pw[maxn], f[maxn][maxn][2], pre[maxn][maxn][2], h[maxn];\n\nint main() {\n scanf(\"%d %d %d\", &n, &A, &B);\n if (A < B) swap(A, B);\n pw[0] = pw[1] = 1;\n for (int i = 2; i <= n; i++) {\n pw[i] = (pw[i - 1] + pw[i - 1]) % P;\n }\n f[0][0][0] = f[0][0][1] = 1, h[0] = 1;\n pre[0][0][0] = pre[0][0][1] = 1;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= i; j++) {\n (f[i][j][0] += pre[i - 1][i - j][1]) %= P;\n (f[i][j][1] += pre[i - B][i - j][0]) %= P;\n }\n for (int j = max(0, i - B + 1); j < i; j++) {\n (f[i][0][1] += h[j]) %= P;\n }\n for (int j = A; j <= i; j++) {\n int s = 1LL * (f[i][j][0] + f[i][j][1]) * pw[n - i] % P;\n (ans += s) %= P, f[i][j][0] = f[i][j][1] = 0;\n }\n for (int j = 0; j <= i; j++) {\n (h[i] += f[i][j][0]) %= P;\n pre[i][i - j][0] = (pre[i - 1][i - j][0] + f[i][j][0]) % P;\n pre[i][i - j][1] = (pre[i - 1][i - j][1] + f[i][j][1]) % P;\n }\n }\n printf(\"%d\\n\", (ans + P) % P);\n return 0;\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nSnuke has a string x of length N.\nInitially, every character in x is 0.\n\nSnuke can do the following two operations any number of times in any order:\n\nChoose A consecutive characters in x and replace each of them with 0.\n\nChoose B consecutive characters in x and replace each of them with 1.\n\nFind the number of different strings that x can be after Snuke finishes doing operations.\nThis count can be enormous, so compute it modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq A,B \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of different strings that x can be after Snuke finishes doing operations, modulo (10^9+7).\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n11\n\nFor example, x can be 0011 or 1111 in the end, but cannot be 0110.\n\nSample Input 2\n\n10 7 2\n\nSample Output 2\n\n533\n\nSample Input 3\n\n1000 100 10\n\nSample Output 3\n\n828178524", "sample_input": "4 2 3\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02653", "source_text": "Score : 800 points\n\nProblem Statement\n\nSnuke has a string x of length N.\nInitially, every character in x is 0.\n\nSnuke can do the following two operations any number of times in any order:\n\nChoose A consecutive characters in x and replace each of them with 0.\n\nChoose B consecutive characters in x and replace each of them with 1.\n\nFind the number of different strings that x can be after Snuke finishes doing operations.\nThis count can be enormous, so compute it modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq A,B \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of different strings that x can be after Snuke finishes doing operations, modulo (10^9+7).\n\nSample Input 1\n\n4 2 3\n\nSample Output 1\n\n11\n\nFor example, x can be 0011 or 1111 in the end, but cannot be 0110.\n\nSample Input 2\n\n10 7 2\n\nSample Output 2\n\n533\n\nSample Input 3\n\n1000 100 10\n\nSample Output 3\n\n828178524", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1187, "cpu_time_ms": 266, "memory_kb": 237152}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s526850861", "group_id": "codeNet:p02657", "input_text": "#include\n#include\n#include\nusing namespace std;\n\nint n,m;\nint main()\n{\n cin>>n>>m;\n cout<\n#include\n#include\nusing namespace std;\n\nint n,m;\nint main()\n{\n cin>>n>>m;\n cout<\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#define ll long long\nusing namespace std;\n\nint main(){\n\tint a,b;\n\twhile(scanf(\"%d%d\",&a,&b)==2)\n {\n printf(\"%d\\n\",a*b);\n }\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1590973277, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/C++/s679332258.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679332258", "user_id": "u987474395"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#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#define ll long long\nusing namespace std;\n\nint main(){\n\tint a,b;\n\twhile(scanf(\"%d%d\",&a,&b)==2)\n {\n printf(\"%d\\n\",a*b);\n }\n\treturn 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 567, "cpu_time_ms": 5, "memory_kb": 3816}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s152557954", "group_id": "codeNet:p02657", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair P;\nconst int maxn = 500050;\nconst int inf = 0x3f3f3f3f;\nconst int mod = 998244353;\nconst ll linf = 7e18;\nll power(ll x, ll y)\n{\n ll ans = 1;\n while (y)\n {\n if (y & 1)\n ans = ans * x % mod;\n x = x * x % mod;\n y >>= 1;\n }\n return ans;\n}\n\nll gcd(ll x, ll y)\n{\n if (x % y == 0)\n return y;\n return gcd(y, x % y);\n}\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n int n, m;\n cin >> n >> m;\n cout << n * m << \"\\n\";\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1590973265, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/C++/s152557954.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152557954", "user_id": "u526466255"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair P;\nconst int maxn = 500050;\nconst int inf = 0x3f3f3f3f;\nconst int mod = 998244353;\nconst ll linf = 7e18;\nll power(ll x, ll y)\n{\n ll ans = 1;\n while (y)\n {\n if (y & 1)\n ans = ans * x % mod;\n x = x * x % mod;\n y >>= 1;\n }\n return ans;\n}\n\nll gcd(ll x, ll y)\n{\n if (x % y == 0)\n return y;\n return gcd(y, x % y);\n}\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n int n, m;\n cin >> n >> m;\n cout << n * m << \"\\n\";\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 4, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s156539410", "group_id": "codeNet:p02661", "input_text": "#include \n\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n int A[n], B[n];\n for(int i=0; i> A[i] >> B[i];\n\n sort(A, A+n);\n sort(B, B+n);\n\n int left, right;\n if(n%2 == 0) {\n left = A[n/2-1] + A[n/2];\n right = B[n/2-1] + B[n/2];\n } else {\n left = A[n/2];\n right = B[n/2];\n }\n\n cout << right - left +1 << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1591051772, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02661/input.txt", "sample_output_relpath": "derived/input_output/data/p02661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02661/C++/s156539410.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156539410", "user_id": "u878967567"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n int A[n], B[n];\n for(int i=0; i> A[i] >> B[i];\n\n sort(A, A+n);\n sort(B, B+n);\n\n int left, right;\n if(n%2 == 0) {\n left = A[n/2-1] + A[n/2];\n right = B[n/2-1] + B[n/2];\n } else {\n left = A[n/2];\n right = B[n/2];\n }\n\n cout << right - left +1 << endl;\n\n return 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 423, "cpu_time_ms": 144, "memory_kb": 5056}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s700440446", "group_id": "codeNet:p02661", "input_text": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tint N;\n\tcin >> N;\n\tvector< pair> AB(N);\n\tfor (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;\n\n\tif (N % 2 == 0) {\n\t\tsort(AB.begin(), AB.end());\n\t\tdouble Amin = AB[N / 2 - 1].first;\n\t\tdouble Amax = min(AB[N / 2 - 1].second, AB[N / 2].second);\n\t\tsort(AB.begin(), AB.end(), [](auto& a, auto& b) {return a.second > b.second; });\n\t\tdouble Bmin = max(AB[N / 2].first, AB[N / 2 - 1].first);\n\t\tdouble Bmax = AB[N / 2 - 1].second;\n\t\tcout << ((Amax + Bmax) / 2 - (Amin + Bmin) / 2) * 2 + 1 << endl;\n\t}\n\telse {\n\t\tsort(AB.begin(), AB.end());\n\t\tdouble Amin = AB[(N - 1) / 2].first;\n\t\tdouble Amax = min(AB[(N - 1) / 2].second, AB[(N + 1) / 2].second);\n\t\tsort(AB.begin(), AB.end(), [](auto& a, auto& b) {return a.second > b.second; });\n\t\tdouble Bmin = max(AB[(N - 1) / 2].first, AB[(N + 1) / 2].first);\n\t\tdouble Bmax = AB[(N - 1) / 2].second;\n\t\tif (Amax < Bmin) cout << (Amax - Amin) + 1 + (Bmax - Bmin) + 1;\n\t\telse cout << Bmax - Amin + 1;\n\t}\n\n}\n", "language": "C++", "metadata": {"date": 1590978196, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02661/input.txt", "sample_output_relpath": "derived/input_output/data/p02661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02661/C++/s700440446.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s700440446", "user_id": "u868132236"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tint N;\n\tcin >> N;\n\tvector< pair> AB(N);\n\tfor (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;\n\n\tif (N % 2 == 0) {\n\t\tsort(AB.begin(), AB.end());\n\t\tdouble Amin = AB[N / 2 - 1].first;\n\t\tdouble Amax = min(AB[N / 2 - 1].second, AB[N / 2].second);\n\t\tsort(AB.begin(), AB.end(), [](auto& a, auto& b) {return a.second > b.second; });\n\t\tdouble Bmin = max(AB[N / 2].first, AB[N / 2 - 1].first);\n\t\tdouble Bmax = AB[N / 2 - 1].second;\n\t\tcout << ((Amax + Bmax) / 2 - (Amin + Bmin) / 2) * 2 + 1 << endl;\n\t}\n\telse {\n\t\tsort(AB.begin(), AB.end());\n\t\tdouble Amin = AB[(N - 1) / 2].first;\n\t\tdouble Amax = min(AB[(N - 1) / 2].second, AB[(N + 1) / 2].second);\n\t\tsort(AB.begin(), AB.end(), [](auto& a, auto& b) {return a.second > b.second; });\n\t\tdouble Bmin = max(AB[(N - 1) / 2].first, AB[(N + 1) / 2].first);\n\t\tdouble Bmax = AB[(N - 1) / 2].second;\n\t\tif (Amax < Bmin) cout << (Amax - Amin) + 1 + (Bmax - Bmin) + 1;\n\t\telse cout << Bmax - Amin + 1;\n\t}\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1048, "cpu_time_ms": 143, "memory_kb": 4844}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s702672358", "group_id": "codeNet:p02663", "input_text": " #include\n//#include \n//#include \n#define ll long long\n#define pb push_back\n#define mod 1000000007\n#define ff first\n#define ss second\n#define pi 3.1415926535\n#define endl '\\n'\nusing namespace std;\nstruct custom {\n static uint64_t splitmix64(uint64_t x)\n {\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\n//using namespace __gnu_pbds;\n//typedef tree,rb_tree_tag,tree_order_statistics_node_update> indexed_set;\nconst ll inf=1e19;\n/*ll power(ll x,ll y)\n{\n ll res=1;\n while(y>0)\n {\n if(y%2==1)\n res=(res*x)%mod;\n x=(x*x)%mod;\n y=(y>>1);\n }\n return res;\n}*/\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n ll a,b,c,d,x,y,r,k;\n cin>>a>>b>>c>>d>>k;\n x=a*60+b;\n y=c*60+d;\n x=abs(x-y);\n cout<\n//#include \n//#include \n#define ll long long\n#define pb push_back\n#define mod 1000000007\n#define ff first\n#define ss second\n#define pi 3.1415926535\n#define endl '\\n'\nusing namespace std;\nstruct custom {\n static uint64_t splitmix64(uint64_t x)\n {\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\n//using namespace __gnu_pbds;\n//typedef tree,rb_tree_tag,tree_order_statistics_node_update> indexed_set;\nconst ll inf=1e19;\n/*ll power(ll x,ll y)\n{\n ll res=1;\n while(y>0)\n {\n if(y%2==1)\n res=(res*x)%mod;\n x=(x*x)%mod;\n y=(y>>1);\n }\n return res;\n}*/\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n ll a,b,c,d,x,y,r,k;\n cin>>a>>b>>c>>d>>k;\n x=a*60+b;\n y=c*60+d;\n x=abs(x-y);\n cout<\n \n#define int long long\n#define uint unsigned int\n#define ld long double\n#define showoff ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define pb push_back\n#define pii pair\n#define FOR(i,a,b) for(int i=a;ib;--i)\n#define f first\n#define se second\n#define maxn 200005\n#define all(v) v.begin(),v.end()\n#define sz(x) (int)x.size()\n#define mod 998244353\n#define pqueue priority_queue\n#define pdqueue priority_queue< int,vector ,greater< int >>\n \nusing namespace std;\n \n \nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n \nint power(int a,int n)\n{\n a %= mod;\n if(n == 1)return a;\n if(n == 0)return 1;\n if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;\n return power((a*a)%mod,n/2)%mod;\n}\n \nconst int inf = (int) 1e18;\n \nint inverse(int x){\n return power(x,mod-2)%mod;//little fermat....\n} \n\nvoid solve(){\n int h1,m1,h2,m2,k;\n cin >> h1 >> m1 >> h2 >> m2 >> k;\n int tot = 0;\n if(h2 > h1)tot = m2+(h2-h1-1)*60+60-m1;\n else tot = m2-m1;\n cout << max(0LL,tot-k) << \"\\n\";\n} \n\n \nsigned main() \n{\n showoff;\n int T = 1;\n //cin >> T;\n FOR(t,1,T+1){\n solve();\n cout << \"\\n\";\n }\n return 0;\n}\n//*->for large size of matrix take int not long long if possible......\n//*->always take maximum as inf for safer side ...", "language": "C++", "metadata": {"date": 1590887555, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/C++/s048515025.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048515025", "user_id": "u578751202"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "#include \n \n#define int long long\n#define uint unsigned int\n#define ld long double\n#define showoff ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define pb push_back\n#define pii pair\n#define FOR(i,a,b) for(int i=a;ib;--i)\n#define f first\n#define se second\n#define maxn 200005\n#define all(v) v.begin(),v.end()\n#define sz(x) (int)x.size()\n#define mod 998244353\n#define pqueue priority_queue\n#define pdqueue priority_queue< int,vector ,greater< int >>\n \nusing namespace std;\n \n \nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n \nint power(int a,int n)\n{\n a %= mod;\n if(n == 1)return a;\n if(n == 0)return 1;\n if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;\n return power((a*a)%mod,n/2)%mod;\n}\n \nconst int inf = (int) 1e18;\n \nint inverse(int x){\n return power(x,mod-2)%mod;//little fermat....\n} \n\nvoid solve(){\n int h1,m1,h2,m2,k;\n cin >> h1 >> m1 >> h2 >> m2 >> k;\n int tot = 0;\n if(h2 > h1)tot = m2+(h2-h1-1)*60+60-m1;\n else tot = m2-m1;\n cout << max(0LL,tot-k) << \"\\n\";\n} \n\n \nsigned main() \n{\n showoff;\n int T = 1;\n //cin >> T;\n FOR(t,1,T+1){\n solve();\n cout << \"\\n\";\n }\n return 0;\n}\n//*->for large size of matrix take int not long long if possible......\n//*->always take maximum as inf for safer side ...", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1486, "cpu_time_ms": 2, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s859744047", "group_id": "codeNet:p02664", "input_text": "#include \n#include \nusing namespace std;\n\nint main() {\n string t;\n cin >> t;\n int i;\n for(i=0;i<(int)t.size();i++){\n if(t.at(i)=='?'){\n t.at(i)='D';\n }\n }\n cout << t << endl;\n}", "language": "C++", "metadata": {"date": 1590892682, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/C++/s859744047.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859744047", "user_id": "u714851895"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint main() {\n string t;\n cin >> t;\n int i;\n for(i=0;i<(int)t.size();i++){\n if(t.at(i)=='?'){\n t.at(i)='D';\n }\n }\n cout << t << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 14, "memory_kb": 3676}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s936829179", "group_id": "codeNet:p02664", "input_text": "#include \n#include \nusing namespace std;\n\nint main()\n{\n\tstring s;\n cin >> s;\n int l =s.length();\n for(int i=0;i=0 && s[i-1]=='P')\n {\n\t\t\t\ts[i]='D';\n }\n else if(i-1>=0 && s[i-1]=='P' && i+1\n#include \nusing namespace std;\n\nint main()\n{\n\tstring s;\n cin >> s;\n int l =s.length();\n for(int i=0;i=0 && s[i-1]=='P')\n {\n\t\t\t\ts[i]='D';\n }\n else if(i-1>=0 && s[i-1]=='P' && i+1\n#include \n#include \nusing namespace std;\n\nint main() {\n string T;\n cin >> T;\n int len = T.size();\n string n = \"\";\n for (int i=0; i < len; i++) {\n if (T[i] == '?') {\n if (i == (len -1)) {\n n += \"D\";\n } else if (i > 0 && T[i-1] == 'P') {\n n += \"D\";\n } else if (i < (len - 1) && T[i+1] == 'P') {\n n += \"D\";\n }\n else {\n n += \"P\";\n }\n } else {\n n += T[i];\n }\n }\n\n cout << n << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1590887729, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/C++/s000458005.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s000458005", "user_id": "u651314218"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n string T;\n cin >> T;\n int len = T.size();\n string n = \"\";\n for (int i=0; i < len; i++) {\n if (T[i] == '?') {\n if (i == (len -1)) {\n n += \"D\";\n } else if (i > 0 && T[i-1] == 'P') {\n n += \"D\";\n } else if (i < (len - 1) && T[i+1] == 'P') {\n n += \"D\";\n }\n else {\n n += \"P\";\n }\n } else {\n n += T[i];\n }\n }\n\n cout << n << endl;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 14, "memory_kb": 3924}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s200875344", "group_id": "codeNet:p02664", "input_text": "#include\ntypedef long long ll;\ntypedef long double ld;\nusing namespace std;\n\nusing Pii = pair;\nusing Pll = pair;\n\n#define REP(i, l, n) for(int i=(l), i##_len=(n); i> t;\n REP(i, 0, t.size()){\n if(t[i] == '?'){\n cout << \"D\";\n }else{\n cout << t[i];\n }\n }\n cout << endl;\n}", "language": "C++", "metadata": {"date": 1590887089, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/C++/s200875344.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200875344", "user_id": "u639426108"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "#include\ntypedef long long ll;\ntypedef long double ld;\nusing namespace std;\n\nusing Pii = pair;\nusing Pll = pair;\n\n#define REP(i, l, n) for(int i=(l), i##_len=(n); i> t;\n REP(i, 0, t.size()){\n if(t[i] == '?'){\n cout << \"D\";\n }else{\n cout << t[i];\n }\n }\n cout << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 750, "cpu_time_ms": 19, "memory_kb": 3724}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s333941648", "group_id": "codeNet:p02665", "input_text": "#include \n\nusing namespace std;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef vector vll;\ntypedef pair pairll;\n\n#define sll(x) scanf(\"%lld\",&x);\n#define READ freopen(\"in.txt\",\"r\",stdin)\n#define WRITE freopen(\"out.txt\",\"w\",stdout)\n\n#define ff first\n#define ss second\n\ninline ll readInt()\n{\n ll in; scanf(\"%lld\",&in); return in;\n}\n\ninline ll ADD(ll a, ll b, ll mod)\n{\n return (a + b + mod + mod)%mod;\n}\n\ninline ll SUBS(ll a, ll b, ll mod)\n{\n return (a-b+mod + mod) %mod;\n}\n\ninline ll MUL(ll a, ll b, ll mod)\n{\n return (a*b + mod)%mod;\n}\n\nll bigMod(ll base, ll power, ll mod)\n{\n if(!power) return 1;\n if(!base) return 0;\n\n ll temp = bigMod(base, power/2, mod);\n\n if(power%2 == 0)\n {\n return (temp*temp)%mod;\n }\n else return (((temp*temp)%mod)*base)%mod;\n}\n\ninline ll modInverse(ll a, ll modp)\n{\n return bigMod(a, modp -2, modp);\n}\n\ninline ll modInverseExtended(ll a, ll m) \n{ \n ll m0 = m; \n ll y = 0, x = 1; \n \n if (m == 1) \n return 0; \n \n while (a > 1) \n { \n // q is quotient \n ll q = a / m; \n ll t = m; \n \n // m is remainder now, process same as \n // Euclid's algo \n m = a % m, a = t; \n t = y; \n \n // Update y and x \n y = x - q * y; \n x = t; \n } \n \n // Make x positive \n if (x < 0) \n x += m0; \n \n return x; \n} \n \n\nvoid autoinput()\n{\n #ifndef ONLINE_JUDGE\n READ; \n //WRITE;\n\n #endif\n}\n\nint main()\n{\n autoinput();\n\n ll N;\n\n sll(N);\n\n vector leaves(N+1), freedom(N+1);\n\n freedom[0] = 1;\n\n for(ll i = 0; i <= N; i++)\n {\n sll(leaves[i]);\n }\n\n for(ll i = 0; i <= N; i++)\n {\n if(!i)\n { \n freedom[i] -= leaves[i];\n }\n else\n {\n if(freedom[i-1] < INT64_MAX/10) freedom[i] = 2*freedom[i-1] - leaves[i];\n else freedom[i] = freedom[i-1];\n }\n\n if(freedom[i] < 0)\n {\n puts(\"-1\"); return 0;\n }\n\n }\n\n vll tree(N+1);\n\n\n tree[N] = leaves[N];\n\n ll sum = tree[N];\n \n for(ll i = N-1; i >= 0; i--)\n {\n tree[i] = min(freedom[i],tree[i+1]);\n tree[i] += leaves[i];\n\n sum += tree[i];\n\n }\n\n printf(\"%lld\\n\",sum);\n\n}\n\n", "language": "C++", "metadata": {"date": 1590897296, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02665/input.txt", "sample_output_relpath": "derived/input_output/data/p02665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02665/C++/s333941648.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s333941648", "user_id": "u075588643"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef vector vll;\ntypedef pair pairll;\n\n#define sll(x) scanf(\"%lld\",&x);\n#define READ freopen(\"in.txt\",\"r\",stdin)\n#define WRITE freopen(\"out.txt\",\"w\",stdout)\n\n#define ff first\n#define ss second\n\ninline ll readInt()\n{\n ll in; scanf(\"%lld\",&in); return in;\n}\n\ninline ll ADD(ll a, ll b, ll mod)\n{\n return (a + b + mod + mod)%mod;\n}\n\ninline ll SUBS(ll a, ll b, ll mod)\n{\n return (a-b+mod + mod) %mod;\n}\n\ninline ll MUL(ll a, ll b, ll mod)\n{\n return (a*b + mod)%mod;\n}\n\nll bigMod(ll base, ll power, ll mod)\n{\n if(!power) return 1;\n if(!base) return 0;\n\n ll temp = bigMod(base, power/2, mod);\n\n if(power%2 == 0)\n {\n return (temp*temp)%mod;\n }\n else return (((temp*temp)%mod)*base)%mod;\n}\n\ninline ll modInverse(ll a, ll modp)\n{\n return bigMod(a, modp -2, modp);\n}\n\ninline ll modInverseExtended(ll a, ll m) \n{ \n ll m0 = m; \n ll y = 0, x = 1; \n \n if (m == 1) \n return 0; \n \n while (a > 1) \n { \n // q is quotient \n ll q = a / m; \n ll t = m; \n \n // m is remainder now, process same as \n // Euclid's algo \n m = a % m, a = t; \n t = y; \n \n // Update y and x \n y = x - q * y; \n x = t; \n } \n \n // Make x positive \n if (x < 0) \n x += m0; \n \n return x; \n} \n \n\nvoid autoinput()\n{\n #ifndef ONLINE_JUDGE\n READ; \n //WRITE;\n\n #endif\n}\n\nint main()\n{\n autoinput();\n\n ll N;\n\n sll(N);\n\n vector leaves(N+1), freedom(N+1);\n\n freedom[0] = 1;\n\n for(ll i = 0; i <= N; i++)\n {\n sll(leaves[i]);\n }\n\n for(ll i = 0; i <= N; i++)\n {\n if(!i)\n { \n freedom[i] -= leaves[i];\n }\n else\n {\n if(freedom[i-1] < INT64_MAX/10) freedom[i] = 2*freedom[i-1] - leaves[i];\n else freedom[i] = freedom[i-1];\n }\n\n if(freedom[i] < 0)\n {\n puts(\"-1\"); return 0;\n }\n\n }\n\n vll tree(N+1);\n\n\n tree[N] = leaves[N];\n\n ll sum = tree[N];\n \n for(ll i = N-1; i >= 0; i--)\n {\n tree[i] = min(freedom[i],tree[i+1]);\n tree[i] += leaves[i];\n\n sum += tree[i];\n\n }\n\n printf(\"%lld\\n\",sum);\n\n}\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2390, "cpu_time_ms": 24, "memory_kb": 5604}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s433788519", "group_id": "codeNet:p02670", "input_text": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"avx2\")\n//#include\n#include\n#include\n#include\n\nusing namespace std;\ntypedef long long ll;\n#define rep(i, n) for(int i = 0; i < (n); i++)\n#define rep1(i, n) for(int i = 1; i <= (n); i++)\n#define co(x) cout << (x) << \"\\n\"\n#define cosp(x) cout << (x) << \" \"\n#define ce(x) cerr << (x) << \"\\n\"\n#define cesp(x) cerr << (x) << \" \"\n#define pb push_back\n#define mp make_pair\n#define chmin(x, y) x = min(x, y)\n#define chmax(x, y) x = max(x, y)\n#define Would\n#define you\n#define please\n\nconst int CM = 1 << 17, CL = 12;\nchar cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;\nconst ll ma0 = 1157442765409226768;\nconst ll ma1 = 1085102592571150095;\nconst ll ma2 = 71777214294589695;\nconst ll ma3 = 281470681808895;\nconst ll ma4 = 4294967295;\ninline int getint() {\n\tif (ci - owa > 0) {\n\t\tmemcpy(cn, owa, CL);\n\t\tci -= CM;\n\t\tfread(cn + CL, 1, CM, stdin);\n\t}\n\tll tmp = *(ll*)ci;\n\tint dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);\n\ttmp = tmp << dig & ma1;\n\ttmp = tmp * 10 + (tmp >> 8) & ma2;\n\ttmp = tmp * 100 + (tmp >> 16) & ma3;\n\ttmp = tmp * 10000 + (tmp >> 32) & ma4;\n\tci += 72 - dig >> 3;\n\treturn tmp;\n}\n\nunsigned char D[252004];\nbool E[252004];\nint Q[252004];\nint main() {\n\t//cin.tie(0);\n\t//ios::sync_with_stdio(false);\n\n\n\tint N = getint();\n\tint n = N + 2;\n\trep1(i, N) {\n\t\tint ij = n * i + 1;\n\t\tunsigned char kari = min(i - 1, N - i);\n\t\tunsigned char kari2 = 3;\n\n\t\trep(j, kari) {\n\t\t\tD[ij++] = kari2++;\n\t\t}\n\t\trep(j, N - kari - kari) {\n\t\t\tD[ij++] = kari + 3;\n\t\t}\n\t\trep(j, kari) {\n\t\t\tD[ij++] = --kari2;\n\t\t}\n\t}\n\n\tint kotae = 0;\n\trep(k, N * N) {\n\t\tint ij = getint();\n\t\tij += (ij - 1) / N * 2 + N + 2;\n\n\t\tkotae += D[ij];\n\t\tE[ij] = 1;\n\n\t\tint p = 0, q = 0;\n\t\tQ[p++] = ij;\n\n\t\twhile (p > q) {\n\t\t\tint ij = Q[q++];\n\t\t\tint d =\tD[ij] - E[ij] + 1;\n\n\t\t\tif (D[ij - n] > d) {\n\t\t\t\tD[ij - n] = d;\n\t\t\t\tQ[p++] = ij - n;\n\t\t\t}\n\t\t\tif (D[ij + n] > d) {\n\t\t\t\tD[ij + n] = d;\n\t\t\t\tQ[p++] = ij + n;\n\t\t\t}\n\t\t\tif (D[ij - 1] > d) {\n\t\t\t\tD[ij - 1] = d;\n\t\t\t\tQ[p++] = ij - 1;\n\t\t\t}\n\t\t\tif (D[ij + 1] > d) {\n\t\t\t\tD[ij + 1] = d;\n\t\t\t\tQ[p++] = ij + 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", kotae - 3 * N * N);\n\n\n\n\tWould you please return 0;\n}", "language": "C++", "metadata": {"date": 1590957593, "filename_ext": "cpp", "original_language": "C++ (Clang 10.0.0)", "problem_description_relpath": "problem_descriptions/p02670.html", "problem_id": "p02670", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02670/input.txt", "sample_output_relpath": "derived/input_output/data/p02670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02670/C++/s433788519.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433788519", "user_id": "u096883693"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"avx2\")\n//#include\n#include\n#include\n#include\n\nusing namespace std;\ntypedef long long ll;\n#define rep(i, n) for(int i = 0; i < (n); i++)\n#define rep1(i, n) for(int i = 1; i <= (n); i++)\n#define co(x) cout << (x) << \"\\n\"\n#define cosp(x) cout << (x) << \" \"\n#define ce(x) cerr << (x) << \"\\n\"\n#define cesp(x) cerr << (x) << \" \"\n#define pb push_back\n#define mp make_pair\n#define chmin(x, y) x = min(x, y)\n#define chmax(x, y) x = max(x, y)\n#define Would\n#define you\n#define please\n\nconst int CM = 1 << 17, CL = 12;\nchar cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;\nconst ll ma0 = 1157442765409226768;\nconst ll ma1 = 1085102592571150095;\nconst ll ma2 = 71777214294589695;\nconst ll ma3 = 281470681808895;\nconst ll ma4 = 4294967295;\ninline int getint() {\n\tif (ci - owa > 0) {\n\t\tmemcpy(cn, owa, CL);\n\t\tci -= CM;\n\t\tfread(cn + CL, 1, CM, stdin);\n\t}\n\tll tmp = *(ll*)ci;\n\tint dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);\n\ttmp = tmp << dig & ma1;\n\ttmp = tmp * 10 + (tmp >> 8) & ma2;\n\ttmp = tmp * 100 + (tmp >> 16) & ma3;\n\ttmp = tmp * 10000 + (tmp >> 32) & ma4;\n\tci += 72 - dig >> 3;\n\treturn tmp;\n}\n\nunsigned char D[252004];\nbool E[252004];\nint Q[252004];\nint main() {\n\t//cin.tie(0);\n\t//ios::sync_with_stdio(false);\n\n\n\tint N = getint();\n\tint n = N + 2;\n\trep1(i, N) {\n\t\tint ij = n * i + 1;\n\t\tunsigned char kari = min(i - 1, N - i);\n\t\tunsigned char kari2 = 3;\n\n\t\trep(j, kari) {\n\t\t\tD[ij++] = kari2++;\n\t\t}\n\t\trep(j, N - kari - kari) {\n\t\t\tD[ij++] = kari + 3;\n\t\t}\n\t\trep(j, kari) {\n\t\t\tD[ij++] = --kari2;\n\t\t}\n\t}\n\n\tint kotae = 0;\n\trep(k, N * N) {\n\t\tint ij = getint();\n\t\tij += (ij - 1) / N * 2 + N + 2;\n\n\t\tkotae += D[ij];\n\t\tE[ij] = 1;\n\n\t\tint p = 0, q = 0;\n\t\tQ[p++] = ij;\n\n\t\twhile (p > q) {\n\t\t\tint ij = Q[q++];\n\t\t\tint d =\tD[ij] - E[ij] + 1;\n\n\t\t\tif (D[ij - n] > d) {\n\t\t\t\tD[ij - n] = d;\n\t\t\t\tQ[p++] = ij - n;\n\t\t\t}\n\t\t\tif (D[ij + n] > d) {\n\t\t\t\tD[ij + n] = d;\n\t\t\t\tQ[p++] = ij + n;\n\t\t\t}\n\t\t\tif (D[ij - 1] > d) {\n\t\t\t\tD[ij - 1] = d;\n\t\t\t\tQ[p++] = ij - 1;\n\t\t\t}\n\t\t\tif (D[ij + 1] > d) {\n\t\t\t\tD[ij + 1] = d;\n\t\t\t\tQ[p++] = ij + 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", kotae - 3 * N * N);\n\n\n\n\tWould you please return 0;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "sample_input": "3\n1 3 7 9 5 4 8 6 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02670", "source_text": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2169, "cpu_time_ms": 167, "memory_kb": 4512}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s462404729", "group_id": "codeNet:p02670", "input_text": "#include \n\n#define ll long long\n\nusing namespace std;\n\nconst int MAXN = 250010;\nconst int MAXM = 10010;\nconst int MAXINT = 2147483647;\nconst int INF = 0x3f3f3f3f;\nconst int mod = 1e9 + 7;\n\nint n, m, k;\nint ans, tot, cnt;\n\nint a[MAXM][MAXM];\nint vis[MAXM][MAXM];\n\nstring s;\n\ninline int read() {\n\tint s = 0, f = 1;\n\tchar ch = getchar();\n\twhile ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}\n\twhile ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}\n\treturn s * f;\n}\n\nint d[] = {-1, 1, n, -n};\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\n\nvoid Bfs(int s) {\n\tqueue qx, qy;\n\tqueue q1;\n\tqx.push((s - 1) / n + 1);\n\tqy.push((s - 1) % n + 1);\n//\tprintf(\"%d %d\\n\", qx.front(), qy.front());\n\tq1.push(0);\n\tmemset(vis, 0, sizeof(vis));\n//\tvis[z] = 0;\n\tint res = INF;\n\twhile (qx.size()) {\n\t\tint x = qx.front(), y = qy.front(), t = q1.front();\n\t\tqx.pop(); qy.pop();\n\t\tq1.pop();\n\t\tvis[x][y] = 1;\n//\t\tif (x % n == 1 || x <= n || x > n * n - n || x % n == 0)\n\t\tif (x == 1 || x == n || y == 1 || y == n) {\n\t\t\tres = min(res, t);\n//\t\t\tprintf(\"finish: %d\\n\", t);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (int i = 0; i < 4; i++) {\n\t\t\tint xx = x + dx[i];\n\t\t\tint yy = y + dy[i];\n\t\t\tif (1 <= xx && xx <= n && 1 <= yy && yy <= n && !vis[xx][yy]) {\n\t\t\t\tqx.push(xx);\n\t\t\t\tqy.push(yy);\n\t\t\t\tq1.push(t + a[xx][yy]);\n\t\t\t}\n//\t\t\tif (x / n * n < x + d[i] && x + d[i] <= x / n * n + n && !vis[x + d[i]]) {\n//\t\t\t\tq.push(x + d[i]);\n//\t\t\t\tq1.push(t + e[x][i]);\n//\t\t\t}\n\t\t}\n//\t\tfor (int i = 2; i < 4; i++) {\n//\t\t\tif (0 < x + d[i] && x + d[i] <= n * n && !vis[x + d[i]]) {\n//\t\t\t\tq.push(x + d[i]);\n//\t\t\t\tq1.push(t + e[x][i]);\n//\t\t\t}\n//\t\t}\n\t}\n\tans += res;\n\treturn;\n}\n\nint p[MAXN];\n\nint main(){\n\tint T;\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n * n; i++) {\n\t\tscanf(\"%d\", &p[i]);\n\t}\n//\tfor (int i = 1; i <= n * n; i++) {\n//\t\tint c = i;\n//\t\te[c][1] = e[c][2] = e[c][3] = e[c][0] = 1;\n//\t}\n\tfor (int i = 1; i <= n; i++) {\n\t\tfor (int j = 1; j <= n; j++) {\n\t\t\ta[i][j] = 1;\n\t\t}\n\t}\n\t\t\n\tfor (int i = 1; i <= n * n; i++) {\n\t\tBfs(p[i]);\n\t\ta[(p[i] - 1) / n + 1][(p[i] - 1) % n + 1] = 0;\n//\t\tint c = n * (p[i] - 1) + p[i];\n////\t\te[c][1] = e[c][2] = e[c][3] = e[c][4] = 0;\n//\t\tif (c > n) e[c - n][2] = 0;\n//\t\tif (c < n * n - n + 1) e[c + n][3] = 0;\n//\t\te[c - 1][0] = e[c + 1][1] = 0;\n//\t\tprint();\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n\n", "language": "C++", "metadata": {"date": 1590288013, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02670.html", "problem_id": "p02670", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02670/input.txt", "sample_output_relpath": "derived/input_output/data/p02670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02670/C++/s462404729.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s462404729", "user_id": "u965377001"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\n#define ll long long\n\nusing namespace std;\n\nconst int MAXN = 250010;\nconst int MAXM = 10010;\nconst int MAXINT = 2147483647;\nconst int INF = 0x3f3f3f3f;\nconst int mod = 1e9 + 7;\n\nint n, m, k;\nint ans, tot, cnt;\n\nint a[MAXM][MAXM];\nint vis[MAXM][MAXM];\n\nstring s;\n\ninline int read() {\n\tint s = 0, f = 1;\n\tchar ch = getchar();\n\twhile ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}\n\twhile ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}\n\treturn s * f;\n}\n\nint d[] = {-1, 1, n, -n};\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\n\nvoid Bfs(int s) {\n\tqueue qx, qy;\n\tqueue q1;\n\tqx.push((s - 1) / n + 1);\n\tqy.push((s - 1) % n + 1);\n//\tprintf(\"%d %d\\n\", qx.front(), qy.front());\n\tq1.push(0);\n\tmemset(vis, 0, sizeof(vis));\n//\tvis[z] = 0;\n\tint res = INF;\n\twhile (qx.size()) {\n\t\tint x = qx.front(), y = qy.front(), t = q1.front();\n\t\tqx.pop(); qy.pop();\n\t\tq1.pop();\n\t\tvis[x][y] = 1;\n//\t\tif (x % n == 1 || x <= n || x > n * n - n || x % n == 0)\n\t\tif (x == 1 || x == n || y == 1 || y == n) {\n\t\t\tres = min(res, t);\n//\t\t\tprintf(\"finish: %d\\n\", t);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (int i = 0; i < 4; i++) {\n\t\t\tint xx = x + dx[i];\n\t\t\tint yy = y + dy[i];\n\t\t\tif (1 <= xx && xx <= n && 1 <= yy && yy <= n && !vis[xx][yy]) {\n\t\t\t\tqx.push(xx);\n\t\t\t\tqy.push(yy);\n\t\t\t\tq1.push(t + a[xx][yy]);\n\t\t\t}\n//\t\t\tif (x / n * n < x + d[i] && x + d[i] <= x / n * n + n && !vis[x + d[i]]) {\n//\t\t\t\tq.push(x + d[i]);\n//\t\t\t\tq1.push(t + e[x][i]);\n//\t\t\t}\n\t\t}\n//\t\tfor (int i = 2; i < 4; i++) {\n//\t\t\tif (0 < x + d[i] && x + d[i] <= n * n && !vis[x + d[i]]) {\n//\t\t\t\tq.push(x + d[i]);\n//\t\t\t\tq1.push(t + e[x][i]);\n//\t\t\t}\n//\t\t}\n\t}\n\tans += res;\n\treturn;\n}\n\nint p[MAXN];\n\nint main(){\n\tint T;\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n * n; i++) {\n\t\tscanf(\"%d\", &p[i]);\n\t}\n//\tfor (int i = 1; i <= n * n; i++) {\n//\t\tint c = i;\n//\t\te[c][1] = e[c][2] = e[c][3] = e[c][0] = 1;\n//\t}\n\tfor (int i = 1; i <= n; i++) {\n\t\tfor (int j = 1; j <= n; j++) {\n\t\t\ta[i][j] = 1;\n\t\t}\n\t}\n\t\t\n\tfor (int i = 1; i <= n * n; i++) {\n\t\tBfs(p[i]);\n\t\ta[(p[i] - 1) / n + 1][(p[i] - 1) % n + 1] = 0;\n//\t\tint c = n * (p[i] - 1) + p[i];\n////\t\te[c][1] = e[c][2] = e[c][3] = e[c][4] = 0;\n//\t\tif (c > n) e[c - n][2] = 0;\n//\t\tif (c < n * n - n + 1) e[c + n][3] = 0;\n//\t\te[c - 1][0] = e[c + 1][1] = 0;\n//\t\tprint();\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "sample_input": "3\n1 3 7 9 5 4 8 6 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02670", "source_text": "Score : 700 points\n\nProblem Statement\n\nTonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\\times N square. We denote with 1, 2,\\dots, N the viewers in the first row (from left to right); with N+1, \\dots, 2N the viewers in the second row (from left to right); and so on until the last row, whose viewers are denoted by N^2-N+1,\\dots, N^2.\n\nAt the end of the movie, the viewers go out of the cinema in a certain order: the i-th viewer leaving her seat is the one denoted by the number P_i. The viewer P_{i+1} waits until viewer P_i has left the cinema before leaving her seat.\nTo exit from the cinema, a viewer must move from seat to seat until she exits the square of seats (any side of the square is a valid exit). A viewer can move from a seat to one of its 4 adjacent seats (same row or same column).\nWhile leaving the cinema, it might be that a certain viewer x goes through a seat currently occupied by viewer y; in that case viewer y will hate viewer x forever. Each viewer chooses the way that minimizes the number of viewers that will hate her forever.\n\nCompute the number of pairs of viewers (x, y) such that y will hate x forever.\n\nConstraints\n\n2 \\le N \\le 500\n\nThe sequence P_1, P_2, \\dots, P_{N^2} is a permutation of \\{1, 2, \\dots, N^2\\}.\n\nInput\n\nThe input is given from Standard Input in the format\n\nN\nP_1 P_2 \\cdots P_{N^2}\n\nOutput\n\nIf ans is the number of pairs of viewers described in the statement, you should print on Standard Output\n\nans\n\nSample Input 1\n\n3\n1 3 7 9 5 4 8 6 2\n\nSample Output 1\n\n1\n\nBefore the end of the movie, the viewers are arranged in the cinema as follows:\n\n1 2 3\n4 5 6\n7 8 9\n\nThe first four viewers leaving the cinema (1, 3, 7, 9) can leave the cinema without going through any seat, so they will not be hated by anybody.\n\nThen, viewer 5 must go through one of the seats where viewers 2, 4, 6, 8 are currently seated while leaving the cinema; hence he will be hated by at least one of those viewers.\n\nFinally the remaining viewers can leave the cinema (in the order 4, 8, 6, 2) without going through any occupied seat (actually, they can leave the cinema without going through any seat at all).\n\nSample Input 2\n\n4\n6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6\n11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30\n\nSample Output 3\n\n11", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2335, "cpu_time_ms": 2244, "memory_kb": 1189656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s569649283", "group_id": "codeNet:p02675", "input_text": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef pair< ll, ll > Pi;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define rep2(i,n) for(int i=1;i<=(n);i++)\n#define rep3(i,i0,n) for(int i=i0;i<(n);i++)\n#define pb push_back\n#define mod 1000000007\nconst ll INF = 1LL << 60;\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b=h || x>=w){\n return 0;\n }else{\n return 1;\n }\n}\nconst vector dx{1,0,-1,0};\nconst vector dy{0,1,0,-1};\n\n\nint main() {\n ll N;\n cin >>N;\n ll x = N%10;\n if(x==3){\n cout<<\"bon\"<\nusing namespace std;\ntypedef long long ll;\ntypedef pair< ll, ll > Pi;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define rep2(i,n) for(int i=1;i<=(n);i++)\n#define rep3(i,i0,n) for(int i=i0;i<(n);i++)\n#define pb push_back\n#define mod 1000000007\nconst ll INF = 1LL << 60;\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b=h || x>=w){\n return 0;\n }else{\n return 1;\n }\n}\nconst vector dx{1,0,-1,0};\nconst vector dy{0,1,0,-1};\n\n\nint main() {\n ll N;\n cin >>N;\n ll x = N%10;\n if(x==3){\n cout<<\"bon\"<\n#include \n#include \n#include \n\n#define ten5p1 100001\n#define ten6p1 1000001\n#define ten8p1 100000001\n#define ten9p1 1000000001\n#define ll long long\n#define rep(var,n) for(int var=0;varb?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) {for(int _ONEI=0;_ONEI0 ? a%b : b + a % b)\nll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }\n\nFILE* _fin = stdin;\nFILE* _fout = stdout;\nvoid reversei(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\nint bsearch(int val, int* data, int n) { if (data[0] > val) return -1; if (data[n - 1] < val) return n; int l = 0; int r = n - 1; for (; l < r;) { int mid = (l + r + 1) >> 1; if (data[mid] <= val) l = mid; else r = mid - 1; }if (data[r] != val) ++r; return r; }\nint reads(char* str, int maxsize) \n{ \n\tfor (;;)\n\t{ \n\t\tif(fgets(str, maxsize, _fin)==NULL) break; \n\t\tif (str[0] != '\\n' && str[0] != '\\r') break;\n\t} \n\tint slen = strlen(str); \n\tif (slen == 0) return 0;\n\tif (str[slen - 1] == '\\n' || str[slen - 1] == '\\r') str[--slen] = 0;\n\treturn slen; \n}\n\n#define _Vec(type, name) \\\nstruct name { type* data; int size; int n; };\\\nvoid init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\\\nvoid resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\\\nvoid add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\\\nvoid free(name* t) { free(t->data);}\n_Vec(int, Veci)\n_Vec(long long, Vecll)\n_Vec(char*, Vecs)\n\n#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}\n_ispal(int, ispali)\n_ispal(char, ispalc)\n\n\n#define _Pair(type, name) struct name{type x, y;}; \\\nint cmp_##name(const void* _a, const void* _b){name* a = (name*)_a;name* b = (name*)_b;if (a->x == b->x){if (a->y < b->y) return -1;else return 1;}if (a->x < b->x) return -1;else return 1;}\\\nvoid sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}\n\t_Pair(int, Pairi)\n\n\tint cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }\nvoid sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }\n\nint main()\n{\n\tRUN_LOCAL(\"dataabc168B.txt\");\n\n\tint k; readi(&k);\n\tchar s[102];\n\tint len = reads(s, 102);\n\n\trepi(k) writec(s[i]);\n\tif(k<=len) writes(\"...\\n\");\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1590035006, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02676/input.txt", "sample_output_relpath": "derived/input_output/data/p02676/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02676/C++/s444334303.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s444334303", "user_id": "u950002813"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "/*\nURL_HERE\n*/\n/*\n\n*/\n#ifdef _WIN32\n\t#pragma warning(disable:4996)\n#endif\n#include \n#include \n#include \n#include \n\n#define ten5p1 100001\n#define ten6p1 1000001\n#define ten8p1 100000001\n#define ten9p1 1000000001\n#define ll long long\n#define rep(var,n) for(int var=0;varb?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) {for(int _ONEI=0;_ONEI0 ? a%b : b + a % b)\nll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }\n\nFILE* _fin = stdin;\nFILE* _fout = stdout;\nvoid reversei(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\nint bsearch(int val, int* data, int n) { if (data[0] > val) return -1; if (data[n - 1] < val) return n; int l = 0; int r = n - 1; for (; l < r;) { int mid = (l + r + 1) >> 1; if (data[mid] <= val) l = mid; else r = mid - 1; }if (data[r] != val) ++r; return r; }\nint reads(char* str, int maxsize) \n{ \n\tfor (;;)\n\t{ \n\t\tif(fgets(str, maxsize, _fin)==NULL) break; \n\t\tif (str[0] != '\\n' && str[0] != '\\r') break;\n\t} \n\tint slen = strlen(str); \n\tif (slen == 0) return 0;\n\tif (str[slen - 1] == '\\n' || str[slen - 1] == '\\r') str[--slen] = 0;\n\treturn slen; \n}\n\n#define _Vec(type, name) \\\nstruct name { type* data; int size; int n; };\\\nvoid init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\\\nvoid resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\\\nvoid add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\\\nvoid free(name* t) { free(t->data);}\n_Vec(int, Veci)\n_Vec(long long, Vecll)\n_Vec(char*, Vecs)\n\n#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}\n_ispal(int, ispali)\n_ispal(char, ispalc)\n\n\n#define _Pair(type, name) struct name{type x, y;}; \\\nint cmp_##name(const void* _a, const void* _b){name* a = (name*)_a;name* b = (name*)_b;if (a->x == b->x){if (a->y < b->y) return -1;else return 1;}if (a->x < b->x) return -1;else return 1;}\\\nvoid sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}\n\t_Pair(int, Pairi)\n\n\tint cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }\nvoid sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }\n\nint main()\n{\n\tRUN_LOCAL(\"dataabc168B.txt\");\n\n\tint k; readi(&k);\n\tchar s[102];\n\tint len = reads(s, 102);\n\n\trepi(k) writec(s[i]);\n\tif(k<=len) writes(\"...\\n\");\n\treturn 0;\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "sample_input": "7\nnikoandsolstice\n"}, "reference_outputs": ["nikoand...\n"], "source_document_id": "p02676", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have a string S consisting of lowercase English letters.\n\nIf the length of S is at most K, print S without change.\n\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.\n\nConstraints\n\nK is an integer between 1 and 100 (inclusive).\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint a string as stated in Problem Statement.\n\nSample Input 1\n\n7\nnikoandsolstice\n\nSample Output 1\n\nnikoand...\n\nnikoandsolstice has a length of 15, which exceeds K=7.\n\nWe should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....\n\nSample Input 2\n\n40\nferelibenterhominesidquodvoluntcredunt\n\nSample Output 2\n\nferelibenterhominesidquodvoluntcredunt\n\nThe famous quote from Gaius Julius Caesar.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3858, "cpu_time_ms": 8, "memory_kb": 1712}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s131727196", "group_id": "codeNet:p02676", "input_text": "#pragma GCC optimize(\"O3\")\n#include \nusing namespace std;\n#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\n#define fi first\n#define se second\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n#define debugii(x) cerr << \" - \" << #x << \": \" << x.fi<<\",\"<\n#define v vector\n#define vii vector\n#define vv vector >\n#define mp make_pair\n#define INF 1000000000\n#define pb push_back\n#define EPS 1e-9\nconst int MOD = 1000000007; // 998244353\nint32_t main(){\n\tboost;\n\t//freopen(\".in\",\"r\",stdin);\n\tint k;\n\tstring s;\n\tcin>>k>>s;\n\tif(sz(s)<=k)cout<\nusing namespace std;\n#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\n#define fi first\n#define se second\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n#define debugii(x) cerr << \" - \" << #x << \": \" << x.fi<<\",\"<\n#define v vector\n#define vii vector\n#define vv vector >\n#define mp make_pair\n#define INF 1000000000\n#define pb push_back\n#define EPS 1e-9\nconst int MOD = 1000000007; // 998244353\nint32_t main(){\n\tboost;\n\t//freopen(\".in\",\"r\",stdin);\n\tint k;\n\tstring s;\n\tcin>>k>>s;\n\tif(sz(s)<=k)cout<\n#define IOS ios_base::sync_with_stdio(0); cin.tie(0);\nusing namespace std;\ntypedef long long ll;\n\n#define mp make_pair\n#define fi first\n#define se second\n#define pb push_back\n#define PI pair\n\nconst double pi = acos(-1.0);\nconst int inf = 0x3f3f3f3f;\nconst ll INF = 0x3f3f3f3f3f3f3f3fll;\nconst ll mod = (ll)(1e9 + 7);\nconst int N = 1000010;\n\nint A, B, H, M;\n\nint main() { \n while (cin >> A >> B >> H >> M) {\n double e1 = -(1.0 * (H * 60 + M) / 360 * pi - pi / 2);\n double e2 = -(1.0 * M / 30 * pi - pi / 2);\n double a = A * cos(e1), b = A * sin(e1);\n double c = B * cos(e2), d = B * sin(e2);\n double dis = sqrt((a - c) * (a - c) + (b - d) * (b - d));\n cout << setprecision(14) << dis << endl;\n }\n return 0;\n}\n \n", "language": "C++", "metadata": {"date": 1590186873, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/C++/s271914015.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271914015", "user_id": "u753288484"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "#include \n#define IOS ios_base::sync_with_stdio(0); cin.tie(0);\nusing namespace std;\ntypedef long long ll;\n\n#define mp make_pair\n#define fi first\n#define se second\n#define pb push_back\n#define PI pair\n\nconst double pi = acos(-1.0);\nconst int inf = 0x3f3f3f3f;\nconst ll INF = 0x3f3f3f3f3f3f3f3fll;\nconst ll mod = (ll)(1e9 + 7);\nconst int N = 1000010;\n\nint A, B, H, M;\n\nint main() { \n while (cin >> A >> B >> H >> M) {\n double e1 = -(1.0 * (H * 60 + M) / 360 * pi - pi / 2);\n double e2 = -(1.0 * M / 30 * pi - pi / 2);\n double a = A * cos(e1), b = A * sin(e1);\n double c = B * cos(e2), d = B * sin(e2);\n double dis = sqrt((a - c) * (a - c) + (b - d) * (b - d));\n cout << setprecision(14) << dis << endl;\n }\n return 0;\n}\n \n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 801, "cpu_time_ms": 2, "memory_kb": 4156}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s786133660", "group_id": "codeNet:p02677", "input_text": "#include\n#include\n#include\nusing namespace std;\nint h, m, hl, ml;\ndouble angle, radian, ans;\nint main()\n{\n\tscanf(\"%d%d%d%d\", &hl, &ml, &h, &m);\n\tangle = fabs(0.5 *( h * 60 + m) - 6 * m * 0.1 * 10);\n\t//cout< 180) angle -= 180;\n\tif(angle == 0) \n\t{\n\t\tprintf(\"%d\", abs(hl - ml));\n\t\treturn 0;\n\t}\n\tradian = angle * 3.14159265358979323846 / 180 * 1e-9 *1e9;\n\t//cout<\n#include\n#include\nusing namespace std;\nint h, m, hl, ml;\ndouble angle, radian, ans;\nint main()\n{\n\tscanf(\"%d%d%d%d\", &hl, &ml, &h, &m);\n\tangle = fabs(0.5 *( h * 60 + m) - 6 * m * 0.1 * 10);\n\t//cout< 180) angle -= 180;\n\tif(angle == 0) \n\t{\n\t\tprintf(\"%d\", abs(hl - ml));\n\t\treturn 0;\n\t}\n\tradian = angle * 3.14159265358979323846 / 180 * 1e-9 *1e9;\n\t//cout<\n#define REP(i, n) for (ll i = 1; i <= n; i++)\n#define rep(i, n) for (ll i = 0; i < n; i++)\n#define ll long long\nusing namespace std;\n\nint main()\n{\n int A,B,H,M;\n float PI = 3.14159265358979323846f;\n float ans = 0;\n cin >> A >> B >> H >> M;\n float a,b,c;\n a = (60.0f*H + M) * 6.0f;\n b = (60.0f*H + M) * 0.5f;\n c = min(abs(b - a),abs(360.0f - b + a));\n ans = sqrtl(A*A+B*B-2.0f*A*B*cos(PI * c / 180.0f));\n cout << fixed << setprecision(15) << ans << endl;\n \n}\n", "language": "C++", "metadata": {"date": 1589769097, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/C++/s860412183.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s860412183", "user_id": "u442790386"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "#include \n#define REP(i, n) for (ll i = 1; i <= n; i++)\n#define rep(i, n) for (ll i = 0; i < n; i++)\n#define ll long long\nusing namespace std;\n\nint main()\n{\n int A,B,H,M;\n float PI = 3.14159265358979323846f;\n float ans = 0;\n cin >> A >> B >> H >> M;\n float a,b,c;\n a = (60.0f*H + M) * 6.0f;\n b = (60.0f*H + M) * 0.5f;\n c = min(abs(b - a),abs(360.0f - b + a));\n ans = sqrtl(A*A+B*B-2.0f*A*B*cos(PI * c / 180.0f));\n cout << fixed << setprecision(15) << ans << endl;\n \n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 516, "cpu_time_ms": 13, "memory_kb": 4028}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s791003160", "group_id": "codeNet:p02677", "input_text": "#include \nusing namespace std;\n\n#define REP(i, n) for(int64_t i = 0; i < n; i++)\n#define REPR(i, n) for(int64_t i = n; i >= 0; i--)\n#define FOR(i, m, n) for(int64_t i = m; i < n; i++)\n#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)\n#define ALL(v) v.begin(), v.end()\ntypedef long long ll;\ntemplate\nvoid Fill(A (&array)[N], const T &val){\n fill( (T*)array, (T*)(array+N), val );\n}\ntemplate\ninline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}\ntemplate\ninline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}\nconst ll INF= 1ll << 60;\nconst ll MOD = 1000000007;\ndouble EPS = 1e-10;\n//----------------------------------------------------------\n\ndouble a,b,h,m;\nint main(){\n cin >> a >> b >> h >> m;\n double ans = 0;\n double mk = M_PI/1800.0;\n double hk = M_PI/21600.0;\n double mr = ((mk*(h*3600+m*60)-h*2*M_PI)>=0?mk*(h*3600+m*60)-h*2*M_PI:mk*(h*3600+m*60));\n double hr = hk*(h*3600+m*60);\n double dr = ((mr-hr)>=0?mr-hr:hr-mr);\n if(dr>M_PI)\n {\n double t1 = ((2*M_PI-hr)-mr>=0?(2*M_PI-hr)-mr:mr-(2*M_PI-hr));\n double t2 = ((2*M_PI-mr)-hr>=0?(2*M_PI-mr)-hr:hr-(2*M_PI-mr));\n dr=(t1>M_PI?t2:t1);\n }\n ans = sqrt(a*a+b*b-2*a*b*cos(dr));\n cout << fixed << setprecision(11) << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1589766215, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/C++/s791003160.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s791003160", "user_id": "u567406270"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "#include \nusing namespace std;\n\n#define REP(i, n) for(int64_t i = 0; i < n; i++)\n#define REPR(i, n) for(int64_t i = n; i >= 0; i--)\n#define FOR(i, m, n) for(int64_t i = m; i < n; i++)\n#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)\n#define ALL(v) v.begin(), v.end()\ntypedef long long ll;\ntemplate\nvoid Fill(A (&array)[N], const T &val){\n fill( (T*)array, (T*)(array+N), val );\n}\ntemplate\ninline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}\ntemplate\ninline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}\nconst ll INF= 1ll << 60;\nconst ll MOD = 1000000007;\ndouble EPS = 1e-10;\n//----------------------------------------------------------\n\ndouble a,b,h,m;\nint main(){\n cin >> a >> b >> h >> m;\n double ans = 0;\n double mk = M_PI/1800.0;\n double hk = M_PI/21600.0;\n double mr = ((mk*(h*3600+m*60)-h*2*M_PI)>=0?mk*(h*3600+m*60)-h*2*M_PI:mk*(h*3600+m*60));\n double hr = hk*(h*3600+m*60);\n double dr = ((mr-hr)>=0?mr-hr:hr-mr);\n if(dr>M_PI)\n {\n double t1 = ((2*M_PI-hr)-mr>=0?(2*M_PI-hr)-mr:mr-(2*M_PI-hr));\n double t2 = ((2*M_PI-mr)-hr>=0?(2*M_PI-mr)-hr:hr-(2*M_PI-mr));\n dr=(t1>M_PI?t2:t1);\n }\n ans = sqrt(a*a+b*b-2*a*b*cos(dr));\n cout << fixed << setprecision(11) << ans << endl;\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1368, "cpu_time_ms": 8, "memory_kb": 4188}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s269417471", "group_id": "codeNet:p02678", "input_text": "#include\nusing namespace std;\ndouble PI = acos(-1.0);\n#define all(v) v.begin(),v.end()\n\nint main(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n\n int n,m;\n cin >> n >> m;\n\n vector adj[n+1];\n\n for(int i= 0 ; i < m ; ++i ){\n int a,b;\n cin >> a >> b;\n adj[a].push_back(b);\n adj[b].push_back(a);\n }\n\n for( int i = 1 ; i < n + 1 ; ++i ){\n for( int x : adj[i] ) cout << x <<\" \";\n cout << endl;\n }\n vector ans( n - 1 , -1 );\n bool ok = true;\n unordered_set S;\n\n for( int i = 2 ; i <= n ; ++i ){\n sort(all(adj[i]));\n bool ga = binary_search(all(adj[i]), 1);\n if(ga){\n ans[i-2] = 1;\n S.insert(i);\n }\n }\n\n for( int x : S ){\n for( int y : adj[x] ){\n if( ans[y-2] == -1 ) {\n ans[y-2] = x;\n }\n }\n }\n\n for( int i = 0 ; i < ans.size() ; ++i ){\n if( ans[i] == -1 ){\n ok = 0;\n break;\n }\n }\n if( ok ){\n cout << \"Yes\\n\";\n for( int x : ans ) cout << x <<'\\n';\n } else cout << \"No\\n\";\n\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1589775640, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02678/input.txt", "sample_output_relpath": "derived/input_output/data/p02678/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02678/C++/s269417471.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s269417471", "user_id": "u655630568"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "#include\nusing namespace std;\ndouble PI = acos(-1.0);\n#define all(v) v.begin(),v.end()\n\nint main(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n\n int n,m;\n cin >> n >> m;\n\n vector adj[n+1];\n\n for(int i= 0 ; i < m ; ++i ){\n int a,b;\n cin >> a >> b;\n adj[a].push_back(b);\n adj[b].push_back(a);\n }\n\n for( int i = 1 ; i < n + 1 ; ++i ){\n for( int x : adj[i] ) cout << x <<\" \";\n cout << endl;\n }\n vector ans( n - 1 , -1 );\n bool ok = true;\n unordered_set S;\n\n for( int i = 2 ; i <= n ; ++i ){\n sort(all(adj[i]));\n bool ga = binary_search(all(adj[i]), 1);\n if(ga){\n ans[i-2] = 1;\n S.insert(i);\n }\n }\n\n for( int x : S ){\n for( int y : adj[x] ){\n if( ans[y-2] == -1 ) {\n ans[y-2] = x;\n }\n }\n }\n\n for( int i = 0 ; i < ans.size() ; ++i ){\n if( ans[i] == -1 ){\n ok = 0;\n break;\n }\n }\n if( ok ){\n cout << \"Yes\\n\";\n for( int x : ans ) cout << x <<'\\n';\n } else cout << \"No\\n\";\n\n \n return 0;\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1163, "cpu_time_ms": 240, "memory_kb": 13776}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s409697927", "group_id": "codeNet:p02679", "input_text": "#include\n#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define endl '\\n'\n#define INF 0x3f3f3f3f\n#define MAX (1<<20)\n#define MOD 1000000007\n#define i64 long long\n#define all(x) (x).begin() , (x).end()\n#define sz(x) (int)(x).size()\n#define ii pair\n#define fs first\n#define sc second\n#define eb emplace_back\n#define vi vector\n#define vvi vector\n#define vii vector\n#define vvii vector\n#define lsb(x) ((x) & (-x))\n#define gcd(x,y) __gcd((x),(y))\n\nusing namespace std;\n\nmap f;\nvii dir;\nvi pot2;\ni64 n, xz, yz, zz, a, b, ans, fator;\n\nint main(){_\n cin >> n;\n \n pot2.eb(1);\n for (int i=n; i--;){\n pot2.eb((2*pot2.back())%MOD);\n }\n\n dir = vii(n);\n for (auto &[x, y] : dir){\n cin >> x >> y;\n\n if (!x) {\n if (!y){\n ++zz;\n continue;\n }else{\n ++xz;\n }\n }else if (!y){\n ++yz;\n }\n \n if (x<0){\n x = -x; y = -y;\n }\n\n i64 mdc = abs(gcd(x, y));\n x /= mdc; y/=mdc;\n \n ++f[{x,y}];\n }\n \n ans = 1LL;\n \n fator = (pot2[xz] + pot2[yz] - 1LL + MOD)%MOD;\n ans = (ans * fator) % MOD;\n\n for (auto [p, c] : f){\n i64 x = p.fs, y=p.sc;\n\n // cout << x << \" \" << y << \" >> \" << c << endl;\n\n if (!x || !y || !c) continue;\n\n a = (y > 0 ? y : -y);\n b = (y > 0 ? -x : x);\n\n fator = (pot2[c] + pot2[f[{a,b}]] - 1LL + MOD) % MOD;\n ans = (ans * fator) % MOD;\n\n f[{a,b}] *= !(f[{a,b}]);\n }\n\n\n cout << (ans-1LL+zz)%MOD << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1593776165, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/C++/s409697927.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s409697927", "user_id": "u781725464"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include\n#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define endl '\\n'\n#define INF 0x3f3f3f3f\n#define MAX (1<<20)\n#define MOD 1000000007\n#define i64 long long\n#define all(x) (x).begin() , (x).end()\n#define sz(x) (int)(x).size()\n#define ii pair\n#define fs first\n#define sc second\n#define eb emplace_back\n#define vi vector\n#define vvi vector\n#define vii vector\n#define vvii vector\n#define lsb(x) ((x) & (-x))\n#define gcd(x,y) __gcd((x),(y))\n\nusing namespace std;\n\nmap f;\nvii dir;\nvi pot2;\ni64 n, xz, yz, zz, a, b, ans, fator;\n\nint main(){_\n cin >> n;\n \n pot2.eb(1);\n for (int i=n; i--;){\n pot2.eb((2*pot2.back())%MOD);\n }\n\n dir = vii(n);\n for (auto &[x, y] : dir){\n cin >> x >> y;\n\n if (!x) {\n if (!y){\n ++zz;\n continue;\n }else{\n ++xz;\n }\n }else if (!y){\n ++yz;\n }\n \n if (x<0){\n x = -x; y = -y;\n }\n\n i64 mdc = abs(gcd(x, y));\n x /= mdc; y/=mdc;\n \n ++f[{x,y}];\n }\n \n ans = 1LL;\n \n fator = (pot2[xz] + pot2[yz] - 1LL + MOD)%MOD;\n ans = (ans * fator) % MOD;\n\n for (auto [p, c] : f){\n i64 x = p.fs, y=p.sc;\n\n // cout << x << \" \" << y << \" >> \" << c << endl;\n\n if (!x || !y || !c) continue;\n\n a = (y > 0 ? y : -y);\n b = (y > 0 ? -x : x);\n\n fator = (pot2[c] + pot2[f[{a,b}]] - 1LL + MOD) % MOD;\n ans = (ans * fator) % MOD;\n\n f[{a,b}] *= !(f[{a,b}]);\n }\n\n\n cout << (ans-1LL+zz)%MOD << endl;\n\n return 0;\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1659, "cpu_time_ms": 470, "memory_kb": 32948}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s558168219", "group_id": "codeNet:p02679", "input_text": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\n\n#define p_ary(ary,a,b) do { cout << \"[\"; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? \"\" : \", \"); cout << \"]\\n\"; } while(0)\n#define p_map(map,it) do {cout << \"{\";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << \"}\\n\";break;}else cout << \"\" << (it)->first << \"=>\" << (it)->second << \", \";}}while(0)\n\ntemplateostream& operator<<(ostream& os,const pair& a) {os << \"(\" << a.first << \", \" << a.second << \")\";return os;}\n\nconst char newl = '\\n';\n\nconst ll mod = 1000000007;\n//const ll mod = 998244353;\n\nconst int MAX_N = 200010;\nll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];\n\nll pow_mod(ll a,ll b) {\n ll ret;\n if (b < 0) ret = pow_mod(a,mod+b-1);\n else if (b == 0) ret = 1;\n else if (b == 1) ret = a;\n else {\n ll c = pow_mod(a,b/2);\n if (b%2) ret = (c*c)%mod*a%mod;\n else ret = c*c%mod;\n }\n return ret;\n}\n\nvoid init(int x) {\n fact[0] = 1;fact[1] = 1;\n for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;\n fact_inv[x] = pow_mod(fact[x],-1);\n for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;\n for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;\n}\n\nll combi(ll a, ll b) {\n return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;\n}\n\nint main() {\n int n,m = 0;\n cin >> n;\n init(n);\n map mp;\n set

st;\n for (int i = 0;i < n;++i) {\n ll a,b;\n scanf(\"%lld%lld\",&a,&b);\n if (a == 0 && b == 0) {\n n--;\n m++;\n continue;\n }\n ll g = gcd(abs(a),abs(b));\n a /= g;\n b /= g;\n if (a < 0 || (a == 0 && b < 0)) {\n a *= -1;\n b *= -1;\n }\n mp[make_pair(a,b)]++;\n }\n ll ans = pow_mod(2,n)-1,s = 1;\n for (auto p : mp) {\n P q = make_pair(p.first.second,-p.first.first);\n if (q.first < 0 || (q.first == 0 && q.second < 0)) {\n q.first *= -1;\n q.second *= -1;\n }\n if (mp.find(q) == mp.end() || st.find(p.first) != st.end()) continue;\n n -= p.second+mp[q];\n (ans -= (pow_mod(2,p.second)-1)*(pow_mod(2,mp[q])-1)%mod*(pow_mod(2,n)*s%mod)%mod) %= mod;\n st.insert(p.first);\n st.insert(q);\n (s *= (pow_mod(2,p.second+mp[q])-(pow_mod(2,p.second)-1)*(pow_mod(2,mp[q])-1)%mod)%mod) %= mod;\n }\n cout << (ans+m+mod)%mod << endl;\n}", "language": "C++", "metadata": {"date": 1589767290, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02679/input.txt", "sample_output_relpath": "derived/input_output/data/p02679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02679/C++/s558168219.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s558168219", "user_id": "u506255180"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\n\n#define p_ary(ary,a,b) do { cout << \"[\"; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? \"\" : \", \"); cout << \"]\\n\"; } while(0)\n#define p_map(map,it) do {cout << \"{\";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << \"}\\n\";break;}else cout << \"\" << (it)->first << \"=>\" << (it)->second << \", \";}}while(0)\n\ntemplateostream& operator<<(ostream& os,const pair& a) {os << \"(\" << a.first << \", \" << a.second << \")\";return os;}\n\nconst char newl = '\\n';\n\nconst ll mod = 1000000007;\n//const ll mod = 998244353;\n\nconst int MAX_N = 200010;\nll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];\n\nll pow_mod(ll a,ll b) {\n ll ret;\n if (b < 0) ret = pow_mod(a,mod+b-1);\n else if (b == 0) ret = 1;\n else if (b == 1) ret = a;\n else {\n ll c = pow_mod(a,b/2);\n if (b%2) ret = (c*c)%mod*a%mod;\n else ret = c*c%mod;\n }\n return ret;\n}\n\nvoid init(int x) {\n fact[0] = 1;fact[1] = 1;\n for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;\n fact_inv[x] = pow_mod(fact[x],-1);\n for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;\n for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;\n}\n\nll combi(ll a, ll b) {\n return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;\n}\n\nint main() {\n int n,m = 0;\n cin >> n;\n init(n);\n map mp;\n set

st;\n for (int i = 0;i < n;++i) {\n ll a,b;\n scanf(\"%lld%lld\",&a,&b);\n if (a == 0 && b == 0) {\n n--;\n m++;\n continue;\n }\n ll g = gcd(abs(a),abs(b));\n a /= g;\n b /= g;\n if (a < 0 || (a == 0 && b < 0)) {\n a *= -1;\n b *= -1;\n }\n mp[make_pair(a,b)]++;\n }\n ll ans = pow_mod(2,n)-1,s = 1;\n for (auto p : mp) {\n P q = make_pair(p.first.second,-p.first.first);\n if (q.first < 0 || (q.first == 0 && q.second < 0)) {\n q.first *= -1;\n q.second *= -1;\n }\n if (mp.find(q) == mp.end() || st.find(p.first) != st.end()) continue;\n n -= p.second+mp[q];\n (ans -= (pow_mod(2,p.second)-1)*(pow_mod(2,mp[q])-1)%mod*(pow_mod(2,n)*s%mod)%mod) %= mod;\n st.insert(p.first);\n st.insert(q);\n (s *= (pow_mod(2,p.second+mp[q])-(pow_mod(2,p.second)-1)*(pow_mod(2,mp[q])-1)%mod)%mod) %= mod;\n }\n cout << (ans+m+mod)%mod << endl;\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2494, "cpu_time_ms": 312, "memory_kb": 20888}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s136178695", "group_id": "codeNet:p02681", "input_text": "#include \n#define ALL(a) (a).begin(),(a).end()\n#define sz(x) int(x.size())\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\ntypedef pair Pll;\ntypedef vector vi;\ntypedef vector> vvi;\ntypedef vector vll;\ntypedef vector> vvll;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\nconst long long INF = 1LL << 60;\nconst int INT_INF = 1 << 30;\n#define MOD 1000000007LL\n#define PI 3.141592653589793\n#define endl \"\\n\"\n\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n string S, T;\n cin >> S >> T;\n bool flag = false;\n for(int i = 0; i < 26; i++){\n string str = S + (char)(i + 'a');\n if(str == T) flag = true;\n }\n if(flag) cout << \"Yes\" << endl;\n else cout << \"No\" << endl;\n}", "language": "C++", "metadata": {"date": 1589158939, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/C++/s136178695.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s136178695", "user_id": "u455266724"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#define ALL(a) (a).begin(),(a).end()\n#define sz(x) int(x.size())\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\ntypedef pair Pll;\ntypedef vector vi;\ntypedef vector> vvi;\ntypedef vector vll;\ntypedef vector> vvll;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\nconst long long INF = 1LL << 60;\nconst int INT_INF = 1 << 30;\n#define MOD 1000000007LL\n#define PI 3.141592653589793\n#define endl \"\\n\"\n\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n string S, T;\n cin >> S >> T;\n bool flag = false;\n for(int i = 0; i < 26; i++){\n string str = S + (char)(i + 'a');\n if(str == T) flag = true;\n }\n if(flag) cout << \"Yes\" << endl;\n else cout << \"No\" << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 940, "cpu_time_ms": 9, "memory_kb": 3652}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s231737286", "group_id": "codeNet:p02682", "input_text": "#include\nusing namespace std;\nint main(){\n\tlong long a,b,c,k;\n\tscanf(\"%lld %lld %lld %lld\",&a,&b,&c,&k);\n\tlong long ans = min(a,k);\n\tk-=a;\n\tk = k-b;\n\tif(k){\n\t\tans -= k;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1600514167, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/C++/s231737286.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231737286", "user_id": "u653041893"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\nusing namespace std;\nint main(){\n\tlong long a,b,c,k;\n\tscanf(\"%lld %lld %lld %lld\",&a,&b,&c,&k);\n\tlong long ans = min(a,k);\n\tk-=a;\n\tk = k-b;\n\tif(k){\n\t\tans -= k;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 9, "memory_kb": 3732}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s282371064", "group_id": "codeNet:p02682", "input_text": "#include \n#define rep(i,n) for(int i = 0;i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nint main() {\n ll a,b,c;\n ll k;\n cin >> a >> b >> c >> k;\n ll ans;\n if(k - a - b > 0){\n ans = a - (k - a - b);\n }else if(k < a){\n ans = k;\n }else if(k - a - b < 0){\n ans = a;\n }\n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1589160764, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/C++/s282371064.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s282371064", "user_id": "u951586418"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define rep(i,n) for(int i = 0;i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nint main() {\n ll a,b,c;\n ll k;\n cin >> a >> b >> c >> k;\n ll ans;\n if(k - a - b > 0){\n ans = a - (k - a - b);\n }else if(k < a){\n ans = k;\n }else if(k - a - b < 0){\n ans = a;\n }\n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 3, "memory_kb": 3628}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s207004647", "group_id": "codeNet:p02682", "input_text": "#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;\nusing ll = long long;\nconst ll INF = (ll)1e18+1;\nconst ll DIV = 1000000007;\n//#define TEST\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n#ifdef TEST\n chrono::system_clock::time_point start, end;\n start = chrono::system_clock::now();\n#endif\n long A,B,C,K;\n cin >> A >> B >> C >> K;\n if(K <= A) cout << K << endl;\n else if(K > A && K <= A+B) cout << A << endl;\n else cout << A - (K - (A + B)) << endl;\n#ifdef TEST\n end = chrono::system_clock::now();\n cerr << static_cast(chrono::duration_cast(end - start).count() / 1000.0) << \"[ms]\" << endl;\n#endif\n return 0;\n}", "language": "C++", "metadata": {"date": 1589159168, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/C++/s207004647.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207004647", "user_id": "u645961531"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#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;\nusing ll = long long;\nconst ll INF = (ll)1e18+1;\nconst ll DIV = 1000000007;\n//#define TEST\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n#ifdef TEST\n chrono::system_clock::time_point start, end;\n start = chrono::system_clock::now();\n#endif\n long A,B,C,K;\n cin >> A >> B >> C >> K;\n if(K <= A) cout << K << endl;\n else if(K > A && K <= A+B) cout << A << endl;\n else cout << A - (K - (A + B)) << endl;\n#ifdef TEST\n end = chrono::system_clock::now();\n cerr << static_cast(chrono::duration_cast(end - start).count() / 1000.0) << \"[ms]\" << endl;\n#endif\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 897, "cpu_time_ms": 6, "memory_kb": 3604}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s621002870", "group_id": "codeNet:p02683", "input_text": "#include\nusing namespace std;\nint mi=INT_MAX;\nbool xx=false;\nvoid recursrion(int index ,int currSum,int K,vector < pair< int , vector > > &arr,vector Books,int N,int M)\n{\n if(index>=N){return ;}\n recursrion(index+1,currSum,K,arr,Books,N,M);\n int cost=arr[index].first;\n currSum+=cost;\n vector x=arr[index].second;\n for(int i=0;i>N>>M>>K;\n vector < pair < int , vector > > arr;\n for(int i=0;i>x;\n vector S(M);\n for(auto &it:S)\n {\n cin>>it;\n }\n arr.push_back(make_pair(x,S));\n }\n vector Books(M,0);\n recursrion(0,0,K,arr,Books,N,M);\n if(xx==true)\n {\n cout<\nusing namespace std;\nint mi=INT_MAX;\nbool xx=false;\nvoid recursrion(int index ,int currSum,int K,vector < pair< int , vector > > &arr,vector Books,int N,int M)\n{\n if(index>=N){return ;}\n recursrion(index+1,currSum,K,arr,Books,N,M);\n int cost=arr[index].first;\n currSum+=cost;\n vector x=arr[index].second;\n for(int i=0;i>N>>M>>K;\n vector < pair < int , vector > > arr;\n for(int i=0;i>x;\n vector S(M);\n for(auto &it:S)\n {\n cin>>it;\n }\n arr.push_back(make_pair(x,S));\n }\n vector Books(M,0);\n recursrion(0,0,K,arr,Books,N,M);\n if(xx==true)\n {\n cout<\nusing namespace std;\n\n#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)\n#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))\n#define trav(i,a) for(auto& (i) : (a))\n#define all(a) (a).begin(),(a).end()\n#define sz(a) int((a).size())\n#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)\n#define dbg(x) cerr << \"STDERR => \" << __LINE__ << \": \" << #x << \" = \" << (x) << \" :(\\n\";\n#define pb push_back\n#define mp make_pair\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ninline void cpuTime() { cerr << \"cpu time : \" << double(clock())/CLOCKS_PER_SEC << \"\\n\"; return; }\nusing ll = long long;\nusing ull = unsigned long long;\nusing F = float;\nusing D = double;\nusing vi = vector;\nusing pii = pair;\n\n\n\nvoid solve(){\n\n int n, m, x;\n cin >> n >> m >> x;\n\n vector c(n, vi(m+1, 0));\n rep(i,0,n){\n rep(j,0,m+1){\n cin >> c[i][j];\n }\n }\n\n\n vector a(n,0), b(n,0);\n ll cost = 0, ans = LLONG_MAX;\n vi sum(m, 0);\n\n rep(i,0,n){\n a[n-1-i] = 1;\n b = a;\n\n do{\n rep(j,0,m) sum[j] = 0;\n cost = 0;\n rep(j,0,n){\n if(b[j]){\n cost += c[j][0];\n rep(k,0,m){\n sum[k] += c[j][k+1];\n }\n }\n }\n\n rep(k,0,m){\n if(sum[k] < x) break;\n if(k==(m-1)) ans = min(ans, cost);\n }\n }while(next_permutation(all(b)));\n }\n\n if(ans==LLONG_MAX) cout << \"-1\\n\";\n else cout << ans << \"\\n\";\n\n return;\n}\n\n/*\n read the question carefully ( what're the exact constraints? )\n look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS\n Check datatypes\n*/\nint main(){\n\n fast_io;\n int t=1;\n // cin >> t;\n\n while(t--){\n solve();\n }\n\n cpuTime();\nreturn 0;\n}\n", "language": "C++", "metadata": {"date": 1589160833, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02683/input.txt", "sample_output_relpath": "derived/input_output/data/p02683/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02683/C++/s143941947.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143941947", "user_id": "u153767929"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "#include\nusing namespace std;\n\n#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)\n#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))\n#define trav(i,a) for(auto& (i) : (a))\n#define all(a) (a).begin(),(a).end()\n#define sz(a) int((a).size())\n#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)\n#define dbg(x) cerr << \"STDERR => \" << __LINE__ << \": \" << #x << \" = \" << (x) << \" :(\\n\";\n#define pb push_back\n#define mp make_pair\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ninline void cpuTime() { cerr << \"cpu time : \" << double(clock())/CLOCKS_PER_SEC << \"\\n\"; return; }\nusing ll = long long;\nusing ull = unsigned long long;\nusing F = float;\nusing D = double;\nusing vi = vector;\nusing pii = pair;\n\n\n\nvoid solve(){\n\n int n, m, x;\n cin >> n >> m >> x;\n\n vector c(n, vi(m+1, 0));\n rep(i,0,n){\n rep(j,0,m+1){\n cin >> c[i][j];\n }\n }\n\n\n vector a(n,0), b(n,0);\n ll cost = 0, ans = LLONG_MAX;\n vi sum(m, 0);\n\n rep(i,0,n){\n a[n-1-i] = 1;\n b = a;\n\n do{\n rep(j,0,m) sum[j] = 0;\n cost = 0;\n rep(j,0,n){\n if(b[j]){\n cost += c[j][0];\n rep(k,0,m){\n sum[k] += c[j][k+1];\n }\n }\n }\n\n rep(k,0,m){\n if(sum[k] < x) break;\n if(k==(m-1)) ans = min(ans, cost);\n }\n }while(next_permutation(all(b)));\n }\n\n if(ans==LLONG_MAX) cout << \"-1\\n\";\n else cout << ans << \"\\n\";\n\n return;\n}\n\n/*\n read the question carefully ( what're the exact constraints? )\n look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS\n Check datatypes\n*/\nint main(){\n\n fast_io;\n int t=1;\n // cin >> t;\n\n while(t--){\n solve();\n }\n\n cpuTime();\nreturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1987, "cpu_time_ms": 3, "memory_kb": 3852}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s669777914", "group_id": "codeNet:p02683", "input_text": "#include \n\n/*==========type============*/\ntypedef long long ll;\ntypedef std::pair pii;\ntypedef std::pair pll;\ntypedef std::pair psl;\n\n/*==========constant============*/\n#define INF INT_MAX\n#define INF_L LONG_MAX\n#define INF_LL LLONG_MAX\n#define MOD 1000000007\n\n/*==========function============*/\n#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)\n#define RREP(ii,nn,jj) for (ll ii = nn; jj name(__VA_ARGS__)\ntemplate inline auto max(const T& a){ return *max_element(ALL(a)); }\ntemplate inline auto min(const T& a){ return *min_element(ALL(a)); }\ninline ll gcd(ll a,ll b){if(b == 0) return a;return gcd(b,a%b);}\ninline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}\n\nusing namespace std;\n\nll n,m,x;\nvector c(12);\nvector a[12];\n\nbool eval(vector aa){\n REP(i,0,aa.size()){\n if(aa[i] < x)return false;\n }\n return true;\n}\n\nll dfs(ll index, ll cost,vector& aa){\n if(eval(aa))return cost;\n if(index >= n)return INF;\n\n ll ret = INF;\n \n vector aaa = aa;\n REP(i,0,aaa.size())aaa[i] += a[index][i];\n ret = min(ret,dfs(index+1,cost+c[index],aaa));\n\n ret = min(ret,dfs(index+1,cost,aa));\n\n return ret;\n}\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n cin >> n >> m >> x;\n REP(i,0,n){\n cin >> c[i];\n REP(j,0,m){\n ll aa;\n cin >> aa;\n a[i].push_back(aa);\n }\n }\n \n vector aaa(m,0);\n ll ans = dfs(0,0,aaa);\n if(ans == INF)ans = -1;\n \n cout << ans << endl;\n\n return 0;\n} ", "language": "C++", "metadata": {"date": 1589160340, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02683/input.txt", "sample_output_relpath": "derived/input_output/data/p02683/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02683/C++/s669777914.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669777914", "user_id": "u855087874"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "#include \n\n/*==========type============*/\ntypedef long long ll;\ntypedef std::pair pii;\ntypedef std::pair pll;\ntypedef std::pair psl;\n\n/*==========constant============*/\n#define INF INT_MAX\n#define INF_L LONG_MAX\n#define INF_LL LLONG_MAX\n#define MOD 1000000007\n\n/*==========function============*/\n#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)\n#define RREP(ii,nn,jj) for (ll ii = nn; jj name(__VA_ARGS__)\ntemplate inline auto max(const T& a){ return *max_element(ALL(a)); }\ntemplate inline auto min(const T& a){ return *min_element(ALL(a)); }\ninline ll gcd(ll a,ll b){if(b == 0) return a;return gcd(b,a%b);}\ninline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}\n\nusing namespace std;\n\nll n,m,x;\nvector c(12);\nvector a[12];\n\nbool eval(vector aa){\n REP(i,0,aa.size()){\n if(aa[i] < x)return false;\n }\n return true;\n}\n\nll dfs(ll index, ll cost,vector& aa){\n if(eval(aa))return cost;\n if(index >= n)return INF;\n\n ll ret = INF;\n \n vector aaa = aa;\n REP(i,0,aaa.size())aaa[i] += a[index][i];\n ret = min(ret,dfs(index+1,cost+c[index],aaa));\n\n ret = min(ret,dfs(index+1,cost,aa));\n\n return ret;\n}\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n cin >> n >> m >> x;\n REP(i,0,n){\n cin >> c[i];\n REP(j,0,m){\n ll aa;\n cin >> aa;\n a[i].push_back(aa);\n }\n }\n \n vector aaa(m,0);\n ll ans = dfs(0,0,aaa);\n if(ans == INF)ans = -1;\n \n cout << ans << endl;\n\n return 0;\n} ", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1838, "cpu_time_ms": 5, "memory_kb": 3664}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s913111433", "group_id": "codeNet:p02687", "input_text": "#include\nusing namespace std;\nint main(){\n string S;\n cin >> S;\n \n if(S == \"ABC\") cout << \"ARC\" << endl;\n else cout << \"ABC\" << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1588554455, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/C++/s913111433.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s913111433", "user_id": "u750541753"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "#include\nusing namespace std;\nint main(){\n string S;\n cin >> S;\n \n if(S == \"ABC\") cout << \"ARC\" << endl;\n else cout << \"ABC\" << endl;\n \n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 170, "cpu_time_ms": 2, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s545682789", "group_id": "codeNet:p02688", "input_text": "#include\nusing namespace std;\nint main()\n{\n int a,b,c;\n cin>>a>>b;\n vectorm(a+1,0);\n m[0]=1;\n for(int i=0; i>c;\n vectorn(c);\n for(int j=0; j>n[i];\n m[n[i]]++;\n }\n }\n int p=0;\n for(int k=0; k\nusing namespace std;\nint main()\n{\n int a,b,c;\n cin>>a>>b;\n vectorm(a+1,0);\n m[0]=1;\n for(int i=0; i>c;\n vectorn(c);\n for(int j=0; j>n[i];\n m[n[i]]++;\n }\n }\n int p=0;\n for(int k=0; k>n>>k;\n bool snuke[n+1] = {0};\n for(int i = 0,temp; i >temp;\n for(int j=0,l; j>l;\n snuke[l] = true;\n }\n }\n int ans = 0;\n for(int i=1; i<=n; i++) {\n ans += (!snuke[i]);\n }\n cout << ans << endl;\n\n}\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(nullptr);\n // int t;cin>>t;while(t--)\n sol();\n}\n ", "language": "C++", "metadata": {"date": 1588595350, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/C++/s151986949.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151986949", "user_id": "u256710795"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#define dbg(...) \"amit_dwivedi\"\n#define db(...) \"Too OP\"\n#include \"bits/stdc++.h\" \nusing namespace std;using ll=long long;\nll n,m,L,R;\nconst int mod = 1e9+7;\n\nvoid sol(){\n int n,k;\n cin>>n>>k;\n bool snuke[n+1] = {0};\n for(int i = 0,temp; i >temp;\n for(int j=0,l; j>l;\n snuke[l] = true;\n }\n }\n int ans = 0;\n for(int i=1; i<=n; i++) {\n ans += (!snuke[i]);\n }\n cout << ans << endl;\n\n}\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(nullptr);\n // int t;cin>>t;while(t--)\n sol();\n}\n ", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 612, "cpu_time_ms": 3, "memory_kb": 3620}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s590089134", "group_id": "codeNet:p02688", "input_text": "#include\n#include\nusing namespace std;\nint main() {\n\tint n, k, d,numofnusuke,count=0;\n\tcin >> n >> k;\n\tvector nusuke(n,false);\n\tfor (int i = 0; i < k; i++) {\n\t\tcin >> d;\n\t\tfor (int j = 0; j < d; j++) {\n\t\t\tcin >> numofnusuke;\n\t\t\tnusuke[numofnusuke-1] = true;\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tif (nusuke[i] == false)\n\t\t\tcount++;\n\t}\n\tcout << count;\n}", "language": "C++", "metadata": {"date": 1588557998, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02688/input.txt", "sample_output_relpath": "derived/input_output/data/p02688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02688/C++/s590089134.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590089134", "user_id": "u417503954"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\n#include\nusing namespace std;\nint main() {\n\tint n, k, d,numofnusuke,count=0;\n\tcin >> n >> k;\n\tvector nusuke(n,false);\n\tfor (int i = 0; i < k; i++) {\n\t\tcin >> d;\n\t\tfor (int j = 0; j < d; j++) {\n\t\t\tcin >> numofnusuke;\n\t\t\tnusuke[numofnusuke-1] = true;\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tif (nusuke[i] == false)\n\t\t\tcount++;\n\t}\n\tcout << count;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 378, "cpu_time_ms": 4, "memory_kb": 3584}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s229179027", "group_id": "codeNet:p02689", "input_text": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nint main(){\n int N,M;\n cin >> N >> M;\n\n vector H(N,0);\n for(int i=0;i> H[i];\n\n int A,B;\n vector bad(N,0);\n for(int i=0;i> A >> B;\n if(H[A-1]<=H[B-1]){\n bad[A-1] = 1; // 悪である\n }\n if(H[A-1]>=H[B-1]){\n bad[B-1] = 1; // 悪である\n }\n }\n\n int count=0;\n for(int i=0;i\n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nint main(){\n int N,M;\n cin >> N >> M;\n\n vector H(N,0);\n for(int i=0;i> H[i];\n\n int A,B;\n vector bad(N,0);\n for(int i=0;i> A >> B;\n if(H[A-1]<=H[B-1]){\n bad[A-1] = 1; // 悪である\n }\n if(H[A-1]>=H[B-1]){\n bad[B-1] = 1; // 悪である\n }\n }\n\n int count=0;\n for(int i=0;i\nusing namespace std;\n\nvector vec_splitter(string s) {\n for(char& c: s) c = c == ','? ' ': c;\n stringstream ss; ss << s;\n vector res;\n for(string z; ss >> z; res.push_back(z));\n return res;\n}\n\nvoid debug_out(vector __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }\ntemplate \nvoid debug_out(vector args, int idx, Head H, Tail... T) {\n if(idx > 0) cerr << \", \";\n stringstream ss; ss << H;\n cerr << args[idx] << \" = \" << ss.str();\n debug_out(args, idx + 1, T...);\n}\n\n#ifdef XOX\n#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n\nconst double PI = acos(-1);\ntypedef long long ll;\n#define int ll\n#define fori(n) for(int i=0; i>s;\n#define cini(i) int i; cin>>i;\n#define cind(d) double d; cin>>d;\n#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }\n#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }\n#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }\n\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vd;\ntypedef vector vb;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vvvi;\ntypedef vector vs;\n\nvoid solve() {\n cini(n);\n cini(m);\n cinai(h,n);\n vvi adj(n);\n for(int i=0; i\nusing namespace std;\n\nvector vec_splitter(string s) {\n for(char& c: s) c = c == ','? ' ': c;\n stringstream ss; ss << s;\n vector res;\n for(string z; ss >> z; res.push_back(z));\n return res;\n}\n\nvoid debug_out(vector __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }\ntemplate \nvoid debug_out(vector args, int idx, Head H, Tail... T) {\n if(idx > 0) cerr << \", \";\n stringstream ss; ss << H;\n cerr << args[idx] << \" = \" << ss.str();\n debug_out(args, idx + 1, T...);\n}\n\n#ifdef XOX\n#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n\nconst double PI = acos(-1);\ntypedef long long ll;\n#define int ll\n#define fori(n) for(int i=0; i>s;\n#define cini(i) int i; cin>>i;\n#define cind(d) double d; cin>>d;\n#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }\n#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }\n#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }\n\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vd;\ntypedef vector vb;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vvvi;\ntypedef vector vs;\n\nvoid solve() {\n cini(n);\n cini(m);\n cinai(h,n);\n vvi adj(n);\n for(int i=0; i(n);--i)\n#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)\nusing namespace std;\nusing ll = long long;\n\nint main()\n{\n\tint x;\n\tcin >> x;\n\tllrep(i, -200, 200)\n\t\tllrep(j, -200, 200)\n\t\tif (i*i*i*i*i - j * j*j*j*j == x) {\n\t\t\tcout << i << \" \" << j << endl;\n\t\t\treturn 0;\n\t\t}\n\t//cout << a << b << endl;\n}\n\n/*\nライブラリ\n・string\n・vector\n::::vector> A(N,vector(M));\n::::A[i][j] = i;\n・map\n\n関数\n・rep(i,n) … ループ(i=0;i(n);--i)\n#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)\nusing namespace std;\nusing ll = long long;\n\nint main()\n{\n\tint x;\n\tcin >> x;\n\tllrep(i, -200, 200)\n\t\tllrep(j, -200, 200)\n\t\tif (i*i*i*i*i - j * j*j*j*j == x) {\n\t\t\tcout << i << \" \" << j << endl;\n\t\t\treturn 0;\n\t\t}\n\t//cout << a << b << endl;\n}\n\n/*\nライブラリ\n・string\n・vector\n::::vector> A(N,vector(M));\n::::A[i][j] = i;\n・map\n\n関数\n・rep(i,n) … ループ(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n signed long X;\n cin>>X;\n signed long A,B;\n vector ALL;\n for(int i=0;i<10;i++){\n long tmp=pow(i,5);\n ALL.push_back(tmp);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n signed long X;\n cin>>X;\n signed long A,B;\n vector ALL;\n for(int i=0;i<10;i++){\n long tmp=pow(i,5);\n ALL.push_back(tmp);\n cout<\nusing namespace std;\nusing ll = long long;\nusing grid = vector>;\n\nint dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 }; // i<4:4way i<8:8way\nint dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };\n\nconstexpr ll MOD = 1000000007;\n//constexpr ll MOD = 998244353;\n\nconstexpr ll INF = 1050000000;\nconstexpr ll LONGINF = 1050000000000000000;\nstruct all_init {\n all_init() {\n cout.tie(nullptr);\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n cout << fixed << setprecision(11);\n };\n} ALL_INIT;\nstruct edge {\n int from, to;\n ll cost;\n ll capa;\n \n edge(int s, int d) : from(s), to(d) {cost = 0;capa = 0;}\n edge(int s, int d, ll w) : from(s), to(d), cost(w) { capa = 0; }\n edge(int s, int d, ll x, ll y) : from(s), to(d), cost(x), capa(y) {}\n \n bool operator<(const edge& x) const {\n if(cost>;\nvoid add_edge(vector>& g, int a, int b, ll cost, ll cap) {\n g[a].emplace_back(a, b, cost, cap);\n g[b].emplace_back(b, a, cost, cap);\n}\n \n#define CIN(vector_array_etc, n) \\\n for (int loop = 0; loop < n; loop++) { \\\n cin >> vector_array_etc[loop]; \\\n }\n#define COUT(vector_array_etc, n) \\\n for (int LOOP = 0; LOOP < n; LOOP++) { \\\n cout << vector_array_etc[LOOP] << (LOOP == n - 1 ? '\\n' : ' '); \\\n }\n#define VC(Type_name) vector\n#define SORT(vector_etc) sort(vector_etc.begin(), vector_etc.end())\n#define ALL(vec_etc) vec_etc.begin(), vec_etc.end()\n#define VCVC(Type_name) vector> \n#define WARSHALL vector> g(n, vector(n, LONGINF))\n#define endl '\\n'\n\n \ntemplate \nbool chmax(T& a, const T& b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nbool chmin(T& a, const T& b) {\n if (b < a) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nistream& operator>>(istream& is, vector& Vec) {\n for (T& x : Vec) {\n is >> x;\n }\n return is;\n}\ntemplate \nvoid resize(vector& vec, const H head) {\n vec.resize(head);\n}\ntemplate \nvoid resize(vector& vec, const H& head, const T... tail) {\n vec.resize(head);\n for (auto& v : vec) {\n resize(v, tail...);\n }\n}\ntemplate \nstruct ModInt {\n long long val;\n constexpr ModInt(long long v = 0) noexcept : val(v% mod) {\n if (val < 0) val += mod;\n }\n constexpr int getmod() { return mod; }\n constexpr ModInt operator-() const noexcept { return val ? mod - val : 0; }\n constexpr ModInt operator+(const ModInt& r) const noexcept {\n return ModInt(*this) += r;\n }\n constexpr ModInt operator-(const ModInt& r) const noexcept {\n return ModInt(*this) -= r;\n }\n constexpr ModInt operator*(const ModInt& r) const noexcept {\n return ModInt(*this) *= r;\n }\n constexpr ModInt operator/(const ModInt& r) const noexcept {\n return ModInt(*this) /= r;\n }\n constexpr ModInt& operator+=(const ModInt& r) noexcept {\n val += r.val;\n if (val >= mod) val -= mod;\n return *this;\n }\n constexpr ModInt& operator-=(const ModInt& r) noexcept {\n val -= r.val;\n if (val < 0) val += mod;\n return *this;\n }\n constexpr ModInt& operator*=(const ModInt& r) noexcept {\n val = val * r.val % mod;\n return *this;\n }\n constexpr ModInt& operator/=(const ModInt& r) noexcept {\n long long a = r.val, b = mod, 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 val = val * u % mod;\n if (val < 0) val += mod;\n return *this;\n }\n constexpr bool operator==(const ModInt& r) const noexcept {\n return this->val == r.val;\n }\n constexpr bool operator!=(const ModInt& r) const noexcept {\n return this->val != r.val;\n }\n friend ostream& operator<<(ostream& os, const ModInt& x) noexcept {\n return os << x.val;\n }\n friend istream& operator>>(istream& is, ModInt& x) noexcept {\n return is >> x.val;\n }\n friend constexpr ModInt modpow(const ModInt& a,\n long long n) noexcept {\n if (n == 0) return 1;\n auto t = modpow(a, n / 2);\n t = t * t;\n if (n & 1) t = t * a;\n return t;\n }\n};\ntemplate \nstruct nCk {\n vector fact_, inv_, finv_;\n constexpr nCk() {}\n constexpr nCk(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {\n init(n);\n }\n constexpr void init(int n) noexcept {\n fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);\n ll MOD = 1000000007;\n for (ll i = 2; i < n; i++) {\n fact_[i] = fact_[i - 1] * i;\n inv_[i] = -inv_[MOD % i] * (MOD / i);\n finv_[i] = finv_[i - 1] * inv_[i];\n }\n }\n constexpr T com(ll n, ll k) const noexcept {\n if (n < k || n < 0 || k < 0) return 0;\n return fact_[n] * finv_[k] * finv_[n - k];\n }\n constexpr T fact(int n) const noexcept {\n if (n < 0) return 0;\n return fact_[n];\n }\n constexpr T inv(int n) const noexcept {\n if (n < 0) return 0;\n return inv_[n];\n }\n constexpr T finv(int n) const noexcept {\n if (n < 0) return 0;\n return finv_[n];\n }\n};\n\nll PowMod(ll n, ll k, ll mod) {\n ll r = 1;\n \n for (; k > 0; k >>= 1) {\n if (k & 1) {\n r = (r * n) % mod;\n }\n n = (n * n) % mod;\n }\n return r;\n}\nll Gcd(ll a, ll b) {\n return b != 0 ? Gcd(b, a % b) : a;\n}\nll Lcm(ll a, ll b) {\n return a / Gcd(a, b) * b;\n}\nvector Split(string s, string t) {\n vector v;\n int p = s.find(t);\n while (p != s.npos) {\n v.emplace_back(s.substr(0, p));\n s = s.substr(p + (int)t.size());\n p = s.find(t);\n }\n v.emplace_back(s);\n return v;\n}\nvector Lis(const vector& a) {\n #define Index_of(as, x) distance(as.begin(), upper_bound(as.begin(), as.end(),x))\n//#define Index_of(as, x) \\\n distance(as.begin(), upper_bound(as.begin(), as.end(), x))\n const int n = a.size();\n vector A(n, INF);\n vector id(n);\n for (int i = 0; i < n; ++i) {\n id[i] = Index_of(A, a[i]);\n A[id[i]] = a[i];\n }\n int m = *max_element(id.begin(), id.end());\n vector b(m + 1);\n for (int i = n - 1; i >= 0; --i)\n if (id[i] == m) b[m--] = a[i];\n return b;\n}\nstring LcsAlphabeticalMinOrder(string a, string b) {\n if (a.size() < b.size()) {\n swap(a, b);\n }\n \n int n = a.size(), m = b.size();\n \n vector dp(m + 1);\n \n for (int i = 0; i < n; i++) {\n vector to(m + 1);\n for (int j = 0; j < m; j++) {\n if (a[i] == b[j]) {\n to[j + 1] = dp[j] + a[i];\n }\n else {\n if (to[j].size() > dp[j + 1].size()) {\n to[j + 1] = to[j];\n }\n else if (to[j].size() < dp[j + 1].size()) {\n to[j + 1] = dp[j + 1];\n }\n else if (to[j] < dp[j + 1]) {\n to[j + 1] = to[j];\n }\n else {\n to[j + 1] = dp[j + 1];\n }\n }\n }\n dp.swap(to);\n }\n return dp[m];\n}\nstring Lcs(const string& s, const string& t) {\n int n = s.size();\n int m = t.size();\n int dp[n+1][m+1];\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= m; j++) {\n if (s[i - 1] == t[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n }\n else {\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n string ans = \"\";\n int i = s.size(), j = t.size();\n while (i > 0 && j > 0) {\n if (s[i - 1] == t[j - 1]) {\n ans += s[i - 1];\n i--;\n j--;\n }\n else if (dp[i - 1][j] >= dp[i][j - 1])\n i--;\n else\n j--;\n }\n reverse(ans.begin(), ans.end());\n return ans;\n}\nvector LcsInteger(const vector &a, const vector &b) {\n#define index_of(as, x) \\\n distance(as.begin(), lower_bound(as.begin(), as.end(), x))\n struct node {\n int value;\n node* next;\n node(int value, node* next) : value(value), next(next) {}\n };\n const int n = a.size(), m = b.size();\n map> M;\n for (int j = m - 1; j >= 0; --j) M[b[j]].push_back(j);\n vector xs(n + 1, INF);\n xs[0] = -INF;\n vector link(n + 1);\n for (int i = 0; i < n; ++i) {\n if (M.count(a[i])) {\n vector ys = M[a[i]];\n for (int j = 0; j < (int)ys.size(); ++j) {\n int k = index_of(xs, ys[j]);\n xs[k] = ys[j];\n link[k] = new node(b[ys[j]], link[k - 1]);\n }\n }\n }\n vector c;\n int l = index_of(xs, INF - 1) - 1;\n for (node* p = link[l]; p; p = p->next) c.push_back(p->value);\n reverse(c.begin(), c.end());\n return c;\n}\nbool IsPrime(ll n) {\n if (n < 2) return false;\n for (ll i = 2; i * i <= n; i++)\n if (!(n % i)) return false;\n return true;\n}\nvector Eratosthenes(int n) {\n vector res;\n vector Prime(n + 1, true);\n Prime[0] = Prime[1] = false;\n for (int i = 2; i * i <= n; i++) {\n if (Prime[i]) {\n for (int j = 2; i * j <= n; j++) {\n Prime[i * j] = false;\n }\n }\n }\n for (int i = 2; i <= n; i++) {\n if (Prime[i]) {\n res.emplace_back(i);\n }\n }\n return res;\n}\nll maxSubArraySum(vector a,int left,int right) {\n //[left,right)\n int size=a.size(); \n ll max_so_far = -LONGINF, max_ending_here = 0; \n \n for (int i = left; i < right; i++) { \n max_ending_here = max_ending_here + a[i]; \n if (max_so_far < max_ending_here) {\n max_so_far = max_ending_here; \n }\n \n if (max_ending_here < 0) {\n max_ending_here = 0; \n }\n } \n return max_so_far; \n}\nll MergeCount(vector& a) {\n ll count = 0;\n int n = a.size();\n if (n > 1) {\n vector b(a.begin(), a.begin() + n / 2);\n vector c(a.begin() + n / 2, a.end());\n count += MergeCount(b);\n count += MergeCount(c);\n for (int i = 0, j = 0, k = 0; i < n; ++i)\n if (k == (int)c.size())\n a[i] = b[j++];\n else if (j == (int)b.size())\n a[i] = c[k++];\n else if (b[j] <= c[k])\n a[i] = b[j++];\n else {\n a[i] = c[k++];\n count += n / 2 - j;\n }\n }\n return count;\n}\nbool WarshallFloyd(vector>& c) {\n int V = c.size();\n for (int i = 0; i < V; i++) {\n c[i][i] = 0;\n }\n \n for (int i = 0; i < V; i++) {\n for (int j = 0; j < V; j++) {\n for (int k = 0; k < V; k++) {\n if (c[j][k] > c[j][i] + c[i][k]) {\n if(c[j][i] != LONGINF && c[i][k] != LONGINF){\n c[j][k] = c[j][i] + c[i][k];\n }\n }\n }\n }\n }\n \n for (int i = 0; i < V; i++) {\n if (c[i][i] < 0) {\n return false;\n }\n }\n \n return true;\n}\nvector Dijkstra(int i, vector> graph) {\n int n = graph.size();\n vector d(n, LONGINF);\n d[i] = 0;\n priority_queue, vector>, greater>>\n q;\n q.push(make_pair(0, i));\n while (!q.empty()) {\n pair p = q.top();\n q.pop();\n int v = p.second;\n if (d[v] < p.first) {\n continue;\n }\n for (auto x : graph[v]) {\n if (d[x.to] > d[v] + x.cost) {\n d[x.to] = d[v] + x.cost;\n q.push(make_pair(d[x.to], x.to));\n }\n }\n }\n return d;\n}\nvector> gridDijkstra(const int &start_h,const int &start_w,const vector> &a){\n const int h=a.size();\n const int w=a[0].size();\n vector> dp(h,vector(w,LONGINF));\n\n struct status{\n int x,y;\n ll cost;\n status(int x_,int y_):status(x_,y_,1LL){};\n status(int x_,int y_,ll cost_):x(x_),y(y_),cost(cost_){};\n };\n class Compare {\n public:\n\t bool operator()(const status&from, const status&to) {\n\t\t return from.cost>to.cost;\n\t }\n };\n\n priority_queue,Compare> q;\n status tmp_start(start_h,start_w,0LL);\n q.push(tmp_start);\n\n //from,to cost\n auto costFunction=[](const ll a,const ll b){return max(b-a,0LL);};\n //auto costFinction=[](const ll a,const ll b){return a+b};\n\n #define COST costFunction(a[x][y],a[nx][ny])\n\n while(q.size()){\n status tmp1(q.top());\n int x=tmp1.x;\n int y=tmp1.y;\n ll sum=tmp1.cost;\n q.pop();\n if(chmin(dp[x][y],sum)){\n for(int i=0;i<4;i++){\n int nx=x+dx[i];\n int ny=y+dy[i];\n if(nx<0||nx>=h||ny<0||ny>=w){\n continue;\n }\n if(dp[nx][ny]!=LONGINF&&dp[nx][ny]<=sum+COST){\n continue;\n }\n status tmp2(nx,ny,sum+COST);\n q.push(tmp2);\n }\n }\n }\n\n return dp;\n}\nbool BellmanFord(int start, int V, int E, vector Edge, vector& d) {\n resize(d, V);\n fill(d.begin(), d.end(), LONGINF);\n d[start] = 0;\n vector t(V, false);\n for (int i = 0; i < V - 1; i++) {\n for (int j = 0; j < E; j++) {\n edge e = Edge[j];\n if (d[e.from] == LONGINF) {\n continue;\n }\n if (d[e.to] > d[e.from] + e.cost) {\n d[e.to] = d[e.from] + e.cost;\n }\n }\n }\n for (int i = 0; i < V; i++) {\n for (int j = 0; j < E; j++) {\n edge e = Edge[j];\n if (d[e.from] == LONGINF) {\n continue;\n }\n if (d[e.to] > d[e.from] + e.cost) {\n d[e.to] = d[e.from] + e.cost;\n t[e.to] = true;\n /*\n if (i == V - 1) {\n return false;\n }\n */\n }\n if (t[e.from]) {\n t[e.to] = true;\n }\n }\n }\n \n if (t[V - 1]) {\n return false;\n }\n \n return true;\n}\nbool TopologicalSort(const vector>& g, vector& ans) {\n int n = g.size(), k = 0;\n vector ord(n), in(n);\n for (auto& es : g) {\n for (auto& e : es) {\n in[e.to]++;\n }\n }\n queue q;\n for (int i = 0; i < n; ++i) {\n if (in[i] == 0) q.push(i);\n }\n while (!q.empty()) {\n int v = q.front();\n q.pop();\n ord[k++] = v;\n for (auto& e : g[v]) {\n if (--in[e.to] == 0) q.push(e.to);\n }\n }\n ans = ord;\n if (*max_element(in.begin(), in.end()) == 0) {\n return true;\n }\n return false;\n}\nvector ArticulationNode(const vector>& g) {\n int n = g.size(), idx;\n vector low(n), ord(n), art;\n function DFS = [&](int v) {\n low[v] = ord[v] = ++idx;\n for (auto& e : g[v]) {\n int w = e.to;\n if (ord[w] == 0) {\n DFS(w);\n low[v] = min(low[v], low[w]);\n if ((ord[v] == 1 && ord[w] != 2) || (ord[v] != 1 && low[w] >= ord[v])) {\n art.push_back(v);\n }\n }\n else {\n low[v] = min(low[v], ord[w]);\n }\n }\n };\n for (int u = 0; u < n; u++) {\n if (ord[u] == 0) {\n idx = 0;\n DFS(u);\n }\n }\n \n sort(art.begin(), art.end());\n art.erase(unique(art.begin(), art.end()),\n art.end());\n \n return art;\n}\nedge TreeDiameter(const vector>& g) {\n int start = 0;\n static const auto bfs = [](const vector>& g, int s,\n queue& q, vector& dist) {\n while (!q.empty()) {\n q.pop();\n }\n q.push(s);\n int n = g.size();\n dist.assign(n, LONGINF);\n dist[s] = 0;\n while (q.size()) {\n int u = q.front();\n q.pop();\n for (auto& e : g[u]) {\n int v = e.to;\n if (dist[v] == LONGINF) {\n dist[v] = dist[u] + e.cost;\n q.push(v);\n }\n }\n }\n return dist;\n };\n vector dist;\n queue q;\n bfs(g, start, q, dist);\n int n = g.size(), u = -1, v = -1;\n for (int i = 0; i < n; i++)\n if (dist[i] != LONGINF && (u == -1 || dist[i] > dist[u])) u = i;\n bfs(g, u, q, dist);\n for (int i = 0; i < n; i++)\n if (dist[i] != LONGINF && (v == -1 || dist[i] > dist[v])) v = i;\n ll d = dist[v];\n if (u > v) swap(u, v);\n return edge(u, v, d);\n}\nclass UnionFind {\nprivate:\n std::vector parent;\n std::vector height;\n std::vector m_size;\n int forest_num;\n \npublic:\n UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {\n forest_num = size_;\n for (int i = 0; i < size_; ++i) parent[i] = i;\n }\n void init(int size_) {\n parent.resize(size_);\n height.resize(size_, 0);\n m_size.resize(size_, 1);\n forest_num = size_;\n for (int i = 0; i < size_; ++i) parent[i] = i;\n }\n int find(int x) {\n if (parent[x] == x) return x;\n return parent[x] = find(parent[x]);\n }\n bool unite(int x, int y) {\n x = find(x);\n y = find(y);\n if (x == y) return false;\n int t = size(x) + size(y);\n m_size[x] = m_size[y] = t;\n if (height[x] < height[y])\n parent[x] = y;\n else\n parent[y] = x;\n if (height[x] == height[y]) ++height[x];\n forest_num--;\n return true;\n }\n bool same(int x, int y) { return find(x) == find(y); }\n int size(int x) {\n if (parent[x] == x) return m_size[x];\n return size(parent[x] = find(parent[x]));\n }\n int forest() { return forest_num; }\n vector get_parent(){\n return parent;\n }\n};\nclass Dinic {\nprivate:\n int n, s, t;\n vector level, prog, que;\n vector> cap, flow;\n vector> g;\n ll inf;\n \npublic:\n Dinic(const vector>& graph)\n : n(graph.size()),\n cap(n, vector(n)),\n flow(n, vector(n)),\n g(n, vector()),\n inf(LONGINF) {\n for (int i = 0; i < n; i++) {\n for (auto& e : graph[i]) {\n int u = e.from, v = e.to;\n ll c = e.capa;\n cap[u][v] += c;\n cap[v][u] += c;\n flow[v][u] += c;\n g[u].push_back(v);\n g[v].push_back(u);\n }\n }\n }\n inline ll residue(int u, int v) { return cap[u][v] - flow[u][v]; }\n ll solve(int s_, int t_) {\n this->t = t_, this->s = s_;\n que.resize(n + 1);\n ll res = 0;\n while (levelize()) {\n prog.assign(n, 0);\n res += augment(s, inf);\n }\n return res;\n }\n bool levelize() {\n int l = 0, r = 0;\n level.assign(n, -1);\n level[s] = 0;\n que[r++] = s;\n while (l != r) {\n int v = que[l++];\n if (v == t) break;\n for (const int& d : g[v])\n if (level[d] == -1 && residue(v, d) != 0) {\n level[d] = level[v] + 1;\n que[r++] = d;\n }\n }\n return level[t] != -1;\n }\n ll augment(int v, ll lim) {\n ll res = 0;\n if (v == t) return lim;\n for (int& i = prog[v]; i < (int)g[v].size(); i++) {\n const int& d = g[v][i];\n if (residue(v, d) == 0 || level[v] >= level[d]) continue;\n const ll aug = augment(d, min(lim, residue(v, d)));\n flow[v][d] += aug;\n flow[d][v] -= aug;\n res += aug;\n lim -= aug;\n if (lim == 0) break;\n }\n return res;\n }\n};\nclass MinimumCostFlow {\nprivate:\n using Flow = ll;\n using Cost = ll;\n struct Edge {\n int d;\n Flow c, f;\n Cost w;\n int r, is_r;\n Edge(int d_, Flow c_, Flow f_, Cost w_, int r_, bool is_r_)\n : d(d_), c(c_), f(f_), w(w_), r(r_), is_r(is_r_) {}\n };\n int n;\n vector> g;\n \npublic:\n MinimumCostFlow(int n_) : n(n_), g(vector>(n_)) {}\n \n void add_edge(int src, int dst, Cost cost,Flow cap) {\n int rsrc = g[dst].size();\n int rdst = g[src].size();\n g[src].emplace_back(dst, cap, 0, cost, rsrc, false);\n g[dst].emplace_back(src, cap, cap, -cost, rdst, true);\n }\n \n Cost solve(int s, int t, Flow f) {\n Cost res = 0;\n \n vector h(n + 10), dist(n);\n vector prevv(n + 10), preve(n + 10);\n \n using pcv = pair;\n priority_queue, greater> q;\n fill(h.begin(), h.end(), 0);\n while (f > 0) {\n fill(dist.begin(), dist.end(), LONGINF);\n dist[s] = 0;\n q.emplace(0, s);\n while (q.size()) {\n Cost cd;\n int v;\n tie(cd, v) = q.top();\n q.pop();\n if (dist[v] < cd) continue;\n for (int i = 0; i < (int)(g[v].size()); ++i) {\n Edge& e = g[v][i];\n if (residue(e) == 0) continue;\n if (dist[e.d] + h[e.d] > cd + h[v] + e.w) {\n dist[e.d] = dist[v] + e.w + h[v] - h[e.d];\n prevv[e.d] = v;\n preve[e.d] = i;\n q.emplace(dist[e.d], e.d);\n }\n }\n }\n \n if (dist[t] == LONGINF) return -1;\n \n for (int i = 0; i < n; ++i) h[i] += dist[i];\n Flow d = f;\n for (int v = t; v != s; v = prevv[v]) {\n chmin(d, residue(g[prevv[v]][preve[v]]));\n }\n f -= d;\n res += d * h[t];\n for (int v = t; v != s; v = prevv[v]) {\n Edge& e = g[prevv[v]][preve[v]];\n e.f += d;\n g[v][e.r].f -= d;\n }\n }\n return res;\n }\n \n Flow residue(const Edge& e) { return e.c - e.f; }\n \n void show() {\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < (int)(g[i].size()); ++j) {\n Edge& e = g[i][j];\n if (e.is_r) continue;\n cout << i << \"->\" << e.d << \"(flow:\" << e.f << \")\" << endl;\n }\n }\n }\n};\nclass BipartiteMatching {\nprivate:\n int V;\n vector match;\n vector used;\n vector> g;\n vector> match_pair;\n \n bool dfs(int v) {\n used[v] = true;\n for (int i = 0; i < (int)g[v].size(); i++) {\n int u = g[v][i];\n int w = match[u];\n if (w < 0 || !used[w] && dfs(w)) {\n match[v] = u;\n match[u] = v;\n match_pair.emplace_back(make_pair(u, v));\n return true;\n }\n }\n return false;\n }\n \npublic:\n BipartiteMatching(int n) {\n V = n;\n resize(match, n);\n resize(used, n);\n resize(g, n);\n }\n \n void add_edge(int u, int v) {\n g[u].emplace_back(v);\n g[v].emplace_back(u);\n }\n \n int MatchingSolve() {\n int res = 0;\n fill(match.begin(), match.end(), -1);\n \n for (int v = 0; v < V; v++) {\n if (match[v] < 0) {\n fill(used.begin(), used.end(), false);\n if (dfs(v)) {\n res++;\n }\n }\n }\n return res;\n }\n \n vector> get_pair() {\n for (auto x : match_pair) {\n cout << x.first << \" \" << x.second << endl;\n }\n return match_pair;\n }\n};\nclass Lca {\nprivate:\n int n;\n int log2_n;\n vector> parent;\n vector depth;\n \n void dfs(const vector>& g, int v, int p, int d) {\n parent[0][v] = p;\n depth[v] = d;\n for (auto& e : g[v]) {\n if (e.to != p) {\n dfs(g, e.to, v, d + 1);\n }\n }\n }\n \npublic:\n Lca(const vector>& g, int root) {\n n = g.size();\n log2_n = (int)log2(n) + 1;\n resize(parent, log2_n, n);\n resize(depth, n);\n \n dfs(g, root, -1, 0);\n \n for (int k = 0; k + 1 < log2_n; k++) {\n for (int v = 0; v < (int)g.size(); v++) {\n if (parent[k][v] < 0) {\n parent[k + 1][v] = -1;\n }\n else {\n parent[k + 1][v] = parent[k][parent[k][v]];\n }\n }\n }\n }\n \n int get_lca(int u, int v) {\n if (depth[u] > depth[v]) {\n swap(u, v);\n }\n \n for (int k = 0; k < log2_n; k++) {\n if ((depth[v] - depth[u]) >> k & 1) {\n v = parent[k][v];\n }\n }\n if (u == v) {\n return u;\n }\n \n for (int k = log2_n - 1; k >= 0; k--) {\n if (parent[k][u] != parent[k][v]) {\n u = parent[k][u];\n v = parent[k][v];\n }\n }\n return parent[0][u];\n }\n \n int get_depth(int v) { return depth[v]; }\n};\nclass DAG {\nprivate:\n int n;\n vector> g;\n vector visited;\n vector dp;\n vector topological;\n \n int dfs(int s) {\n if ((int)g[s].size() == 0) {\n return 1;\n }\n if (dp[s] > 0) {\n return dp[s];\n }\n \n int mx = 1;\n for (auto j : g[s]) {\n if (visited[j.to] == 0) {\n visited[j.to] = 1;\n int l = 0;\n l = dfs(j.to);\n chmax(mx, l);\n }\n else {\n chmax(mx, dp[j.to]);\n }\n }\n return dp[s] = mx + 1;\n }\n \npublic:\n DAG(const vector>& f) {\n g = f;\n n = f.size();\n resize(visited, n + 1);\n fill(visited.begin(), visited.end(), 0);\n resize(dp, n + 1);\n fill(dp.begin(), dp.end(), -1);\n resize(topological, n);\n }\n DAG(int x) {\n n = x;\n resize(g, n);\n resize(visited, n + 1);\n fill(visited.begin(), visited.end(), 0);\n resize(dp, n + 1);\n fill(dp.begin(), dp.end(), -1);\n }\n \n void add_edge(int a, int b) { g[a].emplace_back(a, b); }\n void add_edge(int a, int b, ll c) { g[a].emplace_back(a, b, c); }\n void add_edge(int a, int b, ll c, ll d) { g[a].emplace_back(a, b, c, d); }\n \n int longest_path() {\n int mx = -1;\n int res=0;\n for (int i = 0; i < n; i++) {\n int h = 0;\n if (visited[i] == 0) {\n h = dfs(i);\n if(mx ord(n), in(n);\n for (int i=0;i q;\n for (int i = 0; i < n; ++i) {\n if (in[i] == 0) q.push(i);\n }\n while (!q.empty()) {\n int v = q.top();\n q.pop();\n ord[v] = k;\n k--;\n for (auto& e : g[v]) {\n in[e.to]-=1;\n if (in[e.to] == 0) {\n q.push(e.to);\n }\n }\n }\n topological = ord;\n if (*max_element(in.begin(), in.end()) == 0) {\n return true;\n }\n return false;\n }\n \n vector getTopologicalArray(){\n return topological;\n }\n};\n\n//↑ここまでGitHubに突っ込んだ\n\n\n\n\nclass RangeMinimumUpdateQuerySegmentTree {\nprivate:\n int n;\n ll inf = (1LL << 31) - 1; // 2^31-1\n vector dat, lazy;\n \n void eval(int len, int k) {\n if (lazy[k] == inf) return;\n if (k * 2 + 1 < n * 2 - 1) {\n lazy[2 * k + 1] = lazy[k];\n lazy[2 * k + 2] = lazy[k];\n }\n dat[k] = lazy[k];\n lazy[k] = inf;\n }\n \npublic:\n RangeMinimumUpdateQuerySegmentTree() {}\n RangeMinimumUpdateQuerySegmentTree(int n_) {\n n = 1;\n while (n < n_) n *= 2;\n dat.assign(n * 2, inf);\n lazy.assign(n * 2, inf);\n }\n \n // [a,b)\n ll update(int a, int b, ll x, int k, int l, int r) {\n eval(r - l, k);\n if (b <= l || r <= a) return dat[k];\n if (a <= l && r <= b) {\n lazy[k] = x;\n return lazy[k];\n }\n return dat[k] = min(update(a, b, x, 2 * k + 1, l, (l + r) / 2),\n update(a, b, x, 2 * k + 2, (l + r) / 2, r));\n }\n ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }\n \n // [a, b)\n ll query(int a, int b, int k, int l, int r) {\n eval(r - l, k);\n if (b <= l || r <= a) return inf;\n if (a <= l && r <= b) return dat[k];\n ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);\n ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);\n return min(vl, vr);\n }\n ll query(int a, int b) { return query(a, b, 0, 0, n); }\n};\nclass RangeSumQuerySegmentTree {\nprivate:\n struct Node {\n Node* left, * right;\n ll v;\n \n Node() : left(nullptr), right(nullptr), v(0) {}\n };\n Node* root;\n ll n, n0;\n ll query(ll a, ll b, Node* n, ll l, ll r) {\n if (a <= l && r <= b) {\n return n->v;\n }\n if (r <= a || b <= l) {\n return 0;\n }\n \n ll lv = n->left ? query(a, b, n->left, l, (l + r) >> 1) : 0;\n ll rv = n->right ? query(a, b, n->right, (l + r) >> 1, r) : 0;\n return (lv + rv) % MOD;\n }\n \npublic:\n RangeSumQuerySegmentTree(ll n) : n(n) {\n n0 = 1;\n while (n0 < n) n0 <<= 1;\n root = new Node();\n }\n ~RangeSumQuerySegmentTree() {\n delete root;\n root = nullptr;\n }\n \n void update(ll k, ll x) {\n Node* n = root;\n ll l = 0, r = n0;\n n->v = (n->v + x) % MOD;\n while (r - l > 1) {\n ll m = (l + r) >> 1;\n if (k < m) {\n if (!n->left) n->left = new Node();\n n = n->left;\n \n r = m;\n }\n else {\n if (!n->right) n->right = new Node();\n n = n->right;\n \n l = m;\n }\n n->v = (n->v + x) % MOD;\n }\n }\n \n ll query(ll a, ll b) { return query(a, b, root, 0, n0); }\n \n ll lquery(ll b) { return query(0, b, root, 0, n0); }\n \n ll rquery(ll a) { return query(a, n0, root, 0, n0); }\n};\nclass KDimensionalTree {\npublic:\n struct Node {\n int location;\n int p, l, r;\n Node() {}\n };\n struct Point {\n int id, x, y;\n Point() {}\n Point(int i, int a, int b) {\n id = i;\n x = a;\n y = b;\n }\n bool operator<(const Point& p) const { return id < p.id; }\n void print() { cout << id << endl; }\n };\n static const ll NIL = -1;\n static bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }\n static bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }\n \n int N;\n vector P;\n vector T;\n int np;\n \n KDimensionalTree() {}\n KDimensionalTree(int N) { init(N); }\n \n void init(int n) {\n N = n;\n P.clear();\n T.clear();\n resize(P, N);\n resize(T, N);\n np = 0;\n }\n \n int makeKDTree(int l, int r, int depth) {\n if (l >= r) {\n return NIL;\n }\n int mid = (l + r) / 2;\n int t = np++;\n if (depth & 1) {\n sort(P.begin() + l, P.begin() + r, lessY);\n }\n else {\n sort(P.begin() + l, P.begin() + r, lessX);\n }\n T[t].location = mid;\n T[t].l = makeKDTree(l, mid, depth + 1);\n T[t].r = makeKDTree(mid + 1, r, depth + 1);\n return t;\n }\n void find(int v, int sx, int tx, int sy, int ty, int depth,\n vector& ans) {\n int x = P[T[v].location].x;\n int y = P[T[v].location].y;\n if (sx <= x && x <= tx && sy <= y && y <= ty) {\n ans.push_back(P[T[v].location]);\n }\n if (depth % 2 == 0) {\n if (T[v].l != NIL) {\n if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);\n }\n if (T[v].r != NIL) {\n if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);\n }\n }\n else {\n if (T[v].l != NIL) {\n if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);\n }\n if (T[v].r != NIL) {\n if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);\n }\n }\n }\n void add_point(int i, int x, int y) {\n P[i].id = i;\n P[i].x = x;\n P[i].y = y;\n T[i].l = T[i].r = T[i].p = NIL;\n }\n};\nclass RangeAddQuerySegmentTree {\nprivate:\n int n;\n vector data;\n \npublic:\n RangeAddQuerySegmentTree() {}\n RangeAddQuerySegmentTree(int N) {\n n = N;\n resize(data, n + 1);\n fill(data.begin(), data.end(), 0);\n }\n \n void add(int i, ll x) {\n while (i) {\n data[i] += x;\n i -= (i & -i);\n }\n }\n void add(int i, int j, ll x) {\n add(j, x);\n add(i - 1, -x);\n }\n \n ll get(int i) {\n ll res = 0;\n while (i <= n) {\n res += data[i];\n i += (i & -i);\n }\n return res;\n }\n};\nclass RangeSumAddQuerySegmentTree {\nprivate:\n vector bit0, bit1;\n int n;\n \n ll sum(const vector& b, int i) {\n ll s = 0;\n while (i > 0) {\n s += b[i];\n i -= (i & -i);\n }\n return s;\n }\n \n void add(vector& b, int i, ll v) {\n while (i <= n) {\n b[i] += v;\n i += (i & -i);\n }\n }\n \npublic:\n RangeSumAddQuerySegmentTree() {}\n RangeSumAddQuerySegmentTree(int N) {\n n = N;\n resize(bit0, n + 1);\n resize(bit1, n + 1);\n fill(bit0.begin(), bit0.end(), 0);\n fill(bit1.begin(), bit1.end(), 0);\n }\n \n void update(int l, int r, ll x) {\n add(bit0, l, -x * (l - 1));\n add(bit1, l, x);\n add(bit0, r + 1, x * r);\n add(bit1, r + 1, -x);\n }\n \n ll query(int l, int r) {\n ll res = 0;\n res += sum(bit0, r) + sum(bit1, r) * r;\n res -= sum(bit0, l - 1) + sum(bit1, l - 1) * (l - 1);\n return res;\n }\n};\n\n\nlong double cross(const complex &a, const complex &b) { return a.real() * b.imag() - a.imag() * b.real(); }\nlong double dot(const complex &a, const complex &b) { return a.real() * b.real() + a.imag() * b.imag(); }\n\npair> smallest_enclosing_disc(vector> ps){\n const long double pi = 3.1415926535897932384626;\n static const long double eps = 1e-10;\n static const long double inf = 1e12;\n\n using circle = pair, long double>;\n\n auto c3 = [](const complex &a, const complex &b, const complex &c){\n long double A = norm(b - c);\n long double B = norm(c - a);\n long double C = norm(a - b);\n long double S = abs(cross(b - a, c - a));\n complex p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);\n long double r = abs(p - a);\n return make_pair(r, p);\n };\n\n auto c2 = [](const complex &a, const complex &b){\n complex c = (a + b) / (long double)2;\n long double r = abs(a - c);\n return make_pair(r, c);\n };\n\n auto in_circle = [](const complex &a, const pair> &c){\n return norm(a - c.second) <= c.first*c.first + eps;\n };\n\n int n = ps.size();\n random_shuffle(ps.begin(), ps.end());\n pair> c = c2(ps[0], ps[1]);\n for(int i = 2; i < n; ++i){\n if(!in_circle(ps[i], c)){\n c = c2(ps[0], ps[i]);\n for(int j = 1; j < i; ++j){\n if(!in_circle(ps[j], c)){\n c = c2(ps[j], ps[i]);\n for(int k = 0; k < j; ++k){\n if(!in_circle(ps[k], c)){\n c = c3(ps[i], ps[j], ps[k]);\n }\n }\n }\n }\n }\n }\n return c;\n}\n\npair> Prim_minimumSpanningTree(const vector> &g, int r,int K) {\n int n = g.size();\n vector T;\n ll total = 0;\n\n vector visited(n);\n priority_queue Q;\n Q.push( edge(-1, r, 0,0));\n ll ans=0;\n int k=0;\n while (!Q.empty()) {\n edge e = Q.top(); Q.pop();\n if (visited[e.to]) continue;\n T.push_back(e);\n total += e.cost;\n ans=max(ans,-e.cost);\n k++;\n if(k==K){\n break;\n }\n visited[e.to] = true;\n for(auto f:g[e.to]) if (!visited[f.to]) Q.push(f);\n }\n return pair>(ans, T);\n}\n\n\n\nclass NodeTwoColoring{\n private:\n vector> G;\n vector visited;\n vector white;\n vector black;\n \n void dfs(const vector> &G,int v=0, ll d=0) { \n if(d & 1){white.push_back(v+1);}\n else{black.push_back(v+1);}\n visited[v]=1+(d&1);\n \n\t for (auto nv : G[v]) {\n\t\t if (visited[nv.to]==-1){}\n else{\n continue;\n }\n\t\t dfs(G,nv.to,d+nv.cost);\n\t }\n }\n \n public:\n NodeTwoColoring(){};\n NodeTwoColoring(const vector> &g):G(g){\n int n=G.size();\n visited.resize(n,-1);\n dfs(G);\n };\n \n vector get_white(){\n return white;\n }\n vector get_black(){\n return black;\n }\n\n vector get_color(){\n return visited;\n }\n \n};\n\n/*\nconst int MAX = 510000;\nlong long fac[MAX], finv[MAX], inv[MAX];\n\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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\nlong long COM(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*/\n\n\nint main() {\n ll x;cin>>x;\n\n for(ll i=-5000;i<=5000;i++){\n for(ll j=-5000;j<=5000;j++){\n if(i*i*i*i*i-(j*j*j*j*j)==x){\n cout<\nusing namespace std;\nusing ll = long long;\nusing grid = vector>;\n\nint dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 }; // i<4:4way i<8:8way\nint dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };\n\nconstexpr ll MOD = 1000000007;\n//constexpr ll MOD = 998244353;\n\nconstexpr ll INF = 1050000000;\nconstexpr ll LONGINF = 1050000000000000000;\nstruct all_init {\n all_init() {\n cout.tie(nullptr);\n cin.tie(nullptr);\n ios::sync_with_stdio(false);\n cout << fixed << setprecision(11);\n };\n} ALL_INIT;\nstruct edge {\n int from, to;\n ll cost;\n ll capa;\n \n edge(int s, int d) : from(s), to(d) {cost = 0;capa = 0;}\n edge(int s, int d, ll w) : from(s), to(d), cost(w) { capa = 0; }\n edge(int s, int d, ll x, ll y) : from(s), to(d), cost(x), capa(y) {}\n \n bool operator<(const edge& x) const {\n if(cost>;\nvoid add_edge(vector>& g, int a, int b, ll cost, ll cap) {\n g[a].emplace_back(a, b, cost, cap);\n g[b].emplace_back(b, a, cost, cap);\n}\n \n#define CIN(vector_array_etc, n) \\\n for (int loop = 0; loop < n; loop++) { \\\n cin >> vector_array_etc[loop]; \\\n }\n#define COUT(vector_array_etc, n) \\\n for (int LOOP = 0; LOOP < n; LOOP++) { \\\n cout << vector_array_etc[LOOP] << (LOOP == n - 1 ? '\\n' : ' '); \\\n }\n#define VC(Type_name) vector\n#define SORT(vector_etc) sort(vector_etc.begin(), vector_etc.end())\n#define ALL(vec_etc) vec_etc.begin(), vec_etc.end()\n#define VCVC(Type_name) vector> \n#define WARSHALL vector> g(n, vector(n, LONGINF))\n#define endl '\\n'\n\n \ntemplate \nbool chmax(T& a, const T& b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nbool chmin(T& a, const T& b) {\n if (b < a) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nistream& operator>>(istream& is, vector& Vec) {\n for (T& x : Vec) {\n is >> x;\n }\n return is;\n}\ntemplate \nvoid resize(vector& vec, const H head) {\n vec.resize(head);\n}\ntemplate \nvoid resize(vector& vec, const H& head, const T... tail) {\n vec.resize(head);\n for (auto& v : vec) {\n resize(v, tail...);\n }\n}\ntemplate \nstruct ModInt {\n long long val;\n constexpr ModInt(long long v = 0) noexcept : val(v% mod) {\n if (val < 0) val += mod;\n }\n constexpr int getmod() { return mod; }\n constexpr ModInt operator-() const noexcept { return val ? mod - val : 0; }\n constexpr ModInt operator+(const ModInt& r) const noexcept {\n return ModInt(*this) += r;\n }\n constexpr ModInt operator-(const ModInt& r) const noexcept {\n return ModInt(*this) -= r;\n }\n constexpr ModInt operator*(const ModInt& r) const noexcept {\n return ModInt(*this) *= r;\n }\n constexpr ModInt operator/(const ModInt& r) const noexcept {\n return ModInt(*this) /= r;\n }\n constexpr ModInt& operator+=(const ModInt& r) noexcept {\n val += r.val;\n if (val >= mod) val -= mod;\n return *this;\n }\n constexpr ModInt& operator-=(const ModInt& r) noexcept {\n val -= r.val;\n if (val < 0) val += mod;\n return *this;\n }\n constexpr ModInt& operator*=(const ModInt& r) noexcept {\n val = val * r.val % mod;\n return *this;\n }\n constexpr ModInt& operator/=(const ModInt& r) noexcept {\n long long a = r.val, b = mod, 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 val = val * u % mod;\n if (val < 0) val += mod;\n return *this;\n }\n constexpr bool operator==(const ModInt& r) const noexcept {\n return this->val == r.val;\n }\n constexpr bool operator!=(const ModInt& r) const noexcept {\n return this->val != r.val;\n }\n friend ostream& operator<<(ostream& os, const ModInt& x) noexcept {\n return os << x.val;\n }\n friend istream& operator>>(istream& is, ModInt& x) noexcept {\n return is >> x.val;\n }\n friend constexpr ModInt modpow(const ModInt& a,\n long long n) noexcept {\n if (n == 0) return 1;\n auto t = modpow(a, n / 2);\n t = t * t;\n if (n & 1) t = t * a;\n return t;\n }\n};\ntemplate \nstruct nCk {\n vector fact_, inv_, finv_;\n constexpr nCk() {}\n constexpr nCk(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {\n init(n);\n }\n constexpr void init(int n) noexcept {\n fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);\n ll MOD = 1000000007;\n for (ll i = 2; i < n; i++) {\n fact_[i] = fact_[i - 1] * i;\n inv_[i] = -inv_[MOD % i] * (MOD / i);\n finv_[i] = finv_[i - 1] * inv_[i];\n }\n }\n constexpr T com(ll n, ll k) const noexcept {\n if (n < k || n < 0 || k < 0) return 0;\n return fact_[n] * finv_[k] * finv_[n - k];\n }\n constexpr T fact(int n) const noexcept {\n if (n < 0) return 0;\n return fact_[n];\n }\n constexpr T inv(int n) const noexcept {\n if (n < 0) return 0;\n return inv_[n];\n }\n constexpr T finv(int n) const noexcept {\n if (n < 0) return 0;\n return finv_[n];\n }\n};\n\nll PowMod(ll n, ll k, ll mod) {\n ll r = 1;\n \n for (; k > 0; k >>= 1) {\n if (k & 1) {\n r = (r * n) % mod;\n }\n n = (n * n) % mod;\n }\n return r;\n}\nll Gcd(ll a, ll b) {\n return b != 0 ? Gcd(b, a % b) : a;\n}\nll Lcm(ll a, ll b) {\n return a / Gcd(a, b) * b;\n}\nvector Split(string s, string t) {\n vector v;\n int p = s.find(t);\n while (p != s.npos) {\n v.emplace_back(s.substr(0, p));\n s = s.substr(p + (int)t.size());\n p = s.find(t);\n }\n v.emplace_back(s);\n return v;\n}\nvector Lis(const vector& a) {\n #define Index_of(as, x) distance(as.begin(), upper_bound(as.begin(), as.end(),x))\n//#define Index_of(as, x) \\\n distance(as.begin(), upper_bound(as.begin(), as.end(), x))\n const int n = a.size();\n vector A(n, INF);\n vector id(n);\n for (int i = 0; i < n; ++i) {\n id[i] = Index_of(A, a[i]);\n A[id[i]] = a[i];\n }\n int m = *max_element(id.begin(), id.end());\n vector b(m + 1);\n for (int i = n - 1; i >= 0; --i)\n if (id[i] == m) b[m--] = a[i];\n return b;\n}\nstring LcsAlphabeticalMinOrder(string a, string b) {\n if (a.size() < b.size()) {\n swap(a, b);\n }\n \n int n = a.size(), m = b.size();\n \n vector dp(m + 1);\n \n for (int i = 0; i < n; i++) {\n vector to(m + 1);\n for (int j = 0; j < m; j++) {\n if (a[i] == b[j]) {\n to[j + 1] = dp[j] + a[i];\n }\n else {\n if (to[j].size() > dp[j + 1].size()) {\n to[j + 1] = to[j];\n }\n else if (to[j].size() < dp[j + 1].size()) {\n to[j + 1] = dp[j + 1];\n }\n else if (to[j] < dp[j + 1]) {\n to[j + 1] = to[j];\n }\n else {\n to[j + 1] = dp[j + 1];\n }\n }\n }\n dp.swap(to);\n }\n return dp[m];\n}\nstring Lcs(const string& s, const string& t) {\n int n = s.size();\n int m = t.size();\n int dp[n+1][m+1];\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= m; j++) {\n if (s[i - 1] == t[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n }\n else {\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n string ans = \"\";\n int i = s.size(), j = t.size();\n while (i > 0 && j > 0) {\n if (s[i - 1] == t[j - 1]) {\n ans += s[i - 1];\n i--;\n j--;\n }\n else if (dp[i - 1][j] >= dp[i][j - 1])\n i--;\n else\n j--;\n }\n reverse(ans.begin(), ans.end());\n return ans;\n}\nvector LcsInteger(const vector &a, const vector &b) {\n#define index_of(as, x) \\\n distance(as.begin(), lower_bound(as.begin(), as.end(), x))\n struct node {\n int value;\n node* next;\n node(int value, node* next) : value(value), next(next) {}\n };\n const int n = a.size(), m = b.size();\n map> M;\n for (int j = m - 1; j >= 0; --j) M[b[j]].push_back(j);\n vector xs(n + 1, INF);\n xs[0] = -INF;\n vector link(n + 1);\n for (int i = 0; i < n; ++i) {\n if (M.count(a[i])) {\n vector ys = M[a[i]];\n for (int j = 0; j < (int)ys.size(); ++j) {\n int k = index_of(xs, ys[j]);\n xs[k] = ys[j];\n link[k] = new node(b[ys[j]], link[k - 1]);\n }\n }\n }\n vector c;\n int l = index_of(xs, INF - 1) - 1;\n for (node* p = link[l]; p; p = p->next) c.push_back(p->value);\n reverse(c.begin(), c.end());\n return c;\n}\nbool IsPrime(ll n) {\n if (n < 2) return false;\n for (ll i = 2; i * i <= n; i++)\n if (!(n % i)) return false;\n return true;\n}\nvector Eratosthenes(int n) {\n vector res;\n vector Prime(n + 1, true);\n Prime[0] = Prime[1] = false;\n for (int i = 2; i * i <= n; i++) {\n if (Prime[i]) {\n for (int j = 2; i * j <= n; j++) {\n Prime[i * j] = false;\n }\n }\n }\n for (int i = 2; i <= n; i++) {\n if (Prime[i]) {\n res.emplace_back(i);\n }\n }\n return res;\n}\nll maxSubArraySum(vector a,int left,int right) {\n //[left,right)\n int size=a.size(); \n ll max_so_far = -LONGINF, max_ending_here = 0; \n \n for (int i = left; i < right; i++) { \n max_ending_here = max_ending_here + a[i]; \n if (max_so_far < max_ending_here) {\n max_so_far = max_ending_here; \n }\n \n if (max_ending_here < 0) {\n max_ending_here = 0; \n }\n } \n return max_so_far; \n}\nll MergeCount(vector& a) {\n ll count = 0;\n int n = a.size();\n if (n > 1) {\n vector b(a.begin(), a.begin() + n / 2);\n vector c(a.begin() + n / 2, a.end());\n count += MergeCount(b);\n count += MergeCount(c);\n for (int i = 0, j = 0, k = 0; i < n; ++i)\n if (k == (int)c.size())\n a[i] = b[j++];\n else if (j == (int)b.size())\n a[i] = c[k++];\n else if (b[j] <= c[k])\n a[i] = b[j++];\n else {\n a[i] = c[k++];\n count += n / 2 - j;\n }\n }\n return count;\n}\nbool WarshallFloyd(vector>& c) {\n int V = c.size();\n for (int i = 0; i < V; i++) {\n c[i][i] = 0;\n }\n \n for (int i = 0; i < V; i++) {\n for (int j = 0; j < V; j++) {\n for (int k = 0; k < V; k++) {\n if (c[j][k] > c[j][i] + c[i][k]) {\n if(c[j][i] != LONGINF && c[i][k] != LONGINF){\n c[j][k] = c[j][i] + c[i][k];\n }\n }\n }\n }\n }\n \n for (int i = 0; i < V; i++) {\n if (c[i][i] < 0) {\n return false;\n }\n }\n \n return true;\n}\nvector Dijkstra(int i, vector> graph) {\n int n = graph.size();\n vector d(n, LONGINF);\n d[i] = 0;\n priority_queue, vector>, greater>>\n q;\n q.push(make_pair(0, i));\n while (!q.empty()) {\n pair p = q.top();\n q.pop();\n int v = p.second;\n if (d[v] < p.first) {\n continue;\n }\n for (auto x : graph[v]) {\n if (d[x.to] > d[v] + x.cost) {\n d[x.to] = d[v] + x.cost;\n q.push(make_pair(d[x.to], x.to));\n }\n }\n }\n return d;\n}\nvector> gridDijkstra(const int &start_h,const int &start_w,const vector> &a){\n const int h=a.size();\n const int w=a[0].size();\n vector> dp(h,vector(w,LONGINF));\n\n struct status{\n int x,y;\n ll cost;\n status(int x_,int y_):status(x_,y_,1LL){};\n status(int x_,int y_,ll cost_):x(x_),y(y_),cost(cost_){};\n };\n class Compare {\n public:\n\t bool operator()(const status&from, const status&to) {\n\t\t return from.cost>to.cost;\n\t }\n };\n\n priority_queue,Compare> q;\n status tmp_start(start_h,start_w,0LL);\n q.push(tmp_start);\n\n //from,to cost\n auto costFunction=[](const ll a,const ll b){return max(b-a,0LL);};\n //auto costFinction=[](const ll a,const ll b){return a+b};\n\n #define COST costFunction(a[x][y],a[nx][ny])\n\n while(q.size()){\n status tmp1(q.top());\n int x=tmp1.x;\n int y=tmp1.y;\n ll sum=tmp1.cost;\n q.pop();\n if(chmin(dp[x][y],sum)){\n for(int i=0;i<4;i++){\n int nx=x+dx[i];\n int ny=y+dy[i];\n if(nx<0||nx>=h||ny<0||ny>=w){\n continue;\n }\n if(dp[nx][ny]!=LONGINF&&dp[nx][ny]<=sum+COST){\n continue;\n }\n status tmp2(nx,ny,sum+COST);\n q.push(tmp2);\n }\n }\n }\n\n return dp;\n}\nbool BellmanFord(int start, int V, int E, vector Edge, vector& d) {\n resize(d, V);\n fill(d.begin(), d.end(), LONGINF);\n d[start] = 0;\n vector t(V, false);\n for (int i = 0; i < V - 1; i++) {\n for (int j = 0; j < E; j++) {\n edge e = Edge[j];\n if (d[e.from] == LONGINF) {\n continue;\n }\n if (d[e.to] > d[e.from] + e.cost) {\n d[e.to] = d[e.from] + e.cost;\n }\n }\n }\n for (int i = 0; i < V; i++) {\n for (int j = 0; j < E; j++) {\n edge e = Edge[j];\n if (d[e.from] == LONGINF) {\n continue;\n }\n if (d[e.to] > d[e.from] + e.cost) {\n d[e.to] = d[e.from] + e.cost;\n t[e.to] = true;\n /*\n if (i == V - 1) {\n return false;\n }\n */\n }\n if (t[e.from]) {\n t[e.to] = true;\n }\n }\n }\n \n if (t[V - 1]) {\n return false;\n }\n \n return true;\n}\nbool TopologicalSort(const vector>& g, vector& ans) {\n int n = g.size(), k = 0;\n vector ord(n), in(n);\n for (auto& es : g) {\n for (auto& e : es) {\n in[e.to]++;\n }\n }\n queue q;\n for (int i = 0; i < n; ++i) {\n if (in[i] == 0) q.push(i);\n }\n while (!q.empty()) {\n int v = q.front();\n q.pop();\n ord[k++] = v;\n for (auto& e : g[v]) {\n if (--in[e.to] == 0) q.push(e.to);\n }\n }\n ans = ord;\n if (*max_element(in.begin(), in.end()) == 0) {\n return true;\n }\n return false;\n}\nvector ArticulationNode(const vector>& g) {\n int n = g.size(), idx;\n vector low(n), ord(n), art;\n function DFS = [&](int v) {\n low[v] = ord[v] = ++idx;\n for (auto& e : g[v]) {\n int w = e.to;\n if (ord[w] == 0) {\n DFS(w);\n low[v] = min(low[v], low[w]);\n if ((ord[v] == 1 && ord[w] != 2) || (ord[v] != 1 && low[w] >= ord[v])) {\n art.push_back(v);\n }\n }\n else {\n low[v] = min(low[v], ord[w]);\n }\n }\n };\n for (int u = 0; u < n; u++) {\n if (ord[u] == 0) {\n idx = 0;\n DFS(u);\n }\n }\n \n sort(art.begin(), art.end());\n art.erase(unique(art.begin(), art.end()),\n art.end());\n \n return art;\n}\nedge TreeDiameter(const vector>& g) {\n int start = 0;\n static const auto bfs = [](const vector>& g, int s,\n queue& q, vector& dist) {\n while (!q.empty()) {\n q.pop();\n }\n q.push(s);\n int n = g.size();\n dist.assign(n, LONGINF);\n dist[s] = 0;\n while (q.size()) {\n int u = q.front();\n q.pop();\n for (auto& e : g[u]) {\n int v = e.to;\n if (dist[v] == LONGINF) {\n dist[v] = dist[u] + e.cost;\n q.push(v);\n }\n }\n }\n return dist;\n };\n vector dist;\n queue q;\n bfs(g, start, q, dist);\n int n = g.size(), u = -1, v = -1;\n for (int i = 0; i < n; i++)\n if (dist[i] != LONGINF && (u == -1 || dist[i] > dist[u])) u = i;\n bfs(g, u, q, dist);\n for (int i = 0; i < n; i++)\n if (dist[i] != LONGINF && (v == -1 || dist[i] > dist[v])) v = i;\n ll d = dist[v];\n if (u > v) swap(u, v);\n return edge(u, v, d);\n}\nclass UnionFind {\nprivate:\n std::vector parent;\n std::vector height;\n std::vector m_size;\n int forest_num;\n \npublic:\n UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {\n forest_num = size_;\n for (int i = 0; i < size_; ++i) parent[i] = i;\n }\n void init(int size_) {\n parent.resize(size_);\n height.resize(size_, 0);\n m_size.resize(size_, 1);\n forest_num = size_;\n for (int i = 0; i < size_; ++i) parent[i] = i;\n }\n int find(int x) {\n if (parent[x] == x) return x;\n return parent[x] = find(parent[x]);\n }\n bool unite(int x, int y) {\n x = find(x);\n y = find(y);\n if (x == y) return false;\n int t = size(x) + size(y);\n m_size[x] = m_size[y] = t;\n if (height[x] < height[y])\n parent[x] = y;\n else\n parent[y] = x;\n if (height[x] == height[y]) ++height[x];\n forest_num--;\n return true;\n }\n bool same(int x, int y) { return find(x) == find(y); }\n int size(int x) {\n if (parent[x] == x) return m_size[x];\n return size(parent[x] = find(parent[x]));\n }\n int forest() { return forest_num; }\n vector get_parent(){\n return parent;\n }\n};\nclass Dinic {\nprivate:\n int n, s, t;\n vector level, prog, que;\n vector> cap, flow;\n vector> g;\n ll inf;\n \npublic:\n Dinic(const vector>& graph)\n : n(graph.size()),\n cap(n, vector(n)),\n flow(n, vector(n)),\n g(n, vector()),\n inf(LONGINF) {\n for (int i = 0; i < n; i++) {\n for (auto& e : graph[i]) {\n int u = e.from, v = e.to;\n ll c = e.capa;\n cap[u][v] += c;\n cap[v][u] += c;\n flow[v][u] += c;\n g[u].push_back(v);\n g[v].push_back(u);\n }\n }\n }\n inline ll residue(int u, int v) { return cap[u][v] - flow[u][v]; }\n ll solve(int s_, int t_) {\n this->t = t_, this->s = s_;\n que.resize(n + 1);\n ll res = 0;\n while (levelize()) {\n prog.assign(n, 0);\n res += augment(s, inf);\n }\n return res;\n }\n bool levelize() {\n int l = 0, r = 0;\n level.assign(n, -1);\n level[s] = 0;\n que[r++] = s;\n while (l != r) {\n int v = que[l++];\n if (v == t) break;\n for (const int& d : g[v])\n if (level[d] == -1 && residue(v, d) != 0) {\n level[d] = level[v] + 1;\n que[r++] = d;\n }\n }\n return level[t] != -1;\n }\n ll augment(int v, ll lim) {\n ll res = 0;\n if (v == t) return lim;\n for (int& i = prog[v]; i < (int)g[v].size(); i++) {\n const int& d = g[v][i];\n if (residue(v, d) == 0 || level[v] >= level[d]) continue;\n const ll aug = augment(d, min(lim, residue(v, d)));\n flow[v][d] += aug;\n flow[d][v] -= aug;\n res += aug;\n lim -= aug;\n if (lim == 0) break;\n }\n return res;\n }\n};\nclass MinimumCostFlow {\nprivate:\n using Flow = ll;\n using Cost = ll;\n struct Edge {\n int d;\n Flow c, f;\n Cost w;\n int r, is_r;\n Edge(int d_, Flow c_, Flow f_, Cost w_, int r_, bool is_r_)\n : d(d_), c(c_), f(f_), w(w_), r(r_), is_r(is_r_) {}\n };\n int n;\n vector> g;\n \npublic:\n MinimumCostFlow(int n_) : n(n_), g(vector>(n_)) {}\n \n void add_edge(int src, int dst, Cost cost,Flow cap) {\n int rsrc = g[dst].size();\n int rdst = g[src].size();\n g[src].emplace_back(dst, cap, 0, cost, rsrc, false);\n g[dst].emplace_back(src, cap, cap, -cost, rdst, true);\n }\n \n Cost solve(int s, int t, Flow f) {\n Cost res = 0;\n \n vector h(n + 10), dist(n);\n vector prevv(n + 10), preve(n + 10);\n \n using pcv = pair;\n priority_queue, greater> q;\n fill(h.begin(), h.end(), 0);\n while (f > 0) {\n fill(dist.begin(), dist.end(), LONGINF);\n dist[s] = 0;\n q.emplace(0, s);\n while (q.size()) {\n Cost cd;\n int v;\n tie(cd, v) = q.top();\n q.pop();\n if (dist[v] < cd) continue;\n for (int i = 0; i < (int)(g[v].size()); ++i) {\n Edge& e = g[v][i];\n if (residue(e) == 0) continue;\n if (dist[e.d] + h[e.d] > cd + h[v] + e.w) {\n dist[e.d] = dist[v] + e.w + h[v] - h[e.d];\n prevv[e.d] = v;\n preve[e.d] = i;\n q.emplace(dist[e.d], e.d);\n }\n }\n }\n \n if (dist[t] == LONGINF) return -1;\n \n for (int i = 0; i < n; ++i) h[i] += dist[i];\n Flow d = f;\n for (int v = t; v != s; v = prevv[v]) {\n chmin(d, residue(g[prevv[v]][preve[v]]));\n }\n f -= d;\n res += d * h[t];\n for (int v = t; v != s; v = prevv[v]) {\n Edge& e = g[prevv[v]][preve[v]];\n e.f += d;\n g[v][e.r].f -= d;\n }\n }\n return res;\n }\n \n Flow residue(const Edge& e) { return e.c - e.f; }\n \n void show() {\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < (int)(g[i].size()); ++j) {\n Edge& e = g[i][j];\n if (e.is_r) continue;\n cout << i << \"->\" << e.d << \"(flow:\" << e.f << \")\" << endl;\n }\n }\n }\n};\nclass BipartiteMatching {\nprivate:\n int V;\n vector match;\n vector used;\n vector> g;\n vector> match_pair;\n \n bool dfs(int v) {\n used[v] = true;\n for (int i = 0; i < (int)g[v].size(); i++) {\n int u = g[v][i];\n int w = match[u];\n if (w < 0 || !used[w] && dfs(w)) {\n match[v] = u;\n match[u] = v;\n match_pair.emplace_back(make_pair(u, v));\n return true;\n }\n }\n return false;\n }\n \npublic:\n BipartiteMatching(int n) {\n V = n;\n resize(match, n);\n resize(used, n);\n resize(g, n);\n }\n \n void add_edge(int u, int v) {\n g[u].emplace_back(v);\n g[v].emplace_back(u);\n }\n \n int MatchingSolve() {\n int res = 0;\n fill(match.begin(), match.end(), -1);\n \n for (int v = 0; v < V; v++) {\n if (match[v] < 0) {\n fill(used.begin(), used.end(), false);\n if (dfs(v)) {\n res++;\n }\n }\n }\n return res;\n }\n \n vector> get_pair() {\n for (auto x : match_pair) {\n cout << x.first << \" \" << x.second << endl;\n }\n return match_pair;\n }\n};\nclass Lca {\nprivate:\n int n;\n int log2_n;\n vector> parent;\n vector depth;\n \n void dfs(const vector>& g, int v, int p, int d) {\n parent[0][v] = p;\n depth[v] = d;\n for (auto& e : g[v]) {\n if (e.to != p) {\n dfs(g, e.to, v, d + 1);\n }\n }\n }\n \npublic:\n Lca(const vector>& g, int root) {\n n = g.size();\n log2_n = (int)log2(n) + 1;\n resize(parent, log2_n, n);\n resize(depth, n);\n \n dfs(g, root, -1, 0);\n \n for (int k = 0; k + 1 < log2_n; k++) {\n for (int v = 0; v < (int)g.size(); v++) {\n if (parent[k][v] < 0) {\n parent[k + 1][v] = -1;\n }\n else {\n parent[k + 1][v] = parent[k][parent[k][v]];\n }\n }\n }\n }\n \n int get_lca(int u, int v) {\n if (depth[u] > depth[v]) {\n swap(u, v);\n }\n \n for (int k = 0; k < log2_n; k++) {\n if ((depth[v] - depth[u]) >> k & 1) {\n v = parent[k][v];\n }\n }\n if (u == v) {\n return u;\n }\n \n for (int k = log2_n - 1; k >= 0; k--) {\n if (parent[k][u] != parent[k][v]) {\n u = parent[k][u];\n v = parent[k][v];\n }\n }\n return parent[0][u];\n }\n \n int get_depth(int v) { return depth[v]; }\n};\nclass DAG {\nprivate:\n int n;\n vector> g;\n vector visited;\n vector dp;\n vector topological;\n \n int dfs(int s) {\n if ((int)g[s].size() == 0) {\n return 1;\n }\n if (dp[s] > 0) {\n return dp[s];\n }\n \n int mx = 1;\n for (auto j : g[s]) {\n if (visited[j.to] == 0) {\n visited[j.to] = 1;\n int l = 0;\n l = dfs(j.to);\n chmax(mx, l);\n }\n else {\n chmax(mx, dp[j.to]);\n }\n }\n return dp[s] = mx + 1;\n }\n \npublic:\n DAG(const vector>& f) {\n g = f;\n n = f.size();\n resize(visited, n + 1);\n fill(visited.begin(), visited.end(), 0);\n resize(dp, n + 1);\n fill(dp.begin(), dp.end(), -1);\n resize(topological, n);\n }\n DAG(int x) {\n n = x;\n resize(g, n);\n resize(visited, n + 1);\n fill(visited.begin(), visited.end(), 0);\n resize(dp, n + 1);\n fill(dp.begin(), dp.end(), -1);\n }\n \n void add_edge(int a, int b) { g[a].emplace_back(a, b); }\n void add_edge(int a, int b, ll c) { g[a].emplace_back(a, b, c); }\n void add_edge(int a, int b, ll c, ll d) { g[a].emplace_back(a, b, c, d); }\n \n int longest_path() {\n int mx = -1;\n int res=0;\n for (int i = 0; i < n; i++) {\n int h = 0;\n if (visited[i] == 0) {\n h = dfs(i);\n if(mx ord(n), in(n);\n for (int i=0;i q;\n for (int i = 0; i < n; ++i) {\n if (in[i] == 0) q.push(i);\n }\n while (!q.empty()) {\n int v = q.top();\n q.pop();\n ord[v] = k;\n k--;\n for (auto& e : g[v]) {\n in[e.to]-=1;\n if (in[e.to] == 0) {\n q.push(e.to);\n }\n }\n }\n topological = ord;\n if (*max_element(in.begin(), in.end()) == 0) {\n return true;\n }\n return false;\n }\n \n vector getTopologicalArray(){\n return topological;\n }\n};\n\n//↑ここまでGitHubに突っ込んだ\n\n\n\n\nclass RangeMinimumUpdateQuerySegmentTree {\nprivate:\n int n;\n ll inf = (1LL << 31) - 1; // 2^31-1\n vector dat, lazy;\n \n void eval(int len, int k) {\n if (lazy[k] == inf) return;\n if (k * 2 + 1 < n * 2 - 1) {\n lazy[2 * k + 1] = lazy[k];\n lazy[2 * k + 2] = lazy[k];\n }\n dat[k] = lazy[k];\n lazy[k] = inf;\n }\n \npublic:\n RangeMinimumUpdateQuerySegmentTree() {}\n RangeMinimumUpdateQuerySegmentTree(int n_) {\n n = 1;\n while (n < n_) n *= 2;\n dat.assign(n * 2, inf);\n lazy.assign(n * 2, inf);\n }\n \n // [a,b)\n ll update(int a, int b, ll x, int k, int l, int r) {\n eval(r - l, k);\n if (b <= l || r <= a) return dat[k];\n if (a <= l && r <= b) {\n lazy[k] = x;\n return lazy[k];\n }\n return dat[k] = min(update(a, b, x, 2 * k + 1, l, (l + r) / 2),\n update(a, b, x, 2 * k + 2, (l + r) / 2, r));\n }\n ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }\n \n // [a, b)\n ll query(int a, int b, int k, int l, int r) {\n eval(r - l, k);\n if (b <= l || r <= a) return inf;\n if (a <= l && r <= b) return dat[k];\n ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);\n ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);\n return min(vl, vr);\n }\n ll query(int a, int b) { return query(a, b, 0, 0, n); }\n};\nclass RangeSumQuerySegmentTree {\nprivate:\n struct Node {\n Node* left, * right;\n ll v;\n \n Node() : left(nullptr), right(nullptr), v(0) {}\n };\n Node* root;\n ll n, n0;\n ll query(ll a, ll b, Node* n, ll l, ll r) {\n if (a <= l && r <= b) {\n return n->v;\n }\n if (r <= a || b <= l) {\n return 0;\n }\n \n ll lv = n->left ? query(a, b, n->left, l, (l + r) >> 1) : 0;\n ll rv = n->right ? query(a, b, n->right, (l + r) >> 1, r) : 0;\n return (lv + rv) % MOD;\n }\n \npublic:\n RangeSumQuerySegmentTree(ll n) : n(n) {\n n0 = 1;\n while (n0 < n) n0 <<= 1;\n root = new Node();\n }\n ~RangeSumQuerySegmentTree() {\n delete root;\n root = nullptr;\n }\n \n void update(ll k, ll x) {\n Node* n = root;\n ll l = 0, r = n0;\n n->v = (n->v + x) % MOD;\n while (r - l > 1) {\n ll m = (l + r) >> 1;\n if (k < m) {\n if (!n->left) n->left = new Node();\n n = n->left;\n \n r = m;\n }\n else {\n if (!n->right) n->right = new Node();\n n = n->right;\n \n l = m;\n }\n n->v = (n->v + x) % MOD;\n }\n }\n \n ll query(ll a, ll b) { return query(a, b, root, 0, n0); }\n \n ll lquery(ll b) { return query(0, b, root, 0, n0); }\n \n ll rquery(ll a) { return query(a, n0, root, 0, n0); }\n};\nclass KDimensionalTree {\npublic:\n struct Node {\n int location;\n int p, l, r;\n Node() {}\n };\n struct Point {\n int id, x, y;\n Point() {}\n Point(int i, int a, int b) {\n id = i;\n x = a;\n y = b;\n }\n bool operator<(const Point& p) const { return id < p.id; }\n void print() { cout << id << endl; }\n };\n static const ll NIL = -1;\n static bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }\n static bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }\n \n int N;\n vector P;\n vector T;\n int np;\n \n KDimensionalTree() {}\n KDimensionalTree(int N) { init(N); }\n \n void init(int n) {\n N = n;\n P.clear();\n T.clear();\n resize(P, N);\n resize(T, N);\n np = 0;\n }\n \n int makeKDTree(int l, int r, int depth) {\n if (l >= r) {\n return NIL;\n }\n int mid = (l + r) / 2;\n int t = np++;\n if (depth & 1) {\n sort(P.begin() + l, P.begin() + r, lessY);\n }\n else {\n sort(P.begin() + l, P.begin() + r, lessX);\n }\n T[t].location = mid;\n T[t].l = makeKDTree(l, mid, depth + 1);\n T[t].r = makeKDTree(mid + 1, r, depth + 1);\n return t;\n }\n void find(int v, int sx, int tx, int sy, int ty, int depth,\n vector& ans) {\n int x = P[T[v].location].x;\n int y = P[T[v].location].y;\n if (sx <= x && x <= tx && sy <= y && y <= ty) {\n ans.push_back(P[T[v].location]);\n }\n if (depth % 2 == 0) {\n if (T[v].l != NIL) {\n if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);\n }\n if (T[v].r != NIL) {\n if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);\n }\n }\n else {\n if (T[v].l != NIL) {\n if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);\n }\n if (T[v].r != NIL) {\n if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);\n }\n }\n }\n void add_point(int i, int x, int y) {\n P[i].id = i;\n P[i].x = x;\n P[i].y = y;\n T[i].l = T[i].r = T[i].p = NIL;\n }\n};\nclass RangeAddQuerySegmentTree {\nprivate:\n int n;\n vector data;\n \npublic:\n RangeAddQuerySegmentTree() {}\n RangeAddQuerySegmentTree(int N) {\n n = N;\n resize(data, n + 1);\n fill(data.begin(), data.end(), 0);\n }\n \n void add(int i, ll x) {\n while (i) {\n data[i] += x;\n i -= (i & -i);\n }\n }\n void add(int i, int j, ll x) {\n add(j, x);\n add(i - 1, -x);\n }\n \n ll get(int i) {\n ll res = 0;\n while (i <= n) {\n res += data[i];\n i += (i & -i);\n }\n return res;\n }\n};\nclass RangeSumAddQuerySegmentTree {\nprivate:\n vector bit0, bit1;\n int n;\n \n ll sum(const vector& b, int i) {\n ll s = 0;\n while (i > 0) {\n s += b[i];\n i -= (i & -i);\n }\n return s;\n }\n \n void add(vector& b, int i, ll v) {\n while (i <= n) {\n b[i] += v;\n i += (i & -i);\n }\n }\n \npublic:\n RangeSumAddQuerySegmentTree() {}\n RangeSumAddQuerySegmentTree(int N) {\n n = N;\n resize(bit0, n + 1);\n resize(bit1, n + 1);\n fill(bit0.begin(), bit0.end(), 0);\n fill(bit1.begin(), bit1.end(), 0);\n }\n \n void update(int l, int r, ll x) {\n add(bit0, l, -x * (l - 1));\n add(bit1, l, x);\n add(bit0, r + 1, x * r);\n add(bit1, r + 1, -x);\n }\n \n ll query(int l, int r) {\n ll res = 0;\n res += sum(bit0, r) + sum(bit1, r) * r;\n res -= sum(bit0, l - 1) + sum(bit1, l - 1) * (l - 1);\n return res;\n }\n};\n\n\nlong double cross(const complex &a, const complex &b) { return a.real() * b.imag() - a.imag() * b.real(); }\nlong double dot(const complex &a, const complex &b) { return a.real() * b.real() + a.imag() * b.imag(); }\n\npair> smallest_enclosing_disc(vector> ps){\n const long double pi = 3.1415926535897932384626;\n static const long double eps = 1e-10;\n static const long double inf = 1e12;\n\n using circle = pair, long double>;\n\n auto c3 = [](const complex &a, const complex &b, const complex &c){\n long double A = norm(b - c);\n long double B = norm(c - a);\n long double C = norm(a - b);\n long double S = abs(cross(b - a, c - a));\n complex p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);\n long double r = abs(p - a);\n return make_pair(r, p);\n };\n\n auto c2 = [](const complex &a, const complex &b){\n complex c = (a + b) / (long double)2;\n long double r = abs(a - c);\n return make_pair(r, c);\n };\n\n auto in_circle = [](const complex &a, const pair> &c){\n return norm(a - c.second) <= c.first*c.first + eps;\n };\n\n int n = ps.size();\n random_shuffle(ps.begin(), ps.end());\n pair> c = c2(ps[0], ps[1]);\n for(int i = 2; i < n; ++i){\n if(!in_circle(ps[i], c)){\n c = c2(ps[0], ps[i]);\n for(int j = 1; j < i; ++j){\n if(!in_circle(ps[j], c)){\n c = c2(ps[j], ps[i]);\n for(int k = 0; k < j; ++k){\n if(!in_circle(ps[k], c)){\n c = c3(ps[i], ps[j], ps[k]);\n }\n }\n }\n }\n }\n }\n return c;\n}\n\npair> Prim_minimumSpanningTree(const vector> &g, int r,int K) {\n int n = g.size();\n vector T;\n ll total = 0;\n\n vector visited(n);\n priority_queue Q;\n Q.push( edge(-1, r, 0,0));\n ll ans=0;\n int k=0;\n while (!Q.empty()) {\n edge e = Q.top(); Q.pop();\n if (visited[e.to]) continue;\n T.push_back(e);\n total += e.cost;\n ans=max(ans,-e.cost);\n k++;\n if(k==K){\n break;\n }\n visited[e.to] = true;\n for(auto f:g[e.to]) if (!visited[f.to]) Q.push(f);\n }\n return pair>(ans, T);\n}\n\n\n\nclass NodeTwoColoring{\n private:\n vector> G;\n vector visited;\n vector white;\n vector black;\n \n void dfs(const vector> &G,int v=0, ll d=0) { \n if(d & 1){white.push_back(v+1);}\n else{black.push_back(v+1);}\n visited[v]=1+(d&1);\n \n\t for (auto nv : G[v]) {\n\t\t if (visited[nv.to]==-1){}\n else{\n continue;\n }\n\t\t dfs(G,nv.to,d+nv.cost);\n\t }\n }\n \n public:\n NodeTwoColoring(){};\n NodeTwoColoring(const vector> &g):G(g){\n int n=G.size();\n visited.resize(n,-1);\n dfs(G);\n };\n \n vector get_white(){\n return white;\n }\n vector get_black(){\n return black;\n }\n\n vector get_color(){\n return visited;\n }\n \n};\n\n/*\nconst int MAX = 510000;\nlong long fac[MAX], finv[MAX], inv[MAX];\n\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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\nlong long COM(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*/\n\n\nint main() {\n ll x;cin>>x;\n\n for(ll i=-5000;i<=5000;i++){\n for(ll j=-5000;j<=5000;j++){\n if(i*i*i*i*i-(j*j*j*j*j)==x){\n cout<\n#define REP(i,n) for (int i = 0; i < (n); i++)\n#define RREP(i, s, n) for (int i = s; i < (n); i++)\n#define ALL(a) a.begin(), a.end()\n#define RALL(a) a.rbegin(), a.rend()\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\nusing namespace std;\nusing ll = long long;\ntypedef pair pint;\ntypedef pair pll;\nconst ll MOD = 1000000007;\nconst ll INF = MOD * MOD;\nconst int inf = (1<<29);\n\nint main() {\n\n int n;\n cin >> n;\n vector a(n);\n REP(i, n) cin >> a[i];\n \n int res = 0;\n\n for(int i = 0; i < n; i++) {\n for(int j = i+1; j < n; j++) {\n if (abs(i-j) == a[i] + a[j]) res++;\n }\n }\n\n cout << res << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1596121141, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02691.html", "problem_id": "p02691", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02691/input.txt", "sample_output_relpath": "derived/input_output/data/p02691/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02691/C++/s253950378.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s253950378", "user_id": "u538125576"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#define REP(i,n) for (int i = 0; i < (n); i++)\n#define RREP(i, s, n) for (int i = s; i < (n); i++)\n#define ALL(a) a.begin(), a.end()\n#define RALL(a) a.rbegin(), a.rend()\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\nusing namespace std;\nusing ll = long long;\ntypedef pair pint;\ntypedef pair pll;\nconst ll MOD = 1000000007;\nconst ll INF = MOD * MOD;\nconst int inf = (1<<29);\n\nint main() {\n\n int n;\n cin >> n;\n vector a(n);\n REP(i, n) cin >> a[i];\n \n int res = 0;\n\n for(int i = 0; i < n; i++) {\n for(int j = i+1; j < n; j++) {\n if (abs(i-j) == a[i] + a[j]) res++;\n }\n }\n\n cout << res << endl;\n \n return 0;\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "sample_input": "6\n2 3 3 1 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02691", "source_text": "Score: 500 points\n\nProblem Statement\n\nYou are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\n\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\n\nAccording to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.\n\nThe absolute difference of their attendee numbers is equal to the sum of their heights.\n\nThere are \\frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?\n\nP.S.: We cannot let you know the secret.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the number of pairs satisfying the condition.\n\nSample Input 1\n\n6\n2 3 3 1 3 1\n\nSample Output 1\n\n3\n\nA_1 + A_4 = 3, so the pair of Attendee 1 and 4 satisfy the condition.\n\nA_2 + A_6 = 4, so the pair of Attendee 2 and 6 satisfy the condition.\n\nA_4 + A_6 = 2, so the pair of Attendee 4 and 6 satisfy the condition.\n\nNo other pair satisfies the condition, so you should print 3.\n\nSample Input 2\n\n6\n5 2 4 2 8 8\n\nSample Output 2\n\n0\n\nNo pair satisfies the condition, so you should print 0.\n\nSample Input 3\n\n32\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5\n\nSample Output 3\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 851, "cpu_time_ms": 2205, "memory_kb": 4188}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s450250619", "group_id": "codeNet:p02692", "input_text": "#include \nusing namespace std;\n\nint main() {\n int n; cin >> n;\n vector v(3);\n vector ans(n);\n int ind=0;\n cin >> v[0] >> v[1] >> v[2];\n int t=v[0]+v[1]+v[2];\n bool ok=1;\n while (n--) {\n string s; cin >> s;\n if (!ok) continue;\n if (!v[s[0]-'A'] && !v[s[1]-'A']) {\n ok=0;\n continue;\n }\n if (!v[s[0]-'A']) v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else if (!v[s[1]-'A']) v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n else {\n if (t == 2) {\n string c=\"#\";\n if (n--) {\n cin >> c;\n }\n if (c != \"#\") {\n if (s[0] == c[0] || s[0] == c[1])\n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else\n v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n }\n else \n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n }\n else {\n if (v[s[1]-'A'] == t-1)\n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else\n v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n }\n }\n }\n if (n == 0 || !ok) cout << \"No\";\n else {\n cout << \"Yes\\n\";\n for (char c : ans)\n cout << c << \"\\n\";\n }\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1591533695, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/C++/s450250619.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s450250619", "user_id": "u376415869"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int n; cin >> n;\n vector v(3);\n vector ans(n);\n int ind=0;\n cin >> v[0] >> v[1] >> v[2];\n int t=v[0]+v[1]+v[2];\n bool ok=1;\n while (n--) {\n string s; cin >> s;\n if (!ok) continue;\n if (!v[s[0]-'A'] && !v[s[1]-'A']) {\n ok=0;\n continue;\n }\n if (!v[s[0]-'A']) v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else if (!v[s[1]-'A']) v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n else {\n if (t == 2) {\n string c=\"#\";\n if (n--) {\n cin >> c;\n }\n if (c != \"#\") {\n if (s[0] == c[0] || s[0] == c[1])\n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else\n v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n }\n else \n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n }\n else {\n if (v[s[1]-'A'] == t-1)\n v[s[0]-'A']++, v[s[1]-'A']--, ans[ind++]=s[0];\n else\n v[s[1]-'A']++, v[s[0]-'A']--, ans[ind++]=s[1];\n }\n }\n }\n if (n == 0 || !ok) cout << \"No\";\n else {\n cout << \"Yes\\n\";\n for (char c : ans)\n cout << c << \"\\n\";\n }\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1196, "cpu_time_ms": 26, "memory_kb": 3708}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s447744827", "group_id": "codeNet:p02692", "input_text": "#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#define repr(i,a,b) for(int i=a;i=a;i--)\n#define invrep(i,n) invrepr(i,0,n)\n \nusing namespace std;\ntypedef long long ll;\nconst ll MOD=1e9+7;\n \nint main() {\n std::ios::sync_with_stdio(0); cin.tie(0);\n \n ll i,j,h;\n ll Q,M,K,P,A,B,C,N,X;\n \n long double x;\n \n string S;\n \n ll ans=0;\n ll count=0;\n ll flag=0;\n ll temp=0;\n vector kotae;\n vector ss;\n ll a,b;\n cin >>N>>A>>B>>C;\n\nrep(i,N){\n cin>>S;\n ss.push_back(S);\n}\n//cout<<\"aa\"< mm;\nmm['B']=B;\nmm['A']=A;\nmm['C']=C;\n//cout<<0;\nif(A+B+C==0){\n cout<<\"No\"<\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#define repr(i,a,b) for(int i=a;i=a;i--)\n#define invrep(i,n) invrepr(i,0,n)\n \nusing namespace std;\ntypedef long long ll;\nconst ll MOD=1e9+7;\n \nint main() {\n std::ios::sync_with_stdio(0); cin.tie(0);\n \n ll i,j,h;\n ll Q,M,K,P,A,B,C,N,X;\n \n long double x;\n \n string S;\n \n ll ans=0;\n ll count=0;\n ll flag=0;\n ll temp=0;\n vector kotae;\n vector ss;\n ll a,b;\n cin >>N>>A>>B>>C;\n\nrep(i,N){\n cin>>S;\n ss.push_back(S);\n}\n//cout<<\"aa\"< mm;\nmm['B']=B;\nmm['A']=A;\nmm['C']=C;\n//cout<<0;\nif(A+B+C==0){\n cout<<\"No\"<\nusing namespace std;\ntypedef long long ll;\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define INF (1LL<<50)\n#define MOD 1000000007\n\nint main(){\n int N,A,B,C,D;\n cin >> N >> A >> B >> C;\n vector S(N);\n rep(i,N){\n cin >> S[i];\n }\n bool flg = true;\n rep(i,N){\n if(S[i]==\"AB\"){\n if(A\nusing namespace std;\ntypedef long long ll;\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define INF (1LL<<50)\n#define MOD 1000000007\n\nint main(){\n int N,A,B,C,D;\n cin >> N >> A >> B >> C;\n vector S(N);\n rep(i,N){\n cin >> S[i];\n }\n bool flg = true;\n rep(i,N){\n if(S[i]==\"AB\"){\n if(A\n\nusing namespace std;\n\nconst int N = 1e5 + 10;\n\nint n, d[3];\nint a[3][N], step[N];\n\nint finddif(int x, int y) {\n for (int i = 0; i < 3; i++)\n if (a[i][x] && i != y)\n return i;\n}\n\nvoid solve(int p0, int p1, int p2) {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n if (a[p0][i]) {\n t[p0]++; t[finddif(i, p0)]--;\n step[i] = p0;\n } else {\n t[p1]++; t[finddif(i, p1)]--;\n step[i] = p1;\n }\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nvoid Try1() {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n int x = rand() % 2 + 1;\n if (t[a[!x][i]] == 0) x ^= 1;\n t[a[x][i]]++; t[a[!x][i]]--;\n step[i] = x;\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nvoid Try2() {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n int x = 0;\n if (t[a[x][i]] < t[a[!x][i]]) x ^= 1;\n t[a[x][i]]++; t[a[!x][i]]--;\n step[i] = x;\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nint main() {\n if (fopen(\"A.inp\", \"r\"))\n freopen(\"A.inp\", \"r\", stdin),\n freopen(\"A.out\", \"w\", stdout);\n cin >> n >> d[0] >> d[1] >> d[2];\n for (int i = 0; i < n; i++) {\n string str; cin >> str;\n a[str[0] - 'A'][i] = a[str[1] - 'A'][i] = 1;\n }\n solve(0, 1, 2);\n solve(0, 2, 1);\n solve(1, 0, 2);\n solve(1, 2, 0);\n solve(2, 0, 1);\n solve(2, 1, 0);\n// for (int i = 0; i < 200; i++)\n// Try1();\n// Try2();\n puts(\"No\");\n}\n", "language": "C++", "metadata": {"date": 1588536600, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/C++/s930037947.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s930037947", "user_id": "u401341828"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nconst int N = 1e5 + 10;\n\nint n, d[3];\nint a[3][N], step[N];\n\nint finddif(int x, int y) {\n for (int i = 0; i < 3; i++)\n if (a[i][x] && i != y)\n return i;\n}\n\nvoid solve(int p0, int p1, int p2) {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n if (a[p0][i]) {\n t[p0]++; t[finddif(i, p0)]--;\n step[i] = p0;\n } else {\n t[p1]++; t[finddif(i, p1)]--;\n step[i] = p1;\n }\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nvoid Try1() {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n int x = rand() % 2 + 1;\n if (t[a[!x][i]] == 0) x ^= 1;\n t[a[x][i]]++; t[a[!x][i]]--;\n step[i] = x;\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nvoid Try2() {\n int t[3];\n t[0] = d[0]; t[1] = d[1]; t[2] = d[2];\n for (int i = 0; i < n; i++) {\n int x = 0;\n if (t[a[x][i]] < t[a[!x][i]]) x ^= 1;\n t[a[x][i]]++; t[a[!x][i]]--;\n step[i] = x;\n if (t[0] < 0) return;\n if (t[1] < 0) return;\n if (t[2] < 0) return;\n }\n puts(\"Yes\");\n for (int i = 0; i < n; i++)\n cout << (char)(step[i] + 'A') << endl;\n exit(0);\n}\n\nint main() {\n if (fopen(\"A.inp\", \"r\"))\n freopen(\"A.inp\", \"r\", stdin),\n freopen(\"A.out\", \"w\", stdout);\n cin >> n >> d[0] >> d[1] >> d[2];\n for (int i = 0; i < n; i++) {\n string str; cin >> str;\n a[str[0] - 'A'][i] = a[str[1] - 'A'][i] = 1;\n }\n solve(0, 1, 2);\n solve(0, 2, 1);\n solve(1, 0, 2);\n solve(1, 2, 0);\n solve(2, 0, 1);\n solve(2, 1, 0);\n// for (int i = 0; i < 200; i++)\n// Try1();\n// Try2();\n puts(\"No\");\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2105, "cpu_time_ms": 155, "memory_kb": 5140}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s050594044", "group_id": "codeNet:p02693", "input_text": "#include \nusing namespace std;\n\nint main() {\n int K, A, B;\n bool flag;\n cin >> K >> A >> B;\n\n\n flag = false;\n for (int i=1; i<=1000; i++) {\n if (A<=i*K and i*K<=B) {\n flag = true;\n break;\n }\n }\n\n if (flag) {\n cout << \"OK\" << endl;\n } else {\n cout << \"NG\" << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1588470186, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/C++/s050594044.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s050594044", "user_id": "u963164554"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int K, A, B;\n bool flag;\n cin >> K >> A >> B;\n\n\n flag = false;\n for (int i=1; i<=1000; i++) {\n if (A<=i*K and i*K<=B) {\n flag = true;\n break;\n }\n }\n\n if (flag) {\n cout << \"OK\" << endl;\n } else {\n cout << \"NG\" << endl;\n }\n return 0;\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 2, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s712271223", "group_id": "codeNet:p02694", "input_text": "#include\nusing namespace std;\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define dup(x,y) (((x)+(y)-1)/(y))\n#define ALL(x) (x).begin(), (x).end()\ntypedef long long ll;\ntypedef pair pii;\nconst double EPS = 1e-10;\nconst int INF = 1e9;\nconst ll LINF = 1e15;\nconst int MOD = 1000000007;\nconst double PI = acos(-1);\nint dx[4] = {0,1,0,-1};\nint dy[4] = {1,0,-1,0};\n\nint main() {\n\tll x;\n\tcin >> x;\n\tll cur = 100;\n\tint ans = 0;\n\tif (x == 100) {\n\t\tcout << 0 << endl;\n\t\treturn 0;\n\t}\n\twhile (cur < x / 1.01) {\n\t\tans++;\n\t\tcur *= 1.01;\n\t}\n\tcout << ans + 1 << endl;\n}", "language": "C++", "metadata": {"date": 1599979294, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/C++/s712271223.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s712271223", "user_id": "u280175105"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\nusing namespace std;\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define dup(x,y) (((x)+(y)-1)/(y))\n#define ALL(x) (x).begin(), (x).end()\ntypedef long long ll;\ntypedef pair pii;\nconst double EPS = 1e-10;\nconst int INF = 1e9;\nconst ll LINF = 1e15;\nconst int MOD = 1000000007;\nconst double PI = acos(-1);\nint dx[4] = {0,1,0,-1};\nint dy[4] = {1,0,-1,0};\n\nint main() {\n\tll x;\n\tcin >> x;\n\tll cur = 100;\n\tint ans = 0;\n\tif (x == 100) {\n\t\tcout << 0 << endl;\n\t\treturn 0;\n\t}\n\twhile (cur < x / 1.01) {\n\t\tans++;\n\t\tcur *= 1.01;\n\t}\n\tcout << ans + 1 << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 8, "memory_kb": 3644}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s020058443", "group_id": "codeNet:p02694", "input_text": "#define ll long long\n#include \"bits/stdc++.h\"\nusing namespace std;\nvector>vc;\nconst int N = 2e5 + 2;\nll arr[N];\nint main() {\nll n;\ncin>>n;\nll res=100;\nll cnt=0;\nwhile(res <= n)\n{\n res+=(.01 * res );\n cnt++;\n if(res==n)break;\n\n}\ncout<>vc;\nconst int N = 2e5 + 2;\nll arr[N];\nint main() {\nll n;\ncin>>n;\nll res=100;\nll cnt=0;\nwhile(res <= n)\n{\n res+=(.01 * res );\n cnt++;\n if(res==n)break;\n\n}\ncout<\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vpii;\ntypedef vector vpll;\n#define F first\n#define S second\ntypedef vector vpli;\n#define MOD 1000000007\n#define mp make_pair\n#define pb push_back\n#define all(v) v.begin(),v.end() \n#define tests int t; cin>>t; while(t--)\n#define take(a,b,c) for(b=0;b>a[b];\n#define INF 1e18\n// https://codeforces.com/problemset/page/3?tags=1500-1800\nmap > m;\nint main()\n{\t\n ll x;\n cin>>x;\n ll y=100;\n ll j=1;\n while(1){\n y+=y/100;\n if(y>=x){\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vpii;\ntypedef vector vpll;\n#define F first\n#define S second\ntypedef vector vpli;\n#define MOD 1000000007\n#define mp make_pair\n#define pb push_back\n#define all(v) v.begin(),v.end() \n#define tests int t; cin>>t; while(t--)\n#define take(a,b,c) for(b=0;b>a[b];\n#define INF 1e18\n// https://codeforces.com/problemset/page/3?tags=1500-1800\nmap > m;\nint main()\n{\t\n ll x;\n cin>>x;\n ll y=100;\n ll j=1;\n while(1){\n y+=y/100;\n if(y>=x){\n cout<\n#define INF 1e9\nusing namespace std;\n\n#define REPR(i,n) for(int i=(n); i >= 0; --i)\n#define FOR(i, m, n) for(int i = (m); i < (n); ++i)\n#define REP(i, n) for(int i=0, i##_len=(n); ibool chmin(T &a, const T &b) { if (bbool chmax(T &a, const T &b) { if (a> X;\n int nen = 0;\n ll now = 100;\n while (now < X) {\n nen++;\n now*=1.01;\n }\n cout << nen << endl;\n}\n\nint main() {\n solve();\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1588468624, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02694/input.txt", "sample_output_relpath": "derived/input_output/data/p02694/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02694/C++/s034586657.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034586657", "user_id": "u492030100"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#define INF 1e9\nusing namespace std;\n\n#define REPR(i,n) for(int i=(n); i >= 0; --i)\n#define FOR(i, m, n) for(int i = (m); i < (n); ++i)\n#define REP(i, n) for(int i=0, i##_len=(n); ibool chmin(T &a, const T &b) { if (bbool chmax(T &a, const T &b) { if (a> X;\n int nen = 0;\n ll now = 100;\n while (now < X) {\n nen++;\n now*=1.01;\n }\n cout << nen << endl;\n}\n\nint main() {\n solve();\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 697, "cpu_time_ms": 2, "memory_kb": 3632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s599239787", "group_id": "codeNet:p02695", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\n#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)\n#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)\n#define REP(var, length) FOR(var, 0, length - 1)\n#define RREP(var, length) RFOR(var, length - 1, 0)\n#define EACH(value, var) for (auto value : var)\n#define SORT(var) sort(var.begin(), var.end())\n#define REVERSE(var) reverse(var.begin(), var.end())\n#define RSORT(var) \\\n SORT(var); \\\n REVERSE(var)\n#define OPTIMIZE_STDIO \\\n ios::sync_with_stdio(false); \\\n cin.tie(0); \\\n cout.precision(10); \\\n cout << fixed\n#define endl '\\n'\n\nconst int INF = 1e9;\nconst ll MOD = 1e9 + 7;\nconst ll LINF = 1e18;\nstruct mint {\n ll x;\n mint() : x(0) {\n }\n mint(ll x) : x((x % MOD + MOD) % MOD) {\n }\n mint& operator+=(const mint& r) {\n if ((x += r.x) >= MOD) {\n x -= MOD;\n }\n return *this;\n }\n mint& operator-=(const mint& r) {\n if ((x -= r.x) < 0) {\n x += MOD;\n }\n return *this;\n }\n mint& operator*=(const mint& r) {\n if ((x *= r.x) > MOD) {\n x %= MOD;\n }\n return *this;\n }\n mint& operator++() {\n if ((++x) >= MOD) {\n x -= MOD;\n }\n return *this;\n }\n mint operator++(int) {\n mint ret = x;\n if ((++x) >= MOD) {\n x -= MOD;\n }\n return ret;\n }\n mint& operator--() {\n if ((--x) < 0) {\n x += MOD;\n }\n return *this;\n }\n mint operator--(int) {\n mint ret = x;\n if ((--x) < 0) {\n x += MOD;\n }\n return ret;\n }\n mint operator+(const mint& r) {\n mint ret;\n return ret = x + r.x;\n }\n mint operator-(const mint& r) {\n mint ret;\n return ret = x - r.x;\n }\n mint operator*(const mint& r) {\n mint ret;\n return ret = x * r.x;\n }\n mint operator-() {\n return mint() - *this;\n }\n bool operator<(const mint& a) {\n return x < a.x;\n }\n bool operator>(const mint& a) {\n return x > a.x;\n }\n bool operator<=(const mint& a) {\n return x <= a.x;\n }\n bool operator>=(const mint& a) {\n return x >= a.x;\n }\n bool operator==(const mint& a) {\n return x == a.x;\n }\n bool operator!=(const mint& a) {\n return x != a.x;\n }\n};\nostream& operator<<(ostream& os, const mint& r) {\n os << r.x;\n return os;\n}\nostream& operator>>(ostream& os, const mint& r) {\n os >> r.x;\n return os;\n}\n\nint n, m, q;\nvector a, b, c, d;\nint ans;\n\nvoid dfs(vector buf) {\n if (buf.size() == n + 1) {\n int now = 0;\n REP(i, q) {\n if ((buf[b[i]] - buf[a[i]]) == c[i]) now += d[i];\n }\n ans = max(ans, now);\n return;\n }\n\n buf.push_back(buf.back());\n while (buf.back() <= m) {\n dfs(buf);\n buf.back()++;\n }\n}\n\nvoid solve(istream& cin, ostream& cout) {\n cin >> n >> m >> q;\n a = b = c = d = vector(q);\n REP(i, q) {\n cin >> a[i] >> b[i] >> c[i] >> d[i];\n }\n dfs(vector(1, 1));\n cout << ans << endl;\n}\n\n#ifndef TEST\nint main() {\n OPTIMIZE_STDIO;\n solve(cin, cout);\n return 0;\n}\n#endif\n", "language": "C++", "metadata": {"date": 1588483056, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/C++/s599239787.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s599239787", "user_id": "u068177169"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\n#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)\n#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)\n#define REP(var, length) FOR(var, 0, length - 1)\n#define RREP(var, length) RFOR(var, length - 1, 0)\n#define EACH(value, var) for (auto value : var)\n#define SORT(var) sort(var.begin(), var.end())\n#define REVERSE(var) reverse(var.begin(), var.end())\n#define RSORT(var) \\\n SORT(var); \\\n REVERSE(var)\n#define OPTIMIZE_STDIO \\\n ios::sync_with_stdio(false); \\\n cin.tie(0); \\\n cout.precision(10); \\\n cout << fixed\n#define endl '\\n'\n\nconst int INF = 1e9;\nconst ll MOD = 1e9 + 7;\nconst ll LINF = 1e18;\nstruct mint {\n ll x;\n mint() : x(0) {\n }\n mint(ll x) : x((x % MOD + MOD) % MOD) {\n }\n mint& operator+=(const mint& r) {\n if ((x += r.x) >= MOD) {\n x -= MOD;\n }\n return *this;\n }\n mint& operator-=(const mint& r) {\n if ((x -= r.x) < 0) {\n x += MOD;\n }\n return *this;\n }\n mint& operator*=(const mint& r) {\n if ((x *= r.x) > MOD) {\n x %= MOD;\n }\n return *this;\n }\n mint& operator++() {\n if ((++x) >= MOD) {\n x -= MOD;\n }\n return *this;\n }\n mint operator++(int) {\n mint ret = x;\n if ((++x) >= MOD) {\n x -= MOD;\n }\n return ret;\n }\n mint& operator--() {\n if ((--x) < 0) {\n x += MOD;\n }\n return *this;\n }\n mint operator--(int) {\n mint ret = x;\n if ((--x) < 0) {\n x += MOD;\n }\n return ret;\n }\n mint operator+(const mint& r) {\n mint ret;\n return ret = x + r.x;\n }\n mint operator-(const mint& r) {\n mint ret;\n return ret = x - r.x;\n }\n mint operator*(const mint& r) {\n mint ret;\n return ret = x * r.x;\n }\n mint operator-() {\n return mint() - *this;\n }\n bool operator<(const mint& a) {\n return x < a.x;\n }\n bool operator>(const mint& a) {\n return x > a.x;\n }\n bool operator<=(const mint& a) {\n return x <= a.x;\n }\n bool operator>=(const mint& a) {\n return x >= a.x;\n }\n bool operator==(const mint& a) {\n return x == a.x;\n }\n bool operator!=(const mint& a) {\n return x != a.x;\n }\n};\nostream& operator<<(ostream& os, const mint& r) {\n os << r.x;\n return os;\n}\nostream& operator>>(ostream& os, const mint& r) {\n os >> r.x;\n return os;\n}\n\nint n, m, q;\nvector a, b, c, d;\nint ans;\n\nvoid dfs(vector buf) {\n if (buf.size() == n + 1) {\n int now = 0;\n REP(i, q) {\n if ((buf[b[i]] - buf[a[i]]) == c[i]) now += d[i];\n }\n ans = max(ans, now);\n return;\n }\n\n buf.push_back(buf.back());\n while (buf.back() <= m) {\n dfs(buf);\n buf.back()++;\n }\n}\n\nvoid solve(istream& cin, ostream& cout) {\n cin >> n >> m >> q;\n a = b = c = d = vector(q);\n REP(i, q) {\n cin >> a[i] >> b[i] >> c[i] >> d[i];\n }\n dfs(vector(1, 1));\n cout << ans << endl;\n}\n\n#ifndef TEST\nint main() {\n OPTIMIZE_STDIO;\n solve(cin, cout);\n return 0;\n}\n#endif\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2996, "cpu_time_ms": 26, "memory_kb": 3668}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s658761323", "group_id": "codeNet:p02696", "input_text": "#include \n#define rep(i,n) for(int i = 0; i < n; i++)\n#define vi vector\n#define vvi vector\n#define pii pair\n#define mod 1000000007\nusing ll = long long;\nusing namespace std;\nint main(){\n ll a,b,n;\n cin >> a >> b >> n;\n ll ans = 0;\n for(ll x = n; x >= 0; x--){\n ll val = ll(a * x / b) - a * ll(x / b);\n ans = ans < val ? val : ans;\n if(ans > val + 10) break;\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1588473449, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/C++/s658761323.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s658761323", "user_id": "u396266329"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define rep(i,n) for(int i = 0; i < n; i++)\n#define vi vector\n#define vvi vector\n#define pii pair\n#define mod 1000000007\nusing ll = long long;\nusing namespace std;\nint main(){\n ll a,b,n;\n cin >> a >> b >> n;\n ll ans = 0;\n for(ll x = n; x >= 0; x--){\n ll val = ll(a * x / b) - a * ll(x / b);\n ans = ans < val ? val : ans;\n if(ans > val + 10) break;\n }\n cout << ans << endl;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 433, "cpu_time_ms": 2205, "memory_kb": 3652}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s486257017", "group_id": "codeNet:p02697", "input_text": "//g++ -std=gnu++14 a.cpp\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 ll long long\n#define rep(i, n) for(ll i = 0; i < (n); i++)\nll MOD = 1e9 + 7;\nint INF = 1 << 30;\nll INFL = 1LL << 60;\n\nint main() {\n ll N,M;\n cin >> N >> M;\n ll a,b;\n a=3;\n b=5;\n if(M>=1)cout << 1 << \" \" << 2 << endl;\n if(M>=2)cout << 3 << \" \" << 5 << endl;\n if(M>=3){\n for(int i =3;i <= M;i++){\n a++;\n b=a+i;\n cout << a << \" \" << b << endl;\n }\n }\n\n\n\n\n}\n", "language": "C++", "metadata": {"date": 1588743013, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/C++/s486257017.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s486257017", "user_id": "u388134182"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "//g++ -std=gnu++14 a.cpp\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 ll long long\n#define rep(i, n) for(ll i = 0; i < (n); i++)\nll MOD = 1e9 + 7;\nint INF = 1 << 30;\nll INFL = 1LL << 60;\n\nint main() {\n ll N,M;\n cin >> N >> M;\n ll a,b;\n a=3;\n b=5;\n if(M>=1)cout << 1 << \" \" << 2 << endl;\n if(M>=2)cout << 3 << \" \" << 5 << endl;\n if(M>=3){\n for(int i =3;i <= M;i++){\n a++;\n b=a+i;\n cout << a << \" \" << b << endl;\n }\n }\n\n\n\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 749, "cpu_time_ms": 131, "memory_kb": 3644}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s017604377", "group_id": "codeNet:p02697", "input_text": "#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)\ntypedef long long ll;\n#define ALL(v) v.begin(), v.end()\n#define vmax(v) *max_element(ALL(v))\n#define vmin(v) *min_element(ALL(v))\n#define chmax(x, a) x = max(x, a)\n#define chmin(x, a) x = min(x, a)\n\nint main() {\n int N, M; cin >> N >> M;\n if (M % 2 == 1) {\n int tmp = 1;\n int mx = M;\n while(tmp != mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n tmp = M+1;\n mx = 2*M+1;\n while(tmp < mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n }\n else {\n int tmp = 1;\n int mx = M+1;\n while(tmp != M-tmp+2) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n tmp = M+2;\n mx = 2*M+1;\n while(tmp < mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n }\n}\n", "language": "C++", "metadata": {"date": 1588527503, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/C++/s017604377.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017604377", "user_id": "u552357043"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)\ntypedef long long ll;\n#define ALL(v) v.begin(), v.end()\n#define vmax(v) *max_element(ALL(v))\n#define vmin(v) *min_element(ALL(v))\n#define chmax(x, a) x = max(x, a)\n#define chmin(x, a) x = min(x, a)\n\nint main() {\n int N, M; cin >> N >> M;\n if (M % 2 == 1) {\n int tmp = 1;\n int mx = M;\n while(tmp != mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n tmp = M+1;\n mx = 2*M+1;\n while(tmp < mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n }\n else {\n int tmp = 1;\n int mx = M+1;\n while(tmp != M-tmp+2) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n tmp = M+2;\n mx = 2*M+1;\n while(tmp < mx) {\n cout << tmp << \" \" << mx << endl;\n tmp++;\n mx--;\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1091, "cpu_time_ms": 132, "memory_kb": 3548}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s552000481", "group_id": "codeNet:p02697", "input_text": "#include\nusing namespace std;\n\nint main(){\n int N, M;\n cin >> N >> M;\n int LL, LR, RL, RR;\n LL = 1;\n LR = N / 2;\n RL = LR + 1;\n RR = N;\n if(N % 2 == 0) LR--;\n int count = 0;\n while(true){\n cout << RL << \" \" << RR << endl;\n count++;\n if(count == M) break;\n RL++;\n RR--;\n cout << LL << \" \" << LR << endl;\n count++;\n if(count == M) break;\n LL++;\n LR++;\n }\n}", "language": "C++", "metadata": {"date": 1588473431, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/C++/s552000481.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s552000481", "user_id": "u811542492"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\n int N, M;\n cin >> N >> M;\n int LL, LR, RL, RR;\n LL = 1;\n LR = N / 2;\n RL = LR + 1;\n RR = N;\n if(N % 2 == 0) LR--;\n int count = 0;\n while(true){\n cout << RL << \" \" << RR << endl;\n count++;\n if(count == M) break;\n RL++;\n RR--;\n cout << LL << \" \" << LR << endl;\n count++;\n if(count == M) break;\n LL++;\n LR++;\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 134, "memory_kb": 3604}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s096759321", "group_id": "codeNet:p02697", "input_text": "#include //Andrei Alexandru a.k.a Sho10\n#define ll long long int\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"Ofast\")\n#define all(a) (a).begin(), (a).end()\n#define sz size\n#define f first\n#define s second\n#define pb push_back\n#define er erase\n#define in insert\n#define mp make_pair\n#define pi pair\n#define rc(s) return cout<v;\nint32_t main(){\nCODE_START;\ncin>>n>>m;\nif(n%2==1){\n n--;\nll l=1,r=n;\nfor(ll i=0;i //Andrei Alexandru a.k.a Sho10\n#define ll long long int\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"Ofast\")\n#define all(a) (a).begin(), (a).end()\n#define sz size\n#define f first\n#define s second\n#define pb push_back\n#define er erase\n#define in insert\n#define mp make_pair\n#define pi pair\n#define rc(s) return cout<v;\nint32_t main(){\nCODE_START;\ncin>>n>>m;\nif(n%2==1){\n n--;\nll l=1,r=n;\nfor(ll i=0;i\n#define ll long long\n#define ALL(v) (v).begin(),(v).end()\n#define REP(i,p,n) for(int i=p;i<(int)(n);++i)\n#define rep(i,n) REP(i,0,n)\n#define dump(a) (cerr << #a << \"=\" << (a) << endl)\n#define DUMP(list) cout << \"{ \"; for(auto nth : list){ cout << nth << \" \"; } cout << \"}\" << endl;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }\n\nusing namespace std;\ntypedef pair pint;\n\nconst int MOD = 1000000007;\nvoid yesno(bool b) {\n if (b) {\n cout << \"Yes\" << endl;\n } else {\n cout << \"No\" << endl;\n }\n}\n\nint main() {\n int N, M;\n cin >> N >> M;\n ll l = 1;\n ll r = N;\n// rep(i, M) {\n// cout << l << \" \" << r << endl;\n// l++;\n// r--;\n// }\n if (N % 2 == 0) {\n rep(i, M) {\n if (i != M- 1) {\n cout << l << \" \" << r << endl;\n l++;\n r--;\n } else {\n r--;\n cout << l << \" \" << r << endl;\n }\n }\n } else {\n rep(i, M) {\n cout << l << \" \" << r << endl;\n l++;\n r--;\n }\n }\n}\n", "language": "C++", "metadata": {"date": 1588471980, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/C++/s302902696.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s302902696", "user_id": "u545305086"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "#include\n#define ll long long\n#define ALL(v) (v).begin(),(v).end()\n#define REP(i,p,n) for(int i=p;i<(int)(n);++i)\n#define rep(i,n) REP(i,0,n)\n#define dump(a) (cerr << #a << \"=\" << (a) << endl)\n#define DUMP(list) cout << \"{ \"; for(auto nth : list){ cout << nth << \" \"; } cout << \"}\" << endl;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }\n\nusing namespace std;\ntypedef pair pint;\n\nconst int MOD = 1000000007;\nvoid yesno(bool b) {\n if (b) {\n cout << \"Yes\" << endl;\n } else {\n cout << \"No\" << endl;\n }\n}\n\nint main() {\n int N, M;\n cin >> N >> M;\n ll l = 1;\n ll r = N;\n// rep(i, M) {\n// cout << l << \" \" << r << endl;\n// l++;\n// r--;\n// }\n if (N % 2 == 0) {\n rep(i, M) {\n if (i != M- 1) {\n cout << l << \" \" << r << endl;\n l++;\n r--;\n } else {\n r--;\n cout << l << \" \" << r << endl;\n }\n }\n } else {\n rep(i, M) {\n cout << l << \" \" << r << endl;\n l++;\n r--;\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1289, "cpu_time_ms": 135, "memory_kb": 3640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s762349234", "group_id": "codeNet:p02698", "input_text": "#include\nusing namespace std;\n#include \n#include \nusing namespace __gnu_pbds;\n#define M1 \t\t\t\t\t1000000007\n#define M2 \t\t\t\t\t998244353\n#define ll \t\t\t\t\tint\n#define pll \t\t\t\tpair\n#define mll \t\t\t\tmap\n#define F \t\t\t\t\tfirst\n#define S \t\t\t\t\tsecond\n#define PB \t\t\t\t\tpush_back\n#define mp \t\t\t\t\tmake_pair\n#define lb \t\t\t\t\tlower_bound\n#define ub \t\t\t\t\tupper_bound\n#define V(a) \t\t\t\tvector\n#define endl \t\t\t\t'\\n'\n#define test(t) \t\t\twhile(t--)\n#define PI \t\t\t\t\tacos(-1.0)\n#define rep(i,a,b) \t\t\tfor(ll i=a;i=a;i--)\n#define clr(ar, val)\t\tmemset(ar, val, sizeof(ar))\n#define setbits(x) \t\t\t__builtin_popcountll(x)\n#define zrobits(x) \t\t\t__builtin_ctzll(x)\n#define ps(y) \t\t\t\tfixed << setprecision(y)\n#define all(x) \t\t\t\tbegin(x),end(x)\n#define allr(x) \t\t\trbegin(x),rend(x)\nconst int inf= \t\t\t\t0x3f3f3f3f;\n// const ll INF= \t\t\t\t0x3f3f3f3f3f3f3f3f;\nconst int dx[4]= \t\t\t{ 0, -1, 0, 1 };\nconst int dy[4]= \t\t\t{ -1, 0, 1, 0 };\n\nunsigned int randInt (){ \n static unsigned int tx = 123456789 , ty = 362436069 , tz = 521288629 , tw = 88675123 ; \n unsigned int tt = ( tx ^ ( tx << 11 )); \n tx = ty ; ty = tz ; tz = tw ; \n return ( tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 )) ); \n}\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ntemplate\n#define o_set(T) tree, rb_tree_tag,tree_order_statistics_node_update>\n//member functions :\n//1. order_of_key(k) : number of elements strictly lesser than k\n//2. find_by_order(k) : k-th element in the set\n\nll floor_div(ll a, ll b) {\n\treturn a / b - (((a ^ b) < 0) and a % b);\n}\nll ceil_div(ll a, ll b){\n return a / b + (((a ^ b) >= 0) and a % b);\n}\n\nvector suffix_array_cyclic(string s){\n int n = s.size(), N = n + 256;\n vector sa(n), ra(n);\n for(int i = 0; i < n; i++) sa[i] = i, ra[i] = s[i];\n for(int k = 0; k < n; k ? k *= 2 : k++)\n {\n vector nsa(sa), nra(n), cnt(N);\n for(int i = 0; i < n; i++) nsa[i] = (nsa[i] - k + n) % n;\n for(int i = 0; i < n; i++) cnt[ra[i]]++;\n for(int i = 1; i < N; i++) cnt[i] += cnt[i - 1];\n for(int i = n - 1; i >= 0; i--) sa[--cnt[ra[nsa[i]]]] = nsa[i];\n \n int r = 0;\n for(int i = 1; i < n; i++)\n {\n if(ra[sa[i]] != ra[sa[i - 1]]) r++;\n else if(ra[(sa[i] + k) % n] != ra[(sa[i - 1] + k) % n]) r++;\n nra[sa[i]] = r;\n }\n ra = nra;\n }\n return sa;\n}\n \nvector kasai(string s, vector sa)\n{\n int n = s.size(), k = 0;\n vector ra(n), lcp(n);\n for(int i = 0; i < n; i++) ra[sa[i]] = i;\n for(int i = 0; i < n; i++)\n {\n if(k) k--;\n if(ra[i] == n - 1) {k = 0; continue;}\n int j = sa[ra[i] + 1];\n while(k < n && s[(i + k) % n] == s[(j + k) % n]) k++;\n lcp[ra[i]] = k;\n if(ra[(sa[ra[i]] + 1) % n] > ra[(sa[ra[j]] + 1) % n]) k = 0;\n }\n return lcp;\n}\n\ninline void INP()\n{\n\t#ifndef ONLINE_JUDGE\n\t freopen(\"input.txt\",\"r\",stdin); \n\t freopen(\"output.txt\",\"w\",stdout);\n\t#endif \n}\nV(ll) adj[200005];\nll n,k;\nll val[200005];\nll dp[200005];\no_set(int) v;\n\nll mytree[800005];\n\n\nvoid build(ll ind, ll l, ll r){\n if (l == r){\n mytree[ind] = 0;\n return;\n }\n ll mid = (l+r)/2;\n build(2*ind,l,mid);\n build(2*ind+1,mid+1,r);\n mytree[ind] = max(mytree[2*ind],mytree[2*ind+1]);\n}\n\nvoid update(ll ind, ll l, ll r, ll t, ll val){\n if (t < l || t > r){\n return;\n }\n if (l == r){\n mytree[ind] = val;\n return;\n }\n ll mid = (l+r)/2;\n update(2*ind,l,mid,t,val);\n update(2*ind+1,mid+1,r,t,val);\n mytree[ind] = max(mytree[2*ind],mytree[2*ind+1]);\n\n}\n\nll query(ll ind, ll l, ll r, ll qs, ll qe){\n if (qe < l || qs > r){\n return -1;\n }\n if (l >= qs && r <= qe){\n return mytree[ind];\n }\n ll mid = (l+r)/2;\n return max(query(2*ind,l,mid,qs,qe),query(2*ind+1,mid+1,r,qs,qe));\n}\nmap visited;\nvoid dfs(ll node, ll depth){\n visited[node] = 1;\n ll qps = v.order_of_key(val[node]);\n v.insert(val[node]);\n ll qry = query(1,0,n-1,0,max(qps-1,0))+1;\n dp[node] =qry;\n update(1,0,n-1,depth,dp[node]);\n dp[node] = query(1,0,n-1,0,n-1);\n \n for(ll child:adj[node]){\n if (!visited[child]){\n dfs(child,depth+1);\n }\n }\n v.erase(val[node]);\n update(1,0,n-1,depth,0);\n}\n\nvoid solve()\n{\n\t\n\tcin >> n;\n rep(i,1,n+1) cin >> val[i];\n rep(i,0,n-1){\n ll x,y;\n cin >> x >> y;\n adj[x].PB(y);\n adj[y].PB(x);\n }\n rep(i,0,200005) dp[i] = 1;\n build(1,0,n-1);\n dfs(1,0);\n\trep(i,1,n+1) cout << dp[i] << endl;\n}\n\nint32_t main(){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n int t=1;\n // cin>>t;\n test(t){\n solve();\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1588538937, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02698.html", "problem_id": "p02698", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02698/input.txt", "sample_output_relpath": "derived/input_output/data/p02698/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02698/C++/s762349234.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s762349234", "user_id": "u050982791"}, "prompt_components": {"gold_output": "1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n", "input_to_evaluate": "#include\nusing namespace std;\n#include \n#include \nusing namespace __gnu_pbds;\n#define M1 \t\t\t\t\t1000000007\n#define M2 \t\t\t\t\t998244353\n#define ll \t\t\t\t\tint\n#define pll \t\t\t\tpair\n#define mll \t\t\t\tmap\n#define F \t\t\t\t\tfirst\n#define S \t\t\t\t\tsecond\n#define PB \t\t\t\t\tpush_back\n#define mp \t\t\t\t\tmake_pair\n#define lb \t\t\t\t\tlower_bound\n#define ub \t\t\t\t\tupper_bound\n#define V(a) \t\t\t\tvector\n#define endl \t\t\t\t'\\n'\n#define test(t) \t\t\twhile(t--)\n#define PI \t\t\t\t\tacos(-1.0)\n#define rep(i,a,b) \t\t\tfor(ll i=a;i=a;i--)\n#define clr(ar, val)\t\tmemset(ar, val, sizeof(ar))\n#define setbits(x) \t\t\t__builtin_popcountll(x)\n#define zrobits(x) \t\t\t__builtin_ctzll(x)\n#define ps(y) \t\t\t\tfixed << setprecision(y)\n#define all(x) \t\t\t\tbegin(x),end(x)\n#define allr(x) \t\t\trbegin(x),rend(x)\nconst int inf= \t\t\t\t0x3f3f3f3f;\n// const ll INF= \t\t\t\t0x3f3f3f3f3f3f3f3f;\nconst int dx[4]= \t\t\t{ 0, -1, 0, 1 };\nconst int dy[4]= \t\t\t{ -1, 0, 1, 0 };\n\nunsigned int randInt (){ \n static unsigned int tx = 123456789 , ty = 362436069 , tz = 521288629 , tw = 88675123 ; \n unsigned int tt = ( tx ^ ( tx << 11 )); \n tx = ty ; ty = tz ; tz = tw ; \n return ( tw = ( tw^ ( tw >> 19 )) ^ ( tt ^ ( tt >> 8 )) ); \n}\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ntemplate\n#define o_set(T) tree, rb_tree_tag,tree_order_statistics_node_update>\n//member functions :\n//1. order_of_key(k) : number of elements strictly lesser than k\n//2. find_by_order(k) : k-th element in the set\n\nll floor_div(ll a, ll b) {\n\treturn a / b - (((a ^ b) < 0) and a % b);\n}\nll ceil_div(ll a, ll b){\n return a / b + (((a ^ b) >= 0) and a % b);\n}\n\nvector suffix_array_cyclic(string s){\n int n = s.size(), N = n + 256;\n vector sa(n), ra(n);\n for(int i = 0; i < n; i++) sa[i] = i, ra[i] = s[i];\n for(int k = 0; k < n; k ? k *= 2 : k++)\n {\n vector nsa(sa), nra(n), cnt(N);\n for(int i = 0; i < n; i++) nsa[i] = (nsa[i] - k + n) % n;\n for(int i = 0; i < n; i++) cnt[ra[i]]++;\n for(int i = 1; i < N; i++) cnt[i] += cnt[i - 1];\n for(int i = n - 1; i >= 0; i--) sa[--cnt[ra[nsa[i]]]] = nsa[i];\n \n int r = 0;\n for(int i = 1; i < n; i++)\n {\n if(ra[sa[i]] != ra[sa[i - 1]]) r++;\n else if(ra[(sa[i] + k) % n] != ra[(sa[i - 1] + k) % n]) r++;\n nra[sa[i]] = r;\n }\n ra = nra;\n }\n return sa;\n}\n \nvector kasai(string s, vector sa)\n{\n int n = s.size(), k = 0;\n vector ra(n), lcp(n);\n for(int i = 0; i < n; i++) ra[sa[i]] = i;\n for(int i = 0; i < n; i++)\n {\n if(k) k--;\n if(ra[i] == n - 1) {k = 0; continue;}\n int j = sa[ra[i] + 1];\n while(k < n && s[(i + k) % n] == s[(j + k) % n]) k++;\n lcp[ra[i]] = k;\n if(ra[(sa[ra[i]] + 1) % n] > ra[(sa[ra[j]] + 1) % n]) k = 0;\n }\n return lcp;\n}\n\ninline void INP()\n{\n\t#ifndef ONLINE_JUDGE\n\t freopen(\"input.txt\",\"r\",stdin); \n\t freopen(\"output.txt\",\"w\",stdout);\n\t#endif \n}\nV(ll) adj[200005];\nll n,k;\nll val[200005];\nll dp[200005];\no_set(int) v;\n\nll mytree[800005];\n\n\nvoid build(ll ind, ll l, ll r){\n if (l == r){\n mytree[ind] = 0;\n return;\n }\n ll mid = (l+r)/2;\n build(2*ind,l,mid);\n build(2*ind+1,mid+1,r);\n mytree[ind] = max(mytree[2*ind],mytree[2*ind+1]);\n}\n\nvoid update(ll ind, ll l, ll r, ll t, ll val){\n if (t < l || t > r){\n return;\n }\n if (l == r){\n mytree[ind] = val;\n return;\n }\n ll mid = (l+r)/2;\n update(2*ind,l,mid,t,val);\n update(2*ind+1,mid+1,r,t,val);\n mytree[ind] = max(mytree[2*ind],mytree[2*ind+1]);\n\n}\n\nll query(ll ind, ll l, ll r, ll qs, ll qe){\n if (qe < l || qs > r){\n return -1;\n }\n if (l >= qs && r <= qe){\n return mytree[ind];\n }\n ll mid = (l+r)/2;\n return max(query(2*ind,l,mid,qs,qe),query(2*ind+1,mid+1,r,qs,qe));\n}\nmap visited;\nvoid dfs(ll node, ll depth){\n visited[node] = 1;\n ll qps = v.order_of_key(val[node]);\n v.insert(val[node]);\n ll qry = query(1,0,n-1,0,max(qps-1,0))+1;\n dp[node] =qry;\n update(1,0,n-1,depth,dp[node]);\n dp[node] = query(1,0,n-1,0,n-1);\n \n for(ll child:adj[node]){\n if (!visited[child]){\n dfs(child,depth+1);\n }\n }\n v.erase(val[node]);\n update(1,0,n-1,depth,0);\n}\n\nvoid solve()\n{\n\t\n\tcin >> n;\n rep(i,1,n+1) cin >> val[i];\n rep(i,0,n-1){\n ll x,y;\n cin >> x >> y;\n adj[x].PB(y);\n adj[y].PB(x);\n }\n rep(i,0,200005) dp[i] = 1;\n build(1,0,n-1);\n dfs(1,0);\n\trep(i,1,n+1) cout << dp[i] << endl;\n}\n\nint32_t main(){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n int t=1;\n // cin>>t;\n test(t){\n solve();\n }\n return 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n\nWe will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.\n\nHere, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \\leq i_1 < i_2 < ... < i_M \\leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq u_i , v_i \\leq N\n\nu_i \\neq v_i\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.\n\nSample Input 1\n\n10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n\nSample Output 1\n\n1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to Vertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4, A_5, with the length of 4.", "sample_input": "10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n"}, "reference_outputs": ["1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n"], "source_document_id": "p02698", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n\nWe will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence.\n\nHere, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \\leq i_1 < i_2 < ... < i_M \\leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq u_i , v_i \\leq N\n\nu_i \\neq v_i\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\nu_1 v_1\nu_2 v_2\n:\nu_{N-1} v_{N-1}\n\nOutput\n\nPrint N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.\n\nSample Input 1\n\n10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10\n\nSample Output 1\n\n1\n2\n3\n3\n4\n4\n5\n2\n2\n3\n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to Vertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4, A_5, with the length of 4.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4893, "cpu_time_ms": 501, "memory_kb": 47632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s256636496", "group_id": "codeNet:p02699", "input_text": "#include \nusing namespace std;\n\n#define int long long\n#define S second\n#define F first\n#define pb push_back\n#define all(c) (c).begin(),(c).end()\n#define rall(c) (c).rbegin(),(c).rend() \n#define lb lower_bound\n#define si(c) (int)((c).size())\n#define lcm(a, b) (a * (b / __gcd(a,b))) \n#define inf (long long )(1e18+1)\n#define endl '\\n'\n#define mp make_pair\n#define time(s) (double(clock()-s)/double(CLOCKS_PER_SEC))\n#define debug(args...) _F(#args, args)\n#define vi std::vector\n#define pii pair \n#define vpi vector\n\nclock_t start;\nmt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());\n\ntemplate void _F(const char *name, T arg1){\n cerr << name << \" = \" << arg1 << endl;\n}\ntemplate void _F(const char *names, T arg1, Args... args){\n const char *name = strchr(names, ',');\n cerr.write(names, name-names) << \" = \" << arg1 << endl;\n _F(name+2, args...);\n}\ntemplate istream& operator>>(istream& in, pair &q){\n in >> q.F >> q.S; return in;\n}\ntemplate ostream& operator<<(ostream& out, pair &q){\n out << q.F << \" \" << q.S; return out;\n}\ntemplate< typename T1, typename T2> pair operator+(pair p1, pair p2){\n return {p1.F+p2.F, p1.S+p2.S};\n}\ntemplate< typename T1, typename T2> pair operator-(pair p1, pair p2){\n return {p1.F-p2.F, p1.S-p2.S};\n}\n\nvoid solve(){\n int s, w;\n cin >> s >> w;\n if(w >= s){\n cout << \"unsafe\" << endl;\n }else{\n cout << \"safe\" << endl;\n }\n}\n\nsigned main(){\n\n ios_base::sync_with_stdio(0); \n cin.tie(0); cout.tie(0); \n\n int t = 1;\n start = clock(); \n\n cout << fixed << setprecision(12);\n\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"error.txt\", \"w\", stderr);\n #endif\n\n //cin >> t;\n\n for(int i = 1; i <= t; ++i){\n //cout << \"Case #\" << i << \": \"; \n solve();\n // cout << endl;\n }\n //cerr << time(start);\n return 0;\n}", "language": "C++", "metadata": {"date": 1588016550, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02699/input.txt", "sample_output_relpath": "derived/input_output/data/p02699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02699/C++/s256636496.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s256636496", "user_id": "u613865539"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "#include \nusing namespace std;\n\n#define int long long\n#define S second\n#define F first\n#define pb push_back\n#define all(c) (c).begin(),(c).end()\n#define rall(c) (c).rbegin(),(c).rend() \n#define lb lower_bound\n#define si(c) (int)((c).size())\n#define lcm(a, b) (a * (b / __gcd(a,b))) \n#define inf (long long )(1e18+1)\n#define endl '\\n'\n#define mp make_pair\n#define time(s) (double(clock()-s)/double(CLOCKS_PER_SEC))\n#define debug(args...) _F(#args, args)\n#define vi std::vector\n#define pii pair \n#define vpi vector\n\nclock_t start;\nmt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());\n\ntemplate void _F(const char *name, T arg1){\n cerr << name << \" = \" << arg1 << endl;\n}\ntemplate void _F(const char *names, T arg1, Args... args){\n const char *name = strchr(names, ',');\n cerr.write(names, name-names) << \" = \" << arg1 << endl;\n _F(name+2, args...);\n}\ntemplate istream& operator>>(istream& in, pair &q){\n in >> q.F >> q.S; return in;\n}\ntemplate ostream& operator<<(ostream& out, pair &q){\n out << q.F << \" \" << q.S; return out;\n}\ntemplate< typename T1, typename T2> pair operator+(pair p1, pair p2){\n return {p1.F+p2.F, p1.S+p2.S};\n}\ntemplate< typename T1, typename T2> pair operator-(pair p1, pair p2){\n return {p1.F-p2.F, p1.S-p2.S};\n}\n\nvoid solve(){\n int s, w;\n cin >> s >> w;\n if(w >= s){\n cout << \"unsafe\" << endl;\n }else{\n cout << \"safe\" << endl;\n }\n}\n\nsigned main(){\n\n ios_base::sync_with_stdio(0); \n cin.tie(0); cout.tie(0); \n\n int t = 1;\n start = clock(); \n\n cout << fixed << setprecision(12);\n\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"error.txt\", \"w\", stderr);\n #endif\n\n //cin >> t;\n\n for(int i = 1; i <= t; ++i){\n //cout << \"Case #\" << i << \": \"; \n solve();\n // cout << endl;\n }\n //cerr << time(start);\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "sample_input": "4 5\n"}, "reference_outputs": ["unsafe\n"], "source_document_id": "p02699", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2272, "cpu_time_ms": 5, "memory_kb": 3640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s857500067", "group_id": "codeNet:p02701", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\n\nbool isKaibun(string s);\n\nint main()\n{\n int num;\n cin >> num;\n //景品の種類が、すでに持っている景品の種類と一致しているかみて、一致していなければインクリメントする\n\n string temp;\n int ans = 0;\n\n vector list(num+1, \"111\");\n\n //くじ引き1つ1つについて確認\n for ( int i = 1; i <= num; i++)\n {\n cin >> temp;\n\n for(int k = 1; k <= num; k++)\n {\n if(list[k] == \"111\")\n {\n list[k] = temp;\n ans++;\n break;\n }\n\n if(list[k] == temp)\n {\n //重複している\n break;\n }\n }\n }\n\n cout << ans << endl;\n \n}", "language": "C++", "metadata": {"date": 1589080638, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/C++/s857500067.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s857500067", "user_id": "u969223279"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\nbool isKaibun(string s);\n\nint main()\n{\n int num;\n cin >> num;\n //景品の種類が、すでに持っている景品の種類と一致しているかみて、一致していなければインクリメントする\n\n string temp;\n int ans = 0;\n\n vector list(num+1, \"111\");\n\n //くじ引き1つ1つについて確認\n for ( int i = 1; i <= num; i++)\n {\n cin >> temp;\n\n for(int k = 1; k <= num; k++)\n {\n if(list[k] == \"111\")\n {\n list[k] = temp;\n ans++;\n break;\n }\n\n if(list[k] == temp)\n {\n //重複している\n break;\n }\n }\n }\n\n cout << ans << endl;\n \n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 2206, "memory_kb": 9632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s150071938", "group_id": "codeNet:p02701", "input_text": "#include \nusing namespace std;\n\nint main(void)\n{\n\tint N;\n\tcin >> N;\n\n\tvector S(N);\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> S.at(i);\n\t}\n\n\tint cnt = 0;\n\tfor (int i = 0; i < N; i++) {\n\t\tint flag = 0;\n\t\tfor (int j = 0; j < i; j++) {\n\t\t\tif (i != j && S.at(i).at(0) == S.at(j).at(0)) {\n\t\t\t\tif (S.at(i) == S.at(j)){\n\t\t\t\t\tflag++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (flag == 0 || i == 0) cnt++;\n\t\tflag = 0;\n\t}\n\n\tcout << cnt << endl;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1587952322, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/C++/s150071938.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s150071938", "user_id": "u175174084"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(void)\n{\n\tint N;\n\tcin >> N;\n\n\tvector S(N);\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> S.at(i);\n\t}\n\n\tint cnt = 0;\n\tfor (int i = 0; i < N; i++) {\n\t\tint flag = 0;\n\t\tfor (int j = 0; j < i; j++) {\n\t\t\tif (i != j && S.at(i).at(0) == S.at(j).at(0)) {\n\t\t\t\tif (S.at(i) == S.at(j)){\n\t\t\t\t\tflag++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (flag == 0 || i == 0) cnt++;\n\t\tflag = 0;\n\t}\n\n\tcout << cnt << endl;\n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 457, "cpu_time_ms": 2206, "memory_kb": 9600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s723169438", "group_id": "codeNet:p02701", "input_text": "#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#include \n\nusing namespace std;\ntypedef long long ll;\n//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))\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\n\nint main()\n{\n\tint n; cin >> n;\n\tset s;\n\trep(i, n)\n\t{\n\t\tstring t; cin >> t;\n\t\ts.insert(t);\n\t}\n\tcout << s.size() << endl;\n}\n", "language": "C++", "metadata": {"date": 1587949463, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/C++/s723169438.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s723169438", "user_id": "u521389909"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#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#include \n\nusing namespace std;\ntypedef long long ll;\n//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))\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\n\nint main()\n{\n\tint n; cin >> n;\n\tset s;\n\trep(i, n)\n\t{\n\t\tstring t; cin >> t;\n\t\ts.insert(t);\n\t}\n\tcout << s.size() << endl;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 690, "cpu_time_ms": 208, "memory_kb": 19220}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s235844901", "group_id": "codeNet:p02706", "input_text": "#include\nusing namespace std;\nint main(){\n int n,m,a[10005],sum = 0;\n cin>>n>>m;\n for(int i=0;i>a[i];\n sum += a[i];\n }\n if(n>=sum){\n cout<\nusing namespace std;\nint main(){\n int n,m,a[10005],sum = 0;\n cin>>n>>m;\n for(int i=0;i>a[i];\n sum += a[i];\n }\n if(n>=sum){\n cout<\nusing namespace std;\nconst double PI = 3.141592653589793238463;\nint main()\n{\n long long int n, sum = 0;\n int m;\n cin >> n >> m;\n int a[m];\n for (int i = 0; i < m; i++)\n {\n cin >> a[i];\n sum += a[i];\n }\n if (sum <= n)\n {\n cout << n - sum;\n }\n else\n {\n cout << \"-1\";\n }\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1587345186, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/C++/s498546782.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s498546782", "user_id": "u968850687"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "#include \nusing namespace std;\nconst double PI = 3.141592653589793238463;\nint main()\n{\n long long int n, sum = 0;\n int m;\n cin >> n >> m;\n int a[m];\n for (int i = 0; i < m; i++)\n {\n cin >> a[i];\n sum += a[i];\n }\n if (sum <= n)\n {\n cout << n - sum;\n }\n else\n {\n cout << \"-1\";\n }\n\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 6, "memory_kb": 3656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s053514636", "group_id": "codeNet:p02706", "input_text": "#include \nusing namespace std;\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n int sum = 0, a;\n for(int i = 0; i < m; i++){\n cin >> a;\n sum += a;\n }\n\n if(n - sum >= 0) cout << n - sum << endl;\n else cout << -1 << endl;\n\n}", "language": "C++", "metadata": {"date": 1587344777, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02706/input.txt", "sample_output_relpath": "derived/input_output/data/p02706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02706/C++/s053514636.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053514636", "user_id": "u147762850"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n int sum = 0, a;\n for(int i = 0; i < m; i++){\n cin >> a;\n sum += a;\n }\n\n if(n - sum >= 0) cout << n - sum << endl;\n else cout << -1 << endl;\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "sample_input": "41 2\n5 6\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02706", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N days of summer vacation.\n\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\n\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\n\nWhat is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?\n\nIf Takahashi cannot finish all the assignments during the vacation, print -1 instead.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\n1 \\leq M \\leq 10^4\n\n1 \\leq A_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 ... A_M\n\nOutput\n\nPrint the maximum number of days Takahashi can hang out during the vacation, or -1.\n\nSample Input 1\n\n41 2\n5 6\n\nSample Output 1\n\n30\n\nFor example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.\n\nSample Input 2\n\n10 2\n5 6\n\nSample Output 2\n\n-1\n\nHe cannot finish his assignments.\n\nSample Input 3\n\n11 2\n5 6\n\nSample Output 3\n\n0\n\nHe can finish his assignments, but he will have no time to hang out.\n\nSample Input 4\n\n314 15\n9 26 5 35 8 9 79 3 23 8 46 2 6 43 3\n\nSample Output 4\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 7, "memory_kb": 3624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s249554225", "group_id": "codeNet:p02707", "input_text": "#include \ntypedef long long ll;\nusing namespace std;\n\nconst int INF = 1e9;\nconst int MOD = 1e9+7;\nconst ll LINF = 1e18;\n\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define REP(i,n) for(int i=0;i<(n);++i)\n#define REPR(i,n) for(int i=n;i>=0;i--)\n#define ALL(v) (v.begin(),v.end())\n#define COUT(x) cout<<(x)<<'\\n'\n\nint main(){\n int n;\n cin >> n;\n int a[200010];\n int t;\n REP(i,n-1){\n cin >> t;\n a[t]++;\n }\n for(int i=1;i\ntypedef long long ll;\nusing namespace std;\n\nconst int INF = 1e9;\nconst int MOD = 1e9+7;\nconst ll LINF = 1e18;\n\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define REP(i,n) for(int i=0;i<(n);++i)\n#define REPR(i,n) for(int i=n;i>=0;i--)\n#define ALL(v) (v.begin(),v.end())\n#define COUT(x) cout<<(x)<<'\\n'\n\nint main(){\n int n;\n cin >> n;\n int a[200010];\n int t;\n REP(i,n-1){\n cin >> t;\n a[t]++;\n }\n for(int i=1;i\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n;\n vector c(n);\n for(int i=0;i> a;\n a--;\n c[a]++;\n }\n for(int i=0;i\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n;\n vector c(n);\n for(int i=0;i> a;\n a--;\n c[a]++;\n }\n for(int i=0;i\nusing namespace std;\ntypedef long long ll;\n\nconst ll maxs = 1e5+5;\nconst ll lmaxs = 20;\nll mod = 1e9+7;\nll oo = 1e15;\n\n#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define I insert\n#define endl '\\n'\n\nvoid pre(){\n\n}\n\nll get(ll x){\n return x*(x-1)/2;\n}\n\nvoid solve(){ \n ll n , k;\n cin >> n >> k;\n ll ans=0;\n \n for(ll i=k;i<=n+1;i++){\n ll MIN = get(i);\n ll MAX = n*i - get(i);\n ans += MAX - MIN + 1; \n ans %= mod;\n }\n\n cout << ans << endl;\n}\n\nint main(){\n // #ifndef ONLINE_JUDGE\n // freopen(\"input00.txt\",\"r\",stdin);\n // #endif\n IOS;\n pre();\n ll T = 1; \n //cin>>T;\n while(T--){ \n solve();\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1588498661, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02708.html", "problem_id": "p02708", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02708/input.txt", "sample_output_relpath": "derived/input_output/data/p02708/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02708/C++/s097126888.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s097126888", "user_id": "u299658942"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include\nusing namespace std;\ntypedef long long ll;\n\nconst ll maxs = 1e5+5;\nconst ll lmaxs = 20;\nll mod = 1e9+7;\nll oo = 1e15;\n\n#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define I insert\n#define endl '\\n'\n\nvoid pre(){\n\n}\n\nll get(ll x){\n return x*(x-1)/2;\n}\n\nvoid solve(){ \n ll n , k;\n cin >> n >> k;\n ll ans=0;\n \n for(ll i=k;i<=n+1;i++){\n ll MIN = get(i);\n ll MAX = n*i - get(i);\n ans += MAX - MIN + 1; \n ans %= mod;\n }\n\n cout << ans << endl;\n}\n\nint main(){\n // #ifndef ONLINE_JUDGE\n // freopen(\"input00.txt\",\"r\",stdin);\n // #endif\n IOS;\n pre();\n ll T = 1; \n //cin>>T;\n while(T--){ \n solve();\n }\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02708", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\n\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq N+1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible values of the sum, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nThe sum can take 10 values, as follows:\n\n(10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n\n(10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n\n(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n\n(10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n\n(10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n\n(10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n\n(10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n\n(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n\n(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\nSample Input 2\n\n200000 200001\n\nSample Output 2\n\n1\n\nWe must choose all of the integers, so the sum can take just 1 value.\n\nSample Input 3\n\n141421 35623\n\nSample Output 3\n\n220280457", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 822, "cpu_time_ms": 6, "memory_kb": 3616}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s353593963", "group_id": "codeNet:p02708", "input_text": "#include\nusing namespace std;\n#define forr(i,a,n)\tfor(long long int i=a; i=n; i--)\nconst long long int m=1e9+7;\nint main() \n{\t\n\tios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);\t\n\n\tlong long int a,b,ct=0;\n\tcin>>a>>b;\n\tforr(i,b,a+2)\n\t{\n\t\tlong long int x=(i*(i-1)/2);\n\t\tlong long int y=(a*(a+1)/2)-((a-i)*(a-i+1)/2);\n\t\tct+=(y-x+1);\n\t\tct%=m;\n\t}\n\tcout<\nusing namespace std;\n#define forr(i,a,n)\tfor(long long int i=a; i=n; i--)\nconst long long int m=1e9+7;\nint main() \n{\t\n\tios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);\t\n\n\tlong long int a,b,ct=0;\n\tcin>>a>>b;\n\tforr(i,b,a+2)\n\t{\n\t\tlong long int x=(i*(i-1)/2);\n\t\tlong long int y=(a*(a+1)/2)-((a-i)*(a-i+1)/2);\n\t\tct+=(y-x+1);\n\t\tct%=m;\n\t}\n\tcout<\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 N_TIMES(i, n) for ( uint64_t i = 0; i < n; ++i )\n#define N_TIMES_REV(i, n) for ( int64_t i = n - 1; i >= 0; --i )\n\nusing namespace std;\n\nstruct VectorItem\n{\n int64_t key, val;\n VectorItem(int64_t key = 0, int64_t val = 0) : key(key), val(val) {}\n bool operator>(const VectorItem &item) const {\n return val > item.val;\n }\n};\n\nint main()\n{\n int64_t N;\n cin >> N;\n\n vector A(N);\n N_TIMES(n, N) {\n int64_t a;\n cin >> a;\n\n A[n] = VectorItem(n, a);\n }\n sort(A.begin(), A.end(), greater());\n\n vector> dp(N + 1, vector(N + 1, 0));\n for (int64_t n = 0; n < N; ++n) {\n for (int64_t x = 0; x <= n; ++x) {\n int64_t y = n - x;\n dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + A[n].val * (((N - 1) - x) - A[n].key));\n dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + A[n].val * (A[n].key - y));\n }\n }\n\n int64_t ans = 0;\n for (int64_t x = 0; x <= N; ++x) {\n int64_t y = N - x;\n ans = max(ans, dp[x][y]);\n }\n cout << ans << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1587367286, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02709.html", "problem_id": "p02709", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02709/input.txt", "sample_output_relpath": "derived/input_output/data/p02709/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02709/C++/s252227588.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252227588", "user_id": "u198355306"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "#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 N_TIMES(i, n) for ( uint64_t i = 0; i < n; ++i )\n#define N_TIMES_REV(i, n) for ( int64_t i = n - 1; i >= 0; --i )\n\nusing namespace std;\n\nstruct VectorItem\n{\n int64_t key, val;\n VectorItem(int64_t key = 0, int64_t val = 0) : key(key), val(val) {}\n bool operator>(const VectorItem &item) const {\n return val > item.val;\n }\n};\n\nint main()\n{\n int64_t N;\n cin >> N;\n\n vector A(N);\n N_TIMES(n, N) {\n int64_t a;\n cin >> a;\n\n A[n] = VectorItem(n, a);\n }\n sort(A.begin(), A.end(), greater());\n\n vector> dp(N + 1, vector(N + 1, 0));\n for (int64_t n = 0; n < N; ++n) {\n for (int64_t x = 0; x <= n; ++x) {\n int64_t y = n - x;\n dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + A[n].val * (((N - 1) - x) - A[n].key));\n dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + A[n].val * (A[n].key - y));\n }\n }\n\n int64_t ans = 0;\n for (int64_t x = 0; x <= N; ++x) {\n int64_t y = N - x;\n ans = max(ans, dp[x][y]);\n }\n cout << ans << endl;\n\n return 0;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "sample_input": "4\n1 3 4 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p02709", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \\times |x-y| happiness points.\n\nFind the maximum total happiness points the children can earn.\n\nConstraints\n\n2 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum total happiness points the children can earn.\n\nSample Input 1\n\n4\n1 3 4 2\n\nSample Output 1\n\n20\n\nIf we move the 1-st child from the left to the 3-rd position from the left, the 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and the 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3 \\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\nSample Input 2\n\n6\n5 5 6 1 1 1\n\nSample Output 2\n\n58\n\nSample Input 3\n\n6\n8 6 9 1 2 1\n\nSample Output 3\n\n85", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1353, "cpu_time_ms": 41, "memory_kb": 34684}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s714366959", "group_id": "codeNet:p02712", "input_text": "#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 vector VI;\ntypedef vector VL;\ntypedef vector VS;\ntypedef vector< vector > VVI;\ntypedef vector< vector > VVL;\ntypedef pair PII;\ntypedef pair PLL;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define all(a) (a).begin(),(a).end()\n#define pf push_front\n#define pb push_back\n#define mp make_pair\n#define mt make_tuple\n#define ub upper_bound\n#define lb lower_bound\n \nint main(){\n int N;\n cin>>N;\n VI X(N);\n rep(i,N) if((i+1)%3 and (i+1)%5) X[i]=i+1;\n ll ans=0;\n rep(i,N) ans+=X[i];\n cout<\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 vector VI;\ntypedef vector VL;\ntypedef vector VS;\ntypedef vector< vector > VVI;\ntypedef vector< vector > VVL;\ntypedef pair PII;\ntypedef pair PLL;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define all(a) (a).begin(),(a).end()\n#define pf push_front\n#define pb push_back\n#define mp make_pair\n#define mt make_tuple\n#define ub upper_bound\n#define lb lower_bound\n \nint main(){\n int N;\n cin>>N;\n VI X(N);\n rep(i,N) if((i+1)%3 and (i+1)%5) X[i]=i+1;\n ll ans=0;\n rep(i,N) ans+=X[i];\n cout<\nusing namespace std;\nusing lint = long long int;\nint main()\n{\n lint num;\n lint sum = 0;\n cin >> num;\n for (lint i = 1; i < num;i++)\n {\n if (i%3 != 0 && i%5 !=0)\n sum = sum + i;\n }\n cout << sum << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1586740915, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02712.html", "problem_id": "p02712", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02712/input.txt", "sample_output_relpath": "derived/input_output/data/p02712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02712/C++/s925785118.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s925785118", "user_id": "u085606120"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "#include \nusing namespace std;\nusing lint = long long int;\nint main()\n{\n lint num;\n lint sum = 0;\n cin >> num;\n for (lint i = 1; i < num;i++)\n {\n if (i%3 != 0 && i%5 !=0)\n sum = sum + i;\n }\n cout << sum << endl;\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 11, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s997911118", "group_id": "codeNet:p02712", "input_text": "#include \n#include // pair\nusing namespace std;\n\ntypedef long long ll;\n#define vec vector\n#define vecll vector\n#define vpair vector>\n#define vpairll vector>\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n#define rep(i,n) for(int i=(int)0; i<(int)n; i++)\n#define llrep(i,n) for(ll i=(ll)0; i<(ll)n; i++)\n#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)\n#define all(var) (var).begin(), (var).end()\n#define prt(var) cout << var << endl\n#define prt_dbl(i,var) cout<\nVal gcd(Val a, Val b) {\n//use ll or int for gcd\n if (b==0) return a;\n else return gcd(b, a%b);\n}\ntemplate \nVal vec_max(vector v){\n return *max_element(v.begin(),v.end());\n}\ntemplate \nVal vec_min(vector v){\n return *min_element(v.begin(),v.end());\n}\n\n\n//---------------------------------------------------------------\n\nint main(){\n ll N;\n cin>>N;\n ll count = 1;\n ll c = 0;\n while(1){\n if(count%3==0||count%5==0){\n c+=0;\n\n }else {\n c+=count;\n }\n if(count==N){\n break;\n }\n count++;\n }\n\n\n cout<\n#include // pair\nusing namespace std;\n\ntypedef long long ll;\n#define vec vector\n#define vecll vector\n#define vpair vector>\n#define vpairll vector>\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n#define rep(i,n) for(int i=(int)0; i<(int)n; i++)\n#define llrep(i,n) for(ll i=(ll)0; i<(ll)n; i++)\n#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)\n#define all(var) (var).begin(), (var).end()\n#define prt(var) cout << var << endl\n#define prt_dbl(i,var) cout<\nVal gcd(Val a, Val b) {\n//use ll or int for gcd\n if (b==0) return a;\n else return gcd(b, a%b);\n}\ntemplate \nVal vec_max(vector v){\n return *max_element(v.begin(),v.end());\n}\ntemplate \nVal vec_min(vector v){\n return *min_element(v.begin(),v.end());\n}\n\n\n//---------------------------------------------------------------\n\nint main(){\n ll N;\n cin>>N;\n ll count = 1;\n ll c = 0;\n while(1){\n if(count%3==0||count%5==0){\n c+=0;\n\n }else {\n c+=count;\n }\n if(count==N){\n break;\n }\n count++;\n }\n\n\n cout<\nusing namespace std;\nusing lint = long long int;\nconst lint MOD = 1e9+7;\n\nlint modpow(lint m, lint n){\n if(n == 0) return 1;\n else if(n % 2 == 0) return modpow(m * m % MOD, n/2);\n else{\n return modpow(m, n - 1) * m % MOD;\n }\n}\n\nsigned main(){\n\tlint N, K; cin >> N >> K;\n\tlint ans = 0;\n\tvector data(K + 1, 0);\n\tfor(lint i = K; i > 0; i--){\n\t\tlint num = modpow(K/i, N);\n\t\tfor(lint j = 2 * i; j <= K; j += i){\n\t\t\tnum = num - data[j] + MOD;\n\t\t\tnum %= MOD;\n\t\t}\n\t\tdata[i] = num;\n\t\tans += num * i;\n\t\tans %= MOD;\n\t}\n\tcout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1587870959, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02715.html", "problem_id": "p02715", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02715/input.txt", "sample_output_relpath": "derived/input_output/data/p02715/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02715/C++/s451870999.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s451870999", "user_id": "u265359795"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#include \nusing namespace std;\nusing lint = long long int;\nconst lint MOD = 1e9+7;\n\nlint modpow(lint m, lint n){\n if(n == 0) return 1;\n else if(n % 2 == 0) return modpow(m * m % MOD, n/2);\n else{\n return modpow(m, n - 1) * m % MOD;\n }\n}\n\nsigned main(){\n\tlint N, K; cin >> N >> K;\n\tlint ans = 0;\n\tvector data(K + 1, 0);\n\tfor(lint i = K; i > 0; i--){\n\t\tlint num = modpow(K/i, N);\n\t\tfor(lint j = 2 * i; j <= K; j += i){\n\t\t\tnum = num - data[j] + MOD;\n\t\t\tnum %= MOD;\n\t\t}\n\t\tdata[i] = num;\n\t\tans += num * i;\n\t\tans %= MOD;\n\t}\n\tcout << ans << endl;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02715", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\n\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\n\nSince this sum can be enormous, print the value modulo (10^9+7).\n\nHere \\gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the sum of \\gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2)\n=1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\nSample Input 2\n\n3 200\n\nSample Output 2\n\n10813692\n\nSample Input 3\n\n100000 100000\n\nSample Output 3\n\n742202979\n\nBe sure to print the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 20, "memory_kb": 4052}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s276744931", "group_id": "codeNet:p02715", "input_text": "#include \n#include \n#include \n#include \n#include \n \n#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define PB push_back\n#define MP make_pair\n#define REP(i,a,b) for (ll i = a; i < b; i++)\n#define enl \"\\n\"\n#define INF std::numeric_limits::max()\n#define F first\n#define S second\n \nusing namespace std;\n \ntypedef long long int ll;\ntypedef unsigned long long int ull;\ntypedef long double ldb;\ntypedef vector vll;\ntypedef pair pll;\n \nll greatestSubarraySum(ll array[], ll n);\nll binarySearch(vll arr, ll l, ll r, ll x);\nll modpower(ll x, ll y, ll p);\nll power(ll x, ll y);\nll gcd(ll a, ll b);\nll lcm(ll a, ll b);\nll search(ll arr[], ll n, ll k);\nstring findSum(string str1, string str2);\nll extendedGcd(ll a, ll b, ll & x, ll & y); \nbool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g);\nll countSetBits(ll n); \nvoid primeFactors(ll n, map& arr2, ll k, ll& flaggy);\nvoid matrixMultiply(ll a[3][3], ll b[3][3]);\nvoid matrixPower(ll F[7][7], ll n);\nll sumSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nvll squareRootDecompositionSumArray(ll arr[], ll n);\nll minSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nll maxSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nvll squareRootDecompositionMinArray(ll arr[], ll n);\nvll squareRootDecompositionMaxArray(ll arr[], ll n);\nvoid updateSquareRootDecompositionMinArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid updateSquareRootDecompositionMaxArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid updateSquareRootDecompositionSumArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid dfs(ll i, set arr[], ll visited[]);\nvoid uni(ll x, ll y, ll par[], ll size[]);\nll find(ll x, ll par[], ll size[]);\nll modulo( ll value, ll m);\nclass FenwickTree;\nvoid pairsort(ll a[], ll b[], ll n);\nll max(ll a, ll b);\nll min(ll a, ll b);\nll modInverse(ll a, ll m);\nll modsum(ll a, ll b, ll m);\nll modmul(ll a, ll b, ll m);\nstring reverseOfString(string s);\nll nCrMod(ll n, ll r, ll mod);\nvll kmpArray(string s);\n \n \n#define MAXI 998244353\n \n \nll fact[1000000];\n\nll floorSqrt(ll x) \n{ \n // Base cases \n if (x == 0 || x == 1) \n return x; \n \n // Do Binary Search for floor(sqrt(x)) \n ll start = 1, end = x, ans; \n while (start <= end) \n { \n ll mid = (start + end) / 2; \n \n // If x is a perfect square \n if (mid*mid == x) \n return mid; \n \n // Since we need floor, we update answer when mid*mid is \n // smaller than x, and move closer to sqrt(x) \n if (mid*mid < x) \n { \n start = mid + 1; \n ans = mid; \n } \n else // If mid*mid is greater than x \n end = mid-1; \n } \n return ans; \n} \n\nint main(){\n \n io\n \n ll q=1;\n // cin>>q;\n REP(currentIndex,0,q){\n\n ll n,k;\n cin>>n>>k;\n\n ll current[k+1];\n REP(i,0,k+1)current[i]=0;\n\n\n ll ans=0;\n\n REP(i,1,k+1){\n\n ll temp=0;\n\n if(i==1){\n\n current[i]=1;\n\n } else {\n\n\n for(ll j=1; j<=floorSqrt(i); j++){\n\n if(i%j==0){\n\n \n\n temp+=current[j];\n if(j!=i/j)temp+=current[i/j];\n }\n\n\n }\n\n\n\n current[i]=i-temp;\n\n\n\n }\n\n\n ans=modsum(ans, modmul(i-temp, modpower(k/i, n, 1000000007), 1000000007), 1000000007);\n\n }\n\n cout<0 && s[len]!=s[i])len=arr[len-1];\n if(s[len]==s[i])len++;\n arr[i]=len;\n \n \n \n }\n \n return arr;\n \n \n \n}\n \n \n \nll nCrMod(ll n, ll r, ll mod){\n \n return (fact[n]* modInverse(fact[r], mod) % mod * modInverse(fact[n-r], mod) % mod) % mod; \n \n}\n \nvoid SieveOfEratosthenes(ll n, bool isPrime[]) \n{ \n \n isPrime[0] = isPrime[1] = false; \n for (ll i = 2; i <= n; i++) \n isPrime[i] = true; \n \n for (ll p = 2; p * p <= n; p++) { \n \n \n if (isPrime[p] == true) { \n \n for (ll i = p * 2; i <= n; i += p) \n isPrime[i] = false; \n } \n } \n} \n \nstring reverseOfString(string s){\n \n string t;\n REP(i,0,s.length()){\n \n t+=s[s.length()-i-1];\n \n }\n \n return t;\n \n}\n \nclass FenwickTree{\n \nprivate:\n ll n;\n \n ll h(ll i){return (i|(i+1));}\n ll g(ll i){return (i&(i+1));}\n \n \n \npublic:\n \n ll *sumtree;\n ll *mainArray;\n \n FenwickTree(ll n){\n \n this->n=n;\n mainArray = (ll*)malloc(n*sizeof(ll));\n sumtree = (ll*)calloc(n, sizeof(ll));\n \n }\n \n \n \n void addElementAtIndex(ll i, ll x){\n mainArray[i]=x;\n update(i,x);\n }\n \n void update(ll i, ll delta){\n \n for(ll j=i; j=0){\n sum1+=sumtree[j];\n j=g(j)-1;\n }\n while(i>=0){\n sum2+=sumtree[i];\n i=g(i)-1;\n }\n return sum1-sum2+mainArray[i1];\n \n }\n \n \n};\n \nll modsum(ll a, ll b, ll m){\n \n return ((a%m)+(b%m))%m;\n \n}\n \nll modmul(ll a, ll b, ll m){\n \n return ((a%m)*(b%m))%m;\n \n \n}\n \nll modInverse(ll a, ll m) \n{ \n \n return modpower(a, m-2, m); \n \n} \n \nll max(ll a, ll b){\n \n if(a>b)return a;\n else return b;\n}\n \nll min(ll a, ll b){\n \n if(a pairt[n]; \n \n \n for (ll i = 0; i < n; i++) \n { \n pairt[i].first = a[i]; \n pairt[i].second = b[i]; \n } \n \n sort(pairt, pairt + n); \n \n for (ll i = 0; i < n; i++) \n { \n a[i] = pairt[i].first; \n b[i] = pairt[i].second; \n } \n}\n \nll extendedGcd(ll a, ll b, ll & x, ll & y) {\n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n }\n ll x1, y1;\n ll d = extendedGcd(b % a, a, x1, y1);\n x = y1 - (b / a) * x1;\n y = x1;\n return d;\n}\n \nbool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {\n g = extendedGcd(abs(a), abs(b), x0, y0);\n if (c % g) {\n return false;\n }\n \n x0 *= c / g;\n y0 *= c / g;\n if (a < 0) x0 = -x0;\n if (b < 0) y0 = -y0;\n return true;\n}\n \n \nstring findSum(string str1, string str2) \n{ \n \n if (str1.length() > str2.length()) {\n string s = str1;\n str1=str2;\n str2=s;\n }\n \n \n string str = \"\"; \n \n \n int n1 = str1.length(), n2 = str2.length(); \n \n \n reverse(str1.begin(), str1.end()); \n reverse(str2.begin(), str2.end()); \n \n int carry = 0; \n for (int i=0; i= l) { \n ll mid = l + (r - l) / 2; \n \n // If the element is present at the middle \n // itself \n if (arr[mid] == x) \n return mid; \n \n // If element is smaller than mid, then \n // it can only be present in left subarray \n if (arr[mid] > x) \n return binarySearch(arr, l, mid - 1, x); \n \n // Else the element can only be present \n // in right subarray \n return binarySearch(arr, mid + 1, r, x); \n } \n \n // We reach here when element is not \n // present in array \n return -1; \n} \n \nll greatestSubarraySum(ll array[], ll n){\n \n ll best = 0, sum = 0;\n for (ll k = 0; k < n; k++) {\n sum = max(array[k],sum+array[k]);\n best = max(best,sum);\n }\n \n return best;\n}\n \nll modpower(ll x, ll y, ll p) \n{ \n ll res = 1; // Initialize result \n \n x = x % p; // Update x if it is more than or \n // equal to p \n \n while (y > 0) \n { \n // If y is odd, multiply x with result \n if (y & 1) \n res = (res*x) % p; \n \n // y must be even now \n y = y>>1; // y = y/2 \n x = (x*x) % p; \n } \n return res; \n} \n \n \nll gcd(ll a, ll b)\n{\n if (a == 0)\n return b;\n \n return gcd(b%a, a);\n}\n \nll lcm(ll a, ll b) \n{ \n return (a*b)/gcd(a, b); \n} \n \n \nll power(ll x, ll y) \n{ \n ll temp; \n if( y == 0) \n return 1; \n temp = power(x, y/2); \n if (y%2 == 0) \n return temp*temp; \n else\n return x*temp*temp; \n}\n \nll modulo( ll value, ll m) {\n ll mod = value % m;\n if (value < 0) {\n mod += m;\n }\n return mod;\n}\n \nll find(ll x, ll par[], ll size[]){\n \n if(x==par[x])return x;\n else return par[x]=find(par[x],par, size);\n \n}\n \nvoid uni(ll x, ll y, ll par[], ll size[]){\n \n x=find(x,par,size);\n y=find(y,par,size);\n \n if(size[x]>size[y])swap(x,y);\n \n par[x]=y;\n size[y]+=size[x];\n \n \n}\n \nvoid dfs(ll i, set arr[], ll visited[]){\n \n if(visited[i])return;\n \n cout<<(char)('a'+i);\n \n visited[i]=1;\n \n for(auto u:arr[i])dfs(u, arr, visited);\n \n \n}\n \n \nll countSetBits(ll n) \n{ \n ll count = 0; \n while (n) { \n count += n & 1; \n n >>= 1; \n } \n return count; \n} \n \n \nll flag2;\n \n \nvoid primeFactors(ll n, map& arr2, ll k, ll& flaggy) \n{ \n ll count=0;\n \n ll flag=0;\n \n while (n % 2 == 0) \n { \n n = n/2;\n count++; \n } \n \n if(count%k != 0){\n \n flag=1;\n \n arr2[2]=count%k;\n \n }\n count=0;\n \n for (int i = 3; i <= sqrt(n); i = i + 2) \n { \n while (n % i == 0) \n { \n n = n/i;\n count++; \n } \n \n \n if(count%k!=0){\n \n flag=1;\n arr2[i]=count%k;\n \n }\n \n count=0;\n } \n \n if (n > 2) \n {\n if(1%k!=0){\n \n flag=1;\n arr2[n]=1%k;\n \n }\n }\n \n if(flag==0){flag2++;flaggy=1;}\n \n} \n \nvoid matrixMultiply(ll* a[], ll *b[], ll n) \n{ \n \n ll mul[n][n]; \n for (ll i = 0; i < n; i++) \n { \n for (ll j = 0; j < n; j++) \n { \n mul[i][j] = 0; \n for (ll k = 0; k < n; k++) \n mul[i][j] += a[i][k]*b[k][j]; \n } \n } \n \n for (int i=0; i\n#include \n#include \n#include \n#include \n \n#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define PB push_back\n#define MP make_pair\n#define REP(i,a,b) for (ll i = a; i < b; i++)\n#define enl \"\\n\"\n#define INF std::numeric_limits::max()\n#define F first\n#define S second\n \nusing namespace std;\n \ntypedef long long int ll;\ntypedef unsigned long long int ull;\ntypedef long double ldb;\ntypedef vector vll;\ntypedef pair pll;\n \nll greatestSubarraySum(ll array[], ll n);\nll binarySearch(vll arr, ll l, ll r, ll x);\nll modpower(ll x, ll y, ll p);\nll power(ll x, ll y);\nll gcd(ll a, ll b);\nll lcm(ll a, ll b);\nll search(ll arr[], ll n, ll k);\nstring findSum(string str1, string str2);\nll extendedGcd(ll a, ll b, ll & x, ll & y); \nbool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g);\nll countSetBits(ll n); \nvoid primeFactors(ll n, map& arr2, ll k, ll& flaggy);\nvoid matrixMultiply(ll a[3][3], ll b[3][3]);\nvoid matrixPower(ll F[7][7], ll n);\nll sumSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nvll squareRootDecompositionSumArray(ll arr[], ll n);\nll minSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nll maxSquareRootDecomposition(ll arr[], vll helper, ll n, ll l, ll r);\nvll squareRootDecompositionMinArray(ll arr[], ll n);\nvll squareRootDecompositionMaxArray(ll arr[], ll n);\nvoid updateSquareRootDecompositionMinArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid updateSquareRootDecompositionMaxArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid updateSquareRootDecompositionSumArray(ll arr[], vll &helper, ll n, ll i, ll x);\nvoid dfs(ll i, set arr[], ll visited[]);\nvoid uni(ll x, ll y, ll par[], ll size[]);\nll find(ll x, ll par[], ll size[]);\nll modulo( ll value, ll m);\nclass FenwickTree;\nvoid pairsort(ll a[], ll b[], ll n);\nll max(ll a, ll b);\nll min(ll a, ll b);\nll modInverse(ll a, ll m);\nll modsum(ll a, ll b, ll m);\nll modmul(ll a, ll b, ll m);\nstring reverseOfString(string s);\nll nCrMod(ll n, ll r, ll mod);\nvll kmpArray(string s);\n \n \n#define MAXI 998244353\n \n \nll fact[1000000];\n\nll floorSqrt(ll x) \n{ \n // Base cases \n if (x == 0 || x == 1) \n return x; \n \n // Do Binary Search for floor(sqrt(x)) \n ll start = 1, end = x, ans; \n while (start <= end) \n { \n ll mid = (start + end) / 2; \n \n // If x is a perfect square \n if (mid*mid == x) \n return mid; \n \n // Since we need floor, we update answer when mid*mid is \n // smaller than x, and move closer to sqrt(x) \n if (mid*mid < x) \n { \n start = mid + 1; \n ans = mid; \n } \n else // If mid*mid is greater than x \n end = mid-1; \n } \n return ans; \n} \n\nint main(){\n \n io\n \n ll q=1;\n // cin>>q;\n REP(currentIndex,0,q){\n\n ll n,k;\n cin>>n>>k;\n\n ll current[k+1];\n REP(i,0,k+1)current[i]=0;\n\n\n ll ans=0;\n\n REP(i,1,k+1){\n\n ll temp=0;\n\n if(i==1){\n\n current[i]=1;\n\n } else {\n\n\n for(ll j=1; j<=floorSqrt(i); j++){\n\n if(i%j==0){\n\n \n\n temp+=current[j];\n if(j!=i/j)temp+=current[i/j];\n }\n\n\n }\n\n\n\n current[i]=i-temp;\n\n\n\n }\n\n\n ans=modsum(ans, modmul(i-temp, modpower(k/i, n, 1000000007), 1000000007), 1000000007);\n\n }\n\n cout<0 && s[len]!=s[i])len=arr[len-1];\n if(s[len]==s[i])len++;\n arr[i]=len;\n \n \n \n }\n \n return arr;\n \n \n \n}\n \n \n \nll nCrMod(ll n, ll r, ll mod){\n \n return (fact[n]* modInverse(fact[r], mod) % mod * modInverse(fact[n-r], mod) % mod) % mod; \n \n}\n \nvoid SieveOfEratosthenes(ll n, bool isPrime[]) \n{ \n \n isPrime[0] = isPrime[1] = false; \n for (ll i = 2; i <= n; i++) \n isPrime[i] = true; \n \n for (ll p = 2; p * p <= n; p++) { \n \n \n if (isPrime[p] == true) { \n \n for (ll i = p * 2; i <= n; i += p) \n isPrime[i] = false; \n } \n } \n} \n \nstring reverseOfString(string s){\n \n string t;\n REP(i,0,s.length()){\n \n t+=s[s.length()-i-1];\n \n }\n \n return t;\n \n}\n \nclass FenwickTree{\n \nprivate:\n ll n;\n \n ll h(ll i){return (i|(i+1));}\n ll g(ll i){return (i&(i+1));}\n \n \n \npublic:\n \n ll *sumtree;\n ll *mainArray;\n \n FenwickTree(ll n){\n \n this->n=n;\n mainArray = (ll*)malloc(n*sizeof(ll));\n sumtree = (ll*)calloc(n, sizeof(ll));\n \n }\n \n \n \n void addElementAtIndex(ll i, ll x){\n mainArray[i]=x;\n update(i,x);\n }\n \n void update(ll i, ll delta){\n \n for(ll j=i; j=0){\n sum1+=sumtree[j];\n j=g(j)-1;\n }\n while(i>=0){\n sum2+=sumtree[i];\n i=g(i)-1;\n }\n return sum1-sum2+mainArray[i1];\n \n }\n \n \n};\n \nll modsum(ll a, ll b, ll m){\n \n return ((a%m)+(b%m))%m;\n \n}\n \nll modmul(ll a, ll b, ll m){\n \n return ((a%m)*(b%m))%m;\n \n \n}\n \nll modInverse(ll a, ll m) \n{ \n \n return modpower(a, m-2, m); \n \n} \n \nll max(ll a, ll b){\n \n if(a>b)return a;\n else return b;\n}\n \nll min(ll a, ll b){\n \n if(a pairt[n]; \n \n \n for (ll i = 0; i < n; i++) \n { \n pairt[i].first = a[i]; \n pairt[i].second = b[i]; \n } \n \n sort(pairt, pairt + n); \n \n for (ll i = 0; i < n; i++) \n { \n a[i] = pairt[i].first; \n b[i] = pairt[i].second; \n } \n}\n \nll extendedGcd(ll a, ll b, ll & x, ll & y) {\n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n }\n ll x1, y1;\n ll d = extendedGcd(b % a, a, x1, y1);\n x = y1 - (b / a) * x1;\n y = x1;\n return d;\n}\n \nbool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {\n g = extendedGcd(abs(a), abs(b), x0, y0);\n if (c % g) {\n return false;\n }\n \n x0 *= c / g;\n y0 *= c / g;\n if (a < 0) x0 = -x0;\n if (b < 0) y0 = -y0;\n return true;\n}\n \n \nstring findSum(string str1, string str2) \n{ \n \n if (str1.length() > str2.length()) {\n string s = str1;\n str1=str2;\n str2=s;\n }\n \n \n string str = \"\"; \n \n \n int n1 = str1.length(), n2 = str2.length(); \n \n \n reverse(str1.begin(), str1.end()); \n reverse(str2.begin(), str2.end()); \n \n int carry = 0; \n for (int i=0; i= l) { \n ll mid = l + (r - l) / 2; \n \n // If the element is present at the middle \n // itself \n if (arr[mid] == x) \n return mid; \n \n // If element is smaller than mid, then \n // it can only be present in left subarray \n if (arr[mid] > x) \n return binarySearch(arr, l, mid - 1, x); \n \n // Else the element can only be present \n // in right subarray \n return binarySearch(arr, mid + 1, r, x); \n } \n \n // We reach here when element is not \n // present in array \n return -1; \n} \n \nll greatestSubarraySum(ll array[], ll n){\n \n ll best = 0, sum = 0;\n for (ll k = 0; k < n; k++) {\n sum = max(array[k],sum+array[k]);\n best = max(best,sum);\n }\n \n return best;\n}\n \nll modpower(ll x, ll y, ll p) \n{ \n ll res = 1; // Initialize result \n \n x = x % p; // Update x if it is more than or \n // equal to p \n \n while (y > 0) \n { \n // If y is odd, multiply x with result \n if (y & 1) \n res = (res*x) % p; \n \n // y must be even now \n y = y>>1; // y = y/2 \n x = (x*x) % p; \n } \n return res; \n} \n \n \nll gcd(ll a, ll b)\n{\n if (a == 0)\n return b;\n \n return gcd(b%a, a);\n}\n \nll lcm(ll a, ll b) \n{ \n return (a*b)/gcd(a, b); \n} \n \n \nll power(ll x, ll y) \n{ \n ll temp; \n if( y == 0) \n return 1; \n temp = power(x, y/2); \n if (y%2 == 0) \n return temp*temp; \n else\n return x*temp*temp; \n}\n \nll modulo( ll value, ll m) {\n ll mod = value % m;\n if (value < 0) {\n mod += m;\n }\n return mod;\n}\n \nll find(ll x, ll par[], ll size[]){\n \n if(x==par[x])return x;\n else return par[x]=find(par[x],par, size);\n \n}\n \nvoid uni(ll x, ll y, ll par[], ll size[]){\n \n x=find(x,par,size);\n y=find(y,par,size);\n \n if(size[x]>size[y])swap(x,y);\n \n par[x]=y;\n size[y]+=size[x];\n \n \n}\n \nvoid dfs(ll i, set arr[], ll visited[]){\n \n if(visited[i])return;\n \n cout<<(char)('a'+i);\n \n visited[i]=1;\n \n for(auto u:arr[i])dfs(u, arr, visited);\n \n \n}\n \n \nll countSetBits(ll n) \n{ \n ll count = 0; \n while (n) { \n count += n & 1; \n n >>= 1; \n } \n return count; \n} \n \n \nll flag2;\n \n \nvoid primeFactors(ll n, map& arr2, ll k, ll& flaggy) \n{ \n ll count=0;\n \n ll flag=0;\n \n while (n % 2 == 0) \n { \n n = n/2;\n count++; \n } \n \n if(count%k != 0){\n \n flag=1;\n \n arr2[2]=count%k;\n \n }\n count=0;\n \n for (int i = 3; i <= sqrt(n); i = i + 2) \n { \n while (n % i == 0) \n { \n n = n/i;\n count++; \n } \n \n \n if(count%k!=0){\n \n flag=1;\n arr2[i]=count%k;\n \n }\n \n count=0;\n } \n \n if (n > 2) \n {\n if(1%k!=0){\n \n flag=1;\n arr2[n]=1%k;\n \n }\n }\n \n if(flag==0){flag2++;flaggy=1;}\n \n} \n \nvoid matrixMultiply(ll* a[], ll *b[], ll n) \n{ \n \n ll mul[n][n]; \n for (ll i = 0; i < n; i++) \n { \n for (ll j = 0; j < n; j++) \n { \n mul[i][j] = 0; \n for (ll k = 0; k < n; k++) \n mul[i][j] += a[i][k]*b[k][j]; \n } \n } \n \n for (int i=0; i\n#include \n#include \n#include \n#include \n#include \n#define FOR(i,k,n) for(int i = (k);i < (n);++i)\n#define REP(i,n) FOR(i,0,n)\n#define ALL(x) begin(x),end(x)\n\nusing namespace std;\nusing namespace boost::adaptors;\nusing namespace std::string_literals;\nusing ll = int64_t;\nusing vecint = vector;\nusing vecll = vector;\nusing boost::irange;\nconstexpr ll MOD = 1000000007;\n\nll pmod(ll base, ll index) {\n if (index == 0) return 1;\n if (index%2 == 1) return pmod(base, index-1) * base % MOD;\n ll h = pmod(base, index/2);\n return h * h % MOD;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n ll n,k;\n cin>>n>>k;\n vecll v(k+1);\n FOR(i,1,k+1) {\n v[i] = pmod(k/i, n);\n }\n for (int i = k; i > 0; --i) {\n for (int j = 2*i; j <= k; j += i) {\n v[i] += MOD - v[j];\n v[i] %= MOD;\n }\n }\n ll ans = 0;\n FOR(i,1,k+1) {\n ans += i * v[i] % MOD;\n ans %= MOD;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#define FOR(i,k,n) for(int i = (k);i < (n);++i)\n#define REP(i,n) FOR(i,0,n)\n#define ALL(x) begin(x),end(x)\n\nusing namespace std;\nusing namespace boost::adaptors;\nusing namespace std::string_literals;\nusing ll = int64_t;\nusing vecint = vector;\nusing vecll = vector;\nusing boost::irange;\nconstexpr ll MOD = 1000000007;\n\nll pmod(ll base, ll index) {\n if (index == 0) return 1;\n if (index%2 == 1) return pmod(base, index-1) * base % MOD;\n ll h = pmod(base, index/2);\n return h * h % MOD;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n ll n,k;\n cin>>n>>k;\n vecll v(k+1);\n FOR(i,1,k+1) {\n v[i] = pmod(k/i, n);\n }\n for (int i = k; i > 0; --i) {\n for (int j = 2*i; j <= k; j += i) {\n v[i] += MOD - v[j];\n v[i] %= MOD;\n }\n }\n ll ans = 0;\n FOR(i,1,k+1) {\n ans += i * v[i] % MOD;\n ans %= MOD;\n }\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nconst int mod=1000000007;\nconst double PI = 3.14159265359;\n#define mxe(v) *max_element(v.begin(),v.end())\n#define mne(v) *min_element(v.begin(),v.end())\n#define INF 1000000000000\n#define pb push_back\n#define pf push_front\n#define ppb pop_back\n#define ppf pop_front\n#define mp make_pair\n#define lb lower_bound\n#define ub upper_bound\n#define FOR(i,n) for(int i=0;i<(n);i++)\n#define FORA(i,a,b) for(int i=(a);i<=(b);i++)\n#define FORD(i,a,b) for(int i=(a);i>=(b);i--)\n#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);\n#define count_1(n) __builtin_popcountll(n)\n#define parity(n) __builtin_parityll(n) //Even parity 0 as output\nvoid show (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i) {cout << a[i] << \" \";}\tcout<>n>>k;\nif(k>=n)\n{\n\tcout<\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nconst int mod=1000000007;\nconst double PI = 3.14159265359;\n#define mxe(v) *max_element(v.begin(),v.end())\n#define mne(v) *min_element(v.begin(),v.end())\n#define INF 1000000000000\n#define pb push_back\n#define pf push_front\n#define ppb pop_back\n#define ppf pop_front\n#define mp make_pair\n#define lb lower_bound\n#define ub upper_bound\n#define FOR(i,n) for(int i=0;i<(n);i++)\n#define FORA(i,a,b) for(int i=(a);i<=(b);i++)\n#define FORD(i,a,b) for(int i=(a);i>=(b);i--)\n#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);\n#define count_1(n) __builtin_popcountll(n)\n#define parity(n) __builtin_parityll(n) //Even parity 0 as output\nvoid show (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i) {cout << a[i] << \" \";}\tcout<>n>>k;\nif(k>=n)\n{\n\tcout<\nusing namespace std;\n\n\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*b)/gcd(a,b)\n#define ll long long\n#define vi std::vector\n#define pb push_back\n#define MAX 100007\n#define End return 0;\n#define pi acos(-1)\n\nmapv;\nint main () {\n ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);\n ll n,k;\n cin>>n>>k;\n ll x=n%k;\n ll y=abs((n/k+1)*(k)-n);\n //cout<\nusing namespace std;\n\n\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*b)/gcd(a,b)\n#define ll long long\n#define vi std::vector\n#define pb push_back\n#define MAX 100007\n#define End return 0;\n#define pi acos(-1)\n\nmapv;\nint main () {\n ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);\n ll n,k;\n cin>>n>>k;\n ll x=n%k;\n ll y=abs((n/k+1)*(k)-n);\n //cout<\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define MIN(a,b) ((a) <= (b) ? (a) : (b))\n#define ALL(v) (v).begin(), (v).end()\n#define SORT(v) sort( ALL(v) )\n\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing ull = unsigned long long;\n\n\n\nint main()\n{\n\n\n ll N,K; cin >> N >> K;\n\n N%=K;\n cout << min(N, K-N)<\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define MIN(a,b) ((a) <= (b) ? (a) : (b))\n#define ALL(v) (v).begin(), (v).end()\n#define SORT(v) sort( ALL(v) )\n\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing ull = unsigned long long;\n\n\n\nint main()\n{\n\n\n ll N,K; cin >> N >> K;\n\n N%=K;\n cout << min(N, K-N)<\n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main()\n{\n ll N, K;\n cin >> N >> K;\n if (N >= K) {\n N = N % K;\n }\n N = min(N, abs(N-K));\n cout << N << endl;\n}", "language": "C++", "metadata": {"date": 1586049844, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/C++/s166514746.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166514746", "user_id": "u027641915"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main()\n{\n ll N, K;\n cin >> N >> K;\n if (N >= K) {\n N = N % K;\n }\n N = min(N, abs(N-K));\n cout << N << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s795416980", "group_id": "codeNet:p02719", "input_text": "// SeeAlso: \n\n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef pair pii;\ntypedef pair pll;\n\n#define MAX 100000\n#define NIL -1\n#define MOD 1000000007\n\ntypedef int _loop_int;\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)\n#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)\n\n#define debug(x) cout<<#x<<\": \"< void print(const T& x){cout << setprecision(12) << x << endl;}\ntemplate void print(const T& first, const A&... rest) { cout << first << \" \"; print(rest...); }\n\nint main() {\n ll n,k;\n cin>>n>>k;\n ll t = n%k;\n print(min(abs(t-k), t));\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1586048976, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/C++/s795416980.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795416980", "user_id": "u185518252"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "// SeeAlso: \n\n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef pair pii;\ntypedef pair pll;\n\n#define MAX 100000\n#define NIL -1\n#define MOD 1000000007\n\ntypedef int _loop_int;\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)\n#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)\n\n#define debug(x) cout<<#x<<\": \"< void print(const T& x){cout << setprecision(12) << x << endl;}\ntemplate void print(const T& first, const A&... rest) { cout << first << \" \"; print(rest...); }\n\nint main() {\n ll n,k;\n cin>>n>>k;\n ll t = n%k;\n print(min(abs(t-k), t));\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1212, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s707094579", "group_id": "codeNet:p02720", "input_text": "#include\n#define pb push_back\n#define mp make_pair\n#define fst first\n#define snd second\nusing namespace std;\n\ntypedef long long ll;\ntypedef double db;\ntypedef long double ldb;\n\ntemplate inline void checkmin(T &a,const T &b){if(b inline void checkmax(T &a,const T &b){if(b>a) a=b;}\n\nconst int inf=1e9+10;\nconst int maxn=15;\nconst int mod=2e5;\n\nint dp[maxn][maxn],k,tot[maxn];\n\nint add(int &a,int b){\n\ta=(a+b)%mod;\n}\n\nint main(){\n\tcin>>k;\n\tfor(int t=0;t<10;t++) dp[1][t]=1;\n\tfor(int i=1;i<=10;i++){\n\t\tfor(int t=0;t<10;t++){\n\t\t\tif(t-1>=0) add(dp[i+1][t-1],dp[i][t]);\n\t\t\tif(t+1<=9) add(dp[i+1][t+1],dp[i][t]); \n\t\t\tadd(dp[i+1][t],dp[i][t]);\n\t\t}\n\t\tfor(int t=1;t<10;t++){\n\t\t\tadd(tot[i],dp[i][t]);\n\t\t}\n\t\tadd(tot[i],tot[i-1]);\n\t}\n\tint len=1,sum=0;\n\tfor(;;){\n\t\tfor(int t=1;t<10;t++){\n\t\t\tsum+=dp[len][t];\n\t\t}\n\t\tif(sum>=k) break;\n\t\tlen++;\n\t}\n//\tcout<=1;i--){\n\t\tfor(int t=mini;t<=maxi;t++){\n\t\t\tif(dp[i][t]>=k){\n\t\t\t\tmini=max(0,t-1);\n\t\t\t\tmaxi=min(9,t+1);\n\t\t\t\tans+=char('0'+t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tk-=dp[i][t];\n\t\t\t//\tcout<\n#define pb push_back\n#define mp make_pair\n#define fst first\n#define snd second\nusing namespace std;\n\ntypedef long long ll;\ntypedef double db;\ntypedef long double ldb;\n\ntemplate inline void checkmin(T &a,const T &b){if(b inline void checkmax(T &a,const T &b){if(b>a) a=b;}\n\nconst int inf=1e9+10;\nconst int maxn=15;\nconst int mod=2e5;\n\nint dp[maxn][maxn],k,tot[maxn];\n\nint add(int &a,int b){\n\ta=(a+b)%mod;\n}\n\nint main(){\n\tcin>>k;\n\tfor(int t=0;t<10;t++) dp[1][t]=1;\n\tfor(int i=1;i<=10;i++){\n\t\tfor(int t=0;t<10;t++){\n\t\t\tif(t-1>=0) add(dp[i+1][t-1],dp[i][t]);\n\t\t\tif(t+1<=9) add(dp[i+1][t+1],dp[i][t]); \n\t\t\tadd(dp[i+1][t],dp[i][t]);\n\t\t}\n\t\tfor(int t=1;t<10;t++){\n\t\t\tadd(tot[i],dp[i][t]);\n\t\t}\n\t\tadd(tot[i],tot[i-1]);\n\t}\n\tint len=1,sum=0;\n\tfor(;;){\n\t\tfor(int t=1;t<10;t++){\n\t\t\tsum+=dp[len][t];\n\t\t}\n\t\tif(sum>=k) break;\n\t\tlen++;\n\t}\n//\tcout<=1;i--){\n\t\tfor(int t=mini;t<=maxi;t++){\n\t\t\tif(dp[i][t]>=k){\n\t\t\t\tmini=max(0,t-1);\n\t\t\t\tmaxi=min(9,t+1);\n\t\t\t\tans+=char('0'+t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tk-=dp[i][t];\n\t\t\t//\tcout<\nusing namespace std;\ntypedef long long ll;\ntemplate bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}\ntemplate bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}\n\n\n\n\nsigned main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(20);\n\n int n,k,c;\n cin>>n>>k>>c;\n string s;\n cin>>s;\n if(c==0){\n int cnt = 0;\n for(int i=0;i ans;\n int a[n+1]={};\n int r = 0;\n for(int i=0;i= r){\n chmax(a[min(n,i+c+1)],a[i]+1);\n r = i+c+1;\n }\n }\n //for(int i=0;i<=n;i++) cout << a[i];\n //cout << endl;\n chmax(a[n],a[n-1]);\n if(a[n] == k){\n int r = n-1;\n for(int p=k-1;p>=0;p--){\n int cnt = 0;\n int v = -1;\n for(int i=r;i>=0;i--){\n if(a[i] != p){\n r = i;\n break;\n }\n if(s[i] == 'o'){\n cnt++;\n v = i+1;\n }\n }\n //cerr << p << \" \" << cnt << endl;\n if(cnt == 1){\n ans.push_back(v);\n r = min(r,v-c-2);\n }\n }\n }\n if(ans.size())sort(ans.begin(),ans.end());\n for(auto i:ans){\n cout << i << \"\\n\";\n }\n\n}", "language": "C++", "metadata": {"date": 1586054364, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02721.html", "problem_id": "p02721", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02721/input.txt", "sample_output_relpath": "derived/input_output/data/p02721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02721/C++/s286623593.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s286623593", "user_id": "u676029460"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include\nusing namespace std;\ntypedef long long ll;\ntemplate bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}\ntemplate bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}\n\n\n\n\nsigned main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(20);\n\n int n,k,c;\n cin>>n>>k>>c;\n string s;\n cin>>s;\n if(c==0){\n int cnt = 0;\n for(int i=0;i ans;\n int a[n+1]={};\n int r = 0;\n for(int i=0;i= r){\n chmax(a[min(n,i+c+1)],a[i]+1);\n r = i+c+1;\n }\n }\n //for(int i=0;i<=n;i++) cout << a[i];\n //cout << endl;\n chmax(a[n],a[n-1]);\n if(a[n] == k){\n int r = n-1;\n for(int p=k-1;p>=0;p--){\n int cnt = 0;\n int v = -1;\n for(int i=r;i>=0;i--){\n if(a[i] != p){\n r = i;\n break;\n }\n if(s[i] == 'o'){\n cnt++;\n v = i+1;\n }\n }\n //cerr << p << \" \" << cnt << endl;\n if(cnt == 1){\n ans.push_back(v);\n r = min(r,v-c-2);\n }\n }\n }\n if(ans.size())sort(ans.begin(),ans.end());\n for(auto i:ans){\n cout << i << \"\\n\";\n }\n\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "sample_input": "11 3 2\nooxxxoxxxoo\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02721", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1691, "cpu_time_ms": 299, "memory_kb": 1812}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s965379663", "group_id": "codeNet:p02721", "input_text": "#include \nusing namespace std; \n#pragma GCC target (\"avx2\")\n#pragma GCC optimization (\"O3\")\n#pragma GCC optimization (\"unroll-loops\")\n#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n#define all(x) (x).begin(),(x).end()\n#define sz(x) (ll)x.size()\n#define ll long long\n#define INF 1000000000\n#define MOD 1000000007\n#define pb push_back\n#define ve vector\n#define dos pair\n#define vedos vector\n#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\n#define EPS 0.000001\nstruct greateri\n{\n template\n bool operator()(T const &a, T const &b) const { return a > b; }\n};\nvoid setIO(string s) {\n ios_base::sync_with_stdio(0); cin.tie(0); \n freopen((s+\".in\").c_str(),\"r\",stdin);\n freopen((s+\".out\").c_str(),\"w\",stdout);\n}\nint dp[300001],dp1[300001];\nstring kal;\nint c,n,k;\nsetpos;\nsetposi;\nint solve(int index)\n{\n int ans=1;\n auto u = pos.lower_bound(index+c+1);\n if(dp[index]!=-1)return dp[index];\n if(u!=pos.end())\n {\n ans=max(ans,1+solve((*u))); \n }\n return dp[index]=ans;\n}\nint solve1(int index)\n{\n int ans=1;\n auto u = posi.lower_bound(-index+c+1);\n if(dp1[index]!=-1)return dp1[index];\n if(u!=pos.end() && (*u)<=0)\n {\n ans=max(ans,1+solve1(-(*u))); \n }\n return dp1[index]=ans;\n}\nint main()\n{\n //flash;\n cin>>n>>k>>c;\n cin>>kal;\n ve kaki;\n memset(dp,-1,sizeof dp);\n memset(dp1,-1,sizeof dp1);\n for (int i = 0; i < kal.size(); ++i)\n {\n if(kal[i]=='o'){pos.insert(i);posi.insert(-i);kaki.pb(i);}\n }\n for(auto it:pos){solve(it);solve1(it);}\n int last=0;\n ve ans;\n for (int i = 0; i < kaki.size(); ++i)\n {\n int v=0;\n int s=0;\n if((i+1)>=kaki.size())s=0;\n else s = dp[kaki[i+1]];\n if((i-1)<0)v=0;\n else v = dp1[kaki[i-1]];\n if((v+s) \nusing namespace std; \n#pragma GCC target (\"avx2\")\n#pragma GCC optimization (\"O3\")\n#pragma GCC optimization (\"unroll-loops\")\n#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n#define all(x) (x).begin(),(x).end()\n#define sz(x) (ll)x.size()\n#define ll long long\n#define INF 1000000000\n#define MOD 1000000007\n#define pb push_back\n#define ve vector\n#define dos pair\n#define vedos vector\n#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\n#define EPS 0.000001\nstruct greateri\n{\n template\n bool operator()(T const &a, T const &b) const { return a > b; }\n};\nvoid setIO(string s) {\n ios_base::sync_with_stdio(0); cin.tie(0); \n freopen((s+\".in\").c_str(),\"r\",stdin);\n freopen((s+\".out\").c_str(),\"w\",stdout);\n}\nint dp[300001],dp1[300001];\nstring kal;\nint c,n,k;\nsetpos;\nsetposi;\nint solve(int index)\n{\n int ans=1;\n auto u = pos.lower_bound(index+c+1);\n if(dp[index]!=-1)return dp[index];\n if(u!=pos.end())\n {\n ans=max(ans,1+solve((*u))); \n }\n return dp[index]=ans;\n}\nint solve1(int index)\n{\n int ans=1;\n auto u = posi.lower_bound(-index+c+1);\n if(dp1[index]!=-1)return dp1[index];\n if(u!=pos.end() && (*u)<=0)\n {\n ans=max(ans,1+solve1(-(*u))); \n }\n return dp1[index]=ans;\n}\nint main()\n{\n //flash;\n cin>>n>>k>>c;\n cin>>kal;\n ve kaki;\n memset(dp,-1,sizeof dp);\n memset(dp1,-1,sizeof dp1);\n for (int i = 0; i < kal.size(); ++i)\n {\n if(kal[i]=='o'){pos.insert(i);posi.insert(-i);kaki.pb(i);}\n }\n for(auto it:pos){solve(it);solve1(it);}\n int last=0;\n ve ans;\n for (int i = 0; i < kaki.size(); ++i)\n {\n int v=0;\n int s=0;\n if((i+1)>=kaki.size())s=0;\n else s = dp[kaki[i+1]];\n if((i-1)<0)v=0;\n else v = dp1[kaki[i-1]];\n if((v+s)\n#define ll long long int\n#define ld long double\n#define inf LLONG_MAX>>2\n#define MAX 1000000\n#define mod 1000000007\n#define pb push_back\n#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))\n#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))\n#define fi first\n#define se second\n#define mk make_pair\n#define pi pair\n#define vt vector\n#define ms multiset\n#define is insert\nusing namespace std;\nvoid read(vt &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}\nll fa[MAX];\nll power(ll p,ll q){\n ll res=1;\n p%=mod;\n while(q){\n if (q&1)\n res=(res*p)%mod;\n q>>=1;\n p=(p*p)%mod;\n }\n return res;\n}\nll fact(ll n){\n if (n<=1)\n return fa[n]=1;\n if (fa[n])\n return fa[n];\n return fa[n]=(n*fact(n-1))%mod;\n}\nll ncr(ll n,ll r){\n if (!r)\n return 1;\n return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;\n}\nvoid solve(){\n ll n,i,n1,count=0;\n vt a;\n cin>>n;\n if (n==2){\n cout<<1<>t;\n while(t--)\n solve();\n return 0;\n}", "language": "C++", "metadata": {"date": 1595917262, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02722.html", "problem_id": "p02722", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02722/input.txt", "sample_output_relpath": "derived/input_output/data/p02722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02722/C++/s939788986.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s939788986", "user_id": "u020278929"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\n#define ll long long int\n#define ld long double\n#define inf LLONG_MAX>>2\n#define MAX 1000000\n#define mod 1000000007\n#define pb push_back\n#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))\n#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))\n#define fi first\n#define se second\n#define mk make_pair\n#define pi pair\n#define vt vector\n#define ms multiset\n#define is insert\nusing namespace std;\nvoid read(vt &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}\nll fa[MAX];\nll power(ll p,ll q){\n ll res=1;\n p%=mod;\n while(q){\n if (q&1)\n res=(res*p)%mod;\n q>>=1;\n p=(p*p)%mod;\n }\n return res;\n}\nll fact(ll n){\n if (n<=1)\n return fa[n]=1;\n if (fa[n])\n return fa[n];\n return fa[n]=(n*fact(n-1))%mod;\n}\nll ncr(ll n,ll r){\n if (!r)\n return 1;\n return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;\n}\nvoid solve(){\n ll n,i,n1,count=0;\n vt a;\n cin>>n;\n if (n==2){\n cout<<1<>t;\n while(t--)\n solve();\n return 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02722", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1728, "cpu_time_ms": 32, "memory_kb": 3648}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s553483874", "group_id": "codeNet:p02722", "input_text": "#include\nusing namespace std;\nusing ull=unsigned long long;\n#define mod 1000000007\n#define mod2 998244353 \n#define PI 3.14159265\n#define ll long long\n#define ld long double\n#define pi pair\n#define pb push_back\n#define vi vector\n#define sz size()\n#define setbits(x) __builtin_popcount(x)\n#define fi first\n#define se second\n#define lz length()\n#define all(x) (x).begin(),(x).end()\n#define scf(x) scanf(\"%lld\",&x)\n#define rep(i,n) for(ll i=0;i> rect;\ndeque dq;\n*/\n/*int find(int a){\n if(a==par[a])return a;\n return par[a]=find(par[a]);\n}\nvoid unite(int a,int b){\n a=find(a),b=find(b);\n if(a==b)return ;\n par[b]=a;\n}\nll modexpo(ll a,ll b)\n{\n ll ans=1LL;\n while(b>0)\n {\n if(b&1)ans=(ans*a)%mod;\n a=(a*a)%mod;\n b>>=1;\n }\n return ans;\n}\n*/\nint main(){\n ll n;\n cin>>n;\n int res=0;\n ll m=n-1;\n for(ll i=1LL;i<=sqrt(n);i++){\n if(n%i==0){\n ll t=n,d=i;\n if(i>1LL){\n while(t%d==0)t/=d;\n if(t%d==1)res++;\n } \n d=n/i;\n t=n;\n if(1LL*i*i!=n){\n while(t%d==0)t/=d;\n if(t%d==1)res++;\n }\n \n \n }\n\n }\n for(int i=1LL;i<=sqrt(m);i++){\n if((m)%i==0){\n if(i>1LL)res++;\n if(1LL*i*i!=m)res++;\n }\n }\n cout<\nusing namespace std;\nusing ull=unsigned long long;\n#define mod 1000000007\n#define mod2 998244353 \n#define PI 3.14159265\n#define ll long long\n#define ld long double\n#define pi pair\n#define pb push_back\n#define vi vector\n#define sz size()\n#define setbits(x) __builtin_popcount(x)\n#define fi first\n#define se second\n#define lz length()\n#define all(x) (x).begin(),(x).end()\n#define scf(x) scanf(\"%lld\",&x)\n#define rep(i,n) for(ll i=0;i> rect;\ndeque dq;\n*/\n/*int find(int a){\n if(a==par[a])return a;\n return par[a]=find(par[a]);\n}\nvoid unite(int a,int b){\n a=find(a),b=find(b);\n if(a==b)return ;\n par[b]=a;\n}\nll modexpo(ll a,ll b)\n{\n ll ans=1LL;\n while(b>0)\n {\n if(b&1)ans=(ans*a)%mod;\n a=(a*a)%mod;\n b>>=1;\n }\n return ans;\n}\n*/\nint main(){\n ll n;\n cin>>n;\n int res=0;\n ll m=n-1;\n for(ll i=1LL;i<=sqrt(n);i++){\n if(n%i==0){\n ll t=n,d=i;\n if(i>1LL){\n while(t%d==0)t/=d;\n if(t%d==1)res++;\n } \n d=n/i;\n t=n;\n if(1LL*i*i!=n){\n while(t%d==0)t/=d;\n if(t%d==1)res++;\n }\n \n \n }\n\n }\n for(int i=1LL;i<=sqrt(m);i++){\n if((m)%i==0){\n if(i>1LL)res++;\n if(1LL*i*i!=m)res++;\n }\n }\n cout<\n \n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define endl \"\\n\"\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)\n#define all(x) (x).begin(),(x).end()\n \nusing namespace std;\nusing ll = long long;\n \ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b vi;\ntypedef vector vvi;\ntypedef pair P;\n \nconst int INF = 1e9;\nconst int MOD = 1e9+7;\nconst double EPS = 1.0e-10;\nconst double PI = acos(-1.0);\n \nconst int mx4[] = {0,1,0,-1};\nconst int my4[] = {1,0,-1,0};\nconst int mx8[] = {0,1,1,1,0,-1,-1,-1};\nconst int my8[] = {1,1,0,-1,-1,-1,0,1};\n\nint main() {\n\tstring s;\n\tcin >> s;\n\tcout << (s[2] == s[3] && s[4] == s[5] ? \"Yes\" : \"No\") << endl;\t\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1585538649, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02723/input.txt", "sample_output_relpath": "derived/input_output/data/p02723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02723/C++/s404197230.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404197230", "user_id": "u216772548"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n \n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define endl \"\\n\"\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)\n#define all(x) (x).begin(),(x).end()\n \nusing namespace std;\nusing ll = long long;\n \ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b vi;\ntypedef vector vvi;\ntypedef pair P;\n \nconst int INF = 1e9;\nconst int MOD = 1e9+7;\nconst double EPS = 1.0e-10;\nconst double PI = acos(-1.0);\n \nconst int mx4[] = {0,1,0,-1};\nconst int my4[] = {1,0,-1,0};\nconst int mx8[] = {0,1,1,1,0,-1,-1,-1};\nconst int my8[] = {1,1,0,-1,-1,-1,0,1};\n\nint main() {\n\tstring s;\n\tcin >> s;\n\tcout << (s[2] == s[3] && s[4] == s[5] ? \"Yes\" : \"No\") << endl;\t\n\treturn 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "sample_input": "sippuu\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02723", "source_text": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 947, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s510517192", "group_id": "codeNet:p02723", "input_text": "#include\nusing namespace std;\n#define ll long long\nint main()\n{\n string s ;\n cin>>s;\n if(s[2]==s[3]&&s[4]==s[5])\n cout<<\"Yes\"<<\"\\n\";\n else\n cout<<\"No\"<<\"\\n\";\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1585443744, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02723/input.txt", "sample_output_relpath": "derived/input_output/data/p02723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02723/C++/s510517192.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510517192", "user_id": "u615662336"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include\nusing namespace std;\n#define ll long long\nint main()\n{\n string s ;\n cin>>s;\n if(s[2]==s[3]&&s[4]==s[5])\n cout<<\"Yes\"<<\"\\n\";\n else\n cout<<\"No\"<<\"\\n\";\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "sample_input": "sippuu\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02723", "source_text": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s243028638", "group_id": "codeNet:p02724", "input_text": "#include\nusing namespace std;\nint main(){\n\tios_base::sync_with_stdio(false);\n long int x;cin>>x;\n \tlong long int ans=(x/500)*1000;\n \tx%=500;\n \tans+=5*(x/5);\n \tcout<\nusing namespace std;\nint main(){\n\tios_base::sync_with_stdio(false);\n long int x;cin>>x;\n \tlong long int ans=(x/500)*1000;\n \tx%=500;\n \tans+=5*(x/5);\n \tcout<\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// Types\nusing ll = long long int;\nusing ld = long double;\nusing str = string;\ntemplate using u_set = unordered_set;\ntemplate using u_map = unordered_map;\ntemplate using graph = u_map>;\n\nnamespace io {\n// Input\nusing IS = istream;\nIS &in(IS &);\nIS &in(IS &i) { return i; }\ntemplate IS &in(IS &i, T &a, Ts &... as) {\n return in(i >> a, as...);\n}\ntemplate IS &operator>>(IS &i, vector &a) {\n for_each(a.begin(), a.end(), [&i](auto &e) { i >> e; });\n return i;\n}\ntemplate IS &operator>>(IS &i, pair &p) {\n return in(i, p.first, p.second);\n}\ntemplate \nIS &tuple_in(IS &i, tuple &t, index_sequence) {\n return in(i, get(t)...);\n}\ntemplate IS &operator>>(IS &i, tuple &t) {\n return tuple_in(i, t, make_index_sequence());\n}\n// Output\nusing OS = ostream;\nOS &out(OS &o) { return o << endl; }\ntemplate OS &out(OS &o, T const &a) { return o << a << endl; }\ntemplate OS &out(OS &o, T const &a, Ts const &... as) {\n return out(o << a << \" \", as...);\n}\ntemplate OS &operator<<(OS &o, pair const &p) {\n return o << p.first << \":\" << p.second;\n}\ntemplate OS &args_out(OS &o, Ts const &... ts);\nOS &args_out(OS &o) { return o; }\ntemplate OS &args_out(OS &o, T const &t) { return o << t; }\ntemplate \nOS &args_out(OS &o, T0 const &t0, T1 const &t1, Ts const &... ts) {\n return args_out(o << t0 << \",\", t1, ts...);\n}\ntemplate \nOS &tuple_out(OS &o, tuple const &t, index_sequence) {\n return args_out(o, get(t)...);\n}\ntemplate OS &operator<<(OS &o, tuple const &t) {\n return tuple_out(o << \"(\", t, make_index_sequence()) << \")\";\n}\ntemplate struct Joiner {\n str const pre;\n str const post;\n str const delim;\n vector const container;\n Joiner(vector v, str const &delim, str const &pre, str const &post)\n : pre(pre), post(post), delim(delim), container(v) {}\n};\ntemplate OS &operator<<(OS &o, Joiner const &joiner) {\n auto itr = joiner.container.begin();\n auto end = joiner.container.end();\n o << joiner.pre;\n if (itr != end)\n o << *(itr++);\n while (itr != end)\n o << joiner.delim << *(itr++);\n return o << joiner.post;\n}\ntemplate ::value_type>\nJoiner join(Itr b, Itr e, str const &delim = \"\"s, str const &pre = \"\"s,\n str const &post = \"\"s) {\n return Joiner(vector(b, e), delim, pre, post);\n}\ntemplate <\n class C,\n class T = typename iterator_traits::value_type,\n typename enable_if::value, nullptr_t>::type = nullptr>\nOS &operator<<(OS &o, C const &a) {\n return o << join(a.begin(), a.end(), \",\", \"[\", \"]\");\n}\n} // namespace io\nauto input = [](auto &... a) { io::in(cin, a...); };\nauto print = [](auto const &... a) { io::out(cout, a...); };\n#ifdef JUMPAKU_DEBUG\nauto dump = [](auto const &... a) { io::out(cerr, a...); };\n#else\nauto dump = [](auto const &...) {};\n#endif\nusing io::join;\n\n// Hash\nnamespace hashcode {\ntemplate uint64_t hash_args(uint64_t h, Ts const &... ts);\nuint64_t hash_args(uint64_t h) { return h; }\ntemplate \nuint64_t hash_args(uint64_t h, T const &t, Ts const &... ts) {\n constexpr hash hasher;\n return hash_args(((h << 19) - h) ^ hasher(t), ts...);\n}\ntemplate \nuint64_t hash_tuple(tuple const &t, index_sequence) {\n return hash_args(17, get(t)...);\n}\n} // namespace hashcode\nnamespace std {\ntemplate struct hash> {\n size_t operator()(tuple const &t) const {\n uint64_t h = hashcode::hash_tuple(t, index_sequence_for());\n return h ^ (h >> 32);\n }\n};\n} // namespace std\n\n// Range\nnamespace ranges {\ntemplate struct iterator_base {\n using difference_type = ll;\n using value_type = T;\n using pointer = T *;\n using reference = T &;\n using iterator_category = random_access_iterator_tag;\n ll i;\n iterator_base(ll const &i = 0) : i(i) {}\n bool operator==(Itr const &itr) const { return i == itr.i; }\n bool operator!=(Itr const &itr) const { return i != itr.i; }\n ll operator-(Itr const &itr) const { return i - itr.i; }\n Itr operator++(int) { return with(i++); }\n Itr operator--(int) { return with(i--); }\n Itr operator+(ll const &n) const { return with(i + n); }\n Itr operator-(ll const &n) const { return with(i - n); }\n Itr &operator+=(ll const &n) {\n i += n;\n return self();\n }\n Itr &operator-=(ll const &n) { return self() += (-n); }\n Itr &operator++() { return self() += 1; }\n Itr &operator--() { return self() -= 1; }\n\nprotected:\n virtual Itr with(ll i) const = 0;\n virtual Itr &self() = 0;\n};\ntemplate struct seq_base {\n ll const b;\n ll const e;\n seq_base(ll b, ll e) : b(b), e(e) {}\n ll size() const { return e - b; }\n bool empty() const { return size() == 0; }\n};\ntemplate struct seq : seq_base {\n struct iterator : iterator_base {\n seq const &s;\n iterator(seq const &s, ll const &i)\n : iterator_base(i), s(s) {}\n iterator with(ll i) const override { return iterator(s, i); }\n iterator &self() override { return *this; }\n T operator*() const { return s[this->i]; }\n iterator &operator=(iterator const &itr) {\n this->i = itr.i;\n return *this;\n }\n };\n function const f;\n seq(ll b, ll e, function const &f) : seq_base(b, e), f(f) {}\n iterator begin() const { return iterator(*this, 0); }\n iterator end() const { return iterator(*this, this->size()); }\n T operator[](ll i) const { return f(i + this->b); }\n};\nstruct range : seq_base {\n struct iterator : iterator_base {\n iterator(ll const &i) : iterator_base(i) {}\n iterator with(ll i) const override { return iterator(i); }\n iterator &self() override { return *this; }\n ll operator*() const { return i; }\n };\n range(ll n) : range(0LL, n) {}\n range(ll b, ll e) : seq_base(b, e) {}\n iterator begin() const { return iterator(b); }\n iterator end() const { return iterator(e); }\n ll operator[](ll i) const { return i + b; }\n};\n} // namespace ranges\nusing range = ranges::range;\nrange::iterator end(ll i) { return range::iterator(i); }\nrange::iterator begin(ll i) { return range::iterator(i); }\ntemplate auto seq(ll b, ll e, F const &f) {\n using T = decltype(f(declval()));\n return ranges::seq(b, e, f);\n}\ntemplate auto seq(ll n, F const &f) { return seq(0, n, f); }\ntemplate vector vec(size_t n, T const &init = T()) {\n return vector(n, init);\n}\n\nll gcd(ll p, ll q) { return (q == 0) ? p : gcd(q, p % q); }\nll lcm(ll p, ll q) { return p / gcd(q, p) * q; }\nbool odd(ll n) { return n & 1; }\nbool even(ll n) { return !odd(n); }\n\nconstexpr ll MOD = 1e9 + 7;\n\nvoid solve();\nint main() {\n ll t = 1;\n /** input(t); /**/\n for ([[maybe_unused]] auto &&i : range(t)) {\n solve();\n }\n}\n\nvoid solve() {\n ll X;\n input(X);\n ll a = X / 500;\n ll b = (X % 500) / 5;\n print(1000 * a + 5 * b);\n}\n", "language": "C++", "metadata": {"date": 1585443866, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02724/input.txt", "sample_output_relpath": "derived/input_output/data/p02724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02724/C++/s027627168.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s027627168", "user_id": "u465699806"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "//#pragma GCC optimize(\"O3\")\n//#pragma GCC target(\"avx\")\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\nusing namespace std;\n\n// Types\nusing ll = long long int;\nusing ld = long double;\nusing str = string;\ntemplate using u_set = unordered_set;\ntemplate using u_map = unordered_map;\ntemplate using graph = u_map>;\n\nnamespace io {\n// Input\nusing IS = istream;\nIS &in(IS &);\nIS &in(IS &i) { return i; }\ntemplate IS &in(IS &i, T &a, Ts &... as) {\n return in(i >> a, as...);\n}\ntemplate IS &operator>>(IS &i, vector &a) {\n for_each(a.begin(), a.end(), [&i](auto &e) { i >> e; });\n return i;\n}\ntemplate IS &operator>>(IS &i, pair &p) {\n return in(i, p.first, p.second);\n}\ntemplate \nIS &tuple_in(IS &i, tuple &t, index_sequence) {\n return in(i, get(t)...);\n}\ntemplate IS &operator>>(IS &i, tuple &t) {\n return tuple_in(i, t, make_index_sequence());\n}\n// Output\nusing OS = ostream;\nOS &out(OS &o) { return o << endl; }\ntemplate OS &out(OS &o, T const &a) { return o << a << endl; }\ntemplate OS &out(OS &o, T const &a, Ts const &... as) {\n return out(o << a << \" \", as...);\n}\ntemplate OS &operator<<(OS &o, pair const &p) {\n return o << p.first << \":\" << p.second;\n}\ntemplate OS &args_out(OS &o, Ts const &... ts);\nOS &args_out(OS &o) { return o; }\ntemplate OS &args_out(OS &o, T const &t) { return o << t; }\ntemplate \nOS &args_out(OS &o, T0 const &t0, T1 const &t1, Ts const &... ts) {\n return args_out(o << t0 << \",\", t1, ts...);\n}\ntemplate \nOS &tuple_out(OS &o, tuple const &t, index_sequence) {\n return args_out(o, get(t)...);\n}\ntemplate OS &operator<<(OS &o, tuple const &t) {\n return tuple_out(o << \"(\", t, make_index_sequence()) << \")\";\n}\ntemplate struct Joiner {\n str const pre;\n str const post;\n str const delim;\n vector const container;\n Joiner(vector v, str const &delim, str const &pre, str const &post)\n : pre(pre), post(post), delim(delim), container(v) {}\n};\ntemplate OS &operator<<(OS &o, Joiner const &joiner) {\n auto itr = joiner.container.begin();\n auto end = joiner.container.end();\n o << joiner.pre;\n if (itr != end)\n o << *(itr++);\n while (itr != end)\n o << joiner.delim << *(itr++);\n return o << joiner.post;\n}\ntemplate ::value_type>\nJoiner join(Itr b, Itr e, str const &delim = \"\"s, str const &pre = \"\"s,\n str const &post = \"\"s) {\n return Joiner(vector(b, e), delim, pre, post);\n}\ntemplate <\n class C,\n class T = typename iterator_traits::value_type,\n typename enable_if::value, nullptr_t>::type = nullptr>\nOS &operator<<(OS &o, C const &a) {\n return o << join(a.begin(), a.end(), \",\", \"[\", \"]\");\n}\n} // namespace io\nauto input = [](auto &... a) { io::in(cin, a...); };\nauto print = [](auto const &... a) { io::out(cout, a...); };\n#ifdef JUMPAKU_DEBUG\nauto dump = [](auto const &... a) { io::out(cerr, a...); };\n#else\nauto dump = [](auto const &...) {};\n#endif\nusing io::join;\n\n// Hash\nnamespace hashcode {\ntemplate uint64_t hash_args(uint64_t h, Ts const &... ts);\nuint64_t hash_args(uint64_t h) { return h; }\ntemplate \nuint64_t hash_args(uint64_t h, T const &t, Ts const &... ts) {\n constexpr hash hasher;\n return hash_args(((h << 19) - h) ^ hasher(t), ts...);\n}\ntemplate \nuint64_t hash_tuple(tuple const &t, index_sequence) {\n return hash_args(17, get(t)...);\n}\n} // namespace hashcode\nnamespace std {\ntemplate struct hash> {\n size_t operator()(tuple const &t) const {\n uint64_t h = hashcode::hash_tuple(t, index_sequence_for());\n return h ^ (h >> 32);\n }\n};\n} // namespace std\n\n// Range\nnamespace ranges {\ntemplate struct iterator_base {\n using difference_type = ll;\n using value_type = T;\n using pointer = T *;\n using reference = T &;\n using iterator_category = random_access_iterator_tag;\n ll i;\n iterator_base(ll const &i = 0) : i(i) {}\n bool operator==(Itr const &itr) const { return i == itr.i; }\n bool operator!=(Itr const &itr) const { return i != itr.i; }\n ll operator-(Itr const &itr) const { return i - itr.i; }\n Itr operator++(int) { return with(i++); }\n Itr operator--(int) { return with(i--); }\n Itr operator+(ll const &n) const { return with(i + n); }\n Itr operator-(ll const &n) const { return with(i - n); }\n Itr &operator+=(ll const &n) {\n i += n;\n return self();\n }\n Itr &operator-=(ll const &n) { return self() += (-n); }\n Itr &operator++() { return self() += 1; }\n Itr &operator--() { return self() -= 1; }\n\nprotected:\n virtual Itr with(ll i) const = 0;\n virtual Itr &self() = 0;\n};\ntemplate struct seq_base {\n ll const b;\n ll const e;\n seq_base(ll b, ll e) : b(b), e(e) {}\n ll size() const { return e - b; }\n bool empty() const { return size() == 0; }\n};\ntemplate struct seq : seq_base {\n struct iterator : iterator_base {\n seq const &s;\n iterator(seq const &s, ll const &i)\n : iterator_base(i), s(s) {}\n iterator with(ll i) const override { return iterator(s, i); }\n iterator &self() override { return *this; }\n T operator*() const { return s[this->i]; }\n iterator &operator=(iterator const &itr) {\n this->i = itr.i;\n return *this;\n }\n };\n function const f;\n seq(ll b, ll e, function const &f) : seq_base(b, e), f(f) {}\n iterator begin() const { return iterator(*this, 0); }\n iterator end() const { return iterator(*this, this->size()); }\n T operator[](ll i) const { return f(i + this->b); }\n};\nstruct range : seq_base {\n struct iterator : iterator_base {\n iterator(ll const &i) : iterator_base(i) {}\n iterator with(ll i) const override { return iterator(i); }\n iterator &self() override { return *this; }\n ll operator*() const { return i; }\n };\n range(ll n) : range(0LL, n) {}\n range(ll b, ll e) : seq_base(b, e) {}\n iterator begin() const { return iterator(b); }\n iterator end() const { return iterator(e); }\n ll operator[](ll i) const { return i + b; }\n};\n} // namespace ranges\nusing range = ranges::range;\nrange::iterator end(ll i) { return range::iterator(i); }\nrange::iterator begin(ll i) { return range::iterator(i); }\ntemplate auto seq(ll b, ll e, F const &f) {\n using T = decltype(f(declval()));\n return ranges::seq(b, e, f);\n}\ntemplate auto seq(ll n, F const &f) { return seq(0, n, f); }\ntemplate vector vec(size_t n, T const &init = T()) {\n return vector(n, init);\n}\n\nll gcd(ll p, ll q) { return (q == 0) ? p : gcd(q, p % q); }\nll lcm(ll p, ll q) { return p / gcd(q, p) * q; }\nbool odd(ll n) { return n & 1; }\nbool even(ll n) { return !odd(n); }\n\nconstexpr ll MOD = 1e9 + 7;\n\nvoid solve();\nint main() {\n ll t = 1;\n /** input(t); /**/\n for ([[maybe_unused]] auto &&i : range(t)) {\n solve();\n }\n}\n\nvoid solve() {\n ll X;\n input(X);\n ll a = X / 500;\n ll b = (X % 500) / 5;\n print(1000 * a + 5 * b);\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7767, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s547485135", "group_id": "codeNet:p02725", "input_text": "#include\nusing namespace std;\nint main(){\n int k,n;\n cin>>k>>n;\n vector a(n);\n for(int i=0; i>a.at(i);\n }\n int ans;\n if((a.at(n-1)-a.at(1))>=20-a.at(n-1)+a.at(1)){\n ans=a.at(1)+20-a.at(n-1);\n }\n else ans=a.at(n-1)-a.at(0);\n \n cout<\nusing namespace std;\nint main(){\n int k,n;\n cin>>k>>n;\n vector a(n);\n for(int i=0; i>a.at(i);\n }\n int ans;\n if((a.at(n-1)-a.at(1))>=20-a.at(n-1)+a.at(1)){\n ans=a.at(1)+20-a.at(n-1);\n }\n else ans=a.at(n-1)-a.at(0);\n \n cout<\nusing namespace std;\nconst int N=2005;\nint n,x,y;\nint cnt[N];\nint main() {\n\tint i,j;\n\tcin>>n>>x>>y;\n\tfor (i=1;iy&&j>y) cnt[j-i]++;\n\t\t\telse if (iy) cnt[j-y+x-i+1]++;\n\t\t\telse if (i=x) cnt[min(j-i,y-j+1+x-i)]++;\n\t\t\telse if (i<=y&&j>y) cnt[min(j-i,i-x+1+j-y)]++;\n\t\t\telse cnt[min(j-i,i-x+y-j+1)]++;\n//\t\t\tcout<\nusing namespace std;\nconst int N=2005;\nint n,x,y;\nint cnt[N];\nint main() {\n\tint i,j;\n\tcin>>n>>x>>y;\n\tfor (i=1;iy&&j>y) cnt[j-i]++;\n\t\t\telse if (iy) cnt[j-y+x-i+1]++;\n\t\t\telse if (i=x) cnt[min(j-i,y-j+1+x-i)]++;\n\t\t\telse if (i<=y&&j>y) cnt[min(j-i,i-x+1+j-y)]++;\n\t\t\telse cnt[min(j-i,i-x+y-j+1)]++;\n//\t\t\tcout<\nusing namespace std;\ntypedef long long ll;\nconst ll MOD = 1e9 + 7;\nconst int inf = 1e9;\nconst ll INF = 1e18;\nconst double pi = 3.14159265358979323846;\n#define rep(i,n) for(ll i=0;i>n;\n\tint x,y;cin>>x>>y;\n\tx--;y--;\n\tint ans[n+1]={};\n\tfor(int i=0;i\nusing namespace std;\ntypedef long long ll;\nconst ll MOD = 1e9 + 7;\nconst int inf = 1e9;\nconst ll INF = 1e18;\nconst double pi = 3.14159265358979323846;\n#define rep(i,n) for(ll i=0;i>n;\n\tint x,y;cin>>x>>y;\n\tx--;y--;\n\tint ans[n+1]={};\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define INF 0x3f3f3f3f\n#define SIS std::ios::sync_with_stdio(false)\nusing namespace std;\nll fast_pow(ll a,ll b,ll mod)\n{\n ll c=1;\n while(b>=2)\n {\n if(b%2==0)\n a*=a,b/=2;\n else\n c*=a,a*=a,b--,b/=2;\n a%=mod,c%=mod;\n }\n return (a*c)%mod;\n}\nll cal(ll n,ll m);\nint main()\n{\n int n,m;\n while(cin>>n>>m)\n {\n ll ans=0;\n if(n>1)\n ans+=cal(n,2);\n if(m>1)\n ans+=cal(m,2);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define INF 0x3f3f3f3f\n#define SIS std::ios::sync_with_stdio(false)\nusing namespace std;\nll fast_pow(ll a,ll b,ll mod)\n{\n ll c=1;\n while(b>=2)\n {\n if(b%2==0)\n a*=a,b/=2;\n else\n c*=a,a*=a,b--,b/=2;\n a%=mod,c%=mod;\n }\n return (a*c)%mod;\n}\nll cal(ll n,ll m);\nint main()\n{\n int n,m;\n while(cin>>n>>m)\n {\n ll ans=0;\n if(n>1)\n ans+=cal(n,2);\n if(m>1)\n ans+=cal(m,2);\n cout<\n#define rep(i,n) for (int i=0;i<(n);i++)\n#define adrep(i,s,n) for (int i=(s);i<(n);i++)\nusing namespace std;\ntypedef long long ll;\n\nint check(string t){\n\n int n=t.length();\n rep(i,n){\n //cout<>s;\n \n int N=s.length();\n \n if(check(s)==0){cout<<\"No\"<\n#define rep(i,n) for (int i=0;i<(n);i++)\n#define adrep(i,s,n) for (int i=(s);i<(n);i++)\nusing namespace std;\ntypedef long long ll;\n\nint check(string t){\n\n int n=t.length();\n rep(i,n){\n //cout<>s;\n \n int N=s.length();\n \n if(check(s)==0){cout<<\"No\"<\nusing namespace std;\n#define int long long\nsigned main() {\n\tstring s;\n\tcin>>s;\n\tint n=s.size();\n\tint i=0;\n\tint j=s.size()-1;\n\twhile(i\nusing namespace std;\n#define int long long\nsigned main() {\n\tstring s;\n\tcin>>s;\n\tint n=s.size();\n\tint i=0;\n\tint j=s.size()-1;\n\twhile(i\nusing namespace std;\ntypedef long long ll;\nusing P = pair;\nconst ll mod = 1e9+7;\n#define ALL(x) (x).begin(),(x).end()\n#define pow(x,y) modpow(x,y)\n#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)\n\ntemplate T in(){\n T x;\n cin >> x;\n return (x);\n}\n\nsigned main(){\n cin.tie(0);\n ios::sync_with_stdio(false);\n cout<();\n bool ok = 1;\n int N = S.size();\n REP(i,N/2)if(S[i] != S[N-1-i])ok = 0;\n REP(i,(N/2)/2)if(S[i] != S[N/2-1-i])ok = 0;\n REP(i,(N/2)/2)if(S[N-1-i] != S[N/2+1-i])ok = 0;\n cout << (ok ? \"Yes\" : \"No\") << \"\\n\";\n}", "language": "C++", "metadata": {"date": 1584925816, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02730/input.txt", "sample_output_relpath": "derived/input_output/data/p02730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02730/C++/s174515385.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s174515385", "user_id": "u017078415"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\nusing P = pair;\nconst ll mod = 1e9+7;\n#define ALL(x) (x).begin(),(x).end()\n#define pow(x,y) modpow(x,y)\n#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)\n\ntemplate T in(){\n T x;\n cin >> x;\n return (x);\n}\n\nsigned main(){\n cin.tie(0);\n ios::sync_with_stdio(false);\n cout<();\n bool ok = 1;\n int N = S.size();\n REP(i,N/2)if(S[i] != S[N-1-i])ok = 0;\n REP(i,(N/2)/2)if(S[i] != S[N/2-1-i])ok = 0;\n REP(i,(N/2)/2)if(S[N-1-i] != S[N/2+1-i])ok = 0;\n cout << (ok ? \"Yes\" : \"No\") << \"\\n\";\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 650, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s202038551", "group_id": "codeNet:p02731", "input_text": "#include \nusing namespace std;\n \nint main(){\n int L;\n cin >> L;\n \n double count=L*L*L/27;\n cout << fixed << setprecision(15) << count << endl;\n}", "language": "C++", "metadata": {"date": 1584932354, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02731/input.txt", "sample_output_relpath": "derived/input_output/data/p02731/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02731/C++/s202038551.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s202038551", "user_id": "u982720765"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "#include \nusing namespace std;\n \nint main(){\n int L;\n cin >> L;\n \n double count=L*L*L/27;\n cout << fixed << setprecision(15) << count << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "sample_input": "3\n"}, "reference_outputs": ["1.000000000000\n"], "source_document_id": "p02731", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s691784520", "group_id": "codeNet:p02731", "input_text": "#include \nusing namespace std;\n\nint main()\n{\n int l;\n cin>>l;\n float f=l/3.0;\n cout< \nusing namespace std;\n\nint main()\n{\n int l;\n cin>>l;\n float f=l/3.0;\n cout<\nusing namespace std;\n \n#define F(i,a,b) for(long long i =a; i=b;i--)\n#define endl \"\\n\"\n#define min1(x,y,z) min(x, min(y,z))\n#define max1(x,y,z) max(x, max(y,z))\n#define input_vector(v,n,type) vector v;for(int i=0;i>x;v.push_back(x);}\n#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n#define int long long\n#define inf (1LL<<61)\ntypedef pair ii;\ntypedef vector> vii;\ntypedef vector vi;\n \n \n \nint32_t main()\n{\n IOS;\n\n int L;\n cin>>L;\n\n if (L == 1) {\n double ans = (double)1/(double)27;\n cout<\nusing namespace std;\n \n#define F(i,a,b) for(long long i =a; i=b;i--)\n#define endl \"\\n\"\n#define min1(x,y,z) min(x, min(y,z))\n#define max1(x,y,z) max(x, max(y,z))\n#define input_vector(v,n,type) vector v;for(int i=0;i>x;v.push_back(x);}\n#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n#define int long long\n#define inf (1LL<<61)\ntypedef pair ii;\ntypedef vector> vii;\ntypedef vector vi;\n \n \n \nint32_t main()\n{\n IOS;\n\n int L;\n cin>>L;\n\n if (L == 1) {\n double ans = (double)1/(double)27;\n cout< A;\n\n cin >> N;\n for (int i = 0; i < N; i++) {\n int tmp;\n cin >> tmp;\n A.emplace_back(tmp);\n }\n \n int count_box[int(2e5) + 1];\n vector memo;\n \n for (int i = 0; i < N; i++) {\n if (count_box[A[i]] == 0) memo.emplace_back(A[i]);\n count_box[A[i]]++;\n }\n\n long long total = 0;\n for (auto& v : memo) total += count_box[v] * (count_box[v] - 1) / 2;\n\n for (int i = 0; i < N; i++) {\n long long result = total - count_box[A[i]] + 1;\n cout << result << endl;\n }\n}", "language": "C++", "metadata": {"date": 1585917708, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02732/input.txt", "sample_output_relpath": "derived/input_output/data/p02732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02732/C++/s940229322.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s940229322", "user_id": "u436976004"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "#include \"./bits/stdc++.h\"\n\nusing namespace std;\n\nint main() {\n int N;\n vector A;\n\n cin >> N;\n for (int i = 0; i < N; i++) {\n int tmp;\n cin >> tmp;\n A.emplace_back(tmp);\n }\n \n int count_box[int(2e5) + 1];\n vector memo;\n \n for (int i = 0; i < N; i++) {\n if (count_box[A[i]] == 0) memo.emplace_back(A[i]);\n count_box[A[i]]++;\n }\n\n long long total = 0;\n for (auto& v : memo) total += count_box[v] * (count_box[v] - 1) / 2;\n\n for (int i = 0; i < N; i++) {\n long long result = total - count_box[A[i]] + 1;\n cout << result << endl;\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "sample_input": "5\n1 1 2 1 2\n"}, "reference_outputs": ["2\n2\n3\n2\n3\n"], "source_document_id": "p02732", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 634, "cpu_time_ms": 372, "memory_kb": 4212}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s134120512", "group_id": "codeNet:p02733", "input_text": "/*\n アリナ・グレイはかわいい\n*/\n\n#include\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n#define itn int\n#define endl \"\\n\"\n\nint main(void){\n int h,w,k;\n cin >> h >> w >> k;\n string s[1004];\n int mn = 1LL<<30;\n \n for(int i = 0;i < h;i++)cin >> s[i];\n \n for(int i = 0;i < (1 << (h-1));i++){\n int sum = 0,a[100] = {};\n for(int j = 0;j < h;j++){\n a[j] = sum;\n if(i & (1 << j))sum++;\n }\n sum++;\n int num = __builtin_popcount(i),b[100] = {};\n \n //for(int p = 0;p < h;p++)b[p] = 0;\n for(int p = 0;p < w;p++){\n for(int q = 0;q < h;q++){\n b[a[q]] += (s[q][p]-'0');\n }\n for(int q = 0;q < sum;q++){\n if(b[q] > k){\n num++;\n for(int l = 0;l < sum;l++)b[l] = 0;\n for(int l = 0;l < h;l++)b[a[l]] += (s[l][p]-'0');\n break;\n }\n }\n for(int l = 0;l < num;l++)if(b[l] > k)num = 1LL<<30;\n }\n mn = min(mn,num);\n }\n cout << mn << endl;\n}\n", "language": "C++", "metadata": {"date": 1584954801, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02733.html", "problem_id": "p02733", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02733/input.txt", "sample_output_relpath": "derived/input_output/data/p02733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02733/C++/s134120512.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s134120512", "user_id": "u512624048"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/*\n アリナ・グレイはかわいい\n*/\n\n#include\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n#define itn int\n#define endl \"\\n\"\n\nint main(void){\n int h,w,k;\n cin >> h >> w >> k;\n string s[1004];\n int mn = 1LL<<30;\n \n for(int i = 0;i < h;i++)cin >> s[i];\n \n for(int i = 0;i < (1 << (h-1));i++){\n int sum = 0,a[100] = {};\n for(int j = 0;j < h;j++){\n a[j] = sum;\n if(i & (1 << j))sum++;\n }\n sum++;\n int num = __builtin_popcount(i),b[100] = {};\n \n //for(int p = 0;p < h;p++)b[p] = 0;\n for(int p = 0;p < w;p++){\n for(int q = 0;q < h;q++){\n b[a[q]] += (s[q][p]-'0');\n }\n for(int q = 0;q < sum;q++){\n if(b[q] > k){\n num++;\n for(int l = 0;l < sum;l++)b[l] = 0;\n for(int l = 0;l < h;l++)b[a[l]] += (s[l][p]-'0');\n break;\n }\n }\n for(int l = 0;l < num;l++)if(b[l] > k)num = 1LL<<30;\n }\n mn = min(mn,num);\n }\n cout << mn << endl;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "sample_input": "3 5 4\n11100\n10001\n00111\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02733", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1164, "cpu_time_ms": 103, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s203990510", "group_id": "codeNet:p02733", "input_text": "#include \nusing namespace std;\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define whole(x) (x).begin(),(x).end()\n#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())\nusing ll = long long;\nusing P = pair;\nconst int mod = 1000000007;\nconst int INF = 1001001001;\nint sum[11][1005];\n\nint main(){\n int h, w, k;\n cin >> h >> w >> k;\n vector s(h);\n rep(i, h) {\n cin >> s[i];\n }\n rep(i, h) rep(j, w) {\n sum[i][j+1] = sum[i][j] + (s[i][j]-'0');\n }\n \n \n int ans = INF;\n rep(i, 1<<(h-1)) {\n int res = __builtin_popcount(i);\n int st = 0;\n int temp = 0;\n rep(j, w) rep(l, h) {\n temp += (sum[l][j+1] - sum[l][st]);\n if (i>>l&1 || l==h-1) {\n if (temp>k) {\n st = j;\n res++;\n l = 0;\n }\n temp = 0;\n \n }\n }\n \n ans = min(ans, res);\n }\n \n \n \n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1584937948, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02733.html", "problem_id": "p02733", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02733/input.txt", "sample_output_relpath": "derived/input_output/data/p02733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02733/C++/s203990510.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s203990510", "user_id": "u488493347"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define whole(x) (x).begin(),(x).end()\n#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())\nusing ll = long long;\nusing P = pair;\nconst int mod = 1000000007;\nconst int INF = 1001001001;\nint sum[11][1005];\n\nint main(){\n int h, w, k;\n cin >> h >> w >> k;\n vector s(h);\n rep(i, h) {\n cin >> s[i];\n }\n rep(i, h) rep(j, w) {\n sum[i][j+1] = sum[i][j] + (s[i][j]-'0');\n }\n \n \n int ans = INF;\n rep(i, 1<<(h-1)) {\n int res = __builtin_popcount(i);\n int st = 0;\n int temp = 0;\n rep(j, w) rep(l, h) {\n temp += (sum[l][j+1] - sum[l][st]);\n if (i>>l&1 || l==h-1) {\n if (temp>k) {\n st = j;\n res++;\n l = 0;\n }\n temp = 0;\n \n }\n }\n \n ans = min(ans, res);\n }\n \n \n \n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "sample_input": "3 5 4\n11100\n10001\n00111\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02733", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\n\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\n\nWe will cut the bar some number of times to divide it into some number of blocks. In each cut, we cut the whole bar by a line running along some boundaries of squares from end to end of the bar.\n\nHow many times do we need to cut the bar so that every block after the cuts has K or less white squares?\n\nConstraints\n\n1 \\leq H \\leq 10\n\n1 \\leq W \\leq 1000\n\n1 \\leq K \\leq H \\times W\n\nS_{i,j} is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nS_{1,1}S_{1,2}...S_{1,W}\n:\nS_{H,1}S_{H,2}...S_{H,W}\n\nOutput\n\nPrint the number of minimum times the bar needs to be cut so that every block after the cuts has K or less white squares.\n\nSample Input 1\n\n3 5 4\n11100\n10001\n00111\n\nSample Output 1\n\n2\n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and 4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the right.\n\nSample Input 2\n\n3 5 8\n11100\n10001\n00111\n\nSample Output 2\n\n0\n\nNo cut is needed.\n\nSample Input 3\n\n4 10 4\n1110010010\n1000101110\n0011101001\n1101000111\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1096, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s336135148", "group_id": "codeNet:p02735", "input_text": "#include\n#include\n#include\nusing namespace std;\nint main(){\n\tint h,w;\n\tcin>>h>>w;\n\tchar ptr[150][150];\n\tint dp[150][150];\n\tfor(int i=1;i<=h;i++){\n\t\tfor(int j=1;j<=w;j++){\n\t\t\tcin>>ptr[i][j];\n\t\t} \n\t}\n\tmemset(dp,0x3f,sizeof(dp));\n\tdp[1][1]=(ptr[1][1]=='#');\n\tfor(int i=1;i<=h;i++){\n\t\tfor(int j=1;j<=w;j++){\n\t\t\tif(ptr[i][j+1]=='.'){//下一步,代表不要变 \n\t\t\t\tdp[i][j+1]=min(dp[i][j+1],dp[i][j]); \n\t\t\t}else{//下一步代表要变 \n\t\t\t\tdp[i][j+1]=min(dp[i][j+1],dp[i][j]+(ptr[i][j]=='.')); \n\t\t\t}\n\t\t\tif(ptr[i+1][j]=='.'){//下一步代表不要变 \n\t\t\t\tdp[i+1][j]=min(dp[i+1][j],dp[i][j]);\n\t\t\t}else{//下一步代表要变 \n\t\t\t\tdp[i+1][j]=min(dp[i+1][j],dp[i][j]+(ptr[i][j]=='.'));\n\t\t\t}\n\t\t}\n\t}\n\tcout<\n#include\n#include\nusing namespace std;\nint main(){\n\tint h,w;\n\tcin>>h>>w;\n\tchar ptr[150][150];\n\tint dp[150][150];\n\tfor(int i=1;i<=h;i++){\n\t\tfor(int j=1;j<=w;j++){\n\t\t\tcin>>ptr[i][j];\n\t\t} \n\t}\n\tmemset(dp,0x3f,sizeof(dp));\n\tdp[1][1]=(ptr[1][1]=='#');\n\tfor(int i=1;i<=h;i++){\n\t\tfor(int j=1;j<=w;j++){\n\t\t\tif(ptr[i][j+1]=='.'){//下一步,代表不要变 \n\t\t\t\tdp[i][j+1]=min(dp[i][j+1],dp[i][j]); \n\t\t\t}else{//下一步代表要变 \n\t\t\t\tdp[i][j+1]=min(dp[i][j+1],dp[i][j]+(ptr[i][j]=='.')); \n\t\t\t}\n\t\t\tif(ptr[i+1][j]=='.'){//下一步代表不要变 \n\t\t\t\tdp[i+1][j]=min(dp[i+1][j],dp[i][j]);\n\t\t\t}else{//下一步代表要变 \n\t\t\t\tdp[i+1][j]=min(dp[i+1][j],dp[i][j]+(ptr[i][j]=='.'));\n\t\t\t}\n\t\t}\n\t}\n\tcout<\n#include \n#include \n#include \n \nusing namespace std;\n \ntypedef long long ll;\ntypedef pair P;\ntypedef pair T;\n \nlong long int INF = 1e18;\nconst ll fact_table = 800008;\ndouble Pi = 3.1415926535897932384626;\n\npriority_queue pql;\npriority_queue

pqp;\npriority_queue

bag;\n//big priority queue\npriority_queue ,greater > pqls;\npriority_queue ,greater

> pqps;\n//small priority queue\n//top pop\n \nll dx[8]={1,0,-1,0,1,1,-1,-1};\nll dy[8]={0,1,0,-1,1,-1,-1,1};\nchar dir[] = \"DRUL\";\n//↓,→,↑,←\n \n \n#define p(x) cout< number2){\n swap(number1,number2);\n }\n if(number1 == 0 || number1 == number2){\n return number2;\n }else{\n return gcd(number2 % number1,number1);\n }\n}\nvoid YES(bool condition){\n \n if(condition){\n p(\"YES\");\n }else{\n p(\"NO\");\n }\n return;\n}\nvoid Yes(bool condition){\n \n if(condition){\n p(\"Yes\");\n }else{\n p(\"No\");\n }\n return;\n}\n \n/*\nll fact[fact_table + 5],rfact[fact_table + 5];\n \n \nvoid c3_init(){\n fact[0] = rfact[0] = 1;\n for(ll i=1; i<=fact_table; i++){\n fact[i] = (fact[i-1]*i) % mod;\n }\n rfact[fact_table] = rui(fact[fact_table],mod - 2);\n for(ll i=fact_table; i>=1; i--){\n rfact[i-1] = rfact[i] * i;\n rfact[i-1] %= mod;\n }\n return;}\nll c3(ll n,ll r){\n return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}\n*/\nbool multicase = false;\n\nll n,m,num,sum,a,b,c,d,e,h,q,p;\nll w, ans;\nll k;\nchar s[105][105];\nvector

G[500005];\nll cost[100005];\n\nvoid solve(){\n cin >> h >> w;\n for(ll i=0;i> s[i];\n }\n for(ll i=0;i= h || ny >= w)continue;\n ll fromid = i * w + j;\n ll toid = nx * w + ny;\n if(s[x][y] == s[nx][ny]){\n G[fromid].pb(P(toid, 0));\n }else{\n G[fromid].pb(P(toid, 1));\n }\n }\n }\n }\n ll c1 = 0, c2 = 0;\n if(s[0][0] == '#')c1++;\n if(s[h-1][w-1] == '#')c2++;\n G[h*w].pb(P(0, c1));\n G[h*w-1].pb(P(h*w+1, c2));\n for(ll i=0;i cost[v])continue;\n for(ll i=0;i newcost){\n cost[nv] = newcost;\n pqps.push(P(newcost, nv));\n }\n\n }\n }\n ll ans = cost[h*w+1];\n p(ans / 2);\n return;\n}\n\nint main(){\n // init();\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n ll q;\n if(multicase){\n cin >> q;\n }else{\n q = 1;\n }\n while(q--){\n solve();\n }\n return 0;\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "language": "C++", "metadata": {"date": 1584840602, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02735/input.txt", "sample_output_relpath": "derived/input_output/data/p02735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02735/C++/s223220013.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s223220013", "user_id": "u399527088"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n \nusing namespace std;\n \ntypedef long long ll;\ntypedef pair P;\ntypedef pair T;\n \nlong long int INF = 1e18;\nconst ll fact_table = 800008;\ndouble Pi = 3.1415926535897932384626;\n\npriority_queue pql;\npriority_queue

pqp;\npriority_queue

bag;\n//big priority queue\npriority_queue ,greater > pqls;\npriority_queue ,greater

> pqps;\n//small priority queue\n//top pop\n \nll dx[8]={1,0,-1,0,1,1,-1,-1};\nll dy[8]={0,1,0,-1,1,-1,-1,1};\nchar dir[] = \"DRUL\";\n//↓,→,↑,←\n \n \n#define p(x) cout< number2){\n swap(number1,number2);\n }\n if(number1 == 0 || number1 == number2){\n return number2;\n }else{\n return gcd(number2 % number1,number1);\n }\n}\nvoid YES(bool condition){\n \n if(condition){\n p(\"YES\");\n }else{\n p(\"NO\");\n }\n return;\n}\nvoid Yes(bool condition){\n \n if(condition){\n p(\"Yes\");\n }else{\n p(\"No\");\n }\n return;\n}\n \n/*\nll fact[fact_table + 5],rfact[fact_table + 5];\n \n \nvoid c3_init(){\n fact[0] = rfact[0] = 1;\n for(ll i=1; i<=fact_table; i++){\n fact[i] = (fact[i-1]*i) % mod;\n }\n rfact[fact_table] = rui(fact[fact_table],mod - 2);\n for(ll i=fact_table; i>=1; i--){\n rfact[i-1] = rfact[i] * i;\n rfact[i-1] %= mod;\n }\n return;}\nll c3(ll n,ll r){\n return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}\n*/\nbool multicase = false;\n\nll n,m,num,sum,a,b,c,d,e,h,q,p;\nll w, ans;\nll k;\nchar s[105][105];\nvector

G[500005];\nll cost[100005];\n\nvoid solve(){\n cin >> h >> w;\n for(ll i=0;i> s[i];\n }\n for(ll i=0;i= h || ny >= w)continue;\n ll fromid = i * w + j;\n ll toid = nx * w + ny;\n if(s[x][y] == s[nx][ny]){\n G[fromid].pb(P(toid, 0));\n }else{\n G[fromid].pb(P(toid, 1));\n }\n }\n }\n }\n ll c1 = 0, c2 = 0;\n if(s[0][0] == '#')c1++;\n if(s[h-1][w-1] == '#')c2++;\n G[h*w].pb(P(0, c1));\n G[h*w-1].pb(P(h*w+1, c2));\n for(ll i=0;i cost[v])continue;\n for(ll i=0;i newcost){\n cost[nv] = newcost;\n pqps.push(P(newcost, nv));\n }\n\n }\n }\n ll ans = cost[h*w+1];\n p(ans / 2);\n return;\n}\n\nint main(){\n // init();\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n ll q;\n if(multicase){\n cin >> q;\n }else{\n q = 1;\n }\n while(q--){\n solve();\n }\n return 0;\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "sample_input": "3 3\n.##\n.#.\n##.\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02735", "source_text": "Score : 400 points\n\nProblem Statement\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left.\nEach square is painted black or white.\n\nThe grid is said to be good if and only if the following condition is satisfied:\n\nFrom (1, 1), we can reach (H, W) by moving one square right or down repeatedly, while always being on a white square.\n\nNote that (1, 1) and (H, W) must be white if the grid is good.\n\nYour task is to make the grid good by repeating the operation below. Find the minimum number of operations needed to complete the task. It can be proved that you can always complete the task in a finite number of operations.\n\nChoose four integers r_0, c_0, r_1, c_1(1 \\leq r_0 \\leq r_1 \\leq H, 1 \\leq c_0 \\leq c_1 \\leq W). For each pair r, c (r_0 \\leq r \\leq r_1, c_0 \\leq c \\leq c_1), invert the color of (r, c) - that is, from white to black and vice versa.\n\nConstraints\n\n2 \\leq H, W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{11} s_{12} \\cdots s_{1W}\ns_{21} s_{22} \\cdots s_{2W}\n\\vdots\ns_{H1} s_{H2} \\cdots s_{HW}\n\nHere s_{rc} represents the color of (r, c) - # stands for black, and . stands for white.\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3 3\n.##\n.#.\n##.\n\nSample Output 1\n\n1\n\nDo the operation with (r_0, c_0, r_1, c_1) = (2, 2, 2, 2) to change just the color of (2, 2), and we are done.\n\nSample Input 2\n\n2 2\n#.\n.#\n\nSample Output 2\n\n2\n\nSample Input 3\n\n4 4\n..##\n#...\n###.\n###.\n\nSample Output 3\n\n0\n\nNo operation may be needed.\n\nSample Input 4\n\n5 5\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n\nSample Output 4\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4196, "cpu_time_ms": 7, "memory_kb": 12544}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s631694037", "group_id": "codeNet:p02736", "input_text": "#include\n#define Tp template\n#define Ts template\n#define Reg register\n#define RI Reg int\n#define Con const\n#define CI Con int&\n#define I inline\n#define W while\n#define N 1000000\nusing namespace std;\nint n,a[N+5];char s[N+5];\nint main()\n{\n\tRI i;for(scanf(\"%d%s\",&n,s),--n,i=0;i^n;++i) a[i]=abs(s[i]-s[i+1]);\n\tRI f=1;for(i=0;i^n;++i) if(a[i]==1) {f=0;break;}\n\tfor(i=0;i^n;++i) a[i]==2&&(a[i]=f);\n\tRI ans=0;for(i=0;i^n;++i) (((n-1)^i)==(n-1)-i)&&(ans^=a[i]);\n\treturn printf(\"%d\",ans*(f+1)),0;\n}", "language": "C++", "metadata": {"date": 1589767076, "filename_ext": "cpp", "original_language": "C++ (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02736.html", "problem_id": "p02736", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02736/input.txt", "sample_output_relpath": "derived/input_output/data/p02736/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02736/C++/s631694037.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631694037", "user_id": "u752711517"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\n#define Tp template\n#define Ts template\n#define Reg register\n#define RI Reg int\n#define Con const\n#define CI Con int&\n#define I inline\n#define W while\n#define N 1000000\nusing namespace std;\nint n,a[N+5];char s[N+5];\nint main()\n{\n\tRI i;for(scanf(\"%d%s\",&n,s),--n,i=0;i^n;++i) a[i]=abs(s[i]-s[i+1]);\n\tRI f=1;for(i=0;i^n;++i) if(a[i]==1) {f=0;break;}\n\tfor(i=0;i^n;++i) a[i]==2&&(a[i]=f);\n\tRI ans=0;for(i=0;i^n;++i) (((n-1)^i)==(n-1)-i)&&(ans^=a[i]);\n\treturn printf(\"%d\",ans*(f+1)),0;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "sample_input": "4\n1231\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02736", "source_text": "Score : 700 points\n\nProblem Statement\n\nGiven is a sequence of N digits a_1a_2\\ldots a_N, where each element is 1, 2, or 3.\nLet x_{i,j} defined as follows:\n\nx_{1,j} := a_j \\quad (1 \\leq j \\leq N)\n\nx_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \\quad (2 \\leq i \\leq N and 1 \\leq j \\leq N+1-i)\n\nFind x_{N,1}.\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\na_i = 1,2,3 (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1a_2\\ldotsa_N\n\nOutput\n\nPrint x_{N,1}.\n\nSample Input 1\n\n4\n1231\n\nSample Output 1\n\n1\n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\nSample Input 2\n\n10\n2311312312\n\nSample Output 2\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 547, "cpu_time_ms": 12, "memory_kb": 5120}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s765853104", "group_id": "codeNet:p02742", "input_text": "#include \nusing namespace std;\n\nint main() {\n\tlong long h,w;cin >>h>>w;\n\tlong long out =1;\n\tif(h>1 && w>1){\n\t\tout= (h/2 + h%2)*(w/2 + w%2) + (h/2)*(w/2);\n\t}\n\tcout << out << endl;\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1587833967, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/C++/s765853104.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765853104", "user_id": "u960687982"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n\tlong long h,w;cin >>h>>w;\n\tlong long out =1;\n\tif(h>1 && w>1){\n\t\tout= (h/2 + h%2)*(w/2 + w%2) + (h/2)*(w/2);\n\t}\n\tcout << out << endl;\n\treturn 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s785850610", "group_id": "codeNet:p02742", "input_text": "#include \n#include \nusing namespace std;\n\nint main() {\n long long H, W;\n cin >> H >> W;\n double ans = ((H+1)/2)*((W+1)/2)+(H/2)*(W/2);\n cout << long(ans) << endl;\n}\n", "language": "C++", "metadata": {"date": 1584237141, "filename_ext": "cpp", "original_language": "C++14 (Clang 3.8.0)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/C++/s785850610.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s785850610", "user_id": "u748503010"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint main() {\n long long H, W;\n cin >> H >> W;\n double ans = ((H+1)/2)*((W+1)/2)+(H/2)*(W/2);\n cout << long(ans) << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 11, "memory_kb": 888}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s088392844", "group_id": "codeNet:p02742", "input_text": "#include \n//上記が使用不可な環境において\n/*\n#include // cout, endl, cin\n#include // string, to_string, stoi\n#include //setprecsion\n#include // vector\n#include // min, max, swap, sort, reverse, lower_bound, upper_bound\n#include // pair, make_pair\n#include //sin, cos, tan\n#include // tuple, make_tuple\n#include // int64_t, int*_t\n#include // printf\n#include // map\n#include // queue, priority_queue\n#include // set\n#include // stack\n#include // deque\n#include // unordered_map\n#include // unordered_set\n#include // bitset\n#include // isupper, islower, isdigit, toupper, tolower\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n*/\nusing namespace std;\n\ntypedef long long int ll;\ntypedef long long int lli;\ntypedef unsigned long long int ull;\ntypedef long double ld;\ntypedef string str;\ntypedef vector vc;\ntypedef vector vb;\ntypedef vector vd;\ntypedef vector vs;\ntypedef vector vll;\ntypedef vector> vpll;\ntypedef vector> vvll;\ntypedef vector> vvc;\ntypedef vector> vvs;\nconst ld PI = acos(-1.0);\nconst ll MAX = 9000000000000000000;\nconst ll MIN = -9000000000000000000;\nconst ld DMAX = 4500;\nconst ld DMIN = -4500;\n\n//謎\nconst int INF = INT_MAX;\nconst ll LLINF = 1LL << 60;\nconst ll MOD = 1000000007;\nconst ld EPS = 1e-9;\nll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};\nll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};\n\n//0~nの範囲操作\n#define rep(i, n) for (ll i = 0; i < (n); ++i)\n//1~nの範囲操作\n#define rrep(i, n) for (ll i = 1; i <= (n); ++i)\n#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)\n#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)\n//出力後改行を\n#define fin(ans) cout << (ans) << endl;\n//出力後空白を\n#define blank(ans) cout << (ans) << \" \";\n#define mp(p, q) make_pair(p, q)\n#define pb(n) push_back(n)\n//配列全操作\n#define all(a) a.begin(), a.end()\n\n//配列の合計\ntemplate \nT Sum(vector n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (accumulate(n.begin() + a, n.end(), 0));\n }\n else\n {\n return (accumulate(n.begin() + a, n.begin() + b, 0));\n }\n}\ntemplate <>\nld Sum(vector n, ll a, ll b)\n{\n if (b == 0)\n {\n return (accumulate(n.begin() + a, n.end(), 0));\n }\n else\n {\n return (accumulate(n.begin() + a, n.begin() + b, 0));\n }\n}\n//配列を昇順\ntemplate \nvoid Sort(T &n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (sort(n.begin() + a, n.end()));\n }\n else\n {\n return (sort(n.begin() + a, n.begin() + b));\n }\n}\n//配列を降順\ntemplate \nvoid Reve(T &n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (reverse(n.begin() + a, n.end()));\n }\n else\n {\n return (reverse(n.begin() + a, n.begin() + b));\n }\n}\n//配列nをmにコピー\ntemplate \nvoid Copy(T &n, U &m, ll a = 0, ll b = 0)\n{\n copy(all(n), m.begin());\n}\n//小数点型に\ntemplate \nld Cast(T n)\n{\n return static_cast(n);\n}\n//配列入力\ntemplate \nvoid V(T &n)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i];\n }\n}\n//2列配列入力\ntemplate \nvoid V2(T &n, U &m)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i] >> m[i];\n }\n}\n//3列配列入力\ntemplate \nvoid V3(T &n, U &m, W &p)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i] >> m[i] >> p[i];\n }\n}\n//yes, noと表示\nvoid yn(bool a)\n{\n if (a)\n cout << \"yes\" << endl;\n else\n cout << \"no\" << endl;\n}\n//Yes, Noと表示\nvoid Yn(bool a)\n{\n if (a)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n}\n//YES, NOと表示\nvoid YN(bool a)\n{\n if (a)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n}\n//yes, noと表示後終了\nvoid fyn(bool a)\n{\n if (a)\n cout << \"yes\" << endl;\n else\n cout << \"no\" << endl;\n exit(0);\n}\n//Yes, Noと表示後終了\nvoid fYn(bool a)\n{\n if (a)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n exit(0);\n}\n//YES, NOと表示後終了\nvoid fYN(bool a)\n{\n if (a)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n exit(0);\n}\n//AC, WAと表示\nvoid AC(bool a)\n{\n if (a)\n cout << \"AC\" << endl;\n else\n cout << \"WA\" << endl;\n}\n//AC, WAと表示後終了\nvoid fAC(bool a)\n{\n if (a)\n cout << \"AC\" << endl;\n else\n cout << \"WA\" << endl;\n exit(0);\n}\n//noneと表示後終了\nvoid fnone(void)\n{\n cout << \"None\" << endl;\n exit(0);\n}\n//Odd(奇数), Even(偶数)と表示後終了\nvoid fOdd(bool a)\n{\n if (a)\n cout << \"Odd\" << endl;\n else\n cout << \"Even\" << endl;\n exit(0);\n}\n//Possible, Impossibleと表示後終了\nvoid Possible(bool a)\n{\n if (a)\n cout << \"Possible\" << endl;\n else\n cout << \"Impossible\" << endl;\n exit(0);\n}\n//POSSIBLE, IMPOSSIBLEと表示後終了\nvoid POSSIBLE(bool a)\n{\n if (a)\n cout << \"POSSIBLE\" << endl;\n else\n cout << \"IMPOSSIBLE\" << endl;\n exit(0);\n}\n//四角 表示文字 a 縦幅 h 横幅 w\nvoid square(char a, ll h, ll w)\n{\n for (ll i = 0; i < h; i++)\n {\n for (ll j = 0; j < w; j++)\n {\n cout << a;\n }\n cout << endl;\n }\n}\n//四角枠 外周 a 中身 b 縦幅 h 横幅 w\nvoid yoke(char a, char b, ll h, ll w)\n{\n for (ll i = 0; i < h; i++)\n {\n for (ll j = 0; j < w; j++)\n {\n if (i == 0 || i == h - 1)\n cout << a;\n else if (j == 0 || j == w - 1)\n cout << a;\n else\n cout << b;\n }\n cout << endl;\n }\n}\n//四捨五入\nll C45(ll n)\n{\n return (n + 1) / 2;\n}\n//文字列からcを探す\nll stcount(str s, char c)\n{\n return count(s.cbegin(), s.cend(), c);\n}\n//素数\nbool IsPrime(ll num)\n{\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 ld sqrtNum = sqrt(num);\n for (ll i = 3; i <= sqrtNum; i += 2)\n {\n if (num % i == 0)\n return false;\n }\n return true;\n}\n//桁数\nll GetDigit(ll num)\n{\n return log10(num) + 1;\n}\n//各桁の和\nll KSum(ll n)\n{\n ll sum = 0;\n if (n < 0)\n return 0;\n while (n > 0)\n {\n sum += n % 10;\n n /= 10;\n }\n return sum;\n}\n//数値反転\nbool KReve(ll n)\n{\n int reverse = 0;\n int remaind;\n int tmp = n;\n while (tmp != 0)\n {\n remaind = tmp % 10;\n reverse = reverse * 10 + remaind;\n tmp /= 10;\n }\n if (reverse == n)\n return true;\n else\n return false;\n}\n//約数全列挙\nvector enum_div(ll n)\n{\n vector ret;\n for (ll i = 1; i * i <= n; ++i)\n {\n if (n % i == 0)\n {\n ret.push_back(i);\n if (i != 1 && i * i != n)\n {\n ret.push_back(n / i);\n }\n }\n }\n return ret;\n}\n//最大公約数\nll gcd(ll a, ll b)\n{\n return b ? gcd(b, a % b) : a;\n}\n//複数個の最大公約数\nll ngcd(vector a)\n{\n ll res;\n res = a[0];\n for (ll i = 1; i < a.size() && res != 1; i++)\n {\n res = gcd(a[i], res);\n }\n return res;\n}\n//最小公倍数\nll lcm(ll a, ll b)\n{\n return a * b / gcd(a, b);\n}\n//複数個の最小公倍数\nll nlcm(vector numbers)\n{\n ll res;\n res = numbers[0];\n for (ll i = 1; i < numbers.size(); i++)\n {\n res = lcm(res, numbers[i]);\n }\n return res;\n}\n//累乗\nll Pow(ll x, ll n)\n{\n ll res = 1;\n rep(i, n) res = res * x;\n return res;\n}\n//累乗(xのn乗%mod)\nll mod_pow(ll x, ll n, ll mod = MAX)\n{\n ll res = 1;\n while (n > 0)\n {\n if (n & 1)\n res = res * x % mod;\n x = x * x % mod;\n n >>= 1;\n }\n return res;\n}\n//階乗\nll factorial(ll n)\n{\n if (n > 0)\n return n * factorial(n - 1);\n else\n return 1;\n}\n//順列 nPr\nll perm(ll a, ll b)\n{\n return (factorial(a) / factorial(a - b));\n}\n//組み合わせ nCr\nll comb(ll a, ll b)\n{\n return (factorial(a) / (factorial(a - b) * factorial(b)));\n}\n//n ~ mの和\nll sigma(ll n, ll m)\n{\n return ((n + m) * (m - n + 1) * 0.5);\n}\n//期待値\nld hope(ld a)\n{\n return (sigma(1, a) / a);\n}\n//謎\ntemplate \ninline bool chmax(T &a, T b)\n{\n if (a < b)\n {\n a = b;\n return 1;\n }\n return 0;\n}\ntemplate \ninline bool chmin(T &a, T b)\n{\n if (a > b)\n {\n a = b;\n return 1;\n }\n return 0;\n}\n/*\n//幅優先探索\n// 各座標に格納したい情報を構造体にする\n// 今回はX座標,Y座標,深さ(距離)を記述している\nstruct Corr\n{\n ll x;\n ll y;\n ll depth;\n};\nqueue q;\nll bfs(vector> grid)\n{\n // 既に探索の場所を1,探索していなかったら0を格納する配列\n vector> ispassed(grid.size(), vector(grid[0].size(), false));\n // このような記述をしておくと,この後のfor文が綺麗にかける\n ll dx[8] = {1, 0, -1, 0};\n ll dy[8] = {0, 1, 0, -1};\n while (!q.empty())\n {\n Corr now = q.front();\n q.pop();\n //今いる座標は(x,y)=(now.x, now.y)で,深さ(距離)はnow.depthである ここで,今いる座標がゴール(探索対象)なのか判定する\n for (ll i = 0; i < 4; i++)\n {\n ll nextx = now.x + dx[i];\n ll nexty = now.y + dy[i];\n\n // 次に探索する場所のX座標がはみ出した時\n if (nextx >= grid[0].size())\n continue;\n if (nextx < 0)\n continue;\n\n // 次に探索する場所のY座標がはみ���した時\n if (nexty >= grid.size())\n continue;\n if (nexty < 0)\n continue;\n\n // 次に探索する場所が既に探索済みの場合\n if (ispassed[nexty][nextx])\n continue;\n\n ispassed[nexty][nextx] = true;\n Corr next = {nextx, nexty, now.depth + 1};\n q.push(next);\n }\n }\n}\n*/\n//謎\n//セグメント木\nclass Monoid\n{\npublic:\n // 単位元\n ll unit;\n\n Monoid()\n {\n // 単位元\n unit = 0;\n }\n\n // 演算関数\n ll calc(ll a, ll b)\n {\n return a + b;\n }\n};\n\nclass SegmentTree\n{\npublic:\n // セグメント木の葉の要素数\n ll n;\n\n // セグメント木\n vector tree;\n\n // モノイド\n Monoid mono;\n\n SegmentTree(vector &v)\n {\n n = 1 << (ll)ceil(log2(v.size()));\n tree = vector(n << 1);\n for (ll i = 0; i < v.size(); i++)\n {\n update(i, v[i]);\n }\n for (ll i = v.size(); i < n; i++)\n {\n update(i, mono.unit);\n }\n }\n\n // k番目の値(0-indexed)をxに変更\n void update(ll k, ll x)\n {\n k += n;\n tree[k] = x;\n for (k = k >> 1; k > 0; k >>= 1)\n {\n tree[k] = mono.calc(tree[k << 1 | 0], tree[k << 1 | 1]);\n }\n }\n\n // [l, r)の最小値(0-indexed)を求める.\n ll query(ll l, ll r)\n {\n ll res = mono.unit;\n l += n;\n r += n;\n while (l < r)\n {\n if (l & 1)\n {\n res = mono.calc(res, tree[l++]);\n }\n if (r & 1)\n {\n res = mono.calc(res, tree[--r]);\n }\n l >>= 1;\n r >>= 1;\n }\n return res;\n }\n ll operator[](ll k)\n {\n // st[i]で添字iの要素の値を返す\n if (k - n >= 0 || k < 0)\n {\n return -INF;\n }\n return tree[tree.size() - n + k];\n }\n\n void show()\n {\n int ret = 2;\n for (ll i = 1; i < 2 * n; i++)\n {\n cout << tree[i] << \" \";\n if (i == ret - 1)\n {\n cout << endl;\n ret <<= 1;\n }\n }\n cout << endl;\n }\n};\n//点と線の最短距離\nstruct Point\n{\n ld x;\n ld y;\n};\n\nstruct LineSegment\n{\n Point start;\n Point end;\n};\n\n/**\n @brief 線分と点の距離を計算する。\n @param line 線分\n @param point 点\n @return ユークリッド距離\n */\nld calc_dist(const LineSegment &line, const Point &point)\n{\n ld x0 = point.x, y0 = point.y;\n ld x1 = line.start.x, y1 = line.start.y;\n ld x2 = line.end.x, y2 = line.end.y;\n\n ld a = x2 - x1;\n ld b = y2 - y1;\n ld a2 = a * a;\n ld b2 = b * b;\n ld r2 = a2 + b2;\n ld tt = -(a * (x1 - x0) + b * (y1 - y0));\n\n if (tt < 0)\n return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));\n else if (tt > r2)\n return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0));\n\n ld f1 = a * (y1 - y0) - b * (x1 - x0);\n return sqrt((f1 * f1) / r2);\n}\n//文字を数字に\nll Moji(char a)\n{\n return (a - 48);\n}\n\n//大文字->小文字(+32)\n\nvoid Main()\n{\n ll h, w; cin >> h >> w;\n if(h * w % 2 == 1) fin(h * w / 2 + 1)\n else fin(h * w / 2)\n}\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(20);\n Main();\n return 0;\n}\n/*\n//test時\ng++ test.cpp -o a;./a\n*/\n", "language": "C++", "metadata": {"date": 1584234883, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/C++/s088392844.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s088392844", "user_id": "u743889070"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \n//上記が使用不可な環境において\n/*\n#include // cout, endl, cin\n#include // string, to_string, stoi\n#include //setprecsion\n#include // vector\n#include // min, max, swap, sort, reverse, lower_bound, upper_bound\n#include // pair, make_pair\n#include //sin, cos, tan\n#include // tuple, make_tuple\n#include // int64_t, int*_t\n#include // printf\n#include // map\n#include // queue, priority_queue\n#include // set\n#include // stack\n#include // deque\n#include // unordered_map\n#include // unordered_set\n#include // bitset\n#include // isupper, islower, isdigit, toupper, tolower\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n*/\nusing namespace std;\n\ntypedef long long int ll;\ntypedef long long int lli;\ntypedef unsigned long long int ull;\ntypedef long double ld;\ntypedef string str;\ntypedef vector vc;\ntypedef vector vb;\ntypedef vector vd;\ntypedef vector vs;\ntypedef vector vll;\ntypedef vector> vpll;\ntypedef vector> vvll;\ntypedef vector> vvc;\ntypedef vector> vvs;\nconst ld PI = acos(-1.0);\nconst ll MAX = 9000000000000000000;\nconst ll MIN = -9000000000000000000;\nconst ld DMAX = 4500;\nconst ld DMIN = -4500;\n\n//謎\nconst int INF = INT_MAX;\nconst ll LLINF = 1LL << 60;\nconst ll MOD = 1000000007;\nconst ld EPS = 1e-9;\nll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};\nll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};\n\n//0~nの範囲操作\n#define rep(i, n) for (ll i = 0; i < (n); ++i)\n//1~nの範囲操作\n#define rrep(i, n) for (ll i = 1; i <= (n); ++i)\n#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)\n#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)\n//出力後改行を\n#define fin(ans) cout << (ans) << endl;\n//出力後空白を\n#define blank(ans) cout << (ans) << \" \";\n#define mp(p, q) make_pair(p, q)\n#define pb(n) push_back(n)\n//配列全操作\n#define all(a) a.begin(), a.end()\n\n//配列の合計\ntemplate \nT Sum(vector n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (accumulate(n.begin() + a, n.end(), 0));\n }\n else\n {\n return (accumulate(n.begin() + a, n.begin() + b, 0));\n }\n}\ntemplate <>\nld Sum(vector n, ll a, ll b)\n{\n if (b == 0)\n {\n return (accumulate(n.begin() + a, n.end(), 0));\n }\n else\n {\n return (accumulate(n.begin() + a, n.begin() + b, 0));\n }\n}\n//配列を昇順\ntemplate \nvoid Sort(T &n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (sort(n.begin() + a, n.end()));\n }\n else\n {\n return (sort(n.begin() + a, n.begin() + b));\n }\n}\n//配列を降順\ntemplate \nvoid Reve(T &n, ll a = 0, ll b = 0)\n{\n if (b == 0)\n {\n return (reverse(n.begin() + a, n.end()));\n }\n else\n {\n return (reverse(n.begin() + a, n.begin() + b));\n }\n}\n//配列nをmにコピー\ntemplate \nvoid Copy(T &n, U &m, ll a = 0, ll b = 0)\n{\n copy(all(n), m.begin());\n}\n//小数点型に\ntemplate \nld Cast(T n)\n{\n return static_cast(n);\n}\n//配列入力\ntemplate \nvoid V(T &n)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i];\n }\n}\n//2列配列入力\ntemplate \nvoid V2(T &n, U &m)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i] >> m[i];\n }\n}\n//3列配列入力\ntemplate \nvoid V3(T &n, U &m, W &p)\n{\n for (ll i = 0; i < n.size(); i++)\n {\n cin >> n[i] >> m[i] >> p[i];\n }\n}\n//yes, noと表示\nvoid yn(bool a)\n{\n if (a)\n cout << \"yes\" << endl;\n else\n cout << \"no\" << endl;\n}\n//Yes, Noと表示\nvoid Yn(bool a)\n{\n if (a)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n}\n//YES, NOと表示\nvoid YN(bool a)\n{\n if (a)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n}\n//yes, noと表示後終了\nvoid fyn(bool a)\n{\n if (a)\n cout << \"yes\" << endl;\n else\n cout << \"no\" << endl;\n exit(0);\n}\n//Yes, Noと表示後終了\nvoid fYn(bool a)\n{\n if (a)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n exit(0);\n}\n//YES, NOと表示後終了\nvoid fYN(bool a)\n{\n if (a)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n exit(0);\n}\n//AC, WAと表示\nvoid AC(bool a)\n{\n if (a)\n cout << \"AC\" << endl;\n else\n cout << \"WA\" << endl;\n}\n//AC, WAと表示後終了\nvoid fAC(bool a)\n{\n if (a)\n cout << \"AC\" << endl;\n else\n cout << \"WA\" << endl;\n exit(0);\n}\n//noneと表示後終了\nvoid fnone(void)\n{\n cout << \"None\" << endl;\n exit(0);\n}\n//Odd(奇数), Even(偶数)と表示後終了\nvoid fOdd(bool a)\n{\n if (a)\n cout << \"Odd\" << endl;\n else\n cout << \"Even\" << endl;\n exit(0);\n}\n//Possible, Impossibleと表示後終了\nvoid Possible(bool a)\n{\n if (a)\n cout << \"Possible\" << endl;\n else\n cout << \"Impossible\" << endl;\n exit(0);\n}\n//POSSIBLE, IMPOSSIBLEと表示後終了\nvoid POSSIBLE(bool a)\n{\n if (a)\n cout << \"POSSIBLE\" << endl;\n else\n cout << \"IMPOSSIBLE\" << endl;\n exit(0);\n}\n//四角 表示文字 a 縦幅 h 横幅 w\nvoid square(char a, ll h, ll w)\n{\n for (ll i = 0; i < h; i++)\n {\n for (ll j = 0; j < w; j++)\n {\n cout << a;\n }\n cout << endl;\n }\n}\n//四角枠 外周 a 中身 b 縦幅 h 横幅 w\nvoid yoke(char a, char b, ll h, ll w)\n{\n for (ll i = 0; i < h; i++)\n {\n for (ll j = 0; j < w; j++)\n {\n if (i == 0 || i == h - 1)\n cout << a;\n else if (j == 0 || j == w - 1)\n cout << a;\n else\n cout << b;\n }\n cout << endl;\n }\n}\n//四捨五入\nll C45(ll n)\n{\n return (n + 1) / 2;\n}\n//文字列からcを探す\nll stcount(str s, char c)\n{\n return count(s.cbegin(), s.cend(), c);\n}\n//素数\nbool IsPrime(ll num)\n{\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 ld sqrtNum = sqrt(num);\n for (ll i = 3; i <= sqrtNum; i += 2)\n {\n if (num % i == 0)\n return false;\n }\n return true;\n}\n//桁数\nll GetDigit(ll num)\n{\n return log10(num) + 1;\n}\n//各桁の和\nll KSum(ll n)\n{\n ll sum = 0;\n if (n < 0)\n return 0;\n while (n > 0)\n {\n sum += n % 10;\n n /= 10;\n }\n return sum;\n}\n//数値反転\nbool KReve(ll n)\n{\n int reverse = 0;\n int remaind;\n int tmp = n;\n while (tmp != 0)\n {\n remaind = tmp % 10;\n reverse = reverse * 10 + remaind;\n tmp /= 10;\n }\n if (reverse == n)\n return true;\n else\n return false;\n}\n//約数全列挙\nvector enum_div(ll n)\n{\n vector ret;\n for (ll i = 1; i * i <= n; ++i)\n {\n if (n % i == 0)\n {\n ret.push_back(i);\n if (i != 1 && i * i != n)\n {\n ret.push_back(n / i);\n }\n }\n }\n return ret;\n}\n//最大公約数\nll gcd(ll a, ll b)\n{\n return b ? gcd(b, a % b) : a;\n}\n//複数個の最大公約数\nll ngcd(vector a)\n{\n ll res;\n res = a[0];\n for (ll i = 1; i < a.size() && res != 1; i++)\n {\n res = gcd(a[i], res);\n }\n return res;\n}\n//最小公倍数\nll lcm(ll a, ll b)\n{\n return a * b / gcd(a, b);\n}\n//複数個の最小公倍数\nll nlcm(vector numbers)\n{\n ll res;\n res = numbers[0];\n for (ll i = 1; i < numbers.size(); i++)\n {\n res = lcm(res, numbers[i]);\n }\n return res;\n}\n//累乗\nll Pow(ll x, ll n)\n{\n ll res = 1;\n rep(i, n) res = res * x;\n return res;\n}\n//累乗(xのn乗%mod)\nll mod_pow(ll x, ll n, ll mod = MAX)\n{\n ll res = 1;\n while (n > 0)\n {\n if (n & 1)\n res = res * x % mod;\n x = x * x % mod;\n n >>= 1;\n }\n return res;\n}\n//階乗\nll factorial(ll n)\n{\n if (n > 0)\n return n * factorial(n - 1);\n else\n return 1;\n}\n//順列 nPr\nll perm(ll a, ll b)\n{\n return (factorial(a) / factorial(a - b));\n}\n//組み合わせ nCr\nll comb(ll a, ll b)\n{\n return (factorial(a) / (factorial(a - b) * factorial(b)));\n}\n//n ~ mの和\nll sigma(ll n, ll m)\n{\n return ((n + m) * (m - n + 1) * 0.5);\n}\n//期待値\nld hope(ld a)\n{\n return (sigma(1, a) / a);\n}\n//謎\ntemplate \ninline bool chmax(T &a, T b)\n{\n if (a < b)\n {\n a = b;\n return 1;\n }\n return 0;\n}\ntemplate \ninline bool chmin(T &a, T b)\n{\n if (a > b)\n {\n a = b;\n return 1;\n }\n return 0;\n}\n/*\n//幅優先探索\n// 各座標に格納したい情報を構造体にする\n// 今回はX座標,Y座標,深さ(距離)を記述している\nstruct Corr\n{\n ll x;\n ll y;\n ll depth;\n};\nqueue q;\nll bfs(vector> grid)\n{\n // 既に探索の場所を1,探索していなかったら0を格納する配列\n vector> ispassed(grid.size(), vector(grid[0].size(), false));\n // このような記述をしておくと,この後のfor文が綺麗にかける\n ll dx[8] = {1, 0, -1, 0};\n ll dy[8] = {0, 1, 0, -1};\n while (!q.empty())\n {\n Corr now = q.front();\n q.pop();\n //今いる座標は(x,y)=(now.x, now.y)で,深さ(距離)はnow.depthである ここで,今いる座標がゴール(探索対象)なのか判定する\n for (ll i = 0; i < 4; i++)\n {\n ll nextx = now.x + dx[i];\n ll nexty = now.y + dy[i];\n\n // 次に探索する場所のX座標がはみ出した時\n if (nextx >= grid[0].size())\n continue;\n if (nextx < 0)\n continue;\n\n // 次に探索する場所のY座標がはみ出した時\n if (nexty >= grid.size())\n continue;\n if (nexty < 0)\n continue;\n\n // 次に探索する場所が既に探索済みの場合\n if (ispassed[nexty][nextx])\n continue;\n\n ispassed[nexty][nextx] = true;\n Corr next = {nextx, nexty, now.depth + 1};\n q.push(next);\n }\n }\n}\n*/\n//謎\n//セグメント木\nclass Monoid\n{\npublic:\n // 単位元\n ll unit;\n\n Monoid()\n {\n // 単位元\n unit = 0;\n }\n\n // 演算関数\n ll calc(ll a, ll b)\n {\n return a + b;\n }\n};\n\nclass SegmentTree\n{\npublic:\n // セグメント木の葉の要素数\n ll n;\n\n // セグメント木\n vector tree;\n\n // モノイド\n Monoid mono;\n\n SegmentTree(vector &v)\n {\n n = 1 << (ll)ceil(log2(v.size()));\n tree = vector(n << 1);\n for (ll i = 0; i < v.size(); i++)\n {\n update(i, v[i]);\n }\n for (ll i = v.size(); i < n; i++)\n {\n update(i, mono.unit);\n }\n }\n\n // k番目の値(0-indexed)をxに変更\n void update(ll k, ll x)\n {\n k += n;\n tree[k] = x;\n for (k = k >> 1; k > 0; k >>= 1)\n {\n tree[k] = mono.calc(tree[k << 1 | 0], tree[k << 1 | 1]);\n }\n }\n\n // [l, r)の最小値(0-indexed)を求める.\n ll query(ll l, ll r)\n {\n ll res = mono.unit;\n l += n;\n r += n;\n while (l < r)\n {\n if (l & 1)\n {\n res = mono.calc(res, tree[l++]);\n }\n if (r & 1)\n {\n res = mono.calc(res, tree[--r]);\n }\n l >>= 1;\n r >>= 1;\n }\n return res;\n }\n ll operator[](ll k)\n {\n // st[i]で添字iの要素の値を返す\n if (k - n >= 0 || k < 0)\n {\n return -INF;\n }\n return tree[tree.size() - n + k];\n }\n\n void show()\n {\n int ret = 2;\n for (ll i = 1; i < 2 * n; i++)\n {\n cout << tree[i] << \" \";\n if (i == ret - 1)\n {\n cout << endl;\n ret <<= 1;\n }\n }\n cout << endl;\n }\n};\n//点と線の最短距離\nstruct Point\n{\n ld x;\n ld y;\n};\n\nstruct LineSegment\n{\n Point start;\n Point end;\n};\n\n/**\n @brief 線分と点の距離を計算する。\n @param line 線分\n @param point 点\n @return ユークリッド距離\n */\nld calc_dist(const LineSegment &line, const Point &point)\n{\n ld x0 = point.x, y0 = point.y;\n ld x1 = line.start.x, y1 = line.start.y;\n ld x2 = line.end.x, y2 = line.end.y;\n\n ld a = x2 - x1;\n ld b = y2 - y1;\n ld a2 = a * a;\n ld b2 = b * b;\n ld r2 = a2 + b2;\n ld tt = -(a * (x1 - x0) + b * (y1 - y0));\n\n if (tt < 0)\n return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));\n else if (tt > r2)\n return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0));\n\n ld f1 = a * (y1 - y0) - b * (x1 - x0);\n return sqrt((f1 * f1) / r2);\n}\n//文字を数字に\nll Moji(char a)\n{\n return (a - 48);\n}\n\n//大文字->小文字(+32)\n\nvoid Main()\n{\n ll h, w; cin >> h >> w;\n if(h * w % 2 == 1) fin(h * w / 2 + 1)\n else fin(h * w / 2)\n}\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(20);\n Main();\n return 0;\n}\n/*\n//test時\ng++ test.cpp -o a;./a\n*/\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 12426, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s030562312", "group_id": "codeNet:p02742", "input_text": "#include \nusing namespace std;\nusing lint = long;\nusing ll = long long;\n#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)\n#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))\nusing lpair = pair;\nusing Vecint = vector;\nusing Llist = list;\n\nll pow(ll k,ll l) {\n\tll ret = 1;\n\trep(i,l) {\n\t\tret *= k;\n\t}\n\treturn ret;\n}\n\ntemplate \nT sum(vector vec) {\n\tll ret = 0;\n\trep(i,vec.size()) {\n\t\tret += vec.at(i);\n\t}\n\treturn ret;\n}\n\nvoid Main() {\n\tll h,w;\n\tcin >> h >> w;\n\tcout << h*w/2 + (h*w)%2 << '\\n';\n}\n\nsigned main() {\n\tcin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\tMain();\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1584234413, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/C++/s030562312.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s030562312", "user_id": "u538351278"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \nusing namespace std;\nusing lint = long;\nusing ll = long long;\n#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)\n#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))\nusing lpair = pair;\nusing Vecint = vector;\nusing Llist = list;\n\nll pow(ll k,ll l) {\n\tll ret = 1;\n\trep(i,l) {\n\t\tret *= k;\n\t}\n\treturn ret;\n}\n\ntemplate \nT sum(vector vec) {\n\tll ret = 0;\n\trep(i,vec.size()) {\n\t\tret += vec.at(i);\n\t}\n\treturn ret;\n}\n\nvoid Main() {\n\tll h,w;\n\tcin >> h >> w;\n\tcout << h*w/2 + (h*w)%2 << '\\n';\n}\n\nsigned main() {\n\tcin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\tMain();\n\treturn 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 662, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s976246339", "group_id": "codeNet:p02742", "input_text": "#include\n\nlong long n, m;\n\nint main() {\n scanf(\"%lld %lld\", &n, &m);\n if (n == 1 || m == 1) {\n printf(\"1\\n\");\n } else {\n printf(\"%lld\\n\", (n*m+1)/2);\n }\n}\n", "language": "C++", "metadata": {"date": 1584234373, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02742/input.txt", "sample_output_relpath": "derived/input_output/data/p02742/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02742/C++/s976246339.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976246339", "user_id": "u475056780"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include\n\nlong long n, m;\n\nint main() {\n scanf(\"%lld %lld\", &n, &m);\n if (n == 1 || m == 1) {\n printf(\"1\\n\");\n } else {\n printf(\"%lld\\n\", (n*m+1)/2);\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 173, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s951302901", "group_id": "codeNet:p02745", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define lson rt<<1\n#define rson rt<<1|1\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\ntypedef pair PP;\nconst int maxn=43+10;\nchar a[maxn],b[maxn],c[maxn];\nbool xab[maxn],xba[maxn],xbc[maxn],xac[maxn],xcb[maxn];\nint main()\n{\n cin>>a>>b>>c;\n int lena=strlen(a),lenb=strlen(b),lenc=strlen(c);\n int len=max(max(strlen(a),strlen(b)),strlen(c));\n for(int i=-len;i<=len;i++)\n {\n int flag=0;\n for(int j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define lson rt<<1\n#define rson rt<<1|1\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\ntypedef pair PP;\nconst int maxn=43+10;\nchar a[maxn],b[maxn],c[maxn];\nbool xab[maxn],xba[maxn],xbc[maxn],xac[maxn],xcb[maxn];\nint main()\n{\n cin>>a>>b>>c;\n int lena=strlen(a),lenb=strlen(b),lenc=strlen(c);\n int len=max(max(strlen(a),strlen(b)),strlen(c));\n for(int i=-len;i<=len;i++)\n {\n int flag=0;\n for(int j=0;j\n#include\nusing namespace std;\ntypedef long long li;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define df 0\ntemplate void print(const T& t){ cout << t << \"\\n\"; }\ntemplate void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << \" \"; print(ts...); }\n// Container コンテナ型, map以外\ntemplate< template class Ctn,class T>\nstd::ostream& operator<<(std::ostream& os,const Ctn& v){\n auto itr=v.begin();\n while(itr!=v.end()){\n if(itr!=v.begin())cout << \" \";\n cout << *(itr++);\n }\n return os;\n}\n\nvoid dfs(vector>& adj,vector>& col,\n int p=-1,int a=0){\n int n=adj.size();\n static vector seen(n,0);\n static int c=0;\n seen[a]=1;\n col[c].push_back(a);\n c^=1;\n for(int x:adj[a]){\n if(x==p) continue;\n dfs(adj,col,a,x);\n }\n c^=1;\n}\n\nvoid balance(vector& p,vector> col){\n int n=p.size();\n int a=0,b=1;\n if(col[0].size()& p,vector> col){\n int n=p.size();\n int a=0,b=1;\n if(col[0].size()>n;\n vector> adj(n);\n rep(i,n-1){\n int a,b; cin >>a >>b; a--; b--;\n adj[a].push_back(b);\n adj[b].push_back(a);\n }\n vector> col(2);\n dfs(adj,col);\n \n vector p(n);\n int a=0,b=1;\n if(col[0].size()\n#include\nusing namespace std;\ntypedef long long li;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define df 0\ntemplate void print(const T& t){ cout << t << \"\\n\"; }\ntemplate void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << \" \"; print(ts...); }\n// Container コンテナ型, map以外\ntemplate< template class Ctn,class T>\nstd::ostream& operator<<(std::ostream& os,const Ctn& v){\n auto itr=v.begin();\n while(itr!=v.end()){\n if(itr!=v.begin())cout << \" \";\n cout << *(itr++);\n }\n return os;\n}\n\nvoid dfs(vector>& adj,vector>& col,\n int p=-1,int a=0){\n int n=adj.size();\n static vector seen(n,0);\n static int c=0;\n seen[a]=1;\n col[c].push_back(a);\n c^=1;\n for(int x:adj[a]){\n if(x==p) continue;\n dfs(adj,col,a,x);\n }\n c^=1;\n}\n\nvoid balance(vector& p,vector> col){\n int n=p.size();\n int a=0,b=1;\n if(col[0].size()& p,vector> col){\n int n=p.size();\n int a=0,b=1;\n if(col[0].size()>n;\n vector> adj(n);\n rep(i,n-1){\n int a,b; cin >>a >>b; a--; b--;\n adj[a].push_back(b);\n adj[b].push_back(a);\n }\n vector> col(2);\n dfs(adj,col);\n \n vector p(n);\n int a=0,b=1;\n if(col[0].size()\n#define _overload3(_1, _2, _3, name, ...) name\n#define _rep(i, n) repi(i, 0, n)\n#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)\n#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)\n#define ll long long\n#define lld long double\n#define ALL(x) x.begin(), x.end()\nusing namespace std;\nconst ll INF = 1ll << 60;\nmap> g;\nmap color;\nint red = 0;\nint blue = 0;\n\nvoid dfs(int cur, int par, int col)\n{\n color[cur] = col;\n if (col == 0)\n red++;\n else\n blue++;\n for (auto x : g[cur])\n {\n if (x != par)\n {\n dfs(x, cur, (col + 1) % 2);\n }\n }\n}\n\nint main()\n{\n int n;\n cin >> n;\n rep(i, n - 1)\n {\n int a, b;\n cin >> a >> b;\n g[a].push_back(b);\n g[b].push_back(a);\n }\n dfs(1, 0, 0);\n deque q[3];\n rep(i, 1, n + 1) q[i % 3].push_back(i);\n map ans;\n //0:red 1:blue\n if (red <= n / 3)\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 0)\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n else\n {\n for (int j = 2; j >= 0; j--)\n {\n if (!q[j].empty())\n {\n ans[i] = q[j].front();\n q[i].pop_front();\n }\n }\n }\n }\n }\n else if (blue <= n / 3)\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 1)\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n else\n {\n for (int j = 2; j >= 0; j--)\n {\n if (!q[j].empty())\n {\n ans[i] = q[j].front();\n q[i].pop_front();\n }\n }\n }\n }\n }\n else\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 0)\n {\n if (!q[1].empty())\n {\n ans[i] = q[1].front();\n q[1].pop_front();\n }\n else\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n }\n else\n {\n if (!q[2].empty())\n {\n ans[i] = q[2].front();\n q[2].pop_front();\n }\n else\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n }\n }\n }\n rep(i, 1, n + 1)\n {\n cout << ans[i] << \" \";\n }\n cout << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1583801287, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02749.html", "problem_id": "p02749", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02749/input.txt", "sample_output_relpath": "derived/input_output/data/p02749/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02749/C++/s446252656.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s446252656", "user_id": "u174404613"}, "prompt_components": {"gold_output": "1 2 5 4 3\n", "input_to_evaluate": "#include \n#define _overload3(_1, _2, _3, name, ...) name\n#define _rep(i, n) repi(i, 0, n)\n#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)\n#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)\n#define ll long long\n#define lld long double\n#define ALL(x) x.begin(), x.end()\nusing namespace std;\nconst ll INF = 1ll << 60;\nmap> g;\nmap color;\nint red = 0;\nint blue = 0;\n\nvoid dfs(int cur, int par, int col)\n{\n color[cur] = col;\n if (col == 0)\n red++;\n else\n blue++;\n for (auto x : g[cur])\n {\n if (x != par)\n {\n dfs(x, cur, (col + 1) % 2);\n }\n }\n}\n\nint main()\n{\n int n;\n cin >> n;\n rep(i, n - 1)\n {\n int a, b;\n cin >> a >> b;\n g[a].push_back(b);\n g[b].push_back(a);\n }\n dfs(1, 0, 0);\n deque q[3];\n rep(i, 1, n + 1) q[i % 3].push_back(i);\n map ans;\n //0:red 1:blue\n if (red <= n / 3)\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 0)\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n else\n {\n for (int j = 2; j >= 0; j--)\n {\n if (!q[j].empty())\n {\n ans[i] = q[j].front();\n q[i].pop_front();\n }\n }\n }\n }\n }\n else if (blue <= n / 3)\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 1)\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n else\n {\n for (int j = 2; j >= 0; j--)\n {\n if (!q[j].empty())\n {\n ans[i] = q[j].front();\n q[i].pop_front();\n }\n }\n }\n }\n }\n else\n {\n rep(i, 1, n + 1)\n {\n if (color[i] == 0)\n {\n if (!q[1].empty())\n {\n ans[i] = q[1].front();\n q[1].pop_front();\n }\n else\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n }\n else\n {\n if (!q[2].empty())\n {\n ans[i] = q[2].front();\n q[2].pop_front();\n }\n else\n {\n ans[i] = q[0].front();\n q[0].pop_front();\n }\n }\n }\n }\n rep(i, 1, n + 1)\n {\n cout << ans[i] << \" \";\n }\n cout << endl;\n return 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nTakahashi loves the number 3. He is seeking a permutation p_1, p_2, \\ldots , p_N of integers from 1 to N satisfying the following condition:\n\nFor every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.\n\nHere the distance between Vertex i and Vertex j is the number of edges contained in the shortest path from Vertex i to Vertex j.\n\nHelp Takahashi by finding a permutation that satisfies the condition.\n\nConstraints\n\n2\\leq N\\leq 2\\times 10^5\n\n1\\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nIf no permutation satisfies the condition, print -1.\n\nOtherwise, print a permutation satisfying the condition, with space in between.\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n5\n1 2\n1 3\n3 4\n3 5\n\nSample Output 1\n\n1 2 5 4 3\n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\np_2 + p_4 = 6\n\np_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition.", "sample_input": "5\n1 2\n1 3\n3 4\n3 5\n"}, "reference_outputs": ["1 2 5 4 3\n"], "source_document_id": "p02749", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nTakahashi loves the number 3. He is seeking a permutation p_1, p_2, \\ldots , p_N of integers from 1 to N satisfying the following condition:\n\nFor every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.\n\nHere the distance between Vertex i and Vertex j is the number of edges contained in the shortest path from Vertex i to Vertex j.\n\nHelp Takahashi by finding a permutation that satisfies the condition.\n\nConstraints\n\n2\\leq N\\leq 2\\times 10^5\n\n1\\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nIf no permutation satisfies the condition, print -1.\n\nOtherwise, print a permutation satisfying the condition, with space in between.\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n5\n1 2\n1 3\n3 4\n3 5\n\nSample Output 1\n\n1 2 5 4 3\n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\np_2 + p_4 = 6\n\np_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2834, "cpu_time_ms": 638, "memory_kb": 46592}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s321899550", "group_id": "codeNet:p02749", "input_text": "#include \nusing namespace std;\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define whole(x) (x).begin(),(x).end()\n#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())\nusing ll = long long;\nusing P = pair;\nconst int mod = 1000000007;\n\nvector to[200005];\n//int root[200005];\nint depth[200005];\n\nvoid dfs(int v, int p=-1) {\n if (p==-1) depth[v] = 0;\n else {\n depth[v] = depth[p]+1;\n }\n for(int e: to[v]) {\n if(e==p) continue;\n dfs(e, v);\n }\n \n}\n\nint main(){\n int n;\n cin >> n;\n vector p(n);\n rep(i, n-1) {\n int a, b;\n cin >> a >> b;\n a--; b--;\n if (a>b) swap(a, b);\n to[a].push_back(b);\n to[b].push_back(a);\n }\n dfs(0, -1);\n int odd = 0;\n int even = 0;\n rep(i, n) {\n if (depth[i]%2) odd++;\n else even++;\n }\n int mod3[3];\n rep(i, 3) {\n if (n%3==0) {\n mod3[0] = n/3;\n mod3[1] = n/3;\n mod3[2] = n/3;\n }\n else if (n%3==1) {\n mod3[0] = n/3;\n mod3[1] = n/3+1;\n mod3[2] = n/3+1;\n }\n else {\n mod3[0] = n/3;\n mod3[1] = n/3+1;\n mod3[2] = n/3+1;\n }\n }\n if (max(odd, even)>(mod3[0]+mod3[1])) {\n cout << \"-1\" << endl;\n return 0;\n }\n \n vector ans(n);\n queue res[3];\n rep(i, n) {\n int v = (i+1)%3;\n res[v].push(i+1);\n }\n if (even>odd) {\n rep(i, n) {\n depth[i]++;\n }\n }\n rep(i, n) {\n if(depth[i]%2) {\n if (!res[1].empty()) {\n ans[i] = res[1].front();\n res[1].pop();\n }\n else {\n ans[i] = res[0].front();\n res[0].pop();\n }\n }\n else {\n if (!res[2].empty()) {\n ans[i] = res[2].front();\n res[2].pop();\n }\n else {\n ans[i] = res[0].front();\n res[0].pop();\n }\n }\n cout << ans[i] << \" \";\n }\n cout << endl;\n \n return 0;\n}\n", "language": "C++", "metadata": {"date": 1583721553, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02749.html", "problem_id": "p02749", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02749/input.txt", "sample_output_relpath": "derived/input_output/data/p02749/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02749/C++/s321899550.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s321899550", "user_id": "u488493347"}, "prompt_components": {"gold_output": "1 2 5 4 3\n", "input_to_evaluate": "#include \nusing namespace std;\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define whole(x) (x).begin(),(x).end()\n#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())\nusing ll = long long;\nusing P = pair;\nconst int mod = 1000000007;\n\nvector to[200005];\n//int root[200005];\nint depth[200005];\n\nvoid dfs(int v, int p=-1) {\n if (p==-1) depth[v] = 0;\n else {\n depth[v] = depth[p]+1;\n }\n for(int e: to[v]) {\n if(e==p) continue;\n dfs(e, v);\n }\n \n}\n\nint main(){\n int n;\n cin >> n;\n vector p(n);\n rep(i, n-1) {\n int a, b;\n cin >> a >> b;\n a--; b--;\n if (a>b) swap(a, b);\n to[a].push_back(b);\n to[b].push_back(a);\n }\n dfs(0, -1);\n int odd = 0;\n int even = 0;\n rep(i, n) {\n if (depth[i]%2) odd++;\n else even++;\n }\n int mod3[3];\n rep(i, 3) {\n if (n%3==0) {\n mod3[0] = n/3;\n mod3[1] = n/3;\n mod3[2] = n/3;\n }\n else if (n%3==1) {\n mod3[0] = n/3;\n mod3[1] = n/3+1;\n mod3[2] = n/3+1;\n }\n else {\n mod3[0] = n/3;\n mod3[1] = n/3+1;\n mod3[2] = n/3+1;\n }\n }\n if (max(odd, even)>(mod3[0]+mod3[1])) {\n cout << \"-1\" << endl;\n return 0;\n }\n \n vector ans(n);\n queue res[3];\n rep(i, n) {\n int v = (i+1)%3;\n res[v].push(i+1);\n }\n if (even>odd) {\n rep(i, n) {\n depth[i]++;\n }\n }\n rep(i, n) {\n if(depth[i]%2) {\n if (!res[1].empty()) {\n ans[i] = res[1].front();\n res[1].pop();\n }\n else {\n ans[i] = res[0].front();\n res[0].pop();\n }\n }\n else {\n if (!res[2].empty()) {\n ans[i] = res[2].front();\n res[2].pop();\n }\n else {\n ans[i] = res[0].front();\n res[0].pop();\n }\n }\n cout << ans[i] << \" \";\n }\n cout << endl;\n \n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nTakahashi loves the number 3. He is seeking a permutation p_1, p_2, \\ldots , p_N of integers from 1 to N satisfying the following condition:\n\nFor every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.\n\nHere the distance between Vertex i and Vertex j is the number of edges contained in the shortest path from Vertex i to Vertex j.\n\nHelp Takahashi by finding a permutation that satisfies the condition.\n\nConstraints\n\n2\\leq N\\leq 2\\times 10^5\n\n1\\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nIf no permutation satisfies the condition, print -1.\n\nOtherwise, print a permutation satisfying the condition, with space in between.\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n5\n1 2\n1 3\n3 4\n3 5\n\nSample Output 1\n\n1 2 5 4 3\n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\np_2 + p_4 = 6\n\np_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition.", "sample_input": "5\n1 2\n1 3\n3 4\n3 5\n"}, "reference_outputs": ["1 2 5 4 3\n"], "source_document_id": "p02749", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nTakahashi loves the number 3. He is seeking a permutation p_1, p_2, \\ldots , p_N of integers from 1 to N satisfying the following condition:\n\nFor every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.\n\nHere the distance between Vertex i and Vertex j is the number of edges contained in the shortest path from Vertex i to Vertex j.\n\nHelp Takahashi by finding a permutation that satisfies the condition.\n\nConstraints\n\n2\\leq N\\leq 2\\times 10^5\n\n1\\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nIf no permutation satisfies the condition, print -1.\n\nOtherwise, print a permutation satisfying the condition, with space in between.\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n5\n1 2\n1 3\n3 4\n3 5\n\nSample Output 1\n\n1 2 5 4 3\n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\np_2 + p_4 = 6\n\np_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2194, "cpu_time_ms": 222, "memory_kb": 20224}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s235372052", "group_id": "codeNet:p02750", "input_text": "#include \nusing namespace std;\n\ntemplate\nvoid out(T x) { cout << x << endl; exit(0); }\n#define watch(x) cout << (#x) << \" is \" << (x) << endl\n\n\n\n\n\nusing ll = long long;\n\nconst ll mod = 1e9+7;\nconst int maxn = 1e3 + 5;\nconst ll inf = 1e18;\n\n\nstruct store {\n ll a, b;\n void read() {\n\tcin>>a>>b;\n }\n bool operator<(const store&o ) const {\n\t//return b/a < o.b/o.a;\n\treturn (1+b)*o.a < (1+o.b)*a;\n }\n};\n\nint n;\nll T;\n\n\nvoid relax(ll &x, ll y) {\n x = min(x, y);\n}\n\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\n cin>>n>>T;\n vector v;\n vector B;\n for (int i=0; i 1e9\n // a(aT+b+1)+b -> a^i -> exponential time increase\n\n vector dp(N+1, inf);\n dp[0] = 0;\n\n for (int i=0; i<(int)v.size(); i++) {\n\tfor (int j=N; j>=0; j--) {\n\t if (dp[j] < T) {\n\t\trelax(dp[j+1], dp[j] + 1 + ((dp[j]+1)*v[i].a + v[i].b));\n\t }\n\t}\n }\n\n\n\n sort(B.begin(), B.end());\n vector cost;\n cost.push_back(0);\n for (int i=1; i<(int)B.size(); i++) {\n\tB[i] += B[i-1];\n }\n for (int i=0; i<(int)B.size(); i++) {\n\tcost.push_back((i+1) + B[i]);\n }\n\n\n int hi = 0;\n for (int i=0; i<=N; i++) {\n\tif (dp[i] <= T) {\n\t ll leftover = T-dp[i];\n\t auto iter = std::prev(upper_bound(cost.begin(), cost.end(), leftover));\n\t int take = i + (iter-cost.begin());\n\t //watch(iter-cost.begin());\n\t hi = max(hi, take);\n\t}\n }\n\n cout<\nusing namespace std;\n\ntemplate\nvoid out(T x) { cout << x << endl; exit(0); }\n#define watch(x) cout << (#x) << \" is \" << (x) << endl\n\n\n\n\n\nusing ll = long long;\n\nconst ll mod = 1e9+7;\nconst int maxn = 1e3 + 5;\nconst ll inf = 1e18;\n\n\nstruct store {\n ll a, b;\n void read() {\n\tcin>>a>>b;\n }\n bool operator<(const store&o ) const {\n\t//return b/a < o.b/o.a;\n\treturn (1+b)*o.a < (1+o.b)*a;\n }\n};\n\nint n;\nll T;\n\n\nvoid relax(ll &x, ll y) {\n x = min(x, y);\n}\n\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\n cin>>n>>T;\n vector v;\n vector B;\n for (int i=0; i 1e9\n // a(aT+b+1)+b -> a^i -> exponential time increase\n\n vector dp(N+1, inf);\n dp[0] = 0;\n\n for (int i=0; i<(int)v.size(); i++) {\n\tfor (int j=N; j>=0; j--) {\n\t if (dp[j] < T) {\n\t\trelax(dp[j+1], dp[j] + 1 + ((dp[j]+1)*v[i].a + v[i].b));\n\t }\n\t}\n }\n\n\n\n sort(B.begin(), B.end());\n vector cost;\n cost.push_back(0);\n for (int i=1; i<(int)B.size(); i++) {\n\tB[i] += B[i-1];\n }\n for (int i=0; i<(int)B.size(); i++) {\n\tcost.push_back((i+1) + B[i]);\n }\n\n\n int hi = 0;\n for (int i=0; i<=N; i++) {\n\tif (dp[i] <= T) {\n\t ll leftover = T-dp[i];\n\t auto iter = std::prev(upper_bound(cost.begin(), cost.end(), leftover));\n\t int take = i + (iter-cost.begin());\n\t //watch(iter-cost.begin());\n\t hi = max(hi, take);\n\t}\n }\n\n cout<\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define sz(x) int(x.size())\nusing namespace std;\n\ntypedef long long ll;\n// const int INF = 1e8;\nconst ll INF = 1LL << 60;\ntypedef pair P;\n\nll N, M;\n\nint main() {\n cin >> N >> M;\n ll n = pow(2, N) - 1;\n ll m = pow(2, M) - 1;\n\n if (n == 1) {\n rep(i, m) {\n cout << 1;\n }\n cout << endl;\n return 0;\n } else if (m == 1) {\n rep(i, n) {\n cout << 1 << endl;\n }\n return 0;\n }\n\n rep(i, n) {\n rep(j, m) {\n if (i == 0 && j == 0) cout << 0;\n else cout << 1;\n }\n cout << endl;\n }\n}", "language": "C++", "metadata": {"date": 1583722027, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02751.html", "problem_id": "p02751", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02751/input.txt", "sample_output_relpath": "derived/input_output/data/p02751/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02751/C++/s224271966.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s224271966", "user_id": "u455366471"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define sz(x) int(x.size())\nusing namespace std;\n\ntypedef long long ll;\n// const int INF = 1e8;\nconst ll INF = 1LL << 60;\ntypedef pair P;\n\nll N, M;\n\nint main() {\n cin >> N >> M;\n ll n = pow(2, N) - 1;\n ll m = pow(2, M) - 1;\n\n if (n == 1) {\n rep(i, m) {\n cout << 1;\n }\n cout << endl;\n return 0;\n } else if (m == 1) {\n rep(i, n) {\n cout << 1 << endl;\n }\n return 0;\n }\n\n rep(i, n) {\n rep(j, m) {\n if (i == 0 && j == 0) cout << 0;\n else cout << 1;\n }\n cout << endl;\n }\n}", "problem_context": "Score : 900 points\n\nProblem Statement\n\nWe have a grid with (2^N - 1) rows and (2^M-1) columns.\nYou are asked to write 0 or 1 in each of these squares.\nLet a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.\n\nFor a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\\leq i_1 \\leq i_2\\leq 2^N-1, 1\\leq j_1 \\leq j_2\\leq 2^M-1, let\nS(i_1, i_2, j_1, j_2) = \\displaystyle \\sum_{r=i_1}^{i_2}\\sum_{c=j_1}^{j_2}a_{r,c}.\nThen, let the oddness of the grid be the number of quadruples (i_1, i_2, j_1, j_2) such that S(i_1, i_2, j_1, j_2) is odd.\n\nFind a way to fill in the grid that maximizes its oddness.\n\nConstraints\n\nN and M are integers between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint numbers to write in the grid so that its oddness is maximized, in the following format:\n\na_{1,1}a_{1,2}\\cdots a_{1,2^M-1}\na_{2,1}a_{2,2}\\cdots a_{2,2^M-1}\n\\vdots\na_{2^N-1,1}a_{2^N-1,2}\\cdots a_{2^N-1,2^M-1}\n\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\n111\n\nFor this grid, S(1, 1, 1, 1), S(1, 1, 2, 2), S(1, 1, 3, 3), and S(1, 1, 1, 3) are odd, so it has the oddness of 4.\n\nWe cannot make the oddness 5 or higher, so this is one of the ways that maximize the oddness.", "sample_input": "1 2\n"}, "reference_outputs": ["111\n"], "source_document_id": "p02751", "source_text": "Score : 900 points\n\nProblem Statement\n\nWe have a grid with (2^N - 1) rows and (2^M-1) columns.\nYou are asked to write 0 or 1 in each of these squares.\nLet a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.\n\nFor a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\\leq i_1 \\leq i_2\\leq 2^N-1, 1\\leq j_1 \\leq j_2\\leq 2^M-1, let\nS(i_1, i_2, j_1, j_2) = \\displaystyle \\sum_{r=i_1}^{i_2}\\sum_{c=j_1}^{j_2}a_{r,c}.\nThen, let the oddness of the grid be the number of quadruples (i_1, i_2, j_1, j_2) such that S(i_1, i_2, j_1, j_2) is odd.\n\nFind a way to fill in the grid that maximizes its oddness.\n\nConstraints\n\nN and M are integers between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint numbers to write in the grid so that its oddness is maximized, in the following format:\n\na_{1,1}a_{1,2}\\cdots a_{1,2^M-1}\na_{2,1}a_{2,2}\\cdots a_{2,2^M-1}\n\\vdots\na_{2^N-1,1}a_{2^N-1,2}\\cdots a_{2^N-1,2^M-1}\n\nIf there are multiple solutions, you can print any of them.\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\n111\n\nFor this grid, S(1, 1, 1, 1), S(1, 1, 2, 2), S(1, 1, 3, 3), and S(1, 1, 1, 3) are odd, so it has the oddness of 4.\n\nWe cannot make the oddness 5 or higher, so this is one of the ways that maximize the oddness.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 687, "cpu_time_ms": 52, "memory_kb": 1280}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s009978965", "group_id": "codeNet:p02753", "input_text": "#include \n#define pi 3.14159\nusing namespace std;\n\nint main()\n {\n \tstring s;\n \tcin>>s;\n \tif(s[0]==s[1]&&s[1]==s[2])\n \t\tcout<<\"No\"<\n#define pi 3.14159\nusing namespace std;\n\nint main()\n {\n \tstring s;\n \tcin>>s;\n \tif(s[0]==s[1]&&s[1]==s[2])\n \t\tcout<<\"No\"<\n#define rep(i, n) for(int i = 0; i < n; i++)\n \nusing namespace std;\n \nint main() {\n int N, A, B, ans;\n cin >> N >> A >> B;\n int x = N / (A + B);\n if(N % (A + B) == 0){\n ans = A * x;\n }\n else{ \n ans = A * x + min(A, N - ((A + B) * x));\n }\n cout << ans << endl;\n \n}", "language": "C++", "metadata": {"date": 1583641097, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/C++/s020571343.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s020571343", "user_id": "u684002488"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \n#define rep(i, n) for(int i = 0; i < n; i++)\n \nusing namespace std;\n \nint main() {\n int N, A, B, ans;\n cin >> N >> A >> B;\n int x = N / (A + B);\n if(N % (A + B) == 0){\n ans = A * x;\n }\n else{ \n ans = A * x + min(A, N - ((A + B) * x));\n }\n cout << ans << endl;\n \n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 98, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s872451548", "group_id": "codeNet:p02754", "input_text": "#include\nusing namespace std;\nint main()\n{\n int n, a ,b, c=0, cntball=0;\n string s=\"\";\n cin>>n>>a>>b;\n for(int i=0 ; i\nusing namespace std;\nint main()\n{\n int n, a ,b, c=0, cntball=0;\n string s=\"\";\n cin>>n>>a>>b;\n for(int i=0 ; i\nusing namespace std;\nint main(){\n long long n,a,b,ans=0;\n cin>>n>>a>>b;\n ans+=(n%(a+b))*a;\n n-=(n%(a+b))*a;\n if(n>=a) ans+=a;\n else ans+=n;\n cout<\nusing namespace std;\nint main(){\n long long n,a,b,ans=0;\n cin>>n>>a>>b;\n ans+=(n%(a+b))*a;\n n-=(n%(a+b))*a;\n if(n>=a) ans+=a;\n else ans+=n;\n cout<\nusing namespace std;\n\nusing ll = long long ;\nint main()\n{\n ll N, A, B;\n cin >> N >> A >> B;\n\n if(A == 0 && B == 0) \n {\n cout << 0 << endl;\n return 0;\n }\n if(A == 0) \n {\n cout << 0 << endl;\n return 0;\n }\n\n ll quotient = N /(A+B);\n ll rem = N % (A+B);\n\n\n ll result = A*quotient ;\n if(rem <= A)\n {\n result += rem;\n }\n else\n {\n result += rem;\n }\n \n cout << result << endl;\n\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1583633812, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02754/input.txt", "sample_output_relpath": "derived/input_output/data/p02754/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02754/C++/s203601883.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s203601883", "user_id": "u090445726"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\n\nusing ll = long long ;\nint main()\n{\n ll N, A, B;\n cin >> N >> A >> B;\n\n if(A == 0 && B == 0) \n {\n cout << 0 << endl;\n return 0;\n }\n if(A == 0) \n {\n cout << 0 << endl;\n return 0;\n }\n\n ll quotient = N /(A+B);\n ll rem = N % (A+B);\n\n\n ll result = A*quotient ;\n if(rem <= A)\n {\n result += rem;\n }\n else\n {\n result += rem;\n }\n \n cout << result << endl;\n\n\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 510, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s023138029", "group_id": "codeNet:p02755", "input_text": "#include \n\nusing namespace std;\n\nint SolveTaxIncrease(int A, int B) {\n for (int p = 10 * B; p <= 10 * B + 9; ++p) {\n const int tax = 8 * p / 100;\n if (tax == A) return p;\n }\n return -1;\n}\n\nint main() {\n int A, B;\n cin >> A >> B;\n cout << SolveTaxIncrease(A, B) << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1583643829, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/C++/s023138029.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023138029", "user_id": "u090097090"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint SolveTaxIncrease(int A, int B) {\n for (int p = 10 * B; p <= 10 * B + 9; ++p) {\n const int tax = 8 * p / 100;\n if (tax == A) return p;\n }\n return -1;\n}\n\nint main() {\n int A, B;\n cin >> A >> B;\n cout << SolveTaxIncrease(A, B) << endl;\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 307, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s240389328", "group_id": "codeNet:p02755", "input_text": "#include\n#include\nusing namespace std;\n\nint main()\n{\n int n, k;\n cin >> n >> k;\n\n int x = ceil((100*n)/8);\n\n if(ceil((x/10)) == k)\n cout << x << endl;\n else\n cout << \"-1\" << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1583637209, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/C++/s240389328.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s240389328", "user_id": "u044179865"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "#include\n#include\nusing namespace std;\n\nint main()\n{\n int n, k;\n cin >> n >> k;\n\n int x = ceil((100*n)/8);\n\n if(ceil((x/10)) == k)\n cout << x << endl;\n else\n cout << \"-1\" << endl;\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s806221926", "group_id": "codeNet:p02756", "input_text": "#include \n#define be(v) (v).begin(),(v).end()\n#define pb(q) push_back(q)\ntypedef long long ll;\nusing namespace std;\nconst ll mod=1000000007, INF=mod*mod*3LL;\n#define doublecout(a) cout< dq;\n string s;\n bool maki = 0;\n int q,t,a;\n char b;\n cin >> s >> q;\n int n = s.length();\n for(int i=0;i> t;\n \tif(t == 1) maki ^= 1;\n \telse {\n \t\tcin >> a >> b;\n \t\tif((a == 1) ^ maki){\n \t\t\tdq.push_front((b - 'a'));\n \t\t}else{\n \t\t\tdq.push_back((b - 'a'));\n \t\t}\n \t}\n }\n if(maki){\n \twhile(!dq.empty()){\n \t\tcout << char('a' + dq.back());\n \t\tdq.pop_back();\n \t}\n }else{\n \twhile(!dq.empty()){\n \t\tcout << char('a' + dq.front());\n \t\tdq.pop_front();\n \t}\n }\n cout << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1590801133, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02756/input.txt", "sample_output_relpath": "derived/input_output/data/p02756/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02756/C++/s806221926.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806221926", "user_id": "u192903163"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "#include \n#define be(v) (v).begin(),(v).end()\n#define pb(q) push_back(q)\ntypedef long long ll;\nusing namespace std;\nconst ll mod=1000000007, INF=mod*mod*3LL;\n#define doublecout(a) cout< dq;\n string s;\n bool maki = 0;\n int q,t,a;\n char b;\n cin >> s >> q;\n int n = s.length();\n for(int i=0;i> t;\n \tif(t == 1) maki ^= 1;\n \telse {\n \t\tcin >> a >> b;\n \t\tif((a == 1) ^ maki){\n \t\t\tdq.push_front((b - 'a'));\n \t\t}else{\n \t\t\tdq.push_back((b - 'a'));\n \t\t}\n \t}\n }\n if(maki){\n \twhile(!dq.empty()){\n \t\tcout << char('a' + dq.back());\n \t\tdq.pop_back();\n \t}\n }else{\n \twhile(!dq.empty()){\n \t\tcout << char('a' + dq.front());\n \t\tdq.pop_front();\n \t}\n }\n cout << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 964, "cpu_time_ms": 34, "memory_kb": 1872}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s486002171", "group_id": "codeNet:p02756", "input_text": "#include \n#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)\n#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)\nusing namespace std;\ntemplate \nusing vec = vector;\nusing lint = long long;\nusing ulint = unsigned long long;\nusing pint = pair;\nusing plint = pair;\n\ntemplate \nostream& operator <<(ostream& os, pair p) {\n os << \"(\";\n os << p.first << \", \" << p.second;\n return os << \")\";\n}\n\ntemplate \nostream& operator <<(ostream& os, vec v) {\n os << \"[\";\n if (v.size() == 0) return os << \"]\";\n for (int i = 0; i < v.size() - 1; i++) {\n os << v.at(i) << \", \";\n }\n return os << v.at(v.size() - 1) << \"]\";\n}\n\ntemplate \nostream& operator <<(ostream& os, set& s) {\n os << \"{\";\n if (s.begin() == s.end()) return os << \"}\";\n auto it_first_item = s.begin();\n os << *it_first_item;\n for (auto it = ++it_first_item; it != s.end(); it++) {\n os << \", \" << *it;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, unordered_set& s) {\n os << \"{\";\n if (s.begin() == s.end()) return os << \"}\";\n auto it_first_item = s.begin();\n os << *it_first_item;\n for (auto it = ++it_first_item; it != s.end(); it++) {\n os << \", \" << *it;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, map m) {\n os << \"{\";\n if (m.begin() == m.end()) return os << \"}\";\n auto it_first_item = m.begin();\n os << it_first_item->first << \": \" << it_first_item->second;\n for (auto it = ++it_first_item; it != m.end(); it++) {\n os << \", \" << it->first << \": \" << it->second;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, unordered_map m) {\n os << \"{\";\n if (m.begin() == m.end()) return os << \"}\";\n auto it_first_item = m.begin();\n os << it_first_item->first << \": \" << it_first_item->second;\n for (auto it = ++it_first_item; it != m.end(); it++) {\n os << \", \" << it->first << \": \" << it->second;\n }\n return os << \"}\";\n}\n\nlint pow(lint num, lint e, lint MOD) {\n lint res = 1;\n lint cur_num = num;\n while (e) {\n if (e & 1) {\n res *= cur_num;\n res %= MOD;\n }\n cur_num *= cur_num;\n cur_num %= MOD;\n e >>= 1;\n }\n return res;\n}\n\nint main() {\n cin.tie(0); cout.tie(0);\n ios::sync_with_stdio(false);\n cout << fixed << setprecision(10);\n string S; cin >> S;\n deque cur_S;\n range(i, 0, S.size()) cur_S.emplace_back(S.at(i));\n lint Q; cin >> Q;\n range(_, 0, Q) {\n lint q_type; cin >> q_type;\n if (q_type == 1) {\n char front, back;\n front = cur_S.front(); \n back = cur_S.back();\n cur_S.at(0) = back;\n cur_S.at(cur_S.size() - 1) = front;\n }\n else {\n lint f; cin >> f;\n char c; cin >> c;\n if (f == 1) cur_S.emplace_front(c);\n else cur_S.emplace_back(c);\n }\n }\n for (const char& c : cur_S) cout << c;\n cout << '\\n';\n}", "language": "C++", "metadata": {"date": 1585097742, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02756/input.txt", "sample_output_relpath": "derived/input_output/data/p02756/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02756/C++/s486002171.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s486002171", "user_id": "u069838609"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "#include \n#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)\n#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)\nusing namespace std;\ntemplate \nusing vec = vector;\nusing lint = long long;\nusing ulint = unsigned long long;\nusing pint = pair;\nusing plint = pair;\n\ntemplate \nostream& operator <<(ostream& os, pair p) {\n os << \"(\";\n os << p.first << \", \" << p.second;\n return os << \")\";\n}\n\ntemplate \nostream& operator <<(ostream& os, vec v) {\n os << \"[\";\n if (v.size() == 0) return os << \"]\";\n for (int i = 0; i < v.size() - 1; i++) {\n os << v.at(i) << \", \";\n }\n return os << v.at(v.size() - 1) << \"]\";\n}\n\ntemplate \nostream& operator <<(ostream& os, set& s) {\n os << \"{\";\n if (s.begin() == s.end()) return os << \"}\";\n auto it_first_item = s.begin();\n os << *it_first_item;\n for (auto it = ++it_first_item; it != s.end(); it++) {\n os << \", \" << *it;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, unordered_set& s) {\n os << \"{\";\n if (s.begin() == s.end()) return os << \"}\";\n auto it_first_item = s.begin();\n os << *it_first_item;\n for (auto it = ++it_first_item; it != s.end(); it++) {\n os << \", \" << *it;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, map m) {\n os << \"{\";\n if (m.begin() == m.end()) return os << \"}\";\n auto it_first_item = m.begin();\n os << it_first_item->first << \": \" << it_first_item->second;\n for (auto it = ++it_first_item; it != m.end(); it++) {\n os << \", \" << it->first << \": \" << it->second;\n }\n return os << \"}\";\n}\n\ntemplate \nostream& operator <<(ostream& os, unordered_map m) {\n os << \"{\";\n if (m.begin() == m.end()) return os << \"}\";\n auto it_first_item = m.begin();\n os << it_first_item->first << \": \" << it_first_item->second;\n for (auto it = ++it_first_item; it != m.end(); it++) {\n os << \", \" << it->first << \": \" << it->second;\n }\n return os << \"}\";\n}\n\nlint pow(lint num, lint e, lint MOD) {\n lint res = 1;\n lint cur_num = num;\n while (e) {\n if (e & 1) {\n res *= cur_num;\n res %= MOD;\n }\n cur_num *= cur_num;\n cur_num %= MOD;\n e >>= 1;\n }\n return res;\n}\n\nint main() {\n cin.tie(0); cout.tie(0);\n ios::sync_with_stdio(false);\n cout << fixed << setprecision(10);\n string S; cin >> S;\n deque cur_S;\n range(i, 0, S.size()) cur_S.emplace_back(S.at(i));\n lint Q; cin >> Q;\n range(_, 0, Q) {\n lint q_type; cin >> q_type;\n if (q_type == 1) {\n char front, back;\n front = cur_S.front(); \n back = cur_S.back();\n cur_S.at(0) = back;\n cur_S.at(cur_S.size() - 1) = front;\n }\n else {\n lint f; cin >> f;\n char c; cin >> c;\n if (f == 1) cur_S.emplace_front(c);\n else cur_S.emplace_back(c);\n }\n }\n for (const char& c : cur_S) cout << c;\n cout << '\\n';\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3232, "cpu_time_ms": 32, "memory_kb": 976}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s705971115", "group_id": "codeNet:p02756", "input_text": "#include \n#include \n#include \n\nvoid solve() {\n std::string str;\n std::deque d;\n int q;\n bool reverse = false;\n std::cin >> str >> q;\n for (int i = 0; i < str.size(); i++) d.push_back(str[i]);\n \n for (int i = 0; i < q; i++) {\n int t;\n if (t == 1) reverse = (!reverse);\n else {\n int f;\n char c;\n std::cin >> f >> c;\n if (f == 1 && !reverse || f == 2 && reverse) d.push_front(c);\n else d.push_back(c);\n }\n }\n if (reverse)\n for (std::deque::reverse_iterator i = d.rbegin(); i != d.rend(); i++)\n std::cout << *i;\n else\n for (std::deque::iterator i = d.begin(); i != d.end(); ++i)\n std::cout << *i;\n}\nint main() {\n solve();\n return 0;\n}", "language": "C++", "metadata": {"date": 1583849478, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02756/input.txt", "sample_output_relpath": "derived/input_output/data/p02756/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02756/C++/s705971115.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s705971115", "user_id": "u420345622"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "#include \n#include \n#include \n\nvoid solve() {\n std::string str;\n std::deque d;\n int q;\n bool reverse = false;\n std::cin >> str >> q;\n for (int i = 0; i < str.size(); i++) d.push_back(str[i]);\n \n for (int i = 0; i < q; i++) {\n int t;\n if (t == 1) reverse = (!reverse);\n else {\n int f;\n char c;\n std::cin >> f >> c;\n if (f == 1 && !reverse || f == 2 && reverse) d.push_front(c);\n else d.push_back(c);\n }\n }\n if (reverse)\n for (std::deque::reverse_iterator i = d.rbegin(); i != d.rend(); i++)\n std::cout << *i;\n else\n for (std::deque::iterator i = d.begin(); i != d.end(); ++i)\n std::cout << *i;\n}\nint main() {\n solve();\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 739, "cpu_time_ms": 17, "memory_kb": 896}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s507966726", "group_id": "codeNet:p02756", "input_text": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\ntypedef vector vdd;\n\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define all(x) (x).begin(),(x).end()\n#define INF 1000000000000\n#define MOD 1000000007\n#define PB push_back\n#define MP make_pair\n#define F first\n#define S second\n\ninline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }\ninline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }\ninline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }\ninline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }\ninline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }\ninline ll modInverse(ll a) { return modPow(a, MOD-2); }\ninline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }\n\nll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\nll lcm(ll a,ll b){return a*b/gcd(a,b);}\n\nint ctoi(char c) {\n\tif (c >= '0' && c <= '9') {\n\t\treturn c - '0';\n\t}\n\treturn 0;\n}\n\nint main(){\n string s;int q;cin>>s>>q;\n int t[q],f[q];\n char c[q];\n deque d;\n rep(i,s.size()){\n d.push_back(s[i]);\n }\n rep(i,q){\n cin>>t[i];\n if(t[i]==2){\n cin>>f[i]>>c[i];\n }\n }\n bool a=true;\n rep(i,q){\n if(t[i]==1){\n if(a)a=false;\n else a=true;\n }\n else{\n if(f[i]==1){\n if(a){\n d.push_front(c[i]);\n }\n else{\n d.push_back(c[i]);\n }\n }\n if(f[i]==2){\n if(!a){\n d.push_front(c[i]);\n }\n else{\n d.push_back(c[i]);\n }\n }\n }\n }\n if(!a) reverse(all(d));\n rep(i,d.size())cout<\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\ntypedef vector vdd;\n\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define all(x) (x).begin(),(x).end()\n#define INF 1000000000000\n#define MOD 1000000007\n#define PB push_back\n#define MP make_pair\n#define F first\n#define S second\n\ninline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }\ninline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }\ninline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }\ninline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }\ninline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }\ninline ll modInverse(ll a) { return modPow(a, MOD-2); }\ninline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }\n\nll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\nll lcm(ll a,ll b){return a*b/gcd(a,b);}\n\nint ctoi(char c) {\n\tif (c >= '0' && c <= '9') {\n\t\treturn c - '0';\n\t}\n\treturn 0;\n}\n\nint main(){\n string s;int q;cin>>s>>q;\n int t[q],f[q];\n char c[q];\n deque d;\n rep(i,s.size()){\n d.push_back(s[i]);\n }\n rep(i,q){\n cin>>t[i];\n if(t[i]==2){\n cin>>f[i]>>c[i];\n }\n }\n bool a=true;\n rep(i,q){\n if(t[i]==1){\n if(a)a=false;\n else a=true;\n }\n else{\n if(f[i]==1){\n if(a){\n d.push_front(c[i]);\n }\n else{\n d.push_back(c[i]);\n }\n }\n if(f[i]==2){\n if(!a){\n d.push_front(c[i]);\n }\n else{\n d.push_back(c[i]);\n }\n }\n }\n }\n if(!a) reverse(all(d));\n rep(i,d.size())cout<\nusing namespace std;\nstring c,st;\nchar zsd;\nint len;\nint q,l,f;\nint main() {\n\tcin>>c>>q;len=c.size();\n\twhile(q--)\n\t{\n\t\tcin>>l;\n\t\tif(l==1) \n\t\t{\n\t\t\tfor(int i=0;i\nusing namespace std;\nstring c,st;\nchar zsd;\nint len;\nint q,l,f;\nint main() {\n\tcin>>c>>q;len=c.size();\n\twhile(q--)\n\t{\n\t\tcin>>l;\n\t\tif(l==1) \n\t\t{\n\t\t\tfor(int i=0;i\nusing namespace std;\n#define ll long long\n#define INF -99999999\ntypedef pair P;\nint main(void)\n{\n string S;\n cin >> S;\n ll Q;\n cin >> Q;\n\n bool swap = false;\n\n for (ll i = 0; i < Q; i++)\n {\n ll T;\n cin >> T;\n\n if (T == 1)\n {\n swap = !swap;\n continue;\n }\n else\n {\n ll F;\n cin >> F;\n string C;\n cin >> C;\n if (!swap)\n {\n if (F == 1)\n {\n S = C+S;\n }\n else\n {\n S += C;\n }\n }\n else{\n if(F==1){\n S+=C;\n }\n else{\n S = C+S;\n }\n }\n }\n }\n\n if (swap)\n {\n reverse(S.begin(), S.end());\n }\n \n cout<\nusing namespace std;\n#define ll long long\n#define INF -99999999\ntypedef pair P;\nint main(void)\n{\n string S;\n cin >> S;\n ll Q;\n cin >> Q;\n\n bool swap = false;\n\n for (ll i = 0; i < Q; i++)\n {\n ll T;\n cin >> T;\n\n if (T == 1)\n {\n swap = !swap;\n continue;\n }\n else\n {\n ll F;\n cin >> F;\n string C;\n cin >> C;\n if (!swap)\n {\n if (F == 1)\n {\n S = C+S;\n }\n else\n {\n S += C;\n }\n }\n else{\n if(F==1){\n S+=C;\n }\n else{\n S = C+S;\n }\n }\n }\n }\n\n if (swap)\n {\n reverse(S.begin(), S.end());\n }\n \n cout<\n#define debug(x) cerr << #x << \": \" << x << endl;\n\nusing namespace std;\nusing ll = long long;\nusing ii = pair;\nusing vi = vector;\n\nconst int MAX { 1000010 };\nconst ll MOD { 1000000007 };\nconst double PI = acos(-1.0);\n\nint main(){\n\tios::sync_with_stdio(false);\n map c;\n for(int i=0; i<3; ++i)\n for(int j=0; j<3; ++j){\n int aux;\n cin >> aux;\n c[aux] = make_pair(i, j);\n }\n\n int N;\n int I[3] = {}, J[3] = {};\n cin >> N;\n while(N--){\n int aux;\n cin >> aux;\n if (c.find(aux) != c.end()){\n debug(aux);\n ii v = c[aux];\n debug(v.first);\n debug(v.second);\n I[v.first]++;\n J[v.second]++;\n }\n }\n\n int aux_dig = 0;\n for(int i=0; i<3; ++i){\n debug(I[i]);\n debug(J[i]);\n if(I[i] && J[i]) aux_dig++;\n\n if(I[i] == 3 || J[i] == 3){\n cout << \"Yes\\n\";\n return 0;\n }\n }\n\n aux_dig == 3? cout << \"Yes\\n\" : cout << \"No\\n\";\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1598689162, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/C++/s869739262.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s869739262", "user_id": "u863370423"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#define debug(x) cerr << #x << \": \" << x << endl;\n\nusing namespace std;\nusing ll = long long;\nusing ii = pair;\nusing vi = vector;\n\nconst int MAX { 1000010 };\nconst ll MOD { 1000000007 };\nconst double PI = acos(-1.0);\n\nint main(){\n\tios::sync_with_stdio(false);\n map c;\n for(int i=0; i<3; ++i)\n for(int j=0; j<3; ++j){\n int aux;\n cin >> aux;\n c[aux] = make_pair(i, j);\n }\n\n int N;\n int I[3] = {}, J[3] = {};\n cin >> N;\n while(N--){\n int aux;\n cin >> aux;\n if (c.find(aux) != c.end()){\n debug(aux);\n ii v = c[aux];\n debug(v.first);\n debug(v.second);\n I[v.first]++;\n J[v.second]++;\n }\n }\n\n int aux_dig = 0;\n for(int i=0; i<3; ++i){\n debug(I[i]);\n debug(J[i]);\n if(I[i] && J[i]) aux_dig++;\n\n if(I[i] == 3 || J[i] == 3){\n cout << \"Yes\\n\";\n return 0;\n }\n }\n\n aux_dig == 3? cout << \"Yes\\n\" : cout << \"No\\n\";\n\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1096, "cpu_time_ms": 8, "memory_kb": 3596}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s137209205", "group_id": "codeNet:p02760", "input_text": "#include \n#include \nusing namespace std;\n\n#define COUT(x) cout << #x << \" = \" << (x) << \" (L\" << __LINE__ << \")\" << endl\ntemplate ostream& operator << (ostream &s, pair P)\n{ return s << '<' << P.first << \", \" << P.second << '>'; }\ntemplate ostream& operator << (ostream &s, vector P)\n{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << \" \"; } s << P[i]; } return s; }\ntemplate ostream& operator << (ostream &s, vector > P)\n{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }\ntemplate ostream& operator << (ostream &s, set P)\n{ for(auto it : P) { s << \"<\" << it << \"> \"; } return s << endl; }\ntemplate ostream& operator << (ostream &s, map P)\n{ for(auto it : P) { s << \"<\" << it.first << \"->\" << it.second << \"> \"; } return s << endl; }\n\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define rrep(i, n) for (int i = 1; i <= (n); ++i)\n#define drep(i, n) for (int i = (n)-1; i >= 0; --i)\n#define ddrep(i, n) for (int i = n; i > 0; --i)\n#define srep(i, s, t) for (int i = s; i < t; ++i)\n#define ssrep(i, s, t) for (int i = s; i <= t; ++i)\n\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\nusing ll = long long;\nusing pi = pair;\nusing vi = vector;\nusing vvi = vector;\nusing vl = vector;\nusing vvl = vector;\nusing ld = long double;\nusing str = string;\n\n#define rng(a) a.begin(), a.end()\n#define rrng(a) a.rbegin(), a.rend()\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\nlong int M = 1e+9+7;\nint inf = 1e+9;\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n cout << std::setprecision(10);\n\n int ans=0;\n vvi a(3,vi(3));\n vvi flag(3,vi(3));\n rep(i,3){\n rep(j,3){\n cin >> a[i][j];\n }\n }\n int n;\n cin >> n;\n vi b(n);\n rep(i,n){\n cin >> b[i];\n rep(j,3){\n rep(k,3){\n if(b[i] == a[j][k]) flag[j][k] = 1;\n }\n }\n }\n\n rep(i,3){\n if(flag[i][0] && flag[i][1] && flag[i][2]) ans++;\n if(flag[0][i] && flag[1][i] && flag[2][i]) ans++;\n }\n if(flag[0][0] && flag[1][1] && flag[2][2]) ans++;\n if(flag[0][2] && flag[1][1] && flag[2][0]) ans++;\n\n /*\n rep(i,3){\n rep(j,3){\n cout << flag[i][j] << \" \";\n }\n cout << endl;\n }\n */\n\n if(ans) cout << \"Yes\" << endl;\n else cout << \"No\" << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1590021083, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/C++/s137209205.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137209205", "user_id": "u636706582"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\n#define COUT(x) cout << #x << \" = \" << (x) << \" (L\" << __LINE__ << \")\" << endl\ntemplate ostream& operator << (ostream &s, pair P)\n{ return s << '<' << P.first << \", \" << P.second << '>'; }\ntemplate ostream& operator << (ostream &s, vector P)\n{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << \" \"; } s << P[i]; } return s; }\ntemplate ostream& operator << (ostream &s, vector > P)\n{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }\ntemplate ostream& operator << (ostream &s, set P)\n{ for(auto it : P) { s << \"<\" << it << \"> \"; } return s << endl; }\ntemplate ostream& operator << (ostream &s, map P)\n{ for(auto it : P) { s << \"<\" << it.first << \"->\" << it.second << \"> \"; } return s << endl; }\n\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define rrep(i, n) for (int i = 1; i <= (n); ++i)\n#define drep(i, n) for (int i = (n)-1; i >= 0; --i)\n#define ddrep(i, n) for (int i = n; i > 0; --i)\n#define srep(i, s, t) for (int i = s; i < t; ++i)\n#define ssrep(i, s, t) for (int i = s; i <= t; ++i)\n\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\nusing ll = long long;\nusing pi = pair;\nusing vi = vector;\nusing vvi = vector;\nusing vl = vector;\nusing vvl = vector;\nusing ld = long double;\nusing str = string;\n\n#define rng(a) a.begin(), a.end()\n#define rrng(a) a.rbegin(), a.rend()\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\nlong int M = 1e+9+7;\nint inf = 1e+9;\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n cout << std::setprecision(10);\n\n int ans=0;\n vvi a(3,vi(3));\n vvi flag(3,vi(3));\n rep(i,3){\n rep(j,3){\n cin >> a[i][j];\n }\n }\n int n;\n cin >> n;\n vi b(n);\n rep(i,n){\n cin >> b[i];\n rep(j,3){\n rep(k,3){\n if(b[i] == a[j][k]) flag[j][k] = 1;\n }\n }\n }\n\n rep(i,3){\n if(flag[i][0] && flag[i][1] && flag[i][2]) ans++;\n if(flag[0][i] && flag[1][i] && flag[2][i]) ans++;\n }\n if(flag[0][0] && flag[1][1] && flag[2][2]) ans++;\n if(flag[0][2] && flag[1][1] && flag[2][0]) ans++;\n\n /*\n rep(i,3){\n rep(j,3){\n cout << flag[i][j] << \" \";\n }\n cout << endl;\n }\n */\n\n if(ans) cout << \"Yes\" << endl;\n else cout << \"No\" << endl;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2643, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s056228792", "group_id": "codeNet:p02760", "input_text": "#include \n#include\n#include\n#include\nusing namespace std;\n#define rep(N) for(int i=0;i>A(3);\n\trep(3)A[i].resize(3);\n\trep2(3, 3)\n\t\tcin >> A[i][j];\n\tint N;\n\tcin >> N;\n\tvectorb(N);\n\trep(N)cin >> b[i];\n\tFor(i, N) {\n\t\tFor(j, 3) {\n\t\t\tFor(k, 3) {\n\t\t\t\tif (b[i] == A[j][k])\n\t\t\t\t\tA[j][k] = 0;\n\t\t\t}\n\t\t}\n\t}\n\tint flag = 0;\n\tint flag2 = 1;\n\tvectorvflag(8, 1);\n\trep(3) {\n\t\tif (A[0][i] != 0)\n\t\t\tvflag[0] = 0;\n\t\tif (A[1][i] != 0)\n\t\t\tvflag[1] = 0;\n\t\tif (A[2][i] != 0)\n\t\t\tvflag[2] = 0;\n\t\tif (A[i][0] != 0)\n\t\t\tvflag[3] = 0;\n\t\tif (A[i][1] != 0)\n\t\t\tvflag[4] = 0;\n\t\tif (A[i][2] != 0)\n\t\t\tvflag[5] = 0;\n\t\tif (A[i][i] != 0)\n\t\t\tvflag[6] = 0;\n\t\tif (A[2 - i][i] != 0)\n\t\t\tvflag[7] = 0;\n\t}\n\trep(8) {\n\t\tif (vflag[i] == 1)\n\t\t\tflag = 1;\n\t}\n\tYn(flag);\n\n}", "language": "C++", "metadata": {"date": 1587921247, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02760/input.txt", "sample_output_relpath": "derived/input_output/data/p02760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02760/C++/s056228792.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s056228792", "user_id": "u868344991"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#include\n#include\n#include\nusing namespace std;\n#define rep(N) for(int i=0;i>A(3);\n\trep(3)A[i].resize(3);\n\trep2(3, 3)\n\t\tcin >> A[i][j];\n\tint N;\n\tcin >> N;\n\tvectorb(N);\n\trep(N)cin >> b[i];\n\tFor(i, N) {\n\t\tFor(j, 3) {\n\t\t\tFor(k, 3) {\n\t\t\t\tif (b[i] == A[j][k])\n\t\t\t\t\tA[j][k] = 0;\n\t\t\t}\n\t\t}\n\t}\n\tint flag = 0;\n\tint flag2 = 1;\n\tvectorvflag(8, 1);\n\trep(3) {\n\t\tif (A[0][i] != 0)\n\t\t\tvflag[0] = 0;\n\t\tif (A[1][i] != 0)\n\t\t\tvflag[1] = 0;\n\t\tif (A[2][i] != 0)\n\t\t\tvflag[2] = 0;\n\t\tif (A[i][0] != 0)\n\t\t\tvflag[3] = 0;\n\t\tif (A[i][1] != 0)\n\t\t\tvflag[4] = 0;\n\t\tif (A[i][2] != 0)\n\t\t\tvflag[5] = 0;\n\t\tif (A[i][i] != 0)\n\t\t\tvflag[6] = 0;\n\t\tif (A[2 - i][i] != 0)\n\t\t\tvflag[7] = 0;\n\t}\n\trep(8) {\n\t\tif (vflag[i] == 1)\n\t\t\tflag = 1;\n\t}\n\tYn(flag);\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1193, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s519440209", "group_id": "codeNet:p02762", "input_text": "#include\nusing namespace std;\nvectorvect[100001];\nvectorblock[100001];\nsetr;\n\nvoid dfs(bool visited[],int src)\n{\n r.insert(src);\n visited[src]=true;\n\n for(int i=0;i>n>>m>>k;\n\n for(int i=1;i<=m;i++)\n {\n int u,v;\n cin>>u>>v;\n\n vect[u].push_back(v);\n vect[v].push_back(u);\n }\n for(int i=1;i<=k;i++)\n {\n int u,v;\n cin>>u>>v;\n\n block[u].push_back(v);\n block[v].push_back(u);\n }\n\n bool visited[n+1]={false};\n\n int arr[n+1];\n\n for(int i=1;i<=n;i++)\n {\n if(visited[i]==false)\n {\n r.clear();\n dfs(visited,i);\n\n for(auto itr = r.begin();itr!=r.end();itr++)\n {\n int x = (*itr);\n\n arr[x] = r.size()-vect[x].size()-1;\n\n for(int j=0;j\nusing namespace std;\nvectorvect[100001];\nvectorblock[100001];\nsetr;\n\nvoid dfs(bool visited[],int src)\n{\n r.insert(src);\n visited[src]=true;\n\n for(int i=0;i>n>>m>>k;\n\n for(int i=1;i<=m;i++)\n {\n int u,v;\n cin>>u>>v;\n\n vect[u].push_back(v);\n vect[v].push_back(u);\n }\n for(int i=1;i<=k;i++)\n {\n int u,v;\n cin>>u>>v;\n\n block[u].push_back(v);\n block[v].push_back(u);\n }\n\n bool visited[n+1]={false};\n\n int arr[n+1];\n\n for(int i=1;i<=n;i++)\n {\n if(visited[i]==false)\n {\n r.clear();\n dfs(visited,i);\n\n for(auto itr = r.begin();itr!=r.end();itr++)\n {\n int x = (*itr);\n\n arr[x] = r.size()-vect[x].size()-1;\n\n for(int j=0;j\n\nusing namespace std;\n\ntypedef long long int ll;\n\nconst ll mod = 1e9 + 7;\nconst ll MAXN = 5e5 + 5;\n\nvector < vector < ll > > t(4 * MAXN, vector < ll > (26, 0));\nll n;\nstring s;\n\nvoid build(ll v, ll tl, ll tr){\n if(tl == tr){\n t[v][s[tl] - 'a']++;\n }else{\n ll tm = (tr - tl) / 2 + tl;\n build(2 * v, tl, tm);\n build(2 * v + 1, tm + 1, tr);\n for(int i = 0; i < 26; i++) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];\n }\n}\n\nvoid update(ll v, ll tl, ll tr, ll pos, char ch){\n if(tl == tr){\n t[v][s[tl] - 'a']--;\n t[v][ch - 'a']++;\n }else{\n ll tm = (tr - tl) / 2 + tl;\n if(pos <= tm) update(2 * v, tl, tm, pos, ch);\n else update(2 * v + 1, tm + 1, tr, pos, ch);\n for(int i = 0; i < 26; i++) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];\n }\n}\n\nvector < ll > query(ll v, ll tl, ll tr, ll l, ll r){\n if(l > r){\n vector < ll > tmp(26, 0);\n return tmp;\n }\n if(tl == l && tr == r){\n return t[v];\n }else{\n ll tm = (tr - tl) / 2 + tl;\n vector < ll > a = query(2 * v, tl, tm, l, min(r, tm));\n vector < ll > b = query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);\n for(int i = 0; i < 26; i++) a[i] += b[i];\n return a;\n }\n}\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(0);cout.tie(0);\n\n cin >> n;\n cin >> s;\n\n build(1, 0, n - 1);\n\n ll q;\n cin >> q;\n while(q--){\n int a;\n cin >> a;\n if(a == 1){\n ll pos;\n cin >> pos;\n char ch;\n cin >> ch;\n update(1, 0, n - 1, pos - 1, ch);\n s[pos - 1] = ch;\n }else{\n ll l, r;\n cin >> l >> r;\n vector < ll > ans = query(1, 0, n - 1, l - 1, r - 1);\n ll cnt = 0;\n for(int i = 0; i < 26; i++){\n if(ans[i]) cnt++;\n }\n cout << cnt << '\\n';\n }\n }\n}\n", "language": "C++", "metadata": {"date": 1587809961, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02763/input.txt", "sample_output_relpath": "derived/input_output/data/p02763/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02763/C++/s319140982.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s319140982", "user_id": "u929156598"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "#include\n\nusing namespace std;\n\ntypedef long long int ll;\n\nconst ll mod = 1e9 + 7;\nconst ll MAXN = 5e5 + 5;\n\nvector < vector < ll > > t(4 * MAXN, vector < ll > (26, 0));\nll n;\nstring s;\n\nvoid build(ll v, ll tl, ll tr){\n if(tl == tr){\n t[v][s[tl] - 'a']++;\n }else{\n ll tm = (tr - tl) / 2 + tl;\n build(2 * v, tl, tm);\n build(2 * v + 1, tm + 1, tr);\n for(int i = 0; i < 26; i++) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];\n }\n}\n\nvoid update(ll v, ll tl, ll tr, ll pos, char ch){\n if(tl == tr){\n t[v][s[tl] - 'a']--;\n t[v][ch - 'a']++;\n }else{\n ll tm = (tr - tl) / 2 + tl;\n if(pos <= tm) update(2 * v, tl, tm, pos, ch);\n else update(2 * v + 1, tm + 1, tr, pos, ch);\n for(int i = 0; i < 26; i++) t[v][i] = t[2 * v][i] + t[2 * v + 1][i];\n }\n}\n\nvector < ll > query(ll v, ll tl, ll tr, ll l, ll r){\n if(l > r){\n vector < ll > tmp(26, 0);\n return tmp;\n }\n if(tl == l && tr == r){\n return t[v];\n }else{\n ll tm = (tr - tl) / 2 + tl;\n vector < ll > a = query(2 * v, tl, tm, l, min(r, tm));\n vector < ll > b = query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);\n for(int i = 0; i < 26; i++) a[i] += b[i];\n return a;\n }\n}\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(0);cout.tie(0);\n\n cin >> n;\n cin >> s;\n\n build(1, 0, n - 1);\n\n ll q;\n cin >> q;\n while(q--){\n int a;\n cin >> a;\n if(a == 1){\n ll pos;\n cin >> pos;\n char ch;\n cin >> ch;\n update(1, 0, n - 1, pos - 1, ch);\n s[pos - 1] = ch;\n }else{\n ll l, r;\n cin >> l >> r;\n vector < ll > ans = query(1, 0, n - 1, l - 1, r - 1);\n ll cnt = 0;\n for(int i = 0; i < 26; i++){\n if(ans[i]) cnt++;\n }\n cout << cnt << '\\n';\n }\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "sample_input": "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"}, "reference_outputs": ["3\n1\n5\n"], "source_document_id": "p02763", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\n\nProcess Q queries of the following two types:\n\nType 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n\nType 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\nConstraints\n\nN, Q, i_q, l_q, and r_q are integers.\n\nS is a string consisting of lowercase English letters.\n\nc_q is a lowercase English letter.\n\n1 \\leq N \\leq 500000\n\n1 \\leq Q \\leq 20000\n\n|S| = N\n\n1 \\leq i_q \\leq N\n\n1 \\leq l_q \\leq r_q \\leq N\n\nThere is at least one query of type 2 in each testcase.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n\n1 i_q c_q\n\n2 l_q r_q\n\nOutput\n\nFor each query of type 2, print a line containing the answer.\n\nSample Input 1\n\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\nSample Output 1\n\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\n\nIn the second query, S is modified to abcdzbd.\n\nIn the third query, a contains one kind of letter: a, so we print 1.\n\nIn the fourth query, S is modified to abcazbd.\n\nIn the fifth query, S does not change and is still abcazbd.\n\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1744, "cpu_time_ms": 426, "memory_kb": 485524}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s863947419", "group_id": "codeNet:p02764", "input_text": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 65;\nconst double pi = acos(-1.0);\n\ndouble x[maxn], y[maxn], c[maxn];\nint n, k;\n\ndouble t[maxn];\n\ninline double sqr(double x){\n return x * x;\n}\n\ninline double dist(double x1,double y1,double x2, double y2){\n return sqrt(sqr(x1 - x2) + sqr(y1 - y2));\n}\n\ndouble calc_time(double c_x,double c_y){\n for (int i = 1;i <= n;i++){\n t[i] = dist(c_x,c_y,x[i],y[i]) * c[i];\n }\n nth_element(t+1,t + k, t+n+1);\n return t[k];\n}\n\nint main(int argc, const char * argv[]) {\n cin >> n >> k;\n for (int i = 1;i <= n;i++){\n cin >> x[i] >> y[i] >> c[i];\n }\n random_device rd;\n mt19937 gen(rd());\n uniform_real_distribution<> dis2(-1000, 1000);\n double init_x = dis2(gen);\n double init_y = dis2(gen);\n\n double radius = 1500;\n double ans = calc_time(init_x,init_y);\n \n\n //hyperparemeters\n double alpha = 0.97;\n int rounds = 750;\n int randoms = 900;\n \n \n\n while (rounds--){\n double best_x = 0;\n double best_y = 0;\n double cur_best = 1e15;\n uniform_real_distribution<> dis(-radius, radius);\n for (int i = 1;i <= randoms;i++){\n double nx = init_x + dis(gen);\n double ny = init_y + dis(gen);\n double score = calc_time(nx, ny);\n if (score < cur_best){\n cur_best = score;\n best_x = nx;\n best_y = ny;\n }\n }\n if (cur_best < ans){\n init_x = best_x;\n init_y = best_y;\n ans = min(ans, cur_best);\n }\n\n radius *= alpha;\n }\n cout << fixed << setprecision(8);\n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1584508160, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02764.html", "problem_id": "p02764", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02764/input.txt", "sample_output_relpath": "derived/input_output/data/p02764/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02764/C++/s863947419.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863947419", "user_id": "u222846612"}, "prompt_components": {"gold_output": "2.4\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 65;\nconst double pi = acos(-1.0);\n\ndouble x[maxn], y[maxn], c[maxn];\nint n, k;\n\ndouble t[maxn];\n\ninline double sqr(double x){\n return x * x;\n}\n\ninline double dist(double x1,double y1,double x2, double y2){\n return sqrt(sqr(x1 - x2) + sqr(y1 - y2));\n}\n\ndouble calc_time(double c_x,double c_y){\n for (int i = 1;i <= n;i++){\n t[i] = dist(c_x,c_y,x[i],y[i]) * c[i];\n }\n nth_element(t+1,t + k, t+n+1);\n return t[k];\n}\n\nint main(int argc, const char * argv[]) {\n cin >> n >> k;\n for (int i = 1;i <= n;i++){\n cin >> x[i] >> y[i] >> c[i];\n }\n random_device rd;\n mt19937 gen(rd());\n uniform_real_distribution<> dis2(-1000, 1000);\n double init_x = dis2(gen);\n double init_y = dis2(gen);\n\n double radius = 1500;\n double ans = calc_time(init_x,init_y);\n \n\n //hyperparemeters\n double alpha = 0.97;\n int rounds = 750;\n int randoms = 900;\n \n \n\n while (rounds--){\n double best_x = 0;\n double best_y = 0;\n double cur_best = 1e15;\n uniform_real_distribution<> dis(-radius, radius);\n for (int i = 1;i <= randoms;i++){\n double nx = init_x + dis(gen);\n double ny = init_y + dis(gen);\n double score = calc_time(nx, ny);\n if (score < cur_best){\n cur_best = score;\n best_x = nx;\n best_y = ny;\n }\n }\n if (cur_best < ans){\n init_x = best_x;\n init_y = best_y;\n ans = min(ans, cur_best);\n }\n\n radius *= alpha;\n }\n cout << fixed << setprecision(8);\n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \\left(x_i, y_i\\right), and its hardness is c_i.\n\nTakahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \\left(X, Y\\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \\times \\sqrt{\\left(X - x_i\\right)^2 + \\left(Y-y_i\\right)^2} seconds.\n\nTakahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 60\n\n1 \\leq K \\leq N\n\n-1000 \\leq x_i , y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) \\left(i \\neq j \\right)\n\n1 \\leq c_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\n\\vdots\nx_N y_N c_N\n\nOutput\n\nPrint the answer.\n\nIt will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n\nSample Output 1\n\n2.4\n\nIf we put the heat source at \\left(-0.2, 0\\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.\n\nSample Input 2\n\n10 5\n-879 981 26\n890 -406 81\n512 859 97\n362 -955 25\n128 553 17\n-885 763 2\n449 310 57\n-656 -204 11\n-270 76 40\n184 170 16\n\nSample Output 2\n\n7411.2252", "sample_input": "4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n"}, "reference_outputs": ["2.4\n"], "source_document_id": "p02764", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \\left(x_i, y_i\\right), and its hardness is c_i.\n\nTakahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \\left(X, Y\\right), where X and Y are real numbers, the i-th piece of meat will be ready to eat in c_i \\times \\sqrt{\\left(X - x_i\\right)^2 + \\left(Y-y_i\\right)^2} seconds.\n\nTakahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 60\n\n1 \\leq K \\leq N\n\n-1000 \\leq x_i , y_i \\leq 1000\n\n\\left(x_i, y_i\\right) \\neq \\left(x_j, y_j\\right) \\left(i \\neq j \\right)\n\n1 \\leq c_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\n\\vdots\nx_N y_N c_N\n\nOutput\n\nPrint the answer.\n\nIt will be considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n4 3\n-1 0 3\n0 0 3\n1 0 2\n1 1 40\n\nSample Output 1\n\n2.4\n\nIf we put the heat source at \\left(-0.2, 0\\right), the 1-st, 2-nd, and 3-rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.\n\nSample Input 2\n\n10 5\n-879 981 26\n890 -406 81\n512 859 97\n362 -955 25\n128 553 17\n-885 763 2\n449 310 57\n-656 -204 11\n-270 76 40\n184 170 16\n\nSample Output 2\n\n7411.2252", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1782, "cpu_time_ms": 384, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s699843919", "group_id": "codeNet:p02765", "input_text": "#define _GLIBCXX_DEBUG\n#include \n#define REP(i, n) for (int i = 0; i < (n); ++i)\n#define REPS(I, a, b) for (int i = (a); i < (b); ++i)\nusing namespace std;\nusing ll = long long;\n\nint main() {\n \n int n,r; \n cin >> n >> r;\n\n if(n < 10){\n r += 100 * (10-n);\n }\n \n cout << r << endl;\n}", "language": "C++", "metadata": {"date": 1599764170, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/C++/s699843919.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s699843919", "user_id": "u514896542"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "#define _GLIBCXX_DEBUG\n#include \n#define REP(i, n) for (int i = 0; i < (n); ++i)\n#define REPS(I, a, b) for (int i = (a); i < (b); ++i)\nusing namespace std;\nusing ll = long long;\n\nint main() {\n \n int n,r; \n cin >> n >> r;\n\n if(n < 10){\n r += 100 * (10-n);\n }\n \n cout << r << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 305, "cpu_time_ms": 6, "memory_kb": 3572}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s067800794", "group_id": "codeNet:p02765", "input_text": "#include \nusing namespace std;\n \nint main(){\n int n,r;\n cin >> n >> r;\n if(n < 10){\n \tr+=100*(10-n);\n }\n cout << r << endl;\n}", "language": "C++", "metadata": {"date": 1582424059, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/C++/s067800794.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s067800794", "user_id": "u262549958"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "#include \nusing namespace std;\n \nint main(){\n int n,r;\n cin >> n >> r;\n if(n < 10){\n \tr+=100*(10-n);\n }\n cout << r << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s019222752", "group_id": "codeNet:p02765", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\n\nint main(void){\n ll n, r;\n cin >> n >> r;\n if(n >= 10)\n cout << r << endl;\n else if(n < 10)\n cout << r + 100*(10-n) << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1582423341, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/C++/s019222752.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019222752", "user_id": "u157195505"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\n\nint main(void){\n ll n, r;\n cin >> n >> r;\n if(n >= 10)\n cout << r << endl;\n else if(n < 10)\n cout << r + 100*(10-n) << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s986142485", "group_id": "codeNet:p02766", "input_text": "#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\nint main(){\n long long n, k, c = 0;\n cin >> n >> k;\n while(n){\n n /= k;\n c++;\n }\n cout << c;\n}", "language": "C++", "metadata": {"date": 1582714530, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/C++/s986142485.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s986142485", "user_id": "u595984176"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#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\nint main(){\n long long n, k, c = 0;\n cin >> n >> k;\n while(n){\n n /= k;\n c++;\n }\n cout << c;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s901617987", "group_id": "codeNet:p02766", "input_text": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef int64_t i6;\n\n#define rep(i, n) for (ll i = 0; i < n; ++i)\n#define Sort(x) sort(x.begin(), x.end())\n#define Sort_rev(x) sort(x.begin(), x.end(), greater())\n#define ALL(v) (v).begin(), (v).end()\n\n// π M_PI\n// deg = rad*180/M_PI\n\nint main() {\n ll n, k;\n cin >> n >> k;\n ll ans = 0;\n while ( n > pow(k, ans) ) {\n // cout << ans << \" \" << pow(k, ans) << endl;\n ans++;\n }\n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1582433031, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/C++/s901617987.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s901617987", "user_id": "u745852541"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef int64_t i6;\n\n#define rep(i, n) for (ll i = 0; i < n; ++i)\n#define Sort(x) sort(x.begin(), x.end())\n#define Sort_rev(x) sort(x.begin(), x.end(), greater())\n#define ALL(v) (v).begin(), (v).end()\n\n// π M_PI\n// deg = rad*180/M_PI\n\nint main() {\n ll n, k;\n cin >> n >> k;\n ll ans = 0;\n while ( n > pow(k, ans) ) {\n // cout << ans << \" \" << pow(k, ans) << endl;\n ans++;\n }\n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 519, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s022668069", "group_id": "codeNet:p02766", "input_text": "//#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst double EPS = 1e-9;\ntypedef vector vint;\ntypedef pair pint;\n#define inf 1e+9\n#define rep(i, n) REP(i, 0, n)\n#define all(v) v.begin(), v.end()\n#define msg(a) cout << #a << \" \" << a << endl;\n#define REP(i, x, n) for(int i = x; i < n; i++)\n#define pri(a) cout << a << endl;\n\nint main(){\n cin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\n ll n,k,ans=0;\n cin >> n >> k;\n\n if(n>=1){\n ans++;\n }\n\n int i=1,h=k;\n while(n>=h){\n ans++;\n i++;\n h = pow(k,i);\n }\n\n\n pri(ans);\n\n}", "language": "C++", "metadata": {"date": 1582424080, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02766/input.txt", "sample_output_relpath": "derived/input_output/data/p02766/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02766/C++/s022668069.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s022668069", "user_id": "u220892578"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "//#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst double EPS = 1e-9;\ntypedef vector vint;\ntypedef pair pint;\n#define inf 1e+9\n#define rep(i, n) REP(i, 0, n)\n#define all(v) v.begin(), v.end()\n#define msg(a) cout << #a << \" \" << a << endl;\n#define REP(i, x, n) for(int i = x; i < n; i++)\n#define pri(a) cout << a << endl;\n\nint main(){\n cin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\n ll n,k,ans=0;\n cin >> n >> k;\n\n if(n>=1){\n ans++;\n }\n\n int i=1,h=k;\n while(n>=h){\n ans++;\n i++;\n h = pow(k,i);\n }\n\n\n pri(ans);\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "sample_input": "11 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02766", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is an integer N. Find the number of digits that N has in base K.\n\nNotes\n\nFor information on base-K representation, see Positional notation - Wikipedia.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^9\n\n2 \\leq K \\leq 10\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of digits that N has in base K.\n\nSample Input 1\n\n11 2\n\nSample Output 1\n\n4\n\nIn binary, 11 is represented as 1011.\n\nSample Input 2\n\n1010101 10\n\nSample Output 2\n\n7\n\nSample Input 3\n\n314159265 3\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 649, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s983532682", "group_id": "codeNet:p02767", "input_text": "#include\n#define ing long long \n#define rap(i,n) for(int i=0;i>n;\n for(int i=0;i>a[i];\n cum+=a[i];\n }\n cum = cum / n+1;\n for(int i=0;i\n#define ing long long \n#define rap(i,n) for(int i=0;i>n;\n for(int i=0;i>a[i];\n cum+=a[i];\n }\n cum = cum / n+1;\n for(int i=0;i\nusing namespace std;\n#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)\ntypedef long long ll;\nconst int maxn = 105;\nint a[maxn];\n\nint main()\n{\n IO;\n int n;\n cin >> n;\n for (int i = 1; i <= n; ++i)\n cin >> a[i];\n ll minn = 0x3f3f3f3f;\n for (int pos = 1; pos <= 100; ++pos)\n {\n ll t = 0;\n for (int i = 1; i <= n; ++i)\n t += (pos - a[i]) * (pos - a[i]);\n minn = min(minn, t);\n }\n cout << minn << endl;\n}", "language": "C++", "metadata": {"date": 1582424005, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02767/input.txt", "sample_output_relpath": "derived/input_output/data/p02767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02767/C++/s613636366.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s613636366", "user_id": "u035226457"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\n#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)\ntypedef long long ll;\nconst int maxn = 105;\nint a[maxn];\n\nint main()\n{\n IO;\n int n;\n cin >> n;\n for (int i = 1; i <= n; ++i)\n cin >> a[i];\n ll minn = 0x3f3f3f3f;\n for (int pos = 1; pos <= 100; ++pos)\n {\n ll t = 0;\n for (int i = 1; i <= n; ++i)\n t += (pos - a[i]) * (pos - a[i]);\n minn = min(minn, t);\n }\n cout << minn << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 504, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s907191769", "group_id": "codeNet:p02767", "input_text": "#include \nusing namespace std;\n\n#if DEBUG && !ONLINE_JUDGE\n #include \"header.h\"\n#else\n #define debug(args...)\n#endif\n\ntypedef vector vi;\ntypedef pair ii;\ntypedef long long lli;\ntypedef long double ld;\n\n#define pb push_back\n#define all(x) x.begin(),x.end()\n#define SZ(x) (int)(x).size()\n#define fi first\n#define se second\n#define lb lower_bound\n#define ub upper_bound\n#define rep(i,a,b) for(auto i=(a);i>n;\n vi x(n);\n rep(i,0,n) cin>>x[i];\n lli ans = 0;\n rep(i,0,n) ans += x[i];\n ans /= n;\n lli fans = MOD * 1LL * MOD;\n rep(k,ans-2,ans+2) {\n lli sum = 0;\n rep(i,0,n) sum += (x[i]-k)*1LL*(x[i]-k);\n fans = min(fans, sum);\n }\n cout<\nusing namespace std;\n\n#if DEBUG && !ONLINE_JUDGE\n #include \"header.h\"\n#else\n #define debug(args...)\n#endif\n\ntypedef vector vi;\ntypedef pair ii;\ntypedef long long lli;\ntypedef long double ld;\n\n#define pb push_back\n#define all(x) x.begin(),x.end()\n#define SZ(x) (int)(x).size()\n#define fi first\n#define se second\n#define lb lower_bound\n#define ub upper_bound\n#define rep(i,a,b) for(auto i=(a);i>n;\n vi x(n);\n rep(i,0,n) cin>>x[i];\n lli ans = 0;\n rep(i,0,n) ans += x[i];\n ans /= n;\n lli fans = MOD * 1LL * MOD;\n rep(k,ans-2,ans+2) {\n lli sum = 0;\n rep(i,0,n) sum += (x[i]-k)*1LL*(x[i]-k);\n fans = min(fans, sum);\n }\n cout<\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#include \n#include \n#include \n#include \n#include \n#include \ntemplate inline bool chmin(T& a, T b) {\n\tif (a > b) {\n\t\ta = b;\n\t\treturn true;\n\t}\n\treturn false;\n}\ntemplate inline bool chmax(T& a, T b) {\n\tif (a < b) {\n\t\ta = b;\n\t\treturn true;\n\t}\n\treturn false;\n}\nusing namespace std;\n#define int long long\n#define ll long long\n#define rep(i, n) for (ll i = 0; i < (n); i++)\n#define P pair\n#define sz(x) (ll)x.size()\n#define ALL(x) (x).begin(),(x).end()\n#define ALLR(x) (x).rbegin(),(x).rend()\n#define VE vector\n#define COUT(x) cout<<(x)<\n#define SE set\n#define PQ priority_queue\n#define PQR priority_queue>\n#define YES(n) cout << ((n) ? \"YES\" : \"NO\" ) << endl\n#define Yes(n) cout << ((n) ? \"Yes\" : \"No\" ) << endl\n#define EPS (1e-14)\n#define pb push_back\nlong long MOD = 1000000007;\n//const long long MOD = 998244353;\nconst long long INF = 1LL << 60;\nconst double PI = acos(-1.0);\nusing Graph = vector;\nstruct mint {\n\tll x; // typedef long long ll;\n\tmint(ll x = 0) :x((x%MOD + MOD) % MOD) {}\n\tmint operator-() const { return mint(-x); }\n\tmint& operator+=(const mint a) {\n\t\tif ((x += a.x) >= MOD) x -= MOD;\n\t\treturn *this;\n\t}\n\tmint& operator-=(const mint a) {\n\t\tif ((x += MOD - a.x) >= MOD) x -= MOD;\n\t\treturn *this;\n\t}\n\tmint& operator*=(const mint a) {\n\t\t(x *= a.x) %= MOD;\n\t\treturn *this;\n\t}\n\tmint operator+(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res += a;\n\t}\n\tmint operator-(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res -= a;\n\t}\n\tmint operator*(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res *= a;\n\t}\n\tmint pow(ll t) const {\n\t\tif (!t) return 1;\n\t\tmint a = pow(t >> 1);\n\t\ta *= a;\n\t\tif (t & 1) a *= *this;\n\t\treturn a;\n\t}\n\n\t// for prime MOD\n\tmint inv() const {\n\t\treturn pow(MOD - 2);\n\t}\n\tmint& operator/=(const mint a) {\n\t\treturn (*this) *= a.inv();\n\t}\n\tmint operator/(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res /= a;\n\t}\n\tfriend ostream& operator<<(ostream& os, const mint& m) {\n\t\tos << m.x;\n\t\treturn os;\n\t}\n};\nstruct combination {\n\tvector fact, ifact;\n\tcombination(int n) :fact(n + 1), ifact(n + 1) {\n\t\t//assert(n < MOD);\n\t\tfact[0] = 1;\n\t\tfor (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;\n\t\tifact[n] = fact[n].inv();\n\t\tfor (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;\n\t}\n\tmint operator()(int n, int k) {\n\t\tif (k < 0 || k > n) return 0;\n\t\treturn fact[n] * ifact[k] * ifact[n - k];\n\t}\n}com(200010);\nstruct Sieve {\n\tint n;\n\tvector f, primes;\n\t\n\tSieve(int n = 1) :n(n), f(n + 1) {\n\t\tf[0] = f[1] = -1;\n\t\tfor (ll i = 2; i <= n; ++i) {\n\t\t\tif (f[i]) continue;\n\t\t\tprimes.push_back(i);\n\t\t\tf[i] = i;\n\t\t\tfor (ll j = i * i; j <= n; j += i) {\n\t\t\t\tif (!f[j]) f[j] = i;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tbool isPrime(int x) { return f[x] == x; }\n\t\n\tvector factorList(int x) {\n\t\tvector res;\n\t\twhile (x != 1) {\n\t\t\tres.push_back(f[x]);\n\t\t\tx /= f[x];\n\t\t}\n\t\treturn res;\n\t}\n\t\n\tvector

factor(int x) {\n\t\tvector fl = factorList(x);\n\t\tif (fl.size() == 0) return {};\n\t\tvector

res(1, P(fl[0], 0));\n\t\tfor (int p : fl) {\n\t\t\tif (res.back().first == p) {\n\t\t\t\tres.back().second++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tres.emplace_back(p, 1);\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n};\nclass UnionFind {\npublic:\n\tvector par; \n\tvector siz; \n\n\t// Constructor\n\tUnionFind(ll sz_) : par(sz_), siz(sz_, 1) {\n\t\tfor (ll i = 0; i < sz_; ++i) par[i] = i; \n\t}\n\tvoid init(ll sz_) {\n\t\tpar.resize(sz_);\n\t\tsiz.resize(sz_, 1);\n\t\tfor (ll i = 0; i < sz_; ++i) par[i] = i; \n\t}\n\n\t// Member Function\n\t// Find\n\tll root(ll x) { \n\t\twhile (par[x] != x) {\n\t\t\tx = par[x] = par[par[x]]; \n\t\t}\n\t\treturn x;\n\t}\n\n\t// Union(Unite, Merge)\n\tbool merge(ll x, ll y) {\n\t\tx = root(x);\n\t\ty = root(y);\n\t\tif (x == y) return false;\n\t\t\n\t\tif (siz[x] < siz[y]) swap(x, y);\n\t\tsiz[x] += siz[y];\n\t\tpar[y] = x;\n\t\treturn true;\n\t}\n\n\tbool issame(ll x, ll y) {\n\t\treturn root(x) == root(y);\n\t}\n\n\tll size(ll x) {\n\t\treturn siz[root(x)];\n\t}\n};\ntemplate t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }\nll lcm(ll a, ll b) {\n\tll g = gcd(a, b);\n\treturn a * b / g;\n}\nbool prime(ll n) {\n\tfor (ll i = 2; i <= sqrt(n); i++) {\n\t\tif (n%i == 0)return false;\n\t}\n\treturn n != 1;\n}\nmap prime_factor(ll n) {\n\tmap ret;\n\tfor (ll i = 2; i * i <= n; i++) {\n\t\twhile (n % i == 0) {\n\t\t\tret[i]++;\n\t\t\tn /= i;\n\t\t}\n\t}\n\tif (n != 1) ret[n] = 1;\n\treturn ret;\n}\nll modinv(ll a, ll m) {\n\tll b = m, u = 1, v = 0;\n\twhile (b) {\n\t\tll t = a / b;\n\t\ta -= t * b; swap(a, b);\n\t\tu -= t * v; swap(u, v);\n\t}\n\tu %= m;\n\tif (u < 0) u += m;\n\treturn u;\n}\nvector> RunLength(string s) {\n\tif (s.size() == 0)return {};\n\tvector>res(1, pair(s[0], 0));\n\tfor (char p : s) {\n\t\tif (res.back().first == p) {\n\t\t\tres.back().second++;\n\t\t}\n\t\telse {\n\t\t\tres.emplace_back(p, 1);\n\t\t}\n\t}\n\treturn res;\n}\n// Digit Count\nint GetDigit(int num) {\n\treturn log10(num) + 1;\n}\n// bit calculation[how many \"1\"] (= __builtin_popcount())\nint bit_count(int n) {\n\tint cnt = 0;\n\twhile (n > 0) {\n\t\tif (n % 2 == 1)cnt++;\n\t\tn /= 2;\n\t}\n\treturn cnt;\n}\nmint POW(mint n, int p) {\n\tif (p == 0)return 1;\n\tif (p % 2 == 0) {\n\t\tmint t = POW(n, p / 2);\n\t\treturn t * t;\n\t}\n\treturn n * POW(n, p - 1);\n}\n\n\nconst int dx[4] = { 1,0,-1,0 };\nconst int dy[4] = { 0,1,0,-1 };\n\nstruct edge { ll to, cost; };\ntypedef long double ld;\n\nsigned main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\t//cout << fixed << setprecision(15);\n\tint n, a, b; cin >> n >> a >> b;\n\tmint ans = POW(2,n);\n\tans -= 1;\n\tmint tmp = 1;\n\trep(i, a) {\n\t\ttmp *= n - i;\n\t\ttmp /= i + 1;\n\t}\n\tans -= tmp;\n\ttmp = 1;\n\trep(i, b) {\n\t\ttmp *= n - i; tmp /= i + 1;\n\t}\n\tans -= tmp;\n\tcout << ans << endl;\n\treturn 0;\n\n}", "language": "C++", "metadata": {"date": 1584889698, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/C++/s312312066.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312312066", "user_id": "u809967037"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#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#include \n#include \n#include \n#include \n#include \n#include \n#include \ntemplate inline bool chmin(T& a, T b) {\n\tif (a > b) {\n\t\ta = b;\n\t\treturn true;\n\t}\n\treturn false;\n}\ntemplate inline bool chmax(T& a, T b) {\n\tif (a < b) {\n\t\ta = b;\n\t\treturn true;\n\t}\n\treturn false;\n}\nusing namespace std;\n#define int long long\n#define ll long long\n#define rep(i, n) for (ll i = 0; i < (n); i++)\n#define P pair\n#define sz(x) (ll)x.size()\n#define ALL(x) (x).begin(),(x).end()\n#define ALLR(x) (x).rbegin(),(x).rend()\n#define VE vector\n#define COUT(x) cout<<(x)<\n#define SE set\n#define PQ priority_queue\n#define PQR priority_queue>\n#define YES(n) cout << ((n) ? \"YES\" : \"NO\" ) << endl\n#define Yes(n) cout << ((n) ? \"Yes\" : \"No\" ) << endl\n#define EPS (1e-14)\n#define pb push_back\nlong long MOD = 1000000007;\n//const long long MOD = 998244353;\nconst long long INF = 1LL << 60;\nconst double PI = acos(-1.0);\nusing Graph = vector;\nstruct mint {\n\tll x; // typedef long long ll;\n\tmint(ll x = 0) :x((x%MOD + MOD) % MOD) {}\n\tmint operator-() const { return mint(-x); }\n\tmint& operator+=(const mint a) {\n\t\tif ((x += a.x) >= MOD) x -= MOD;\n\t\treturn *this;\n\t}\n\tmint& operator-=(const mint a) {\n\t\tif ((x += MOD - a.x) >= MOD) x -= MOD;\n\t\treturn *this;\n\t}\n\tmint& operator*=(const mint a) {\n\t\t(x *= a.x) %= MOD;\n\t\treturn *this;\n\t}\n\tmint operator+(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res += a;\n\t}\n\tmint operator-(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res -= a;\n\t}\n\tmint operator*(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res *= a;\n\t}\n\tmint pow(ll t) const {\n\t\tif (!t) return 1;\n\t\tmint a = pow(t >> 1);\n\t\ta *= a;\n\t\tif (t & 1) a *= *this;\n\t\treturn a;\n\t}\n\n\t// for prime MOD\n\tmint inv() const {\n\t\treturn pow(MOD - 2);\n\t}\n\tmint& operator/=(const mint a) {\n\t\treturn (*this) *= a.inv();\n\t}\n\tmint operator/(const mint a) const {\n\t\tmint res(*this);\n\t\treturn res /= a;\n\t}\n\tfriend ostream& operator<<(ostream& os, const mint& m) {\n\t\tos << m.x;\n\t\treturn os;\n\t}\n};\nstruct combination {\n\tvector fact, ifact;\n\tcombination(int n) :fact(n + 1), ifact(n + 1) {\n\t\t//assert(n < MOD);\n\t\tfact[0] = 1;\n\t\tfor (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;\n\t\tifact[n] = fact[n].inv();\n\t\tfor (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;\n\t}\n\tmint operator()(int n, int k) {\n\t\tif (k < 0 || k > n) return 0;\n\t\treturn fact[n] * ifact[k] * ifact[n - k];\n\t}\n}com(200010);\nstruct Sieve {\n\tint n;\n\tvector f, primes;\n\t\n\tSieve(int n = 1) :n(n), f(n + 1) {\n\t\tf[0] = f[1] = -1;\n\t\tfor (ll i = 2; i <= n; ++i) {\n\t\t\tif (f[i]) continue;\n\t\t\tprimes.push_back(i);\n\t\t\tf[i] = i;\n\t\t\tfor (ll j = i * i; j <= n; j += i) {\n\t\t\t\tif (!f[j]) f[j] = i;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tbool isPrime(int x) { return f[x] == x; }\n\t\n\tvector factorList(int x) {\n\t\tvector res;\n\t\twhile (x != 1) {\n\t\t\tres.push_back(f[x]);\n\t\t\tx /= f[x];\n\t\t}\n\t\treturn res;\n\t}\n\t\n\tvector

factor(int x) {\n\t\tvector fl = factorList(x);\n\t\tif (fl.size() == 0) return {};\n\t\tvector

res(1, P(fl[0], 0));\n\t\tfor (int p : fl) {\n\t\t\tif (res.back().first == p) {\n\t\t\t\tres.back().second++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tres.emplace_back(p, 1);\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n};\nclass UnionFind {\npublic:\n\tvector par; \n\tvector siz; \n\n\t// Constructor\n\tUnionFind(ll sz_) : par(sz_), siz(sz_, 1) {\n\t\tfor (ll i = 0; i < sz_; ++i) par[i] = i; \n\t}\n\tvoid init(ll sz_) {\n\t\tpar.resize(sz_);\n\t\tsiz.resize(sz_, 1);\n\t\tfor (ll i = 0; i < sz_; ++i) par[i] = i; \n\t}\n\n\t// Member Function\n\t// Find\n\tll root(ll x) { \n\t\twhile (par[x] != x) {\n\t\t\tx = par[x] = par[par[x]]; \n\t\t}\n\t\treturn x;\n\t}\n\n\t// Union(Unite, Merge)\n\tbool merge(ll x, ll y) {\n\t\tx = root(x);\n\t\ty = root(y);\n\t\tif (x == y) return false;\n\t\t\n\t\tif (siz[x] < siz[y]) swap(x, y);\n\t\tsiz[x] += siz[y];\n\t\tpar[y] = x;\n\t\treturn true;\n\t}\n\n\tbool issame(ll x, ll y) {\n\t\treturn root(x) == root(y);\n\t}\n\n\tll size(ll x) {\n\t\treturn siz[root(x)];\n\t}\n};\ntemplate t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }\nll lcm(ll a, ll b) {\n\tll g = gcd(a, b);\n\treturn a * b / g;\n}\nbool prime(ll n) {\n\tfor (ll i = 2; i <= sqrt(n); i++) {\n\t\tif (n%i == 0)return false;\n\t}\n\treturn n != 1;\n}\nmap prime_factor(ll n) {\n\tmap ret;\n\tfor (ll i = 2; i * i <= n; i++) {\n\t\twhile (n % i == 0) {\n\t\t\tret[i]++;\n\t\t\tn /= i;\n\t\t}\n\t}\n\tif (n != 1) ret[n] = 1;\n\treturn ret;\n}\nll modinv(ll a, ll m) {\n\tll b = m, u = 1, v = 0;\n\twhile (b) {\n\t\tll t = a / b;\n\t\ta -= t * b; swap(a, b);\n\t\tu -= t * v; swap(u, v);\n\t}\n\tu %= m;\n\tif (u < 0) u += m;\n\treturn u;\n}\nvector> RunLength(string s) {\n\tif (s.size() == 0)return {};\n\tvector>res(1, pair(s[0], 0));\n\tfor (char p : s) {\n\t\tif (res.back().first == p) {\n\t\t\tres.back().second++;\n\t\t}\n\t\telse {\n\t\t\tres.emplace_back(p, 1);\n\t\t}\n\t}\n\treturn res;\n}\n// Digit Count\nint GetDigit(int num) {\n\treturn log10(num) + 1;\n}\n// bit calculation[how many \"1\"] (= __builtin_popcount())\nint bit_count(int n) {\n\tint cnt = 0;\n\twhile (n > 0) {\n\t\tif (n % 2 == 1)cnt++;\n\t\tn /= 2;\n\t}\n\treturn cnt;\n}\nmint POW(mint n, int p) {\n\tif (p == 0)return 1;\n\tif (p % 2 == 0) {\n\t\tmint t = POW(n, p / 2);\n\t\treturn t * t;\n\t}\n\treturn n * POW(n, p - 1);\n}\n\n\nconst int dx[4] = { 1,0,-1,0 };\nconst int dy[4] = { 0,1,0,-1 };\n\nstruct edge { ll to, cost; };\ntypedef long double ld;\n\nsigned main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\t//cout << fixed << setprecision(15);\n\tint n, a, b; cin >> n >> a >> b;\n\tmint ans = POW(2,n);\n\tans -= 1;\n\tmint tmp = 1;\n\trep(i, a) {\n\t\ttmp *= n - i;\n\t\ttmp /= i + 1;\n\t}\n\tans -= tmp;\n\ttmp = 1;\n\trep(i, b) {\n\t\ttmp *= n - i; tmp /= i + 1;\n\t}\n\tans -= tmp;\n\tcout << ans << endl;\n\treturn 0;\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6133, "cpu_time_ms": 332, "memory_kb": 3328}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s100130684", "group_id": "codeNet:p02768", "input_text": "#include \nusing namespace std;\n\nint kaizyou(int x,int y);\nint main(){\n int N=0;\n int a=0;\n int b=0;\n int result=0;\n cin >> N >> a >> b;\n for(int i=1;i<=N;i++){\n if((i==a)||(i==b)){\n continue;\n }else{\n result+=kaizyou(N,i)/kaizyou(i,i);\n }\n }\n cout << result << endl;\n}\nint kaizyou(int x,int y){\n int point=x;\n int result=1;\n for(int i=1;i\nusing namespace std;\n\nint kaizyou(int x,int y);\nint main(){\n int N=0;\n int a=0;\n int b=0;\n int result=0;\n cin >> N >> a >> b;\n for(int i=1;i<=N;i++){\n if((i==a)||(i==b)){\n continue;\n }else{\n result+=kaizyou(N,i)/kaizyou(i,i);\n }\n }\n cout << result << endl;\n}\nint kaizyou(int x,int y){\n int point=x;\n int result=1;\n for(int i=1;i\nusing namespace std;\n#define rep(i,n) for(int i=0;i;\nusing vint = vector;using vvint = vector>;\nusing vll = vector;using vvll = vector>;\ntemplatebool chmax(T &a, const T &b){if(abool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}\ntemplate void initvv(vector > &v, int a, int b, const T &t = T()){\n v.assign(a, vector(b, t));\n}\ntemplate T gcd(T &a, T &b){if(a>n>>a>>b;\n ll base = pow2(2, n) - 1;\n \n ll par = 1;\n ll chil = 1;\n for(int i = n;i>n-min(a, n-a);i--){\n //if(i<=n+1-i)break;\n par = par*i%mod;\n chil = chil*(n+1-i)%mod;\n }\n ll minusa = par*pow2(chil, mod-2) % mod;\n par = 1;\n chil = 1;\n for(int i = n;i>n-min(b, n-b);i--){\n //if(i<=n+1-i)break;\n par = par*i%mod;\n chil = chil*(n+1-i)%mod;\n }\n ll minusb = par*pow2(chil, mod-2) % mod;\n debug(\"nf %d\\n\", base);\n cout << (base - minusa - minusb + mod) % mod << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1582463219, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02768/input.txt", "sample_output_relpath": "derived/input_output/data/p02768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02768/C++/s054791758.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s054791758", "user_id": "u398437835"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include \nusing namespace std;\n#define rep(i,n) for(int i=0;i;\nusing vint = vector;using vvint = vector>;\nusing vll = vector;using vvll = vector>;\ntemplatebool chmax(T &a, const T &b){if(abool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}\ntemplate void initvv(vector > &v, int a, int b, const T &t = T()){\n v.assign(a, vector(b, t));\n}\ntemplate T gcd(T &a, T &b){if(a>n>>a>>b;\n ll base = pow2(2, n) - 1;\n \n ll par = 1;\n ll chil = 1;\n for(int i = n;i>n-min(a, n-a);i--){\n //if(i<=n+1-i)break;\n par = par*i%mod;\n chil = chil*(n+1-i)%mod;\n }\n ll minusa = par*pow2(chil, mod-2) % mod;\n par = 1;\n chil = 1;\n for(int i = n;i>n-min(b, n-b);i--){\n //if(i<=n+1-i)break;\n par = par*i%mod;\n chil = chil*(n+1-i)%mod;\n }\n ll minusb = par*pow2(chil, mod-2) % mod;\n debug(\"nf %d\\n\", base);\n cout << (base - minusa - minusb + mod) % mod << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1848, "cpu_time_ms": 9, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s804868368", "group_id": "codeNet:p02769", "input_text": "// warm heart, wagging tail,and a smile just for you!\n// ██���████████\n// ███╬╬╬╬╬╬╬╬╬╬███\n// ███╬╬╬╬╬████╬╬╬╬╬╬███\n// ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██\n// █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██\n// ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██\n// ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██\n// ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██\n// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████\n// █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████\n// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██\n// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███\n// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██\n// ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████\n// ███████ █████ ███████████████████ \n//\n#include \"bits/stdc++.h\"\nusing namespace std;\n#define INF (1LL<<60)\n#define fs first\n#define sc second\n#define int long long\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)\n#define REP(i,n) FOR(i,0,(n))\n#define RREP(i,n) RFOR(i,0,(n))\n#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)\n#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)\n#define range(i,a,b) ((a)<=(i) && (i)<(b))\n#define debug(x) cout << #x << \" = \" << (x) << endl\n#define SP << \" \" << \ntemplate inline void chmin(T1 &a,T2 b){if(a>b) a=b;}\ntemplate inline void chmax(T1 &a,T2 b){if(a P;\ntypedef tuple T;\n\nvector MODS = { 1000000007, 998244353 }; // 実行時に決まる\ntemplate struct Fp {\n long long val;\n \n int MOD = MODS[IND];\n constexpr Fp(long long v = 0) noexcept : val(v % MODS[IND]) {\n if (val < 0) val += MOD;\n }\n constexpr int getmod() { return MOD; }\n constexpr Fp operator - () const noexcept {\n return val ? MOD - val : 0;\n }\n constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }\n constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }\n constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }\n constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }\n constexpr Fp& operator += (const Fp& r) noexcept {\n val += r.val;\n if (val >= MOD) val -= MOD;\n return *this;\n }\n constexpr Fp& operator -= (const Fp& r) noexcept {\n val -= r.val;\n if (val < 0) val += MOD;\n return *this;\n }\n constexpr Fp& operator *= (const Fp& r) noexcept {\n val = val * r.val % MOD;\n return *this;\n }\n constexpr Fp& operator /= (const Fp& r) noexcept {\n long long a = r.val, b = MOD, u = 1, v = 0;\n while (b) {\n long long t = a / b;\n a -= t * b; swap(a, b);\n u -= t * v; swap(u, v);\n }\n val = val * u % MOD;\n if (val < 0) val += MOD;\n return *this;\n }\n constexpr bool operator == (const Fp& r) const noexcept {\n return this->val == r.val;\n }\n constexpr bool operator != (const Fp& r) const noexcept {\n return this->val != r.val;\n }\n friend constexpr ostream& operator << (ostream &os, const Fp& x) noexcept {\n return os << x.val;\n }\n friend constexpr istream& operator >> (istream &is, Fp& x) noexcept {\n return is >> x.val;\n }\n friend constexpr Fp modpow(const Fp &a, long long n) noexcept {\n if (n == 0) return 1;\n auto t = modpow(a, n / 2);\n t = t * t;\n if (n & 1) t = t * a;\n return t;\n }\n};\nusing mint = Fp<0>; // MODを変える場合は値を変更\ntypedef vector vec;\ntypedef vector> mat;\n\nsigned main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n int n,k;\n cin >> n >> k;\n\n vec fact(n+10,1),inv(n+10,1);\n REP(i,n+5) fact[i+1] = fact[i]*(i+1), inv[i+1] /= fact[i+1];\n\n chmin(k,n-1);\n mint ans = 0;\n REP(i,k+1){\n mint c = fact[n]*inv[i]*inv[n-i];\n ans += c*fact[n-1]*inv[i]*inv[n-1-i];\n // debug(ans);\n }\n\n cout << ans << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1582407101, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02769.html", "problem_id": "p02769", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02769/input.txt", "sample_output_relpath": "derived/input_output/data/p02769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02769/C++/s804868368.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s804868368", "user_id": "u239493918"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "// warm heart, wagging tail,and a smile just for you!\n// ███████████\n// ███╬╬╬╬╬╬╬╬╬╬███\n// ███╬╬╬╬╬████╬╬╬╬╬╬███\n// ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██\n// █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██\n// ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██\n// ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██\n// ���██╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██\n// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████\n// █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████\n// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██\n// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███\n// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████\n// ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██\n// ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████\n// ███████ █████ ███████████████████ \n//\n#include \"bits/stdc++.h\"\nusing namespace std;\n#define INF (1LL<<60)\n#define fs first\n#define sc second\n#define int long long\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)\n#define REP(i,n) FOR(i,0,(n))\n#define RREP(i,n) RFOR(i,0,(n))\n#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)\n#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)\n#define range(i,a,b) ((a)<=(i) && (i)<(b))\n#define debug(x) cout << #x << \" = \" << (x) << endl\n#define SP << \" \" << \ntemplate inline void chmin(T1 &a,T2 b){if(a>b) a=b;}\ntemplate inline void chmax(T1 &a,T2 b){if(a P;\ntypedef tuple T;\n\nvector MODS = { 1000000007, 998244353 }; // 実行時に決まる\ntemplate struct Fp {\n long long val;\n \n int MOD = MODS[IND];\n constexpr Fp(long long v = 0) noexcept : val(v % MODS[IND]) {\n if (val < 0) val += MOD;\n }\n constexpr int getmod() { return MOD; }\n constexpr Fp operator - () const noexcept {\n return val ? MOD - val : 0;\n }\n constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }\n constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }\n constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }\n constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }\n constexpr Fp& operator += (const Fp& r) noexcept {\n val += r.val;\n if (val >= MOD) val -= MOD;\n return *this;\n }\n constexpr Fp& operator -= (const Fp& r) noexcept {\n val -= r.val;\n if (val < 0) val += MOD;\n return *this;\n }\n constexpr Fp& operator *= (const Fp& r) noexcept {\n val = val * r.val % MOD;\n return *this;\n }\n constexpr Fp& operator /= (const Fp& r) noexcept {\n long long a = r.val, b = MOD, u = 1, v = 0;\n while (b) {\n long long t = a / b;\n a -= t * b; swap(a, b);\n u -= t * v; swap(u, v);\n }\n val = val * u % MOD;\n if (val < 0) val += MOD;\n return *this;\n }\n constexpr bool operator == (const Fp& r) const noexcept {\n return this->val == r.val;\n }\n constexpr bool operator != (const Fp& r) const noexcept {\n return this->val != r.val;\n }\n friend constexpr ostream& operator << (ostream &os, const Fp& x) noexcept {\n return os << x.val;\n }\n friend constexpr istream& operator >> (istream &is, Fp& x) noexcept {\n return is >> x.val;\n }\n friend constexpr Fp modpow(const Fp &a, long long n) noexcept {\n if (n == 0) return 1;\n auto t = modpow(a, n / 2);\n t = t * t;\n if (n & 1) t = t * a;\n return t;\n }\n};\nusing mint = Fp<0>; // MODを変える場合は値を変更\ntypedef vector vec;\ntypedef vector> mat;\n\nsigned main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n int n,k;\n cin >> n >> k;\n\n vec fact(n+10,1),inv(n+10,1);\n REP(i,n+5) fact[i+1] = fact[i]*(i+1), inv[i+1] /= fact[i+1];\n\n chmin(k,n-1);\n mint ans = 0;\n REP(i,k+1){\n mint c = fact[n]*inv[i]*inv[n-i];\n ans += c*fact[n-1]*inv[i]*inv[n-1-i];\n // debug(ans);\n }\n\n cout << ans << endl;\n\n return 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02769", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8294, "cpu_time_ms": 84, "memory_kb": 6528}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s172040789", "group_id": "codeNet:p02769", "input_text": "#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#include \n#include \n#include \n\nusing namespace std;\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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)\n#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)\n#define DEBUG(C) cerr << #C << \" = \" << C << endl;\nusing LL = long long;\nusing VI = vector;\nusing VVI = vector;\nusing VL = vector;\nusing VVL = vector;\nusing VD = vector;\nusing VVD = vector;\nusing PII = pair;\nusing PDD = pair;\nusing PLL = pair;\nusing VPII = vector;\ntemplate using VT = vector;\n#define ALL(a) begin((a)), end((a))\n#define RALL(a) rbegin((a)), rend((a))\n#define SORT(a) sort(ALL((a)))\n#define RSORT(a) sort(RALL((a)))\n#define REVERSE(a) reverse(ALL((a)))\n#define MP make_pair\n#define FORE(a, b) for (auto &&a : (b))\n#define EB emplace_back\n#define GREATER(T) T, VT greater\ntemplate inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}\ntemplate inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}\n\nconst int INF = 1e9;\nconst int MOD = INF + 7;\nconst LL LLINF = 1e18;\n\n// 剰余計算,MOD計算,順列・組み合わせ,Permutation・Combination\n\ntemplate\nclass mod_calc {\nprivate:\n const int defnum = -1;\npublic:\n mod_calc() { }\n const inline int add(int a, const int b) const {\n a += b;\n while (a < 0) a += mod;\n while (a >= mod) a -= mod;\n return a;\n }\n const inline int mul(const int a, const int b) const {\n return (long long)a * b % mod;\n }\n const inline void add_ref(int &a, const int b) const {\n a = this->add(a, b);\n }\n const inline void mul_ref(int &a, const int b) const {\n a = this->mul(a, b);\n }\n const inline void add_ref(long long &a, const int b) const {\n a = this->add(a, b);\n }\n const inline void mul_ref(long long &a, const int b) const {\n a = this->mul(a, b);\n }\n const inline int pow(int a, int p) const {\n int res = 1;\n while (p > 0) {\n if (p & 1) res = this->mul(res, a);\n a = this->mul(a, a);\n p >>= 1;\n }\n return res;\n }\n const inline int inverse(int a) const {\n return this->pow(a, mod - 2);\n }\n};\n\nconst int MAX = 5e5 + 10;\nmod_calc mc;\nint memo_fact[MAX], memo_inv_fact[MAX];\n\ninline int fact(int n) {\n if (memo_fact[n] != -1) return memo_fact[n];\n return memo_fact[n] = (n == 0 ? 1 : mc.mul(n, fact(n - 1)));\n}\n\ninline int inv_fact(int n) {\n if (memo_inv_fact[n] != -1) return memo_inv_fact[n];\n return memo_inv_fact[n] = mc.inverse(fact(n));\n}\n\ninline long long perm(int n, int r) {\n return mc.mul(fact(n), inv_fact(n - r));\n}\n\ninline long long comb(int n, int r) {\n return mc.mul(mc.mul(fact(n), inv_fact(r)), inv_fact(n - r));\n}\n\n// M個の物をN人で分ける\ninline long long comb_with_repetition(int M, int N) {\n return comb(M + N - 1, N - 1);\n}\n\n//最初に呼んで♪ O(MAX)\ninline void init() {\n memset(memo_fact, -1, sizeof(memo_fact));\n memset(memo_inv_fact, -1, sizeof(memo_inv_fact));\n for (int i = 0; i < MAX; i++) {\n fact(i);\n inv_fact(i);\n }\n}\n\nint main(void) {\n init();\n int N, K;\n cin >> N >> K;\n if (N <= K + 1) {\n cout << comb_with_repetition(N, N) << endl;\n return 0;\n }\n\n // 0 個の部屋が K 個以下\n LL ans = comb_with_repetition(N, N);\n FOR(zero_cnt, K + 1, N) {\n LL tmp = comb(N - 1, N - zero_cnt - 1);\n const auto tmp2 = mc.mul(fact(N), mc.mul(inv_fact(N - zero_cnt), inv_fact(zero_cnt)));\n tmp = mc.mul(tmp, tmp2);\n ans = mc.add(ans, -tmp);\n }\n\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1582404574, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02769.html", "problem_id": "p02769", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02769/input.txt", "sample_output_relpath": "derived/input_output/data/p02769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02769/C++/s172040789.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s172040789", "user_id": "u443010331"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#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#include \n#include \n#include \n\nusing namespace std;\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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)\n#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)\n#define DEBUG(C) cerr << #C << \" = \" << C << endl;\nusing LL = long long;\nusing VI = vector;\nusing VVI = vector;\nusing VL = vector;\nusing VVL = vector;\nusing VD = vector;\nusing VVD = vector;\nusing PII = pair;\nusing PDD = pair;\nusing PLL = pair;\nusing VPII = vector;\ntemplate using VT = vector;\n#define ALL(a) begin((a)), end((a))\n#define RALL(a) rbegin((a)), rend((a))\n#define SORT(a) sort(ALL((a)))\n#define RSORT(a) sort(RALL((a)))\n#define REVERSE(a) reverse(ALL((a)))\n#define MP make_pair\n#define FORE(a, b) for (auto &&a : (b))\n#define EB emplace_back\n#define GREATER(T) T, VT greater\ntemplate inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}\ntemplate inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}\n\nconst int INF = 1e9;\nconst int MOD = INF + 7;\nconst LL LLINF = 1e18;\n\n// 剰余計算,MOD計算,順列・組み合わせ,Permutation・Combination\n\ntemplate\nclass mod_calc {\nprivate:\n const int defnum = -1;\npublic:\n mod_calc() { }\n const inline int add(int a, const int b) const {\n a += b;\n while (a < 0) a += mod;\n while (a >= mod) a -= mod;\n return a;\n }\n const inline int mul(const int a, const int b) const {\n return (long long)a * b % mod;\n }\n const inline void add_ref(int &a, const int b) const {\n a = this->add(a, b);\n }\n const inline void mul_ref(int &a, const int b) const {\n a = this->mul(a, b);\n }\n const inline void add_ref(long long &a, const int b) const {\n a = this->add(a, b);\n }\n const inline void mul_ref(long long &a, const int b) const {\n a = this->mul(a, b);\n }\n const inline int pow(int a, int p) const {\n int res = 1;\n while (p > 0) {\n if (p & 1) res = this->mul(res, a);\n a = this->mul(a, a);\n p >>= 1;\n }\n return res;\n }\n const inline int inverse(int a) const {\n return this->pow(a, mod - 2);\n }\n};\n\nconst int MAX = 5e5 + 10;\nmod_calc mc;\nint memo_fact[MAX], memo_inv_fact[MAX];\n\ninline int fact(int n) {\n if (memo_fact[n] != -1) return memo_fact[n];\n return memo_fact[n] = (n == 0 ? 1 : mc.mul(n, fact(n - 1)));\n}\n\ninline int inv_fact(int n) {\n if (memo_inv_fact[n] != -1) return memo_inv_fact[n];\n return memo_inv_fact[n] = mc.inverse(fact(n));\n}\n\ninline long long perm(int n, int r) {\n return mc.mul(fact(n), inv_fact(n - r));\n}\n\ninline long long comb(int n, int r) {\n return mc.mul(mc.mul(fact(n), inv_fact(r)), inv_fact(n - r));\n}\n\n// M個の物をN人で分ける\ninline long long comb_with_repetition(int M, int N) {\n return comb(M + N - 1, N - 1);\n}\n\n//最初に呼んで♪ O(MAX)\ninline void init() {\n memset(memo_fact, -1, sizeof(memo_fact));\n memset(memo_inv_fact, -1, sizeof(memo_inv_fact));\n for (int i = 0; i < MAX; i++) {\n fact(i);\n inv_fact(i);\n }\n}\n\nint main(void) {\n init();\n int N, K;\n cin >> N >> K;\n if (N <= K + 1) {\n cout << comb_with_repetition(N, N) << endl;\n return 0;\n }\n\n // 0 個の部屋が K 個以下\n LL ans = comb_with_repetition(N, N);\n FOR(zero_cnt, K + 1, N) {\n LL tmp = comb(N - 1, N - zero_cnt - 1);\n const auto tmp2 = mc.mul(fact(N), mc.mul(inv_fact(N - zero_cnt), inv_fact(zero_cnt)));\n tmp = mc.mul(tmp, tmp2);\n ans = mc.add(ans, -tmp);\n }\n\n cout << ans << endl;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02769", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4302, "cpu_time_ms": 87, "memory_kb": 4096}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s853599650", "group_id": "codeNet:p02770", "input_text": "#pragma GCC optimize(\"Ofast\")\n//#pragma GCC optimize(\"unroll-loops\")\n//#pragma GCC push_options\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#include\n#include \n#include \nusing namespace::std;\n__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<\n#include\n#include \n#include\n// #include \n// #include \n// namespace mp = boost::multiprecision;\n// typedef mp::number> cdouble;\n// typedef mp::cpp_int cint;\ntemplateusing pbds=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;\ntemplateusing pbds_map=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;\ntemplateusing hash_map=__gnu_pbds::gp_hash_table;\ntemplateusing pqueue =__gnu_pbds::priority_queue,__gnu_pbds::rc_binomial_heap_tag>;\ntypedef long long lint;\n#define INF (1LL<<60)\n#define IINF (1<<30)\n#define EPS (1e-10)\n#define MOD 1000000007LL\n//#define MOD 998244353LL\ntypedef vector vec;\ntypedef vector> mat;\ntypedef vector>> mat3;\ntypedef vector svec;\ntypedef vector> smat;\ntemplateinline void numout(T t){bool f=0;for(auto i:t){cout<<(f?\" \":\"\")<inline void numout2(T t){for(auto i:t)numout(i);}\ntemplateinline void output(T t){bool f=0;for(auto i:t){cout<<(f?\" \":\"\")<inline void output2(T t){for(auto i:t)output(i);}\ntemplateinline void _output(T t){bool f=0;for(lint i=0;iinline void _output2(T t){for(lint i=0;i=0;--i)\n#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)\n#define irep(i) for(lint i=0;;++i)\n#define all(n) begin(n),end(n)\n#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))\ninline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}\ninline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}\n// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}\n// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}\ninline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}\ninline bool chmax(auto& s,const auto& t){bool res=s dx={1,0,-1,0,1,1,-1,-1};\nconst vector dy={0,1,0,-1,1,-1,1,-1};\n#define SUM(v) accumulate(all(v),0LL)\n//auto call=[&](auto f,auto... args){return f(f,args...);};\n\nint main(){\n lint k,q;\n cin>>k>>q;\n vec b(k);\n rep(i,k)cin>>b[i];\n rep(i,q){\n lint n,x,m;\n cin>>n>>x>>m;\n vec c(k);\n rep(j,k)c[j]=(b[j]-1)%m+1;\n __int128_t cnt=__int128_t(SUM(c))*((n-1)/k)+x%m;\n rep(j,(n-1)%k)cnt+=c[j];\n cout<<(lint)(n-1-(cnt/m))<\n#include \n#include \nusing namespace::std;\n__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<\n#include\n#include \n#include\n// #include \n// #include \n// namespace mp = boost::multiprecision;\n// typedef mp::number> cdouble;\n// typedef mp::cpp_int cint;\ntemplateusing pbds=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;\ntemplateusing pbds_map=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;\ntemplateusing hash_map=__gnu_pbds::gp_hash_table;\ntemplateusing pqueue =__gnu_pbds::priority_queue,__gnu_pbds::rc_binomial_heap_tag>;\ntypedef long long lint;\n#define INF (1LL<<60)\n#define IINF (1<<30)\n#define EPS (1e-10)\n#define MOD 1000000007LL\n//#define MOD 998244353LL\ntypedef vector vec;\ntypedef vector> mat;\ntypedef vector>> mat3;\ntypedef vector svec;\ntypedef vector> smat;\ntemplateinline void numout(T t){bool f=0;for(auto i:t){cout<<(f?\" \":\"\")<inline void numout2(T t){for(auto i:t)numout(i);}\ntemplateinline void output(T t){bool f=0;for(auto i:t){cout<<(f?\" \":\"\")<inline void output2(T t){for(auto i:t)output(i);}\ntemplateinline void _output(T t){bool f=0;for(lint i=0;iinline void _output2(T t){for(lint i=0;i=0;--i)\n#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)\n#define irep(i) for(lint i=0;;++i)\n#define all(n) begin(n),end(n)\n#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))\ninline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}\ninline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}\n// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}\n// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}\ninline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}\ninline bool chmax(auto& s,const auto& t){bool res=s dx={1,0,-1,0,1,1,-1,-1};\nconst vector dy={0,1,0,-1,1,-1,1,-1};\n#define SUM(v) accumulate(all(v),0LL)\n//auto call=[&](auto f,auto... args){return f(f,args...);};\n\nint main(){\n lint k,q;\n cin>>k>>q;\n vec b(k);\n rep(i,k)cin>>b[i];\n rep(i,q){\n lint n,x,m;\n cin>>n>>x>>m;\n vec c(k);\n rep(j,k)c[j]=(b[j]-1)%m+1;\n __int128_t cnt=__int128_t(SUM(c))*((n-1)/k)+x%m;\n rep(j,(n-1)%k)cnt+=c[j];\n cout<<(lint)(n-1-(cnt/m))< 0).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq k, q \\leq 5000\n\n0 \\leq d_i \\leq 10^9\n\n2 \\leq n_i \\leq 10^9\n\n0 \\leq x_i \\leq 10^9\n\n2 \\leq m_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nk q\nd_0 d_1 ... d_{k - 1}\nn_1 x_1 m_1\nn_2 x_2 m_2\n:\nn_q x_q m_q\n\nOutput\n\nPrint q lines.\n\nThe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3 1\n3 1 4\n5 3 2\n\nSample Output 1\n\n1\n\nFor the first query, the sequence {a_j} will be 3,6,7,11,14.\n\n(a_0~\\textrm{mod}~2) > (a_1~\\textrm{mod}~2)\n\n(a_1~\\textrm{mod}~2) < (a_2~\\textrm{mod}~2)\n\n(a_2~\\textrm{mod}~2) = (a_3~\\textrm{mod}~2)\n\n(a_3~\\textrm{mod}~2) > (a_4~\\textrm{mod}~2)\n\nThus, the response to this query should be 1.\n\nSample Input 2\n\n7 3\n27 18 28 18 28 46 1000000000\n1000000000 1 7\n1000000000 2 10\n1000000000 3 12\n\nSample Output 2\n\n224489796\n214285714\n559523809", "sample_input": "3 1\n3 1 4\n5 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02770", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.\n\nProcess the following q queries in order:\n\nThe i-th query contains three integers n_i, x_i, and m_i.\nLet a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \\begin{eqnarray} a_j = \\begin{cases} x_i & ( j = 0 ) \\\\ a_{j - 1} + d_{(j - 1)~\\textrm{mod}~k} & ( 0 < j \\leq n_i - 1 ) \\end{cases}\\end{eqnarray}\nPrint the number of j~(0 \\leq j < n_i - 1) such that (a_j~\\textrm{mod}~m_i) < (a_{j + 1}~\\textrm{mod}~m_i).\n\nHere (y~\\textrm{mod}~z) denotes the remainder of y divided by z, for two integers y and z~(z > 0).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq k, q \\leq 5000\n\n0 \\leq d_i \\leq 10^9\n\n2 \\leq n_i \\leq 10^9\n\n0 \\leq x_i \\leq 10^9\n\n2 \\leq m_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nk q\nd_0 d_1 ... d_{k - 1}\nn_1 x_1 m_1\nn_2 x_2 m_2\n:\nn_q x_q m_q\n\nOutput\n\nPrint q lines.\n\nThe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3 1\n3 1 4\n5 3 2\n\nSample Output 1\n\n1\n\nFor the first query, the sequence {a_j} will be 3,6,7,11,14.\n\n(a_0~\\textrm{mod}~2) > (a_1~\\textrm{mod}~2)\n\n(a_1~\\textrm{mod}~2) < (a_2~\\textrm{mod}~2)\n\n(a_2~\\textrm{mod}~2) = (a_3~\\textrm{mod}~2)\n\n(a_3~\\textrm{mod}~2) > (a_4~\\textrm{mod}~2)\n\nThus, the response to this query should be 1.\n\nSample Input 2\n\n7 3\n27 18 28 18 28 46 1000000000\n1000000000 1 7\n1000000000 2 10\n1000000000 3 12\n\nSample Output 2\n\n224489796\n214285714\n559523809", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3333, "cpu_time_ms": 309, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s018802356", "group_id": "codeNet:p02771", "input_text": "#include \n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main(){\n int a, b, c;\n cin>>a>>b>>c;\n\n bool y=false;\n if(a==b && a!=c) y=true;\n if(a==c && a!=b) y=true;\n if(b==c && b!=a) y=true;\n\n if(y) cout<<\"Yes\"<\n#define rep(i,n) for (int i = 0; i < (n); ++i)\n#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main(){\n int a, b, c;\n cin>>a>>b>>c;\n\n bool y=false;\n if(a==b && a!=c) y=true;\n if(a==c && a!=b) y=true;\n if(b==c && b!=a) y=true;\n\n if(y) cout<<\"Yes\"<\nusing namespace std;\n#define rep(i, n) for(long long i=0;i<(long long)(n);i++)\n#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)\n#define all(a) a.begin(),a.end()\n#define pb push_back\n#define eb emplace_back\n#define lb(v,k) (lower_bound(all(v),k)-v.begin())\n#define ub(v,k) (upper_bound(all(v),k)-v.begin())\n#define fi first\n#define se second\n#define pi M_PI\ntypedef long long ll;\ntypedef pair P;\ntypedef tuple PP;\ntypedef multiset S;\ntypedef priority_queue PQ;\ntypedef priority_queue,greater

> SPQ;\nusing vi=vector;\nusing vvi=vector;\nusing vvvi=vector;\nconst ll inf=1001001001001001;\nconst int INF=1001001001;\nconst int mod=1000000007;\ntemplate bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}\ntemplate bool chmax(T&a,T b){if(a void out(T a){cout< void outp(T a){cout<<'('< void outvp(T v){rep(i,v.size())outp(v[i]);}\ntemplate void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout< void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<>n;\n vector v(n),ans;\n rep(i,n)cin>>v[i];\n sort(all(v));\n ll from=-1,to=-1;\n ll m=0;\n while(to=n-1)break;\n }\n chmax(m,to-from);\n }\n from=-1;\n to=-1;\n while(to=n-1)break;\n }\n if(to-from==m)ans.pb(v[to]);\n }\n sort(all(ans));\n for(auto x:ans)out(x);\n}", "language": "C++", "metadata": {"date": 1582552163, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/C++/s741200309.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s741200309", "user_id": "u422633119"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "#include \nusing namespace std;\n#define rep(i, n) for(long long i=0;i<(long long)(n);i++)\n#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)\n#define all(a) a.begin(),a.end()\n#define pb push_back\n#define eb emplace_back\n#define lb(v,k) (lower_bound(all(v),k)-v.begin())\n#define ub(v,k) (upper_bound(all(v),k)-v.begin())\n#define fi first\n#define se second\n#define pi M_PI\ntypedef long long ll;\ntypedef pair P;\ntypedef tuple PP;\ntypedef multiset S;\ntypedef priority_queue PQ;\ntypedef priority_queue,greater

> SPQ;\nusing vi=vector;\nusing vvi=vector;\nusing vvvi=vector;\nconst ll inf=1001001001001001;\nconst int INF=1001001001;\nconst int mod=1000000007;\ntemplate bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}\ntemplate bool chmax(T&a,T b){if(a void out(T a){cout< void outp(T a){cout<<'('< void outvp(T v){rep(i,v.size())outp(v[i]);}\ntemplate void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout< void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<>n;\n vector v(n),ans;\n rep(i,n)cin>>v[i];\n sort(all(v));\n ll from=-1,to=-1;\n ll m=0;\n while(to=n-1)break;\n }\n chmax(m,to-from);\n }\n from=-1;\n to=-1;\n while(to=n-1)break;\n }\n if(to-from==m)ans.pb(v[to]);\n }\n sort(all(ans));\n for(auto x:ans)out(x);\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2009, "cpu_time_ms": 641, "memory_kb": 15988}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s196351034", "group_id": "codeNet:p02773", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int P = 1e6, N = 2e5+9;\nstring s[N], ans[200009];\nint hd[P+9], nxt[N], cnt[N], n, c = 0;\n\nint main(){\n cin >> n;\n string st;\n for(int i = 1; i <= n; i++){\n cin >> st;\n int num = 0;\n bool cr = 0;\n for(int j = 0, power = 1; j < st.size(); j++, power = (power*130)%P){\n num = (num + st.at(j)*power)%P;\n }\n for(int j = hd[num]; j; j = nxt[j]){\n if(s[j] == st){\n cr = 1, cnt[j]++;\n break;\n }\n }\n if(!cr){\n nxt[++c]=hd[num], hd[num]=c, cnt[c]++, s[c] = st;\n }\n }\n int max = 0, a = 0;\n for(int i = 0; i < P; i++){\n for(int j = hd[i]; j; j = nxt[j]){\n if(cnt[j] > max){\n fill(ans, ans+a+1, 0);\n ans[a=0] = s[j];\n max = cnt[j];\n }\n else if(cnt[j] == max) ans[++a] = s[j];\n }\n }\n sort(ans, ans+a+1);\n for(int i = 0; i <= a; i++) cout << ans[i] << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1582029414, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/C++/s196351034.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s196351034", "user_id": "u508187310"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int P = 1e6, N = 2e5+9;\nstring s[N], ans[200009];\nint hd[P+9], nxt[N], cnt[N], n, c = 0;\n\nint main(){\n cin >> n;\n string st;\n for(int i = 1; i <= n; i++){\n cin >> st;\n int num = 0;\n bool cr = 0;\n for(int j = 0, power = 1; j < st.size(); j++, power = (power*130)%P){\n num = (num + st.at(j)*power)%P;\n }\n for(int j = hd[num]; j; j = nxt[j]){\n if(s[j] == st){\n cr = 1, cnt[j]++;\n break;\n }\n }\n if(!cr){\n nxt[++c]=hd[num], hd[num]=c, cnt[c]++, s[c] = st;\n }\n }\n int max = 0, a = 0;\n for(int i = 0; i < P; i++){\n for(int j = hd[i]; j; j = nxt[j]){\n if(cnt[j] > max){\n fill(ans, ans+a+1, 0);\n ans[a=0] = s[j];\n max = cnt[j];\n }\n else if(cnt[j] == max) ans[++a] = s[j];\n }\n }\n sort(ans, ans+a+1);\n for(int i = 0; i <= a; i++) cout << ans[i] << endl;\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1119, "cpu_time_ms": 2103, "memory_kb": 19968}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s020201941", "group_id": "codeNet:p02777", "input_text": "#include\n#include\n#include\n#include\n#include\n\n#define big ((long long)(1e9)+7)\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\n\nint main()\n{\n string s,t;\n cin >> s >> t;\n int a,b;\n cin >> a >> b;\n string u;\n cin >> u;\n if(s == u)\n a--;\n if(t == u)\n b--;\n cout << a << \" \" << b << endl;\n}\n", "language": "C++", "metadata": {"date": 1581278946, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/C++/s020201941.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s020201941", "user_id": "u115819033"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "#include\n#include\n#include\n#include\n#include\n\n#define big ((long long)(1e9)+7)\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\n\nint main()\n{\n string s,t;\n cin >> s >> t;\n int a,b;\n cin >> a >> b;\n string u;\n cin >> u;\n if(s == u)\n a--;\n if(t == u)\n b--;\n cout << a << \" \" << b << endl;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s878210568", "group_id": "codeNet:p02779", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N, c=0;\n string ans = \"YES\";\n cin >> N;\n vector A(N);\n for (int i; i < N; i++){\n cin >> A.at(i);\n }\n set B;\n while (c < N){\n if (B.count(A.at(c)) == 1){\n ans = \"NO\";\n break;\n }\n B.insert(A.at(c));\n c++;\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1595524490, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/C++/s878210568.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878210568", "user_id": "u627600101"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int N, c=0;\n string ans = \"YES\";\n cin >> N;\n vector A(N);\n for (int i; i < N; i++){\n cin >> A.at(i);\n }\n set B;\n while (c < N){\n if (B.count(A.at(c)) == 1){\n ans = \"NO\";\n break;\n }\n B.insert(A.at(c));\n c++;\n }\n cout << ans << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 214, "memory_kb": 25120}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s273224293", "group_id": "codeNet:p02779", "input_text": "#include\nusing namespace std;\nint b=1,a;\nint main(){\n cin>>a;\n vector c(a);\n for(int i=0;i>c[i];\n for(int i=0;i\nusing namespace std;\nint b=1,a;\nint main(){\n cin>>a;\n vector c(a);\n for(int i=0;i>c[i];\n for(int i=0;i\nusing namespace std;\n#define lowbit(x) ((x)&(-x))\ntypedef long long LL;\n\nmap store;\n\nvoid run_case() {\n int N, t;\n cin >> N;\n for(int i = 0; i < N; ++i) {\n cin >> t;\n if(store.count(t)) {\n cout << \"NO\";\n return;\n }\n store[t]++;\n }\n cout << \"YES\";\n}\n\nint main() {\n ios::sync_with_stdio(false), cin.tie(0);\n run_case();\n cout.flush();\n return 0;\n}", "language": "C++", "metadata": {"date": 1581278831, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/C++/s535726320.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s535726320", "user_id": "u545866784"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "#include\nusing namespace std;\n#define lowbit(x) ((x)&(-x))\ntypedef long long LL;\n\nmap store;\n\nvoid run_case() {\n int N, t;\n cin >> N;\n for(int i = 0; i < N; ++i) {\n cin >> t;\n if(store.count(t)) {\n cout << \"NO\";\n return;\n }\n store[t]++;\n }\n cout << \"YES\";\n}\n\nint main() {\n ios::sync_with_stdio(false), cin.tie(0);\n run_case();\n cout.flush();\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 456, "cpu_time_ms": 124, "memory_kb": 9600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s795867565", "group_id": "codeNet:p02780", "input_text": "#include \nusing namespace std;\n\nint main()\n{\n int n,k;\n cin>>n>>k;\n\n vectorp(n);\n\n for(int i=0;i>p[i];\n }\n\n sort(p.begin(),p.end());\n reverse(p.begin(),p.end());\n\n int ans =0;\n \n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n int n,k;\n cin>>n>>k;\n\n vectorp(n);\n\n for(int i=0;i>p[i];\n }\n\n sort(p.begin(),p.end());\n reverse(p.begin(),p.end());\n\n int ans =0;\n \n for(int i=0;i\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(ll i=0;i<(ll)(n);i++)\n#define REPD(i,n) for(ll i=n-1;i>=0;i--)\n#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)\n#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)\n#define ALL(x) (x).begin(),(x).end()\n#define RALL(x) (x).rbegin(),(x).rend()\n\nusing ll = long long;\nusing ld = long double;\n\nconst double PI = 3.14159265358979323846;\n\nll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; } //最大公約数\nll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数\n\nint main()\n{\n int n, k;\n\n cin >> n >> k;\n\n int p[n];\n \n REP(i, n) cin >> p[i];\n\n vector sumList;\n\n ld sum = 0;\n REP(i, n){\n sum += (1.0+(ld)p[i])/2.0;\n sumList.push_back(sum);\n }\n\n ld ans = 0;\n if (n == k) ans = sum;\n else{\n REP(i, n-k){\n ans = max(ans, sumList[i+k] - sumList[i]);\n }\n }\n \n cout << fixed;\n cout << setprecision(12) << ans << endl;\n\n return 0;\n}\n\n", "language": "C++", "metadata": {"date": 1589469146, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02780/input.txt", "sample_output_relpath": "derived/input_output/data/p02780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02780/C++/s239339487.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s239339487", "user_id": "u506417357"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "//\n//AtCoder Beginner Contest 154\n//D - Dice in Line\n//\n\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(ll i=0;i<(ll)(n);i++)\n#define REPD(i,n) for(ll i=n-1;i>=0;i--)\n#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)\n#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)\n#define ALL(x) (x).begin(),(x).end()\n#define RALL(x) (x).rbegin(),(x).rend()\n\nusing ll = long long;\nusing ld = long double;\n\nconst double PI = 3.14159265358979323846;\n\nll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; } //最大公約数\nll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数\n\nint main()\n{\n int n, k;\n\n cin >> n >> k;\n\n int p[n];\n \n REP(i, n) cin >> p[i];\n\n vector sumList;\n\n ld sum = 0;\n REP(i, n){\n sum += (1.0+(ld)p[i])/2.0;\n sumList.push_back(sum);\n }\n\n ld ans = 0;\n if (n == k) ans = sum;\n else{\n REP(i, n-k){\n ans = max(ans, sumList[i+k] - sumList[i]);\n }\n }\n \n cout << fixed;\n cout << setprecision(12) << ans << endl;\n\n return 0;\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1205, "cpu_time_ms": 53, "memory_kb": 7280}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s072262132", "group_id": "codeNet:p02780", "input_text": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int n, k; cin >> n >> k;\n int p[200000]; for (int i = 0; i < n; ++i) cin >> p[i];\n \n int sum = 0;\n for (int i = 0; i < k; ++i) sum += p[i];\n int mx = sum;\n for (int i = k; i < n; ++i) {\n sum += p[i] - p[i-k]; mx = max(mx, sum);\n }\n \n double ans = (mx+k)/2.0;\n cout << fixed << setprecision(12) << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1585271410, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02780/input.txt", "sample_output_relpath": "derived/input_output/data/p02780/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02780/C++/s072262132.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s072262132", "user_id": "u896847891"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int n, k; cin >> n >> k;\n int p[200000]; for (int i = 0; i < n; ++i) cin >> p[i];\n \n int sum = 0;\n for (int i = 0; i < k; ++i) sum += p[i];\n int mx = sum;\n for (int i = k; i < n; ++i) {\n sum += p[i] - p[i-k]; mx = max(mx, sum);\n }\n \n double ans = (mx+k)/2.0;\n cout << fixed << setprecision(12) << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 435, "cpu_time_ms": 63, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s510389062", "group_id": "codeNet:p02783", "input_text": "#include \nusing namespace std;\n\nint main() {\n\tint a,b;\n\tcin >> a >> b;\n\tif(a%b==0)cout << a/b << '\\n';\n\telse cout << a/b+1 << '\\n';\n}", "language": "C++", "metadata": {"date": 1580080310, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02783/input.txt", "sample_output_relpath": "derived/input_output/data/p02783/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02783/C++/s510389062.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510389062", "user_id": "u184704421"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n\tint a,b;\n\tcin >> a >> b;\n\tif(a%b==0)cout << a/b << '\\n';\n\telse cout << a/b+1 << '\\n';\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s060290378", "group_id": "codeNet:p02784", "input_text": "#include\nusing namespace std;\nint main()\n{\n int h,n;\n cin>>h>>n;\n int c,sum=0;\n for(int i=0;i>c;\n sum +=c;\n }\n if(sum>=h)\n cout<<\"Yes\"<\nusing namespace std;\nint main()\n{\n int h,n;\n cin>>h>>n;\n int c,sum=0;\n for(int i=0;i>c;\n sum +=c;\n }\n if(sum>=h)\n cout<<\"Yes\"<\n#define rep(i, x, N) for (long long i = x; i < (N); i++)\nusing namespace std;\nint main()\n{\n\tint N,H;\n\tcin>>H>>N;\n\tvectorA(N);\n\tint sum=0;\n\trep(i,0,N){\n\t\tcin>>A[i];\n\t\tsum+=A[i];\n\t}\n\tif(H<=sum){\n\t\tcout<<\"Yes\"<\n#define rep(i, x, N) for (long long i = x; i < (N); i++)\nusing namespace std;\nint main()\n{\n\tint N,H;\n\tcin>>H>>N;\n\tvectorA(N);\n\tint sum=0;\n\trep(i,0,N){\n\t\tcin>>A[i];\n\t\tsum+=A[i];\n\t}\n\tif(H<=sum){\n\t\tcout<<\"Yes\"< \nusing namespace std;\nbool cmp(int x,int y)\n{\n\treturn x>y;\n}\nlong long n,k,a[200005],ans,h;\nint main(){\n cin>>n>>k;\n for(int i=1;i<=n;i++)\n cin>>a[i],ans+=a[i];\n sort(a+1,a+1+n,cmp);\n h=min(k,n);\n for(int i=1;i<=h;i++) ans-=a[i];\n cout< \nusing namespace std;\nbool cmp(int x,int y)\n{\n\treturn x>y;\n}\nlong long n,k,a[200005],ans,h;\nint main(){\n cin>>n>>k;\n for(int i=1;i<=n;i++)\n cin>>a[i],ans+=a[i];\n sort(a+1,a+1+n,cmp);\n h=min(k,n);\n for(int i=1;i<=h;i++) ans-=a[i];\n cout<\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\n#define REP(i,n) for (ll i = 0; i < (n); ++i)\n\n\nvoid solve(long long N, long long K, std::vector H){\n sort(H.begin(), H.end());\n ll ans = 0;\n for(ll i = 0; i < N - K; ++i){\n ans += H.at(i);\n }\n cout << ans << endl;\n}\n\n// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools\nint main(){\n long long N;\n scanf(\"%lld\",&N);\n long long K;\n scanf(\"%lld\",&K);\n std::vector H(N);\n for(int i = 0 ; i < N ; i++){\n scanf(\"%lld\",&H[i]);\n }\n solve(N, K, std::move(H));\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1584949718, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02785/input.txt", "sample_output_relpath": "derived/input_output/data/p02785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02785/C++/s894621031.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894621031", "user_id": "u455757400"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\n#define REP(i,n) for (ll i = 0; i < (n); ++i)\n\n\nvoid solve(long long N, long long K, std::vector H){\n sort(H.begin(), H.end());\n ll ans = 0;\n for(ll i = 0; i < N - K; ++i){\n ans += H.at(i);\n }\n cout << ans << endl;\n}\n\n// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools\nint main(){\n long long N;\n scanf(\"%lld\",&N);\n long long K;\n scanf(\"%lld\",&K);\n std::vector H(N);\n for(int i = 0 ; i < N ; i++){\n scanf(\"%lld\",&H[i]);\n }\n solve(N, K, std::move(H));\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 659, "cpu_time_ms": 38, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s249435138", "group_id": "codeNet:p02786", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\n unsigned long h;\n cin >> h;\n\n long ans = 0;\n long num = 1;\n while ( h > 0 ) {\n ans += num;\n num *= 2;\n h /= 2;\n }\n \n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1580071516, "filename_ext": "cpp", "original_language": "C++14 (Clang 3.8.0)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02786/input.txt", "sample_output_relpath": "derived/input_output/data/p02786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02786/C++/s249435138.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s249435138", "user_id": "u519759783"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\n unsigned long h;\n cin >> h;\n\n long ans = 0;\n long num = 1;\n while ( h > 0 ) {\n ans += num;\n num *= 2;\n h /= 2;\n }\n \n cout << ans << endl;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "sample_input": "2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02786", "source_text": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s689579608", "group_id": "codeNet:p02788", "input_text": "//MADE BY Y_is_sunshine;\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 INF 0x3f3f3f3f\n#define MAXN 200005\n\ntypedef long long ll;\n\nconst ll mod = 1e9 + 7;\nconst double PI = acos(-1);\n\nusing namespace std;\n\nint N, M, K;\n\nstruct node {\n\tll at;\n\tll cost;\n\tbool operator < (const node a) const {\n\t\treturn this->at < a.at;\n\t}\n}p[MAXN];\n\nint main(void)\n{\n#ifdef Sunshine\n\tfreopen(\"data.txt\", \"r\", stdin);\n#endif\n\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tll N, M, K;\n\tcin >> N >> M >> K;\n\tM *= 2;\n\tfor (int i = 1; i <= N; i++)\n\t\tcin >> p[i].at >> p[i].cost;\n\n\tsort(p + 1, p + 1 + N);\n\tll ans = 0;\n\n\tfor (int i = 1; i <= N; i++) {\n\t\tif (p[i].cost <= 0)\n\t\t\tcontinue;\n\t\tint j = i + 1;\n\t\tll res = p[i].cost / K + (p[i].cost % K == 0ll ? 0 : 1);\n\t\tans += res;\n\t\tfor (; j <= N; j++) {\n\t\t\tif (p[j].at > p[i].at + M)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\tp[j].cost -= res;\n\t\t}\n\t}\n\n\tcout << ans << '\\n';\n\t\n\n\n\n#ifdef Sunshine\n\tfreopen(\"CON\", \"r\", stdin);\n\tsystem(\"pause\");\n#endif\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1580072751, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02788.html", "problem_id": "p02788", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02788/input.txt", "sample_output_relpath": "derived/input_output/data/p02788/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02788/C++/s689579608.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s689579608", "user_id": "u717365311"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//MADE BY Y_is_sunshine;\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 INF 0x3f3f3f3f\n#define MAXN 200005\n\ntypedef long long ll;\n\nconst ll mod = 1e9 + 7;\nconst double PI = acos(-1);\n\nusing namespace std;\n\nint N, M, K;\n\nstruct node {\n\tll at;\n\tll cost;\n\tbool operator < (const node a) const {\n\t\treturn this->at < a.at;\n\t}\n}p[MAXN];\n\nint main(void)\n{\n#ifdef Sunshine\n\tfreopen(\"data.txt\", \"r\", stdin);\n#endif\n\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tll N, M, K;\n\tcin >> N >> M >> K;\n\tM *= 2;\n\tfor (int i = 1; i <= N; i++)\n\t\tcin >> p[i].at >> p[i].cost;\n\n\tsort(p + 1, p + 1 + N);\n\tll ans = 0;\n\n\tfor (int i = 1; i <= N; i++) {\n\t\tif (p[i].cost <= 0)\n\t\t\tcontinue;\n\t\tint j = i + 1;\n\t\tll res = p[i].cost / K + (p[i].cost % K == 0ll ? 0 : 1);\n\t\tans += res;\n\t\tfor (; j <= N; j++) {\n\t\t\tif (p[j].at > p[i].at + M)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\tp[j].cost -= res;\n\t\t}\n\t}\n\n\tcout << ans << '\\n';\n\t\n\n\n\n#ifdef Sunshine\n\tfreopen(\"CON\", \"r\", stdin);\n\tsystem(\"pause\");\n#endif\n\treturn 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_i are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 3 2\n1 2\n5 4\n9 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02788", "source_text": "Score : 600 points\n\nProblem Statement\n\nSilver Fox is fighting with N monsters.\n\nThe monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.\n\nSilver Fox can use bombs to attack the monsters.\nUsing a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A.\nThere is no way other than bombs to decrease the monster's health.\n\nSilver Fox wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of bombs needed to win.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq D \\leq 10^9\n\n1 \\leq A \\leq 10^9\n\n0 \\leq X_i \\leq 10^9\n\n1 \\leq H_i \\leq 10^9\n\nX_i are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D A\nX_1 H_1\n:\nX_N H_N\n\nOutput\n\nPrint the minimum number of bombs needed to win.\n\nSample Input 1\n\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1\n\n2\n\nFirst, let us use a bomb at the coordinate 4 to decrease the first and second monsters' health by 2.\n\nThen, use a bomb at the coordinate 6 to decrease the second and third monsters' health by 2.\n\nNow, all the monsters' healths are 0.\nWe cannot make all the monsters' health drop to 0 or below with just one bomb.\n\nSample Input 2\n\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2\n\n5\n\nWe should use five bombs at the coordinate 5.\n\nSample Input 3\n\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1216, "cpu_time_ms": 2103, "memory_kb": 3328}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s644570189", "group_id": "codeNet:p02790", "input_text": "#pragma GCC optimize(\"Ofast,unroll-loops,no-stack-protector,fast-math\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n \n#include\n#include\n#include\n#include\n#include\n#include\n \nusing namespace std;\n \nconst int MAX_N = int(1e6) + 10;\nconst long long int MOD=1e9+7;\nconst long long int INF=1e18;\n \n \ntypedef long long int ll;\ntypedef unsigned long long int llu;\n \n \n \nstruct fenwick{\n int lim;\n long long int *tree;\n fenwick(int _lim){\n lim=_lim;\n tree=new long long int[lim];\n }\n void init(){\n for(int i=0;i0){\n ans+=tree[x];\n x-=x&(-x);\n }\n return ans;\n }\n int _query(int k){\n int low=1;\n int high=500000;\n int ans=0;int x=k;\n while(low<=high){\n int mid=low+(high-low)/2;\n if(query(mid)>=x){\n ans=mid;\n high=mid-1;\n }else{\n low=mid+1;\n }\n }\n return ans;\n }\n};/*\nstruct z_function{\n string &txt;\n int *z;\n z_function(string &_txt):txt(_txt){\n z=new int[1+txt.length()];\n }\n void cal(){\n z[0]=0;\n int l=0;\n int r=0;\n for(int i=1;ir){\n l=i;\n r=i;\n while(rm;\n int length;\n int end_indx;\n struct palindromic_tree* suffix;\n palindromic_tree(int _length,int _end_indx){\n length=_length;\n end_indx=_end_indx;\n }\n};\nclass palindromic_string{\npublic:\n string &s;\n struct palindromic_tree* real_root;\n struct palindromic_tree* imaginary_root;\n struct palindromic_tree* curr;\n long long int *prefix;\n palindromic_string(string &_s):s(_s){\n real_root=new palindromic_tree(0,-1);\n imaginary_root=new palindromic_tree(-1,-1);\n curr=real_root;\n real_root->suffix=imaginary_root;prefix=new long long int[1+s.length()];\n imaginary_root->suffix=imaginary_root;\n }\n void add(char ch){\n int indx=s.size();\n struct palindromic_tree* temp=curr;\n s+=ch;\n while(indx-temp->length-1<0 || s[indx-temp->length-1]!=s[indx])\n temp=temp->suffix;\n if((temp->m).find(ch)!=(temp->m).end()){\n curr=(temp->m)[ch];\n return;\n }else{\n curr=new palindromic_tree((temp->length)+2,indx);\n }\n \n (temp->m)[ch]=curr;\n \n if(curr->length==1){\n curr->suffix=real_root;\n return;\n }else{\n temp=temp->suffix;\n while(indx-temp->length-1<0 || s[indx-temp->length-1]!=s[indx])\n temp=temp->suffix;\n curr->suffix=(temp->m)[ch];\n }\n }\n \n void cal(){\n prefix[0]=0;\n long long int p=29LL;\n for(int i=0;i=MOD)a=a%MOD;\n while(a<0)a+=MOD;\n if(b>=MOD)b=b%MOD;\n while(b<0)b+=MOD;\n ll c=a*b;\n if(c>=MOD)c=c%MOD;\n while(c<0)c+=MOD;\n return c;\n}\nll add(ll a,ll b){\n if(a>=MOD)a=a%MOD;\n while(a<0)a+=MOD;\n if(b>=MOD)b=b%MOD;\n while(b<0)b+=MOD;\n ll ans=(a+b);\n if(ans>=MOD)ans=ans%MOD;\n while(ans<0)ans+=MOD;\n return ans;\n}\nll power(ll a,ll b,ll c){\n ll ans=1;\n while(b){\n if(b&1){\n ans=mul(ans,a);\n }\n a=mul(a,a);\n b=b/2;\n }\n return ans;\n}\ntemplate\nistream &operator>>(istream &in, pair &P){\n in >> P.first >> P.second;\n return in;\n}\n \ntemplate\nostream &operator<<(ostream &out, const pair &P){\n out << \"(\" << P.first << \", \" << P.second << \")\";\n return out;\n}\ntemplate\nistream &operator>>(istream &in, vector &arr){\n for(auto &x: arr) in >> x;\n return in;\n}\ntemplate\nostream &operator<<(ostream &out, const vector &arr){\n for(auto &x: arr) out << x << ' '; cout << \"\\n\";\n return out;\n}\ntemplate\nistream &operator>>(istream &in, deque &arr){\n for(auto &x: arr) in >> x;\n return in;\n}\ntemplate\nostream &operator<<(ostream &out, const deque &arr){\n for(auto &x: arr) out << x << ' '; cout << \"\\n\";\n return out;\n}\nmt19937 rnd(time(0));\nstruct sparse{\n int table[200005][25];\n int n;\n sparse(int len1):n(len1){\n }\n void init(int *a){\n \n for(int i=1;i<=n;i++){\n table[i][0]=a[i];\n }\n \n // cout<=0;j--){\n if(dis&(1< >v[1000005];\n// ll t[1000005];ll h[1000005]; ;;;;;;multiset > > >s;ll A,B;bool vis[1000005];ll dis[1000005];int parent[1000005];vectorans;\n// ll c[1000005];\n \nstruct SOS{\n ll *dp;\n int limit;\n vector&arr;\n \n SOS(int _limit,vector&v):arr(v){\n \n limit=_limit;\n dp=new ll[(1<=0;j--){\n if(j&(1< *v;\n int n;\n long long int *values;\n int *start;\n int *end;\n graph(int size):n(size){\n v=new vector[n+1];\n values=new ll[n+1];\n for(int i=1;i>x>>y;\n v[x].push_back(y);\n v[y].push_back(x);\n }\n for(int i=1;i<=n;i++){\n cin>>values[i];\n }\n }\n void dfs(){\n int gtime=0;\n start=new int[n+1];\n end=new int[n+1];\n dfs_start_end(1,0,gtime);\n }\n void dfs_start_end(int i,int p,int >ime){\n gtime++;\n start[i]=gtime;\n for(auto it:v[i]){\n if(it!=p){\n dfs_start_end(it,i,gtime);\n }\n }\n end[i]=gtime;\n }\n};\n\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n \n\n \n int n,m;\n cin>>n>>m;\n \n string str1=\"\";\n string str2=\"\";\n\n for(int i=1;i<=m;i++){\n str1+=to_string(n);\n // cout<\n#include\n#include\n#include\n#include\n#include\n \nusing namespace std;\n \nconst int MAX_N = int(1e6) + 10;\nconst long long int MOD=1e9+7;\nconst long long int INF=1e18;\n \n \ntypedef long long int ll;\ntypedef unsigned long long int llu;\n \n \n \nstruct fenwick{\n int lim;\n long long int *tree;\n fenwick(int _lim){\n lim=_lim;\n tree=new long long int[lim];\n }\n void init(){\n for(int i=0;i0){\n ans+=tree[x];\n x-=x&(-x);\n }\n return ans;\n }\n int _query(int k){\n int low=1;\n int high=500000;\n int ans=0;int x=k;\n while(low<=high){\n int mid=low+(high-low)/2;\n if(query(mid)>=x){\n ans=mid;\n high=mid-1;\n }else{\n low=mid+1;\n }\n }\n return ans;\n }\n};/*\nstruct z_function{\n string &txt;\n int *z;\n z_function(string &_txt):txt(_txt){\n z=new int[1+txt.length()];\n }\n void cal(){\n z[0]=0;\n int l=0;\n int r=0;\n for(int i=1;ir){\n l=i;\n r=i;\n while(rm;\n int length;\n int end_indx;\n struct palindromic_tree* suffix;\n palindromic_tree(int _length,int _end_indx){\n length=_length;\n end_indx=_end_indx;\n }\n};\nclass palindromic_string{\npublic:\n string &s;\n struct palindromic_tree* real_root;\n struct palindromic_tree* imaginary_root;\n struct palindromic_tree* curr;\n long long int *prefix;\n palindromic_string(string &_s):s(_s){\n real_root=new palindromic_tree(0,-1);\n imaginary_root=new palindromic_tree(-1,-1);\n curr=real_root;\n real_root->suffix=imaginary_root;prefix=new long long int[1+s.length()];\n imaginary_root->suffix=imaginary_root;\n }\n void add(char ch){\n int indx=s.size();\n struct palindromic_tree* temp=curr;\n s+=ch;\n while(indx-temp->length-1<0 || s[indx-temp->length-1]!=s[indx])\n temp=temp->suffix;\n if((temp->m).find(ch)!=(temp->m).end()){\n curr=(temp->m)[ch];\n return;\n }else{\n curr=new palindromic_tree((temp->length)+2,indx);\n }\n \n (temp->m)[ch]=curr;\n \n if(curr->length==1){\n curr->suffix=real_root;\n return;\n }else{\n temp=temp->suffix;\n while(indx-temp->length-1<0 || s[indx-temp->length-1]!=s[indx])\n temp=temp->suffix;\n curr->suffix=(temp->m)[ch];\n }\n }\n \n void cal(){\n prefix[0]=0;\n long long int p=29LL;\n for(int i=0;i=MOD)a=a%MOD;\n while(a<0)a+=MOD;\n if(b>=MOD)b=b%MOD;\n while(b<0)b+=MOD;\n ll c=a*b;\n if(c>=MOD)c=c%MOD;\n while(c<0)c+=MOD;\n return c;\n}\nll add(ll a,ll b){\n if(a>=MOD)a=a%MOD;\n while(a<0)a+=MOD;\n if(b>=MOD)b=b%MOD;\n while(b<0)b+=MOD;\n ll ans=(a+b);\n if(ans>=MOD)ans=ans%MOD;\n while(ans<0)ans+=MOD;\n return ans;\n}\nll power(ll a,ll b,ll c){\n ll ans=1;\n while(b){\n if(b&1){\n ans=mul(ans,a);\n }\n a=mul(a,a);\n b=b/2;\n }\n return ans;\n}\ntemplate\nistream &operator>>(istream &in, pair &P){\n in >> P.first >> P.second;\n return in;\n}\n \ntemplate\nostream &operator<<(ostream &out, const pair &P){\n out << \"(\" << P.first << \", \" << P.second << \")\";\n return out;\n}\ntemplate\nistream &operator>>(istream &in, vector &arr){\n for(auto &x: arr) in >> x;\n return in;\n}\ntemplate\nostream &operator<<(ostream &out, const vector &arr){\n for(auto &x: arr) out << x << ' '; cout << \"\\n\";\n return out;\n}\ntemplate\nistream &operator>>(istream &in, deque &arr){\n for(auto &x: arr) in >> x;\n return in;\n}\ntemplate\nostream &operator<<(ostream &out, const deque &arr){\n for(auto &x: arr) out << x << ' '; cout << \"\\n\";\n return out;\n}\nmt19937 rnd(time(0));\nstruct sparse{\n int table[200005][25];\n int n;\n sparse(int len1):n(len1){\n }\n void init(int *a){\n \n for(int i=1;i<=n;i++){\n table[i][0]=a[i];\n }\n \n // cout<=0;j--){\n if(dis&(1< >v[1000005];\n// ll t[1000005];ll h[1000005]; ;;;;;;multiset > > >s;ll A,B;bool vis[1000005];ll dis[1000005];int parent[1000005];vectorans;\n// ll c[1000005];\n \nstruct SOS{\n ll *dp;\n int limit;\n vector&arr;\n \n SOS(int _limit,vector&v):arr(v){\n \n limit=_limit;\n dp=new ll[(1<=0;j--){\n if(j&(1< *v;\n int n;\n long long int *values;\n int *start;\n int *end;\n graph(int size):n(size){\n v=new vector[n+1];\n values=new ll[n+1];\n for(int i=1;i>x>>y;\n v[x].push_back(y);\n v[y].push_back(x);\n }\n for(int i=1;i<=n;i++){\n cin>>values[i];\n }\n }\n void dfs(){\n int gtime=0;\n start=new int[n+1];\n end=new int[n+1];\n dfs_start_end(1,0,gtime);\n }\n void dfs_start_end(int i,int p,int >ime){\n gtime++;\n start[i]=gtime;\n for(auto it:v[i]){\n if(it!=p){\n dfs_start_end(it,i,gtime);\n }\n }\n end[i]=gtime;\n }\n};\n\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n \n\n \n int n,m;\n cin>>n>>m;\n \n string str1=\"\";\n string str2=\"\";\n\n for(int i=1;i<=m;i++){\n str1+=to_string(n);\n // cout<\n#include \n#include\n#include \nusing namespace std;\n\nint main() {\n\tint n, P[200000], ans = 0, a1, a2 = 1;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> P[i];\n\t}\n\ta2 = P[0];\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (P[i] <= a2) {\n\t\t\ta2 = P[i];\n\t\t\tans++;\n\t\t}\n\t\n\t}\n\n\tcout << ans << endl;\n\n\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1579467983, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/C++/s486234912.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s486234912", "user_id": "u459447880"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\n#include \n#include\n#include \nusing namespace std;\n\nint main() {\n\tint n, P[200000], ans = 0, a1, a2 = 1;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> P[i];\n\t}\n\ta2 = P[0];\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (P[i] <= a2) {\n\t\t\ta2 = P[i];\n\t\t\tans++;\n\t\t}\n\t\n\t}\n\n\tcout << ans << endl;\n\n\n\treturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 79, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s492600302", "group_id": "codeNet:p02791", "input_text": "#include\nint a[1000000];\nint main()\n{\n\tint n,min,mint=0,i;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i\nint a[1000000];\nint main()\n{\n\tint n,min,mint=0,i;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 20, "memory_kb": 896}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s510453583", "group_id": "codeNet:p02791", "input_text": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef double D;\ntypedef vector VI;\ntypedef vector VL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef long double ld;\n\n#define rd(x) scanf(\"%d\",&x)\n#define rd2(x,y) scanf(\"%d %d\",&x,&y)\n#define rd3(x,y,z) scanf(\"%d %d %d\",&x,&y,&z)\n#define rl(x) scanf(\"%lld\",&x)\n#define rl2(x,y) scanf(\"%lld %lld\",&x,&y)\n#define rl3(x,y,z) scanf(\"%lld %lld %lld\",&x,&y,&z)\n#define wd(x) printf(\"%d\" ,x)\n#define wd2(x,y) printf(\"%d %d\",x,y)\n#define wl(x) printf(\"%lld\",x)\n#define wl2(x,y) printf(\"%lld %lld\",x,y)\n#define PC(x) putchar(x)\n#define GC() getchar()\n#define NL printf(\"\\n\")\n#define SP printf(\" \")\n \n#define SZ(a) (int)a.size()\n#define ALL(a) a.begin(), a.end()\n#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)\n#define FILL(a,value) memset(a, value, sizeof(a))\n\n#define F first\n#define S second\n#define MP make_pair\n#define PB push_back\n\n#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)\n#define fr(i,s,e) for(int i=s;i=e;i--)\n#define frv(i,a) for(int i = 0;i<(int)a.size();i++)\n#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)\n#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)\n\n#define inf 10000000000000\n#define mod 1000000007\n#define maxn 100009\n#define maxr 100009\n\nvoid solve()\n{\n\tll n;\n\trl(n);\n\tVL arr(n),tmp;\n\tfr(i,0,n)\n\t\trl(arr[i]);\n\tll ct=0,mx=inf;\n\n\tfr(i,0,n)\n\t{\n\t\tmx=min(mx,arr[i]);\n\t\tif(mx==arr[i])\n\t\t\tct++;\n\t}\n\twl(ct);\n\tNL;\n\treturn;\n}\nint main(){\n\t//sstd::ios::sync_with_stdio(false); cin.tie(NULL);\n\tsolve();\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1579464351, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02791/input.txt", "sample_output_relpath": "derived/input_output/data/p02791/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02791/C++/s510453583.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510453583", "user_id": "u431615124"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef double D;\ntypedef vector VI;\ntypedef vector VL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef long double ld;\n\n#define rd(x) scanf(\"%d\",&x)\n#define rd2(x,y) scanf(\"%d %d\",&x,&y)\n#define rd3(x,y,z) scanf(\"%d %d %d\",&x,&y,&z)\n#define rl(x) scanf(\"%lld\",&x)\n#define rl2(x,y) scanf(\"%lld %lld\",&x,&y)\n#define rl3(x,y,z) scanf(\"%lld %lld %lld\",&x,&y,&z)\n#define wd(x) printf(\"%d\" ,x)\n#define wd2(x,y) printf(\"%d %d\",x,y)\n#define wl(x) printf(\"%lld\",x)\n#define wl2(x,y) printf(\"%lld %lld\",x,y)\n#define PC(x) putchar(x)\n#define GC() getchar()\n#define NL printf(\"\\n\")\n#define SP printf(\" \")\n \n#define SZ(a) (int)a.size()\n#define ALL(a) a.begin(), a.end()\n#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)\n#define FILL(a,value) memset(a, value, sizeof(a))\n\n#define F first\n#define S second\n#define MP make_pair\n#define PB push_back\n\n#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)\n#define fr(i,s,e) for(int i=s;i=e;i--)\n#define frv(i,a) for(int i = 0;i<(int)a.size();i++)\n#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)\n#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)\n\n#define inf 10000000000000\n#define mod 1000000007\n#define maxn 100009\n#define maxr 100009\n\nvoid solve()\n{\n\tll n;\n\trl(n);\n\tVL arr(n),tmp;\n\tfr(i,0,n)\n\t\trl(arr[i]);\n\tll ct=0,mx=inf;\n\n\tfr(i,0,n)\n\t{\n\t\tmx=min(mx,arr[i]);\n\t\tif(mx==arr[i])\n\t\t\tct++;\n\t}\n\twl(ct);\n\tNL;\n\treturn;\n}\nint main(){\n\t//sstd::ios::sync_with_stdio(false); cin.tie(NULL);\n\tsolve();\n\treturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1814, "cpu_time_ms": 21, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s207396951", "group_id": "codeNet:p02792", "input_text": "#include \nusing namespace std;\nint N;\ntypedef long long ll;\ntypedef pair P;\n\nP f(int x){\n int a = x%10;\n int b = 0;\n while(x){\n b=x;\n x /= 10;\n }\n return P(a,b);\n}\n\n\nint main(){\n cin >> N;\n map freq;\n for(int i = 1;i<=N;i++){\n P p = f(i);\n freq[p]++;\n }\n ll ans = 0;\n for(int i = 1;i<=N;i++){\n P p = f(i);\n P q(p.second, p.first);\n ans += freq[q];\n }\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1587418060, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/C++/s207396951.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207396951", "user_id": "u529722835"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "#include \nusing namespace std;\nint N;\ntypedef long long ll;\ntypedef pair P;\n\nP f(int x){\n int a = x%10;\n int b = 0;\n while(x){\n b=x;\n x /= 10;\n }\n return P(a,b);\n}\n\n\nint main(){\n cin >> N;\n map freq;\n for(int i = 1;i<=N;i++){\n P p = f(i);\n freq[p]++;\n }\n ll ans = 0;\n for(int i = 1;i<=N;i++){\n P p = f(i);\n P q(p.second, p.first);\n ans += freq[q];\n }\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 9, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s039401996", "group_id": "codeNet:p02792", "input_text": "#include\nusing namespace std;\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n\nint c[10][10];\n\nint main(){\n int n;\n cin >> n;\n\n rep(i,10)rep(j,10) c[i][j] = 0;\n\n int first, last;\n for(int i = 1; i <= n; i++){\n int j = i;\n last = j % 10;\n while(j > 10){\n j /= 10;\n }\n first = j;\n c[first][last]++;\n }\n\n long long ans = 0;\n for(int i = 0; i <= 9; i++){\n for(int j = 0; j <= 9; j++){\n ans += c[i][j] * c[j][i];\n }\n }\n\n cout << ans << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1585088974, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/C++/s039401996.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s039401996", "user_id": "u621582427"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "#include\nusing namespace std;\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n\nint c[10][10];\n\nint main(){\n int n;\n cin >> n;\n\n rep(i,10)rep(j,10) c[i][j] = 0;\n\n int first, last;\n for(int i = 1; i <= n; i++){\n int j = i;\n last = j % 10;\n while(j > 10){\n j /= 10;\n }\n first = j;\n c[first][last]++;\n }\n\n long long ans = 0;\n for(int i = 0; i <= 9; i++){\n for(int j = 0; j <= 9; j++){\n ans += c[i][j] * c[j][i];\n }\n }\n\n cout << ans << endl;\n\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 580, "cpu_time_ms": 5, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s414012048", "group_id": "codeNet:p02792", "input_text": "#include \n#include \nusing namespace std;\n\nint maxnum(int n){\n while(n > 9){\n n /= 10;\n }\n return n;\n}\n\nint minnum(int n){\n return n % 10;\n}\n\nint main(void){\n int N;\n cin >> N;\n \n vector>num(10,vector(10,0));\n for(int i=0;i<=N;i++){\n num[maxnum(i)][minnum(i)]++;\n }\n \n long long ans = 0;\n for(int i=1;i<10;i++){\n for(int j=1;j<10;j++){\n ans += num[i][j] * num[j][i];\n }\n }\n \n cout << ans << endl;\n \n return 0;\n}\n", "language": "C++", "metadata": {"date": 1582759246, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/C++/s414012048.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414012048", "user_id": "u407416173"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint maxnum(int n){\n while(n > 9){\n n /= 10;\n }\n return n;\n}\n\nint minnum(int n){\n return n % 10;\n}\n\nint main(void){\n int N;\n cin >> N;\n \n vector>num(10,vector(10,0));\n for(int i=0;i<=N;i++){\n num[maxnum(i)][minnum(i)]++;\n }\n \n long long ans = 0;\n for(int i=1;i<10;i++){\n for(int j=1;j<10;j++){\n ans += num[i][j] * num[j][i];\n }\n }\n \n cout << ans << endl;\n \n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 481, "cpu_time_ms": 5, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s544939004", "group_id": "codeNet:p02793", "input_text": "#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#define rep(i,n) for (int i = 0; i < (n); ++i)\n\nusing namespace std;\nusing P = pair;\ntypedef long long ll;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\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\n//最大公倍数\nll lcm(ll x,ll y){\n return x/gcd(x,y)*y;\n}\n\nconst int MAX = 1e6+1;\nconst ll MOD = 1e9+7;\n\nlong long fac[MAX], finv[MAX], inv[MAX];\n\n// テーブルを作る前処理\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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\nstruct mint {\n ll x; // typedef long long ll;\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 {\n mint res(*this);\n return res+=a;\n }\n mint operator-(const mint a) const {\n mint res(*this);\n return res-=a;\n }\n mint operator*(const mint a) const {\n mint res(*this);\n return res*=a;\n }\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 // for prime MOD\n mint inv() const {\n return pow(MOD-2);\n }\n mint& operator/=(const mint a) {\n return (*this) *= a.inv();\n }\n mint operator/(const mint a) const {\n mint res(*this);\n return res/=a;\n }\n};\n\n// 二項係数計算\nlong long COM(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\n\n//階乗\nll kaijo(ll k){\n ll sum = 1;\n for (ll i = 1; i <= k; ++i)\n {\n sum *= i;\n sum%=1000000000+7;\n }\n return sum;\n}\n\nlong long modpow(long long a, long long n, long long MOD) {\n long long 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\n//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。\nstruct Sieve {\n int n;\n vector f, primes;\n Sieve(int n=1):n(n), f(n+1) {\n f[0] = f[1] = -1;\n for (ll i = 2; i <= n; ++i) {\n if (f[i]) continue;\n primes.push_back(i);\n f[i] = i;\n for (ll j = i*i; j <= n; j += i) {\n if (!f[j]) f[j] = i;\n }\n }\n }\n bool isPrime(int x) { return f[x] == x;}\n vector factorList(int x) {\n vector res;\n while (x != 1) {\n res.push_back(f[x]);\n x /= f[x];\n }\n return res;\n }\n vector

factor(int x) {\n vector fl = factorList(x);\n if (fl.size() == 0) return {};\n vector

res(1, P(fl[0], 0));\n for (int p : fl) {\n if (res.back().first == p) {\n res.back().second++;\n } else {\n res.emplace_back(p, 1);\n }\n }\n return res;\n }\n};\nstruct UnionFind {\n vector par;\n UnionFind(int n) : par(n, -1) { }\n int root(int x) {\n if (par[x] < 0) return x;\n else return par[x] = root(par[x]);\n }\n bool issame(int x, int y) {\n return root(x) == root(y);\n }\n bool merge(int x, int y) {\n x = root(x); y = root(y);\n if (x == y) return false;\n if (par[x] > par[y]) swap(x, y); // merge technique\n par[x] += par[y];\n par[y] = x;\n return true;\n }\n int size(int x) {\n return -par[root(x)];\n }\n};\n\nll count(int n, int a){\n ll bunshi = 1;\n for(int i = 0; i < a; i++){\n bunshi*=(n-i);\n bunshi%=MOD;\n }\n ll bunbo = 1;\n for(int i = 1; i < a+1; i++){\n bunbo*=i;\n bunbo%=MOD;\n }\n bunbo = modpow(bunbo,MOD-2,MOD);\n // cout<<(bunshi*bunbo)%MOD<で返す。計算量はsqrt(n)。\nvector divisor(ll n) {\n vector ret;\n for(ll i = 1; i * i <= n; i++) {\n if(n % i == 0) {\n ret.push_back(i);\n if(i * i != n) ret.push_back(n / i);\n }\n }\n sort(begin(ret), end(ret));\n return (ret);\n}\n\n\n\n// ここから開始\nconst ll INF = 1e18;\n\nint main(){\n Sieve sieve(1e6);\n int N;\n cin>>N;\n int a[N];\n map mp;\n for(int i = 0; i < N; i++){\n cin>>a[i];\n }\n rep(i,N){\n auto f = sieve.factor(a[i]);\n for(auto p: f){\n mp[p.first] = max(mp[p.first],p.second);\n }\n }\n // for(int j = 2; j <= 100000; j++) if(v[j]>0)cout<\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#define rep(i,n) for (int i = 0; i < (n); ++i)\n\nusing namespace std;\nusing P = pair;\ntypedef long long ll;\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\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\n//最大公倍数\nll lcm(ll x,ll y){\n return x/gcd(x,y)*y;\n}\n\nconst int MAX = 1e6+1;\nconst ll MOD = 1e9+7;\n\nlong long fac[MAX], finv[MAX], inv[MAX];\n\n// テーブルを作る前処理\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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\nstruct mint {\n ll x; // typedef long long ll;\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 {\n mint res(*this);\n return res+=a;\n }\n mint operator-(const mint a) const {\n mint res(*this);\n return res-=a;\n }\n mint operator*(const mint a) const {\n mint res(*this);\n return res*=a;\n }\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 // for prime MOD\n mint inv() const {\n return pow(MOD-2);\n }\n mint& operator/=(const mint a) {\n return (*this) *= a.inv();\n }\n mint operator/(const mint a) const {\n mint res(*this);\n return res/=a;\n }\n};\n\n// 二項係数計算\nlong long COM(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\n\n//階乗\nll kaijo(ll k){\n ll sum = 1;\n for (ll i = 1; i <= k; ++i)\n {\n sum *= i;\n sum%=1000000000+7;\n }\n return sum;\n}\n\nlong long modpow(long long a, long long n, long long MOD) {\n long long 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\n//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。\nstruct Sieve {\n int n;\n vector f, primes;\n Sieve(int n=1):n(n), f(n+1) {\n f[0] = f[1] = -1;\n for (ll i = 2; i <= n; ++i) {\n if (f[i]) continue;\n primes.push_back(i);\n f[i] = i;\n for (ll j = i*i; j <= n; j += i) {\n if (!f[j]) f[j] = i;\n }\n }\n }\n bool isPrime(int x) { return f[x] == x;}\n vector factorList(int x) {\n vector res;\n while (x != 1) {\n res.push_back(f[x]);\n x /= f[x];\n }\n return res;\n }\n vector

factor(int x) {\n vector fl = factorList(x);\n if (fl.size() == 0) return {};\n vector

res(1, P(fl[0], 0));\n for (int p : fl) {\n if (res.back().first == p) {\n res.back().second++;\n } else {\n res.emplace_back(p, 1);\n }\n }\n return res;\n }\n};\nstruct UnionFind {\n vector par;\n UnionFind(int n) : par(n, -1) { }\n int root(int x) {\n if (par[x] < 0) return x;\n else return par[x] = root(par[x]);\n }\n bool issame(int x, int y) {\n return root(x) == root(y);\n }\n bool merge(int x, int y) {\n x = root(x); y = root(y);\n if (x == y) return false;\n if (par[x] > par[y]) swap(x, y); // merge technique\n par[x] += par[y];\n par[y] = x;\n return true;\n }\n int size(int x) {\n return -par[root(x)];\n }\n};\n\nll count(int n, int a){\n ll bunshi = 1;\n for(int i = 0; i < a; i++){\n bunshi*=(n-i);\n bunshi%=MOD;\n }\n ll bunbo = 1;\n for(int i = 1; i < a+1; i++){\n bunbo*=i;\n bunbo%=MOD;\n }\n bunbo = modpow(bunbo,MOD-2,MOD);\n // cout<<(bunshi*bunbo)%MOD<で返す。計算量はsqrt(n)。\nvector divisor(ll n) {\n vector ret;\n for(ll i = 1; i * i <= n; i++) {\n if(n % i == 0) {\n ret.push_back(i);\n if(i * i != n) ret.push_back(n / i);\n }\n }\n sort(begin(ret), end(ret));\n return (ret);\n}\n\n\n\n// ここから開始\nconst ll INF = 1e18;\n\nint main(){\n Sieve sieve(1e6);\n int N;\n cin>>N;\n int a[N];\n map mp;\n for(int i = 0; i < N; i++){\n cin>>a[i];\n }\n rep(i,N){\n auto f = sieve.factor(a[i]);\n for(auto p: f){\n mp[p.first] = max(mp[p.first],p.second);\n }\n }\n // for(int j = 2; j <= 100000; j++) if(v[j]>0)cout<\nusing namespace std;\n\nint main() {\n int H, W, N;\n cin >> H >> W >> N;\n int ans = 0;\n if (N%max(H, W)==0) ans = N/max(H, W);\n else ans = N/max(H, W)+1;\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1579377951, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02795.html", "problem_id": "p02795", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02795/input.txt", "sample_output_relpath": "derived/input_output/data/p02795/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02795/C++/s159247731.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159247731", "user_id": "u852770206"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int H, W, N;\n cin >> H >> W >> N;\n int ans = 0;\n if (N%max(H, W)==0) ans = N/max(H, W);\n else ans = N/max(H, W)+1;\n cout << ans << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "sample_input": "3\n7\n10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02795", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid.\nIn one operation, you can do one of the following two actions:\n\nChoose one row, then paint all the squares in that row black.\n\nChoose one column, then paint all the squares in that column black.\n\nAt least how many operations do you need in order to have N or more black squares in the grid?\nIt is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.\n\nConstraints\n\n1 \\leq H \\leq 100\n\n1 \\leq W \\leq 100\n\n1 \\leq N \\leq H \\times W\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\nW\nN\n\nOutput\n\nPrint the minimum number of operations needed.\n\nSample Input 1\n\n3\n7\n10\n\nSample Output 1\n\n2\n\nYou can have 14 black squares in the grid by performing the \"row\" operation twice, on different rows.\n\nSample Input 2\n\n14\n12\n112\n\nSample Output 2\n\n8\n\nSample Input 3\n\n2\n100\n200\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s743099729", "group_id": "codeNet:p02801", "input_text": "#include \nusing namespace std;\n\nint main() {\nchar C;\ncin>>C;\n if(C=='a')\ncout<<\"b\"<\nusing namespace std;\n\nint main() {\nchar C;\ncin>>C;\n if(C=='a')\ncout<<\"b\"<\n\n#ifdef __LOCAL\n #define DBG(X) cout << #X << \" = \" << (X) << endl;\n #define SAY(X) cout << (X) << endl;\n#else\n #define DBG(X)\n #define SAY(X)\n#endif\n\nusing namespace std;\nusing ll = long long int;\ninline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };\n\n\nint main()\n{\n\n ll N,M;\n ll __correct, __wrong;\n __correct = __wrong = 0;\n cin >> N >> M;\n vector AC(N+10,false);\n\n for(int i=0;i> p >> S;\n if(AC[p]) continue;\n else{\n if(S==\"AC\"){\n AC[p] = true;\n __correct++;\n }\n else if(S==\"WA\"){\n __wrong++;\n }\n }\n\n }\n\n cout << __correct << \" \" << __wrong << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1578886124, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02802/input.txt", "sample_output_relpath": "derived/input_output/data/p02802/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02802/C++/s969550745.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s969550745", "user_id": "u858670323"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "#include \n\n#ifdef __LOCAL\n #define DBG(X) cout << #X << \" = \" << (X) << endl;\n #define SAY(X) cout << (X) << endl;\n#else\n #define DBG(X)\n #define SAY(X)\n#endif\n\nusing namespace std;\nusing ll = long long int;\ninline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };\n\n\nint main()\n{\n\n ll N,M;\n ll __correct, __wrong;\n __correct = __wrong = 0;\n cin >> N >> M;\n vector AC(N+10,false);\n\n for(int i=0;i> p >> S;\n if(AC[p]) continue;\n else{\n if(S==\"AC\"){\n AC[p] = true;\n __correct++;\n }\n else if(S==\"WA\"){\n __wrong++;\n }\n }\n\n }\n\n cout << __correct << \" \" << __wrong << endl;\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 846, "cpu_time_ms": 66, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s539538321", "group_id": "codeNet:p02802", "input_text": "#include\nusing namespace std;\n#include\nint main()\n{int n,m, a[10],i,cnt=0,cnt1=0;\n string s[10];\n cin>>n>>m;\n for(i=0;i>a[i]>>s[i];\n for(i=0;i\nusing namespace std;\n#include\nint main()\n{int n,m, a[10],i,cnt=0,cnt1=0;\n string s[10];\n cin>>n>>m;\n for(i=0;i>a[i]>>s[i];\n for(i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing ll = long long;\n\nusing namespace std;\n\nll mod = 1000000007;\n\nll n_pow(ll a, ll n) {\n\tif (n == 0)return 1;\n\tll t = n_pow(a, n / 2);\n\tt *= t;\n\tt %= mod;\n\tif (n % 2 == 1)t *= a;\n\treturn t % mod;\n}\n\nconst int INF = 1001001001;\n\n\nint main() {\n\tll n, k;\n\tcin >> n >> k;\n\tvectora(n);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\tsort(a.begin(), a.end());\n\tvectorf(n + 1), f_inv(n + 1);\n\tf[0] = 1;\n\tf_inv[0] = n_pow(f[0], mod - 2);\n\tfor (int i = 1; i < n + 1; i++) {\n\t\tf[i] = (i*f[i - 1]) % mod;\n\t\tf_inv[i] = n_pow(f[i], mod - 2);\n\t}\n\tll s_max = 0;\n\tfor (int i = k - 1; i < n; i++) {\n\t\tll tmp = (((f[i] * f_inv[i - k + 1]) % mod)*f_inv[k - 1]) % mod;\n\t\ts_max += (tmp * a[i]) % mod;\n\t\ts_max %= mod;\n\t}\n\tll s_min = 0;\n\tfor (int i = 0; i < n - k + 1; i++) {\n\t\tll tmp = (((f[n - i - 1] * f_inv[n - i - k]) % mod)*f_inv[k - 1]) % mod;\n\t\ts_min += (tmp * a[i]) % mod;\n\t\ts_min %= mod;\n\t}\n\tll ans = (s_max - s_min) % mod;\n\tif (ans < 0)ans += mod;\n\tcout << ans << endl;\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1587844426, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02804.html", "problem_id": "p02804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02804/input.txt", "sample_output_relpath": "derived/input_output/data/p02804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02804/C++/s284041490.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s284041490", "user_id": "u670815700"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "#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\nusing ll = long long;\n\nusing namespace std;\n\nll mod = 1000000007;\n\nll n_pow(ll a, ll n) {\n\tif (n == 0)return 1;\n\tll t = n_pow(a, n / 2);\n\tt *= t;\n\tt %= mod;\n\tif (n % 2 == 1)t *= a;\n\treturn t % mod;\n}\n\nconst int INF = 1001001001;\n\n\nint main() {\n\tll n, k;\n\tcin >> n >> k;\n\tvectora(n);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\tsort(a.begin(), a.end());\n\tvectorf(n + 1), f_inv(n + 1);\n\tf[0] = 1;\n\tf_inv[0] = n_pow(f[0], mod - 2);\n\tfor (int i = 1; i < n + 1; i++) {\n\t\tf[i] = (i*f[i - 1]) % mod;\n\t\tf_inv[i] = n_pow(f[i], mod - 2);\n\t}\n\tll s_max = 0;\n\tfor (int i = k - 1; i < n; i++) {\n\t\tll tmp = (((f[i] * f_inv[i - k + 1]) % mod)*f_inv[k - 1]) % mod;\n\t\ts_max += (tmp * a[i]) % mod;\n\t\ts_max %= mod;\n\t}\n\tll s_min = 0;\n\tfor (int i = 0; i < n - k + 1; i++) {\n\t\tll tmp = (((f[n - i - 1] * f_inv[n - i - k]) % mod)*f_inv[k - 1]) % mod;\n\t\ts_min += (tmp * a[i]) % mod;\n\t\ts_min %= mod;\n\t}\n\tll ans = (s_max - s_min) % mod;\n\tif (ans < 0)ans += mod;\n\tcout << ans << endl;\n\treturn 0;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "sample_input": "4 2\n1 1 3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02804", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1216, "cpu_time_ms": 149, "memory_kb": 2560}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s779637861", "group_id": "codeNet:p02804", "input_text": "#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;\ntypedef long long ll;\ntypedef pair p;\n#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)\nconst int mod = 1000000007;\nconst int INF = 1001001001;\n\nstruct mint {\n ll x; // typedef long long ll;\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) { (x *= a.x) %= mod; return *this;}\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 // for prime mod\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;}\n\nstruct combination {\n vector fact, ifact;\n combination(int n):fact(n+1),ifact(n+1) {\n assert(n < mod);\n fact[0] = 1;\n for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;\n ifact[n] = fact[n].inv();\n for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;\n }\n mint operator()(int n, int k) {\n if (k < 0 || k > n) return 0;\n return fact[n]*ifact[k]*ifact[n-k];\n }\n};\n\nint main() {\n int n, k;\n cin >> n >> k;\n vector a(n);\n rep(i, n) cin >> a[i];\n sort(a.begin(), a.end());\n combination comb(n);\n mint ans = 0;\n rep(ii, 2) {\n mint s = 0;\n rep(i, n) {\n s += comb(i, k - 1) * a[i];\n }\n reverse(a.begin(), a.end());\n if(ii == 0) ans += s;\n else ans -= s;\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1586328828, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02804.html", "problem_id": "p02804", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02804/input.txt", "sample_output_relpath": "derived/input_output/data/p02804/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02804/C++/s779637861.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779637861", "user_id": "u239409893"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "#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;\ntypedef long long ll;\ntypedef pair p;\n#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)\nconst int mod = 1000000007;\nconst int INF = 1001001001;\n\nstruct mint {\n ll x; // typedef long long ll;\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) { (x *= a.x) %= mod; return *this;}\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 // for prime mod\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;}\n\nstruct combination {\n vector fact, ifact;\n combination(int n):fact(n+1),ifact(n+1) {\n assert(n < mod);\n fact[0] = 1;\n for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;\n ifact[n] = fact[n].inv();\n for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;\n }\n mint operator()(int n, int k) {\n if (k < 0 || k > n) return 0;\n return fact[n]*ifact[k]*ifact[n-k];\n }\n};\n\nint main() {\n int n, k;\n cin >> n >> k;\n vector a(n);\n rep(i, n) cin >> a[i];\n sort(a.begin(), a.end());\n combination comb(n);\n mint ans = 0;\n rep(ii, 2) {\n mint s = 0;\n rep(i, n) {\n s += comb(i, k - 1) * a[i];\n }\n reverse(a.begin(), a.end());\n if(ii == 0) ans += s;\n else ans -= s;\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "sample_input": "4 2\n1 1 3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p02804", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor a finite set of integers X, let f(X)=\\max X - \\min X.\n\nGiven are N integers A_1,...,A_N.\n\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over all those ways.\n\nSince the answer can be enormous, print it \\bmod (10^9+7).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 ... A_N\n\nOutput\n\nPrint the answer \\bmod (10^9+7).\n\nSample Input 1\n\n4 2\n1 1 3 4\n\nSample Output 1\n\n11\n\nThere are six ways to choose S: \\{1,1\\},\\{1,3\\},\\{1,4\\},\\{1,3\\},\\{1,4\\}, \\{3,4\\} (we distinguish the two 1s). The value of f(S) for these choices are 0,2,3,2,3,1, respectively, for the total of 11.\n\nSample Input 2\n\n6 3\n10 10 10 -10 -10 -10\n\nSample Output 2\n\n360\n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them, f(S)=0.\n\nSample Input 3\n\n3 1\n1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n\nSample Output 4\n\n999998537\n\nPrint the sum \\bmod (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2245, "cpu_time_ms": 51, "memory_kb": 2176}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s851021925", "group_id": "codeNet:p02805", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define llint long long\n#define inf 1e18\n#define eps 1e-9\n#define mod 1000000007\n\nusing namespace std;\ntypedef pair P;\n\nstruct vec2d{\n\tdouble x, y;\n\tvec2d(){}\n\tvec2d(double x, double y){\n\t\tthis->x = x, this->y = y;\n\t}\n\tdouble add(double a, double b){\n\t\tif(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;\n\t\treturn a+b;\n\t}\n\tvec2d operator+(vec2d ope){\n\t\treturn vec2d(add(x, ope.x), add(y, ope.y));\n\t}\n\tvec2d operator-(vec2d ope){\n\t\treturn vec2d(add(x, -ope.x), add(y, -ope.y));\n\t}\n\tvec2d operator*(double t){\n\t\treturn vec2d(x*t, y*t);\n\t}\n\tvec2d operator/(double t){\n\t\treturn vec2d(x/t, y/t);\n\t}\n\tdouble dot(vec2d ope){\n\t\treturn add(x*ope.x, y*ope.y);\n\t}\n\tdouble cross(vec2d ope){\n\t\treturn add(x*ope.y, -y*ope.x);\n\t}\n\tdouble norm(){\n\t\tdouble d2 = dot(*this);\n\t\tif(d2 > 0) return sqrt(d2);\n\t\treturn 0.0;\n\t}\n};\n\ndouble distPP(vec2d p, vec2d q){\n\treturn (p-q).norm();\n}\n\ndouble distSP(vec2d p, vec2d q, vec2d x)\n{\n\tif((x-p).dot(q-p) <= 0) return distPP(p, x);\n\tif((x-q).dot(p-q) <= 0) return distPP(q, x);\n\treturn fabs( (x-p).cross(q-p) / distPP(p, q) );\n}\n\nbool isOnS(vec2d p, vec2d q, vec2d x)\n{\n\treturn (p-x).cross(q-x) == 0 && (p-x).dot(q-x) <= 0;\n}\n\nbool isCross(vec2d p, vec2d q, vec2d r, vec2d s)\n{\n\tif((q-p).cross(s-r) == 0){\n\t\treturn isOnS(p, q, r) || isOnS(p, q, s) || isOnS(r, s, p) || isOnS(r, s, q);\t\n\t}\n\tdouble t = (r-p).cross(s-r) / (q-p).cross(s-r);\n\tvec2d x = p + (q-p)*t;\n\treturn isOnS(p, q, x) && isOnS(r, s, x);\n}\n\nbool getCross(vec2d p, vec2d q, vec2d r, vec2d s, vec2d &ret)\n{\n\tif((q-p).cross(s-r) == 0){\n\t\treturn false;\n\t}\n\tdouble t = (r-p).cross(s-r) / (q-p).cross(s-r);\n\tret = p + (q-p)*t;\n\treturn true;\n}\n\nllint n;\nvec2d p[55];\n\nbool get(vec2d o, vec2d a, vec2d b, vec2d &ret)\n{\n\tvec2d A = (o + a) * 0.5, B = (o + b) * 0.5;\n\tvec2d nA = vec2d(A.y, -A.x), nB = vec2d(B.y, -B.x);\n\tnA = nA / nA.norm(), nB = nB / nB.norm();\n\t//cout << o.x << \" \" << o.y << \" \" << a.x << \" \" << a.y << \" \" << b.x << \" \" << b.y << endl;\n\treturn getCross(A, A+nA, B, B+nB, ret);\n}\n\nbool check(double r)\n{\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tvec2d c = (p[i] + p[j]) * 0.5;\n\t\t\tbool flag = true;\n\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag) return true;\n\t\t}\n\t}\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tfor(int k = j+1; k <= n; k++){\n\t\t\t\tvec2d c;\n\t\t\t\tif(!get(p[i], p[j], p[k], c)) continue;\n\t\t\t\t//cout << c.x << \" \" << c.y << endl;\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\t\tflag = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag) return true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nint main(void)\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\t\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y;\n\t\n\tif(n == 2){\n\t\tprintf(\"%.11f\\n\", distPP(p[1], p[2])*0.5);\n\t\treturn 0;\n\t}\n\t\n\tdouble ans = inf;\n\t\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tvec2d c = (p[i] + p[j]) * 0.5;\n\t\t\tdouble r = distPP(c, p[i]);\n\t\t\tbool flag = true;\n\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag) ans = min(ans, r);\n\t\t}\n\t}\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tfor(int k = j+1; k <= n; k++){\n\t\t\t\tvec2d c;\n\t\t\t\tdouble r = distPP(c, p[i]);\n\t\t\t\tif(!get(p[i], p[j], p[k], c)) continue;\n\t\t\t\t//cout << c.x << \" \" << c.y << endl;\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\t\tflag = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag) ans = min(ans, r);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.11f\\n\", ans);\n\t\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1578883962, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02805.html", "problem_id": "p02805", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02805/input.txt", "sample_output_relpath": "derived/input_output/data/p02805/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02805/C++/s851021925.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s851021925", "user_id": "u319282133"}, "prompt_components": {"gold_output": "0.500000000000000000\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define llint long long\n#define inf 1e18\n#define eps 1e-9\n#define mod 1000000007\n\nusing namespace std;\ntypedef pair P;\n\nstruct vec2d{\n\tdouble x, y;\n\tvec2d(){}\n\tvec2d(double x, double y){\n\t\tthis->x = x, this->y = y;\n\t}\n\tdouble add(double a, double b){\n\t\tif(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;\n\t\treturn a+b;\n\t}\n\tvec2d operator+(vec2d ope){\n\t\treturn vec2d(add(x, ope.x), add(y, ope.y));\n\t}\n\tvec2d operator-(vec2d ope){\n\t\treturn vec2d(add(x, -ope.x), add(y, -ope.y));\n\t}\n\tvec2d operator*(double t){\n\t\treturn vec2d(x*t, y*t);\n\t}\n\tvec2d operator/(double t){\n\t\treturn vec2d(x/t, y/t);\n\t}\n\tdouble dot(vec2d ope){\n\t\treturn add(x*ope.x, y*ope.y);\n\t}\n\tdouble cross(vec2d ope){\n\t\treturn add(x*ope.y, -y*ope.x);\n\t}\n\tdouble norm(){\n\t\tdouble d2 = dot(*this);\n\t\tif(d2 > 0) return sqrt(d2);\n\t\treturn 0.0;\n\t}\n};\n\ndouble distPP(vec2d p, vec2d q){\n\treturn (p-q).norm();\n}\n\ndouble distSP(vec2d p, vec2d q, vec2d x)\n{\n\tif((x-p).dot(q-p) <= 0) return distPP(p, x);\n\tif((x-q).dot(p-q) <= 0) return distPP(q, x);\n\treturn fabs( (x-p).cross(q-p) / distPP(p, q) );\n}\n\nbool isOnS(vec2d p, vec2d q, vec2d x)\n{\n\treturn (p-x).cross(q-x) == 0 && (p-x).dot(q-x) <= 0;\n}\n\nbool isCross(vec2d p, vec2d q, vec2d r, vec2d s)\n{\n\tif((q-p).cross(s-r) == 0){\n\t\treturn isOnS(p, q, r) || isOnS(p, q, s) || isOnS(r, s, p) || isOnS(r, s, q);\t\n\t}\n\tdouble t = (r-p).cross(s-r) / (q-p).cross(s-r);\n\tvec2d x = p + (q-p)*t;\n\treturn isOnS(p, q, x) && isOnS(r, s, x);\n}\n\nbool getCross(vec2d p, vec2d q, vec2d r, vec2d s, vec2d &ret)\n{\n\tif((q-p).cross(s-r) == 0){\n\t\treturn false;\n\t}\n\tdouble t = (r-p).cross(s-r) / (q-p).cross(s-r);\n\tret = p + (q-p)*t;\n\treturn true;\n}\n\nllint n;\nvec2d p[55];\n\nbool get(vec2d o, vec2d a, vec2d b, vec2d &ret)\n{\n\tvec2d A = (o + a) * 0.5, B = (o + b) * 0.5;\n\tvec2d nA = vec2d(A.y, -A.x), nB = vec2d(B.y, -B.x);\n\tnA = nA / nA.norm(), nB = nB / nB.norm();\n\t//cout << o.x << \" \" << o.y << \" \" << a.x << \" \" << a.y << \" \" << b.x << \" \" << b.y << endl;\n\treturn getCross(A, A+nA, B, B+nB, ret);\n}\n\nbool check(double r)\n{\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tvec2d c = (p[i] + p[j]) * 0.5;\n\t\t\tbool flag = true;\n\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag) return true;\n\t\t}\n\t}\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tfor(int k = j+1; k <= n; k++){\n\t\t\t\tvec2d c;\n\t\t\t\tif(!get(p[i], p[j], p[k], c)) continue;\n\t\t\t\t//cout << c.x << \" \" << c.y << endl;\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\t\tflag = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag) return true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nint main(void)\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\t\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y;\n\t\n\tif(n == 2){\n\t\tprintf(\"%.11f\\n\", distPP(p[1], p[2])*0.5);\n\t\treturn 0;\n\t}\n\t\n\tdouble ans = inf;\n\t\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tvec2d c = (p[i] + p[j]) * 0.5;\n\t\t\tdouble r = distPP(c, p[i]);\n\t\t\tbool flag = true;\n\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\tflag = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag) ans = min(ans, r);\n\t\t}\n\t}\n\tfor(int i = 1; i <= n; i++){\n\t\tfor(int j = i+1; j <= n; j++){\n\t\t\tfor(int k = j+1; k <= n; k++){\n\t\t\t\tvec2d c;\n\t\t\t\tdouble r = distPP(c, p[i]);\n\t\t\t\tif(!get(p[i], p[j], p[k], c)) continue;\n\t\t\t\t//cout << c.x << \" \" << c.y << endl;\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int l = 1; l <= n; l++){\n\t\t\t\t\tif(distPP(c, p[l]) > r + eps){\n\t\t\t\t\t\tflag = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag) ans = min(ans, r);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.11f\\n\", ans);\n\t\n\treturn 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\n\nFind the minimum radius of a circle such that all the points are inside or on it.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n0 \\leq x_i \\leq 1000\n\n0 \\leq y_i \\leq 1000\n\nThe given N points are all different.\n\nThe values in input are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum radius of a circle such that all the N points are inside or on it.\n\nYour output will be considered correct if the absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n2\n0 0\n1 0\n\nSample Output 1\n\n0.500000000000000000\n\nBoth points are contained in the circle centered at (0.5,0) with a radius of 0.5.\n\nSample Input 2\n\n3\n0 0\n0 1\n1 0\n\nSample Output 2\n\n0.707106781186497524\n\nSample Input 3\n\n10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n\nSample Output 3\n\n6.726812023536805158\n\nIf the absolute or relative error from our answer is at most 10^{-6}, the output will be considered correct.", "sample_input": "2\n0 0\n1 0\n"}, "reference_outputs": ["0.500000000000000000\n"], "source_document_id": "p02805", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\n\nFind the minimum radius of a circle such that all the points are inside or on it.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n0 \\leq x_i \\leq 1000\n\n0 \\leq y_i \\leq 1000\n\nThe given N points are all different.\n\nThe values in input are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint the minimum radius of a circle such that all the N points are inside or on it.\n\nYour output will be considered correct if the absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n2\n0 0\n1 0\n\nSample Output 1\n\n0.500000000000000000\n\nBoth points are contained in the circle centered at (0.5,0) with a radius of 0.5.\n\nSample Input 2\n\n3\n0 0\n0 1\n1 0\n\nSample Output 2\n\n0.707106781186497524\n\nSample Input 3\n\n10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n\nSample Output 3\n\n6.726812023536805158\n\nIf the absolute or relative error from our answer is at most 10^{-6}, the output will be considered correct.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3760, "cpu_time_ms": 7, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s619908578", "group_id": "codeNet:p02806", "input_text": "#include\n#define F first\n#define S second\nusing ll = long long;\nconst ll mod = 1000000007;\nconst ll infi = 1000000000000000;\nconst ll md = 998244353;\nusing namespace std;\nusing vl = vector;\nusing pll = pair;\n\nvoid solve(){\n int n,sum;\n cin>>n;\n vector> a(n);\n string s;\n for(int i=0;i>a[i].F>>a[i].S;\n }\n cin>>s;\n int f=1,i;\n sum =0;\n for(i=0;i>n; for(int i=0;i\n#define F first\n#define S second\nusing ll = long long;\nconst ll mod = 1000000007;\nconst ll infi = 1000000000000000;\nconst ll md = 998244353;\nusing namespace std;\nusing vl = vector;\nusing pll = pair;\n\nvoid solve(){\n int n,sum;\n cin>>n;\n vector> a(n);\n string s;\n for(int i=0;i>a[i].F>>a[i].S;\n }\n cin>>s;\n int f=1,i;\n sum =0;\n for(i=0;i>n; for(int i=0;i\nusing namespace std;\nint main()\n{\n int p,n;\n cin>>p>>n;\n int mul = p*500;\n if(mul>=n)\n {\n cout<<\"Yes\";\n }\n else cout<<\"No\";\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1590601225, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02811/input.txt", "sample_output_relpath": "derived/input_output/data/p02811/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02811/C++/s666126444.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s666126444", "user_id": "u020840327"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\nint main()\n{\n int p,n;\n cin>>p>>n;\n int mul = p*500;\n if(mul>=n)\n {\n cout<<\"Yes\";\n }\n else cout<<\"No\";\n\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s749510123", "group_id": "codeNet:p02812", "input_text": "#include \nusing namespace std;\n \nint main() {\n int N;\n int x=0;\n string S;\n cin >> N >> S;\n for(int i=0;i\nusing namespace std;\n \nint main() {\n int N;\n int x=0;\n string S;\n cin >> N >> S;\n for(int i=0;i\n#define pi 2*acos(0.0)\n#define ll long long\n#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define Node struct node\n#define spc \" \"\n#define E 2.71828182845904523536\n#define pb push_back\n#define pp pop_back\n#define valid(nx,ny) nx>=0 && nx=0 && ny\n#define infinity 10000000000000000\n#define mod 1000000007\nint fx[]={0,0,+1,-1};\nint fy[]={+1,-1,0,0};\n\nusing namespace std;\n///check n=1;\n///check corner case;\nconst int maX=1e5+1;\nvectorGraph[maX],cost[maX];\nll visit[maX];\n\n\nint main()\n{\n ll n,i,j,cc=0,k;\n cin>>n;\n ll p[n],q[n];for(i=0;i>p[i];\n for(i=0;i>q[i];\n vectora;\n for(i=0;i\n#define pi 2*acos(0.0)\n#define ll long long\n#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define Node struct node\n#define spc \" \"\n#define E 2.71828182845904523536\n#define pb push_back\n#define pp pop_back\n#define valid(nx,ny) nx>=0 && nx=0 && ny\n#define infinity 10000000000000000\n#define mod 1000000007\nint fx[]={0,0,+1,-1};\nint fy[]={+1,-1,0,0};\n\nusing namespace std;\n///check n=1;\n///check corner case;\nconst int maX=1e5+1;\nvectorGraph[maX],cost[maX];\nll visit[maX];\n\n\nint main()\n{\n ll n,i,j,cc=0,k;\n cin>>n;\n ll p[n],q[n];for(i=0;i>p[i];\n for(i=0;i>q[i];\n vectora;\n for(i=0;i\nusing namespace std;\n\nint main()\n{\n int n,i,j,k;cin>>n;\n int p[n],q[n];\n for(i=0;i>p[i];\n for(i=0;i>q[i];\n int arr[n]; for(i=0;i\nusing namespace std;\n\nint main()\n{\n int n,i,j,k;cin>>n;\n int p[n],q[n];\n for(i=0;i>p[i];\n for(i=0;i>q[i];\n int arr[n]; for(i=0;i\nusing namespace std;\n#define ll long long\n#define rep(i,N) for(int i = 0;i < (int)(N);i++)\nint main(){\nint n;\n cin>>n;\n vectorp(n),q(n);\n rep(i,n) cin>>p[i]>>q[i];\n vectora(n);\n rep(i,n) a[i]=i+1;\n \n map,int> mp;\n do{\n mp[a]=mp.size();\n }while(next_permutation(a.begin(),a.end()));\n int ans=abs(mp[p]-mp[q]);\n cout<\nusing namespace std;\n#define ll long long\n#define rep(i,N) for(int i = 0;i < (int)(N);i++)\nint main(){\nint n;\n cin>>n;\n vectorp(n),q(n);\n rep(i,n) cin>>p[i]>>q[i];\n vectora(n);\n rep(i,n) a[i]=i+1;\n \n map,int> mp;\n do{\n mp[a]=mp.size();\n }while(next_permutation(a.begin(),a.end()));\n int ans=abs(mp[p]-mp[q]);\n cout<\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n////\n//#include //\n/////////\n\ntypedef long long LL;\ntypedef long double LD;\ntypedef unsigned long long ULL;\n\n////定数\nconst int INF = (int)1e9 + 10;\nconst LL MOD = (LL)1e9 + 7;\nconst LL LINF = (LL)4e18 + 20;\nconst LD PI = acos(-1.0);\nconst double EPS = 1e-9; \n/////////\nusing namespace::std;\n//////////////\nLL gcd(LL a, LL b) {\n\tif (b == 0) {\n\t\treturn a;\n\t}\n\telse {\n\t\treturn gcd(b, a % b);\n\t}\n}\nLL lcm(LL a, LL b) {\n\treturn a / gcd(a, b) * b;\n}\n\nvoid solve() {\n\tLL N, M;\n\tcin >> N >> M;\n\n\tint SF = -1;\n\tvector A(N);\n\tfor (int i = 0; i < N; ++i) {\n\t\tcin >> A[i];\n\t\tint cnt = 0;\n\t\twhile (A[i] % 2 == 0) {\n\t\t\t++cnt;\n\t\t\tA[i] /= 2;\n\t\t}\n\n\t\tif (SF == -1) {\n\t\t\tSF = cnt;\n\t\t}\n\t\telse if(SF != cnt){\n\t\t\tcout << 0 << endl;\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\t\n\tLL res = A[0];\n\tfor (int i = 1; i < N; ++i) {\n\t\tres = lcm(res, A[i]);\n\t\tif (res > M || res < 0) {\n\t\t\tcout << 0 << endl;//関係ない\n\t\t\treturn;\n\t\t}\n\t}\n\tres <<= (SF-1);\n\tLL ter = (M / res) - (M / (res * 2));\n\tcout << ter << endl;\n}\n\nsigned main(void) {\n\tstd::cin.tie(0);\n\tstd::ios::sync_with_stdio(false);\n\tstd::cout << std::fixed;//小数を10進数表示\n\tcout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別\t\n\n\tsolve();\n}\n", "language": "C++", "metadata": {"date": 1586402189, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/C++/s565306836.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565306836", "user_id": "u870307668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#define _USE_MATH_DEFINES\n\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n////\n//#include //\n/////////\n\ntypedef long long LL;\ntypedef long double LD;\ntypedef unsigned long long ULL;\n\n////定数\nconst int INF = (int)1e9 + 10;\nconst LL MOD = (LL)1e9 + 7;\nconst LL LINF = (LL)4e18 + 20;\nconst LD PI = acos(-1.0);\nconst double EPS = 1e-9; \n/////////\nusing namespace::std;\n//////////////\nLL gcd(LL a, LL b) {\n\tif (b == 0) {\n\t\treturn a;\n\t}\n\telse {\n\t\treturn gcd(b, a % b);\n\t}\n}\nLL lcm(LL a, LL b) {\n\treturn a / gcd(a, b) * b;\n}\n\nvoid solve() {\n\tLL N, M;\n\tcin >> N >> M;\n\n\tint SF = -1;\n\tvector A(N);\n\tfor (int i = 0; i < N; ++i) {\n\t\tcin >> A[i];\n\t\tint cnt = 0;\n\t\twhile (A[i] % 2 == 0) {\n\t\t\t++cnt;\n\t\t\tA[i] /= 2;\n\t\t}\n\n\t\tif (SF == -1) {\n\t\t\tSF = cnt;\n\t\t}\n\t\telse if(SF != cnt){\n\t\t\tcout << 0 << endl;\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\t\n\tLL res = A[0];\n\tfor (int i = 1; i < N; ++i) {\n\t\tres = lcm(res, A[i]);\n\t\tif (res > M || res < 0) {\n\t\t\tcout << 0 << endl;//関係ない\n\t\t\treturn;\n\t\t}\n\t}\n\tres <<= (SF-1);\n\tLL ter = (M / res) - (M / (res * 2));\n\tcout << ter << endl;\n}\n\nsigned main(void) {\n\tstd::cin.tie(0);\n\tstd::ios::sync_with_stdio(false);\n\tstd::cout << std::fixed;//小数を10進数表示\n\tcout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別\t\n\n\tsolve();\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1555, "cpu_time_ms": 16, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s386495902", "group_id": "codeNet:p02814", "input_text": "/*\nこれを入れて実行\ng++ code.cpp\n./a.out\n */\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 \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n \nint dy4[4] = {-1, 0, +1, 0};\nint dx4[4] = {0, +1, 0, -1};\nint dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};\nint dx8[8] = {0, 1, 1, 1, 0, -1, -1, -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 \nll gcd(ll a, ll b){\n\tif (b == 0)return a;\n\treturn gcd(b, a % b);\n}\n \nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n \nll nCr(ll n, ll r){\n if(r == 0 || r == n){\n return 1;\n } else if(r == 1){\n return n;\n }\n return (nCr(n - 1, r) + nCr(n - 1, r - 1));\n}\n \nll nPr(ll n, ll r){\n r = n - r;\n ll ret = 1;\n for (ll i = n; i >= r + 1; i--) ret *= i;\n return ret;\n}\n \n//-----------------------ここから-----------\n\nint main(void){\n ll n,m;\n cin >> n >> m;\n\n vector a(n);\n for(int i = 0; i < n; i++) cin >> a[i];\n\n bool f = true;\n ll maxi = 0;\n ll lcmAll = 1;\n\n set div;\n\n\n for(int i = 0; i < n; i++){\n maxi = max(maxi, a[i]);\n lcmAll = lcm(lcmAll, a[i] / 2);\n if((a[i] / 2) % 2 == 0){\n ll cnt = 0;\n ll tmp = a[i];\n while(true){\n if(tmp % 2 == 0){\n tmp /= 2;\n cnt++;\n } else {\n break;\n }\n }\n div.insert(cnt);\n } else {\n div.insert(1);\n }\n }\n\n if(div.size() > 1){\n f = false;\n }\n\n if(!f){\n cout << 0 << endl;\n return 0;\n }\n\n ll ans = 0;\n\n\n ans = (m / lcmAll) - m / (lcmAll * 2);\n\n\n cout << ans << endl;\n\n\n}", "language": "C++", "metadata": {"date": 1578718291, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/C++/s386495902.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s386495902", "user_id": "u845000384"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/*\nこれを入れて実行\ng++ code.cpp\n./a.out\n */\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 \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n \nint dy4[4] = {-1, 0, +1, 0};\nint dx4[4] = {0, +1, 0, -1};\nint dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};\nint dx8[8] = {0, 1, 1, 1, 0, -1, -1, -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 \nll gcd(ll a, ll b){\n\tif (b == 0)return a;\n\treturn gcd(b, a % b);\n}\n \nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n \nll nCr(ll n, ll r){\n if(r == 0 || r == n){\n return 1;\n } else if(r == 1){\n return n;\n }\n return (nCr(n - 1, r) + nCr(n - 1, r - 1));\n}\n \nll nPr(ll n, ll r){\n r = n - r;\n ll ret = 1;\n for (ll i = n; i >= r + 1; i--) ret *= i;\n return ret;\n}\n \n//-----------------------ここから-----------\n\nint main(void){\n ll n,m;\n cin >> n >> m;\n\n vector a(n);\n for(int i = 0; i < n; i++) cin >> a[i];\n\n bool f = true;\n ll maxi = 0;\n ll lcmAll = 1;\n\n set div;\n\n\n for(int i = 0; i < n; i++){\n maxi = max(maxi, a[i]);\n lcmAll = lcm(lcmAll, a[i] / 2);\n if((a[i] / 2) % 2 == 0){\n ll cnt = 0;\n ll tmp = a[i];\n while(true){\n if(tmp % 2 == 0){\n tmp /= 2;\n cnt++;\n } else {\n break;\n }\n }\n div.insert(cnt);\n } else {\n div.insert(1);\n }\n }\n\n if(div.size() > 1){\n f = false;\n }\n\n if(!f){\n cout << 0 << endl;\n return 0;\n }\n\n ll ans = 0;\n\n\n ans = (m / lcmAll) - m / (lcmAll * 2);\n\n\n cout << ans << endl;\n\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2028, "cpu_time_ms": 58, "memory_kb": 1152}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s447314854", "group_id": "codeNet:p02814", "input_text": "#include \nusing namespace std;\n#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)\n\nint main(){\n int64_t n, m;\n cin >> n >> m;\n vector a(n);\n rep(i,n) cin >> a[i];\n\n vector b(n);\n bool bl = true;\n int64_t ans = 0;\n rep(i,n){\n int64_t ai = a[i];\n int64_t bi = 0;\n while(ai%2 != 0){\n ai /= 2;\n bi++;\n }\n b[i] = bi;\n if(i > 0 && b[i-1] != b[i]){\n bl = false;\n break;\n }\n }\n int64_t lcma = a[n-1];\n if(bl){\n rep(i,n-1){\n int64_t ai = a[i]; \n lcma = ai/__gcd(ai,lcma)*lcma;\n }\n lcma /= 2;\n ans = (m/lcma+1)/2;\n if(ans < 0) ans = 0;\n }\n cout << ans << endl;\n //cout << lcma << endl;\n}", "language": "C++", "metadata": {"date": 1578712980, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/C++/s447314854.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s447314854", "user_id": "u366974105"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)\n\nint main(){\n int64_t n, m;\n cin >> n >> m;\n vector a(n);\n rep(i,n) cin >> a[i];\n\n vector b(n);\n bool bl = true;\n int64_t ans = 0;\n rep(i,n){\n int64_t ai = a[i];\n int64_t bi = 0;\n while(ai%2 != 0){\n ai /= 2;\n bi++;\n }\n b[i] = bi;\n if(i > 0 && b[i-1] != b[i]){\n bl = false;\n break;\n }\n }\n int64_t lcma = a[n-1];\n if(bl){\n rep(i,n-1){\n int64_t ai = a[i]; \n lcma = ai/__gcd(ai,lcma)*lcma;\n }\n lcma /= 2;\n ans = (m/lcma+1)/2;\n if(ans < 0) ans = 0;\n }\n cout << ans << endl;\n //cout << lcma << endl;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 812, "cpu_time_ms": 60, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s188282414", "group_id": "codeNet:p02815", "input_text": "#include \nusing namespace std;\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n#define FOR(x,to) for(x=0;x<(to);x++)\n#define FORR(x,arr) for(auto& x:arr)\n#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)\n#define ALL(a) (a.begin()),(a.end())\n#define ZERO(a) memset(a,0,sizeof(a))\n#define MINUS(a) memset(a,0xff,sizeof(a))\n//-------------------------------------------------------\n\nint N;\nll C[202020];\nll mo=1000000007;\n\nvoid solve() {\n\tint i,j,k,l,r,x,y; string s;\n\t\n\tcin>>N;\n\tFOR(i,N) cin>>C[i];\n\tsort(C,C+N);\n\treverse(C,C+N);\n\tll p=1,q=1;\n\tFOR(i,N) q=q*2%mo;\n\tll sum=1;\n\tll ret=0;\n\tFOR(i,N) {\n\t\tq=q*(mo+1)/2%mo;\n\t\t(ret+=(C[i]*sum)%mo*q)%=mo;\n\t\tsum=(sum*2+p)%mo;\n\t\tp=p*2%mo;\n\t}\n\tcout<\nusing namespace std;\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n#define FOR(x,to) for(x=0;x<(to);x++)\n#define FORR(x,arr) for(auto& x:arr)\n#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)\n#define ALL(a) (a.begin()),(a.end())\n#define ZERO(a) memset(a,0,sizeof(a))\n#define MINUS(a) memset(a,0xff,sizeof(a))\n//-------------------------------------------------------\n\nint N;\nll C[202020];\nll mo=1000000007;\n\nvoid solve() {\n\tint i,j,k,l,r,x,y; string s;\n\t\n\tcin>>N;\n\tFOR(i,N) cin>>C[i];\n\tsort(C,C+N);\n\treverse(C,C+N);\n\tll p=1,q=1;\n\tFOR(i,N) q=q*2%mo;\n\tll sum=1;\n\tll ret=0;\n\tFOR(i,N) {\n\t\tq=q*(mo+1)/2%mo;\n\t\t(ret+=(C[i]*sum)%mo*q)%=mo;\n\t\tsum=(sum*2+p)%mo;\n\t\tp=p*2%mo;\n\t}\n\tcout<\n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\n\nint main(void){\n string s,t;\n \n cin >> s >> t;\n \n cout << t << s << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1583037298, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02817/input.txt", "sample_output_relpath": "derived/input_output/data/p02817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02817/C++/s817559625.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s817559625", "user_id": "u088895504"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\n\nint main(void){\n string s,t;\n \n cin >> s >> t;\n \n cout << t << s << endl;\n \n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s115896107", "group_id": "codeNet:p02819", "input_text": "/**\n * Created by hiramekun at 19:56 on 2019-12-29.\n */\n#include \n\nusing namespace std;\n\nusing ll = long long;\nusing vl = vector;\nusing vvl = vector;\nusing vb = vector;\nusing P = pair;\ntemplate using pq = priority_queue;\ntemplate using minpq = priority_queue, greater>;\ntemplate using ump = unordered_map;\nconst ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};\nconst ll mod = 1000000007;\nconst ll inf = ll(1e9);\nconst ll e5 = ll(1e5);\nconst ll ll_inf = ll(1e9) * ll(1e9);\n\n#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)\n#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)\n#define each(i, mp) for(auto& i:mp)\n#define eb emplace_back\n#define F first\n#define S second\n#define all(obj) (obj).begin(), (obj).end()\n\ntemplate\nostream &operator<<(ostream &out, const vector &list) {\n ll n = list.size();\n rep(i, n) out << list[i] << ' ';\n return out;\n}\n\ntemplate\nistream &operator>>(istream &in, vector &list) {\n ll n = list.size();\n rep(i, n) in >> list[i];\n return in;\n}\n\ntemplate\nostream &operator<<(ostream &out, const vector> &list) {\n ll n = list.size();\n rep(i, n) out << list[i] << '\\n';\n return out;\n}\n\n/* ------------- ANSWER ------------- */\n/* ---------------------------------- */\n// 素因数分解\nmap prime_factor(ll n) {\n map mp;\n for (ll i = 2; i * i <= n; ++i) {\n while (n % i == 0) {\n mp[i]++;\n n /= i;\n }\n }\n if (n != 1) mp[n]++;\n return mp;\n}\n\n// 素数判定\nbool is_prime(ll n) {\n for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;\n return n != 1;\n}\n\n// 約数列挙\nvector divisor(ll n) {\n vector res;\n for (ll i = 1; i * i <= n; ++i) {\n if (n % i == 0) {\n res.emplace_back(i);\n if (i != n / i) res.emplace_back(n / i);\n }\n }\n return res;\n}\n\nvoid solve() {\n ll x;\n cin >> x;\n for (ll i = x; i <= 1e5 * 2; ++i) {\n if (is_prime(i)) {\n cout << i << '\\n';\n return;\n }\n }\n}\n\nint main() {\n#ifdef MY_DEBUG\n while (true) {\n#endif\n solve();\n#ifdef MY_DEBUG\n }\n#endif\n return 0;\n}", "language": "C++", "metadata": {"date": 1577676756, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02819/input.txt", "sample_output_relpath": "derived/input_output/data/p02819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02819/C++/s115896107.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115896107", "user_id": "u136378781"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "/**\n * Created by hiramekun at 19:56 on 2019-12-29.\n */\n#include \n\nusing namespace std;\n\nusing ll = long long;\nusing vl = vector;\nusing vvl = vector;\nusing vb = vector;\nusing P = pair;\ntemplate using pq = priority_queue;\ntemplate using minpq = priority_queue, greater>;\ntemplate using ump = unordered_map;\nconst ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};\nconst ll mod = 1000000007;\nconst ll inf = ll(1e9);\nconst ll e5 = ll(1e5);\nconst ll ll_inf = ll(1e9) * ll(1e9);\n\n#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)\n#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)\n#define each(i, mp) for(auto& i:mp)\n#define eb emplace_back\n#define F first\n#define S second\n#define all(obj) (obj).begin(), (obj).end()\n\ntemplate\nostream &operator<<(ostream &out, const vector &list) {\n ll n = list.size();\n rep(i, n) out << list[i] << ' ';\n return out;\n}\n\ntemplate\nistream &operator>>(istream &in, vector &list) {\n ll n = list.size();\n rep(i, n) in >> list[i];\n return in;\n}\n\ntemplate\nostream &operator<<(ostream &out, const vector> &list) {\n ll n = list.size();\n rep(i, n) out << list[i] << '\\n';\n return out;\n}\n\n/* ------------- ANSWER ------------- */\n/* ---------------------------------- */\n// 素因数分解\nmap prime_factor(ll n) {\n map mp;\n for (ll i = 2; i * i <= n; ++i) {\n while (n % i == 0) {\n mp[i]++;\n n /= i;\n }\n }\n if (n != 1) mp[n]++;\n return mp;\n}\n\n// 素数判定\nbool is_prime(ll n) {\n for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;\n return n != 1;\n}\n\n// 約数列挙\nvector divisor(ll n) {\n vector res;\n for (ll i = 1; i * i <= n; ++i) {\n if (n % i == 0) {\n res.emplace_back(i);\n if (i != n / i) res.emplace_back(n / i);\n }\n }\n return res;\n}\n\nvoid solve() {\n ll x;\n cin >> x;\n for (ll i = x; i <= 1e5 * 2; ++i) {\n if (is_prime(i)) {\n cout << i << '\\n';\n return;\n }\n }\n}\n\nint main() {\n#ifdef MY_DEBUG\n while (true) {\n#endif\n solve();\n#ifdef MY_DEBUG\n }\n#endif\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2277, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s955887450", "group_id": "codeNet:p02821", "input_text": "#include\n#define ll long long\n#define mp make_pair\n#define F first\n#define S second\n#define db double\n#define pb push_back\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\nusing namespace std;\n \n ll mod=1e9 +7;\n \nll expo(ll base,ll exponent,ll mod){\n ll ans=1;\n while(exponent!=0){\n if(exponent&1) ans=(1LL*ans*base)%mod;\n base=(1LL*base*base)%mod;\n exponent>>=1;\n }\n return ans%mod;\n}\n \nvector prime(90000002,true);\nvoid Sieve() \n{ \n \n for (int p=2; p*p<=90000001; p++) \n { \n // If prime[p] is not changed, then it is a prime \n if (prime[p] == true) \n { \n for (int i=p*p; i<=90000001; i += p) \n prime[i] = false; \n } \n } \n}\n\nconst ll M=200006;\nll f[M],inv[M];\n\nvoid compute(){\n f[0]=1;\n rep(i,1,M-1){\n f[i]=(1LL*i*f[i-1])%mod;\n }\n inv[M-1]=expo(f[M-1],mod-2,mod);\n for(ll i=M-2;i>=0;i--){\n inv[i]=(1LL*(i+1)*inv[i+1])%mod;\n }\n}\nll C(ll n,ll r){\n return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;\n}\n\nll pre[200005]={0};\n\npair func(ll x,vector&a,ll n)\n{\n ll num=0,i;\n ll res=0;\n rep(i,0,n-1)\n {\n ll it=lower_bound(a.begin(),a.end(),x-a[i])-a.begin();\n num+=n-it;\n res+=pre[n-1]-pre[it-1];\n res+=(n-it)*a[i];\n }\n return {res,num};\n\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n // compute();\n Sieve();\n ll tests=1;\n // cin>>tests;\n while(tests--)\n {\n ll i,j,n,m;\n cin>>n>>m;\n vectora(n),b(n),c(n);\n rep(i,0,n-1) cin>>a[i];\n sort(a.begin(),a.end());\n pre[0]=a[0];\n rep(i,1,n-1) pre[i]=pre[i-1]+a[i];\n\n ll lo=0,hi=200005;\n ll ans=-1;\n while(hi>=lo)\n {\n ll mid=(lo+hi)/2;\n if(func(mid,a,n).second>=m)\n {\n lo=mid+1;\n }\n else\n {\n // ans=mid;\n hi=mid-1;\n }\n }\n ans=func(lo-1,a,n).first;\n ans-=(func(lo-1,a,n).second-m)*(lo-1);\n cout<\n#define ll long long\n#define mp make_pair\n#define F first\n#define S second\n#define db double\n#define pb push_back\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\nusing namespace std;\n \n ll mod=1e9 +7;\n \nll expo(ll base,ll exponent,ll mod){\n ll ans=1;\n while(exponent!=0){\n if(exponent&1) ans=(1LL*ans*base)%mod;\n base=(1LL*base*base)%mod;\n exponent>>=1;\n }\n return ans%mod;\n}\n \nvector prime(90000002,true);\nvoid Sieve() \n{ \n \n for (int p=2; p*p<=90000001; p++) \n { \n // If prime[p] is not changed, then it is a prime \n if (prime[p] == true) \n { \n for (int i=p*p; i<=90000001; i += p) \n prime[i] = false; \n } \n } \n}\n\nconst ll M=200006;\nll f[M],inv[M];\n\nvoid compute(){\n f[0]=1;\n rep(i,1,M-1){\n f[i]=(1LL*i*f[i-1])%mod;\n }\n inv[M-1]=expo(f[M-1],mod-2,mod);\n for(ll i=M-2;i>=0;i--){\n inv[i]=(1LL*(i+1)*inv[i+1])%mod;\n }\n}\nll C(ll n,ll r){\n return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;\n}\n\nll pre[200005]={0};\n\npair func(ll x,vector&a,ll n)\n{\n ll num=0,i;\n ll res=0;\n rep(i,0,n-1)\n {\n ll it=lower_bound(a.begin(),a.end(),x-a[i])-a.begin();\n num+=n-it;\n res+=pre[n-1]-pre[it-1];\n res+=(n-it)*a[i];\n }\n return {res,num};\n\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n // compute();\n Sieve();\n ll tests=1;\n // cin>>tests;\n while(tests--)\n {\n ll i,j,n,m;\n cin>>n>>m;\n vectora(n),b(n),c(n);\n rep(i,0,n-1) cin>>a[i];\n sort(a.begin(),a.end());\n pre[0]=a[0];\n rep(i,1,n-1) pre[i]=pre[i-1]+a[i];\n\n ll lo=0,hi=200005;\n ll ans=-1;\n while(hi>=lo)\n {\n ll mid=(lo+hi)/2;\n if(func(mid,a,n).second>=m)\n {\n lo=mid+1;\n }\n else\n {\n // ans=mid;\n hi=mid-1;\n }\n }\n ans=func(lo-1,a,n).first;\n ans-=(func(lo-1,a,n).second-m)*(lo-1);\n cout<\n#define rep(i, a, n) for (int i = a; i < n; i++)\n#define repr(i, a, n) for (int i = n - 1; i >= a; i--)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\ntemplate void chmin(T &a, T b) { a = min(a, b); }\ntemplate void chmax(T &a, T b) { a = max(a, b); }\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n ll n, a, b;\n cin >> n >> a >> b;\n if ((b - a) % 2 == 0)\n cout << (b - a) / 2 << endl;\n else {\n if (a - 1 <= n - b)\n cout << b - 1 << endl;\n else\n cout << n - a << endl;\n }\n}\n", "language": "C++", "metadata": {"date": 1591996074, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/C++/s743032252.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s743032252", "user_id": "u688789047"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#define rep(i, a, n) for (int i = a; i < n; i++)\n#define repr(i, a, n) for (int i = n - 1; i >= a; i--)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\ntemplate void chmin(T &a, T b) { a = min(a, b); }\ntemplate void chmax(T &a, T b) { a = max(a, b); }\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n ll n, a, b;\n cin >> n >> a >> b;\n if ((b - a) % 2 == 0)\n cout << (b - a) / 2 << endl;\n else {\n if (a - 1 <= n - b)\n cout << b - 1 << endl;\n else\n cout << n - a << endl;\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 583, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s381486538", "group_id": "codeNet:p02824", "input_text": "#include \n#define int long long\nusing namespace std;\nconst int N=1e5+5;\nint n,m,v,p,cnt;\nint a[N];\nsigned main() \n{\n\tcin>>n>>m>>v>>p;//m个评委,每个评委给v个题目加分,选前p名 \n\tfor (int i=1;i<=n;i++) cin>>a[i];\n\tsort(a+1,a+n+1);\n\tif (v<=p)\n\t{\n\t\tfor (int i=1;i<=n;i++) if (a[i]+m>=a[n-p+1]) cnt++;\n\t\tcout<=v && a[i]+m>=a[n-p+1]) //取比自己低的人和最高的人加满 \n\t\t\t{\n//\t\t\t\tcout<<\"CASE2\"<=tmp && a[i]+m>=a[n-p+1])\n\t\t\t{\n\t\t\t\tcout<\n#define int long long\nusing namespace std;\nconst int N=1e5+5;\nint n,m,v,p,cnt;\nint a[N];\nsigned main() \n{\n\tcin>>n>>m>>v>>p;//m个评委,每个评委给v个题目加分,选前p名 \n\tfor (int i=1;i<=n;i++) cin>>a[i];\n\tsort(a+1,a+n+1);\n\tif (v<=p)\n\t{\n\t\tfor (int i=1;i<=n;i++) if (a[i]+m>=a[n-p+1]) cnt++;\n\t\tcout<=v && a[i]+m>=a[n-p+1]) //取比自己低的人和最高的人加满 \n\t\t\t{\n//\t\t\t\tcout<<\"CASE2\"<=tmp && a[i]+m>=a[n-p+1])\n\t\t\t{\n\t\t\t\tcout<\nusing namespace std;\n\n// macros\n#define pb emplace_back\n#define mk make_pair\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)\n#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)\n#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)\n#define whole(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define bit(n) (1LL<<(n))\n#define F first\n#define S second\n// functions\ntemplate void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}\ntemplate bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}\ntemplate bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}\ntemplate istream &operator>>(istream &is, vector &vec){for(auto &v: vec)is >> v; return is;}\ntemplate ostream &operator<<(ostream &os, const vector& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const set& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_set& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const multiset& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_multiset& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const pair &p){os << \"(\" << p.first << \", \" << p.second << \")\"; return os;}\ntemplate ostream &operator<<(ostream &os, const map &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << \"(\" << itr->first << \", \" << itr->second << \")\"; auto titr = itr; if(++titr != mp.end())os << \" \"; } return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_map &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << \"(\" << itr->first << \", \" << itr->second << \")\"; auto titr = itr; if(++titr != mp.end())os << \" \"; } return os;}\n// types\nusing ll = long long int;\nusing P = pair;\n// constants\nconst int inf = 1e9;\nconst ll linf = 1LL << 60;\nconst double EPS = 1e-10;\nconst int mod = 1000000007;\nconst int dx[4] = {-1, 0, 1, 0};\nconst int dy[4] = {0, -1, 0, 1};\n// io\nstruct fast_io{\n fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}\n} fast_io_;\n\n\nint main(int argc, char const* argv[])\n{\n ll n, m, v, p; cin >> n >> m >> v >> p;\n vector a(n); cin >> a;\n sort(whole(a));\n vector acc = a;\n for(int i = 1; i < n; i++)acc[i] += acc[i-1];\n map fir, cnt;\n rrep(i, n)fir[a[i]] = i;\n rep(i, n)cnt[a[i]]++;\n int res = 0;\n ll sum = 0;\n //cerr << a << endl;\n irep(itr, cnt){\n sum += itr->second;\n bool ok = false;\n if(sum >= v){\n int idx = upper_bound(whole(a), itr->first + m) - a.begin();\n if(n - idx >= p)ok = false;\n else ok = true;\n }\n else{\n ll rem = v - sum;\n int idx = upper_bound(whole(a), itr->first + m) - a.begin();\n if(n - idx >= p)ok = false;\n else if(n - idx >= rem)ok = true;\n else{\n rem = rem - (p - 1);\n ll curr = acc[idx-1] - (acc[fir[itr->first] + itr->second - 1]);\n //cerr << curr << \" \" << rem << endl;\n if((m + itr->first) * (ll)(idx - 1 - (fir[itr->first] + itr->second - 1)) - curr >= rem * m)ok = true;\n }\n }\n if(ok)res += itr->second;\n //cerr << itr->first << \" \" << ok << endl;\n }\n cout << res << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1590978138, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/C++/s920348665.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s920348665", "user_id": "u424110125"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "// includes\n#include \nusing namespace std;\n\n// macros\n#define pb emplace_back\n#define mk make_pair\n#define FOR(i, a, b) for(int i=(a);i<(b);++i)\n#define rep(i, n) FOR(i, 0, n)\n#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)\n#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)\n#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)\n#define whole(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define bit(n) (1LL<<(n))\n#define F first\n#define S second\n// functions\ntemplate void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}\ntemplate bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}\ntemplate bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}\ntemplate istream &operator>>(istream &is, vector &vec){for(auto &v: vec)is >> v; return is;}\ntemplate ostream &operator<<(ostream &os, const vector& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const set& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_set& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const multiset& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_multiset& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << \" \";} return os;}\ntemplate ostream &operator<<(ostream &os, const pair &p){os << \"(\" << p.first << \", \" << p.second << \")\"; return os;}\ntemplate ostream &operator<<(ostream &os, const map &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << \"(\" << itr->first << \", \" << itr->second << \")\"; auto titr = itr; if(++titr != mp.end())os << \" \"; } return os;}\ntemplate ostream &operator<<(ostream &os, const unordered_map &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << \"(\" << itr->first << \", \" << itr->second << \")\"; auto titr = itr; if(++titr != mp.end())os << \" \"; } return os;}\n// types\nusing ll = long long int;\nusing P = pair;\n// constants\nconst int inf = 1e9;\nconst ll linf = 1LL << 60;\nconst double EPS = 1e-10;\nconst int mod = 1000000007;\nconst int dx[4] = {-1, 0, 1, 0};\nconst int dy[4] = {0, -1, 0, 1};\n// io\nstruct fast_io{\n fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}\n} fast_io_;\n\n\nint main(int argc, char const* argv[])\n{\n ll n, m, v, p; cin >> n >> m >> v >> p;\n vector a(n); cin >> a;\n sort(whole(a));\n vector acc = a;\n for(int i = 1; i < n; i++)acc[i] += acc[i-1];\n map fir, cnt;\n rrep(i, n)fir[a[i]] = i;\n rep(i, n)cnt[a[i]]++;\n int res = 0;\n ll sum = 0;\n //cerr << a << endl;\n irep(itr, cnt){\n sum += itr->second;\n bool ok = false;\n if(sum >= v){\n int idx = upper_bound(whole(a), itr->first + m) - a.begin();\n if(n - idx >= p)ok = false;\n else ok = true;\n }\n else{\n ll rem = v - sum;\n int idx = upper_bound(whole(a), itr->first + m) - a.begin();\n if(n - idx >= p)ok = false;\n else if(n - idx >= rem)ok = true;\n else{\n rem = rem - (p - 1);\n ll curr = acc[idx-1] - (acc[fir[itr->first] + itr->second - 1]);\n //cerr << curr << \" \" << rem << endl;\n if((m + itr->first) * (ll)(idx - 1 - (fir[itr->first] + itr->second - 1)) - curr >= rem * m)ok = true;\n }\n }\n if(ok)res += itr->second;\n //cerr << itr->first << \" \" << ok << endl;\n }\n cout << res << endl;\n return 0;\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4105, "cpu_time_ms": 125, "memory_kb": 14336}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s043927989", "group_id": "codeNet:p02824", "input_text": "// Hail god Yato\n \n#include \nusing namespace std;\n \n#define add(x) accumulate(x)\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define ff first\n#define ss second\n#define lb lower_bound\n#define ub upper_bound\n#define all(x) x.begin(), x.end() \n#define rep(i, a, b) for (int i=a; i<(b); i++)\n#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\ntypedef long long ll;\ntypedef pair pll;\ntypedef vector vll;\ntypedef vector vpll;\nconst ll mod = 1000000007;\nconst ll INF = 1e18;\nconst ll MAX = 100001;\n//\n//\n\n ll n,m,p,v;\n int arr[MAX];\n ll oper(ll ix){\n if(ix>=v){\n if(arr[ix]+m>=arr[n-p])\n return 1;\n return 0;\n }\n ll idx=ub(arr+1,arr+n+1,arr[ix]+m)-arr;\n if(n-idx+1>=p){\n // cout<>n>>m>>v>>p;\n // int arr[n+1];\n rep(i,0,n)\n cin>>arr[i+1];\n sort(arr+1,arr+n+1);\n ll lo=0,hi=n+1;\n while(lo>1;\n if(oper(mid))\n hi=mid;\n else\n lo=mid+1;\n }\n cout<>t;\n for (int i=1; i<=t; i++){\n //printf(\"Case #%d: \", i);\n solve();\n }\n return 0; \n} \n ", "language": "C++", "metadata": {"date": 1577701959, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/C++/s043927989.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043927989", "user_id": "u216557283"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "// Hail god Yato\n \n#include \nusing namespace std;\n \n#define add(x) accumulate(x)\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define ff first\n#define ss second\n#define lb lower_bound\n#define ub upper_bound\n#define all(x) x.begin(), x.end() \n#define rep(i, a, b) for (int i=a; i<(b); i++)\n#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\ntypedef long long ll;\ntypedef pair pll;\ntypedef vector vll;\ntypedef vector vpll;\nconst ll mod = 1000000007;\nconst ll INF = 1e18;\nconst ll MAX = 100001;\n//\n//\n\n ll n,m,p,v;\n int arr[MAX];\n ll oper(ll ix){\n if(ix>=v){\n if(arr[ix]+m>=arr[n-p])\n return 1;\n return 0;\n }\n ll idx=ub(arr+1,arr+n+1,arr[ix]+m)-arr;\n if(n-idx+1>=p){\n // cout<>n>>m>>v>>p;\n // int arr[n+1];\n rep(i,0,n)\n cin>>arr[i+1];\n sort(arr+1,arr+n+1);\n ll lo=0,hi=n+1;\n while(lo>1;\n if(oper(mid))\n hi=mid;\n else\n lo=mid+1;\n }\n cout<>t;\n for (int i=1; i<=t; i++){\n //printf(\"Case #%d: \", i);\n solve();\n }\n return 0; \n} \n ", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2434, "cpu_time_ms": 19, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s897786829", "group_id": "codeNet:p02824", "input_text": "#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\ntypedef long long ll;\ntypedef pair pa;\n\nint main()\n{\n ll N, M, V, P;\n cin >> N >> M >> V >> P;\n vector A(N);\n for(int i=0; i> A[i];\n }\n sort(A.begin(), A.end());\n reverse(A.begin(), A.end());\n ll MIN=A[P-1], ans=0;\n if(V-P<=0){\n for(int i=0; i=P-1; i--){\n if(i==R)continue;\n if(tmp=M) pairs.first--;\n else{\n if(r>pairs.second){\n pairs.first--;\n pairs.second+=M;\n }\n pairs.second-=r;\n }\n }\n if(pairs.first<0 || (pairs.first<=0 && pairs.second<=M)) ok=true;\n if(ok){\n cout << N;\n return 0;\n }\n ll L=P-1;\n while(R-L>=2){\n ll mid=(R+L)/2;\n tmp = A[mid]+M;\n pa pairs=pa(V-P, M);\n bool ok=false;\n for(int i=N-1; i>=P-1; i--){\n if(i==mid)continue;\n if(tmp=M) pairs.first--;\n else{\n if(r>pairs.second){\n pairs.first--;\n pairs.second+=M;\n }\n pairs.second-=r;\n }\n }\n\n if(pairs.first<0 || (pairs.second<=M && pairs.first<=0)) ok=true;\n if(ok) L=mid;\n else R=mid;\n }\n cout << L+1 << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1577589058, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02824/input.txt", "sample_output_relpath": "derived/input_output/data/p02824/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02824/C++/s897786829.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s897786829", "user_id": "u227379863"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#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\ntypedef long long ll;\ntypedef pair pa;\n\nint main()\n{\n ll N, M, V, P;\n cin >> N >> M >> V >> P;\n vector A(N);\n for(int i=0; i> A[i];\n }\n sort(A.begin(), A.end());\n reverse(A.begin(), A.end());\n ll MIN=A[P-1], ans=0;\n if(V-P<=0){\n for(int i=0; i=P-1; i--){\n if(i==R)continue;\n if(tmp=M) pairs.first--;\n else{\n if(r>pairs.second){\n pairs.first--;\n pairs.second+=M;\n }\n pairs.second-=r;\n }\n }\n if(pairs.first<0 || (pairs.first<=0 && pairs.second<=M)) ok=true;\n if(ok){\n cout << N;\n return 0;\n }\n ll L=P-1;\n while(R-L>=2){\n ll mid=(R+L)/2;\n tmp = A[mid]+M;\n pa pairs=pa(V-P, M);\n bool ok=false;\n for(int i=N-1; i>=P-1; i--){\n if(i==mid)continue;\n if(tmp=M) pairs.first--;\n else{\n if(r>pairs.second){\n pairs.first--;\n pairs.second+=M;\n }\n pairs.second-=r;\n }\n }\n\n if(pairs.first<0 || (pairs.second<=M && pairs.first<=0)) ok=true;\n if(ok) L=mid;\n else R=mid;\n }\n cout << L+1 << endl;\n \n return 0;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "sample_input": "6 1 2 2\n2 1 1 3 0 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02824", "source_text": "Score : 700 points\n\nProblem Statement\n\nN problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.\n\nM judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,\nand increase the score of each chosen problem by 1.\n\nAfter all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.\nProblems with the same score can be ordered arbitrarily, this order is decided by the chief judge.\n\nHow many problems out of the given N have a chance to be chosen for the problemset?\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le M \\le 10^9\n\n1 \\le V \\le N - 1\n\n1 \\le P \\le N - 1\n\n0 \\le A_i \\le 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M V P\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of problems that have a chance to be chosen for the problemset.\n\nSample Input 1\n\n6 1 2 2\n2 1 1 3 0 2\n\nSample Output 1\n\n5\n\nIf the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.\nThe problemset will consist of problem 4 and one of problems 1, 2, or 6.\n\nIf the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.\nThe problemset will consist of problem 4 and one of problems 1, 3, or 6.\n\nThus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.\n\nSample Input 2\n\n6 1 5 2\n2 1 1 3 0 2\n\nSample Output 2\n\n3\n\nOnly problems 1, 4, and 6 have a chance to be chosen.\n\nSample Input 3\n\n10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1992, "cpu_time_ms": 50, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s726216624", "group_id": "codeNet:p02825", "input_text": "#include \nusing namespace std;\nusing ll = long long;\n\n#define ALL(obj) (obj).begin(),(obj).end()\n#define SPEED cin.tie(0);ios::sync_with_stdio(false);\n\ntemplate using PQ = priority_queue;\ntemplate using PQR = priority_queue,greater>;\n\nconstexpr long long MOD = (long long)1e9 + 7;\nconstexpr long long MOD2 = 998244353;\nconstexpr long long HIGHINF = (long long)1e18;\nconstexpr long long LOWINF = (long long)1e15;\nconstexpr long double PI = 3.1415926535897932384626433L;\n\ntemplate vector multivector(size_t N,T init){return vector(N,init);}\ntemplate auto multivector(size_t N,T... t){return vector(N,multivector(t...));}\ntemplate void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}\ntemplate ostream &operator<<(ostream &o, const map&obj) {o << \"{\"; for (auto &x : obj) o << \" {\" << x.first << \" : \" << x.second << \"}\" << \",\"; o << \" }\"; return o;}\ntemplate ostream &operator<<(ostream &o, const set&obj) {o << \"{\"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? \", \" : \"\") << *itr; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const multiset&obj) {o << \"{\"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? \", \" : \"\") << *itr; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const vector&obj) {o << \"{\"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? \", \" : \"\") << obj[i]; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const pair&obj) {o << \"{\" << obj.first << \", \" << obj.second << \"}\"; return o;}\nvoid print(void) {cout << endl;}\ntemplate void print(Head&& head) {cout << head;print();}\ntemplate void print(Head&& head, Tail&&... tail) {cout << head << \" \";print(forward(tail)...);}\ntemplate void chmax(T& a, const T b){a=max(a,b);}\ntemplate void chmin(T& a, const T b){a=min(a,b);}\nstd::vector split(const std::string &str, const char delemiter) {std::vector res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}\nvoid YN(bool flg) {cout << (flg ? \"YES\" : \"NO\") << endl;}\nvoid Yn(bool flg) {cout << (flg ? \"Yes\" : \"No\") << endl;}\nvoid yn(bool flg) {cout << (flg ? \"yes\" : \"no\") << endl;}\n\nvector f(const int N,map& mv,map>& mp){\n\tvector res(N,string(N,'.'));\n\tint idx=0;\n\tfor(auto e:mv){\n\t\tint x=e.first,y=e.second;\n\t\tfor(int n = 0; n < y; ++n){\n\t\t\tfor(int i = 0; i < x; ++i) {\n\t\t\t\tfor(int j = 0; j < x; ++j) {\n\t\t\t\t\tres[idx+i][idx+j]=mp[x][i][j];\n\t\t\t\t}\n\t\t\t}\n\t\t\tidx+=x;\n\t\t}\n\t}\n\treturn res;\n}\n\nint main() {\n\tmap> mp;\n\tmp[3]={\n\t\t\"aa.\",\n\t\t\"..a\",\n\t\t\"..a\",\n\t\t};\n\tmp[4]={\n\t\t\"abcc\",\n\t\t\"abdd\",\n\t\t\"ccab\",\n\t\t\"ddab\",\n\t\t};\n\tmp[6]={\n\t\t\"aabbaa\",\n\t\t\"b.a.b.\",\n\t\t\"b.a.b.\",\n\t\t\".a.b.a\",\n\t\t\".a.b.a\",\n\t\t\"bbaabb\"\n\t\t};\n\tmp[7]={\n\t\t\"acc..b.\",\n\t\t\"a..aab.\",\n\t\t\"bb..bcc\",\n\t\t\"..ccb.a\",\n\t\t\"a..aa.a\",\n\t\t\"a....cb\",\n\t\t\".aa..cb\"\n\t\t};\n\tmap mv;\n\tint N; cin >> N;\n\tcorner(N==2||N==5,-1);\n\tif(N%3==0){\n\t\tmv[3]=N/3;\n\t}\n\telse{\n\t\tint x,y,z;\n\t\tfor(int i = 0; i*7 <= N; ++i) {\n\t\t\tfor(int j = 0; j*6 + i*7 <= N; ++j) {\n\t\t\t\tint k = N - j*6 - i*7;\n\t\t\t\tif(k<0 || k%4) continue;\n\t\t\t\tk/=4;\n\t\t\t\tx=i,y=j,z=k;\n\t\t\t}\n\t\t}\n\t\tmv[7]=x,mv[6]=y,mv[4]=z;\n\t}\n\tauto ans=f(N,mv,mp);\n\tfor(int i = 0; i < N; ++i) cout << ans[i] << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1596089092, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02825.html", "problem_id": "p02825", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02825/input.txt", "sample_output_relpath": "derived/input_output/data/p02825/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02825/C++/s726216624.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s726216624", "user_id": "u898651494"}, "prompt_components": {"gold_output": "aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\n\n#define ALL(obj) (obj).begin(),(obj).end()\n#define SPEED cin.tie(0);ios::sync_with_stdio(false);\n\ntemplate using PQ = priority_queue;\ntemplate using PQR = priority_queue,greater>;\n\nconstexpr long long MOD = (long long)1e9 + 7;\nconstexpr long long MOD2 = 998244353;\nconstexpr long long HIGHINF = (long long)1e18;\nconstexpr long long LOWINF = (long long)1e15;\nconstexpr long double PI = 3.1415926535897932384626433L;\n\ntemplate vector multivector(size_t N,T init){return vector(N,init);}\ntemplate auto multivector(size_t N,T... t){return vector(N,multivector(t...));}\ntemplate void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}\ntemplate ostream &operator<<(ostream &o, const map&obj) {o << \"{\"; for (auto &x : obj) o << \" {\" << x.first << \" : \" << x.second << \"}\" << \",\"; o << \" }\"; return o;}\ntemplate ostream &operator<<(ostream &o, const set&obj) {o << \"{\"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? \", \" : \"\") << *itr; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const multiset&obj) {o << \"{\"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? \", \" : \"\") << *itr; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const vector&obj) {o << \"{\"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? \", \" : \"\") << obj[i]; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const pair&obj) {o << \"{\" << obj.first << \", \" << obj.second << \"}\"; return o;}\nvoid print(void) {cout << endl;}\ntemplate void print(Head&& head) {cout << head;print();}\ntemplate void print(Head&& head, Tail&&... tail) {cout << head << \" \";print(forward(tail)...);}\ntemplate void chmax(T& a, const T b){a=max(a,b);}\ntemplate void chmin(T& a, const T b){a=min(a,b);}\nstd::vector split(const std::string &str, const char delemiter) {std::vector res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}\nvoid YN(bool flg) {cout << (flg ? \"YES\" : \"NO\") << endl;}\nvoid Yn(bool flg) {cout << (flg ? \"Yes\" : \"No\") << endl;}\nvoid yn(bool flg) {cout << (flg ? \"yes\" : \"no\") << endl;}\n\nvector f(const int N,map& mv,map>& mp){\n\tvector res(N,string(N,'.'));\n\tint idx=0;\n\tfor(auto e:mv){\n\t\tint x=e.first,y=e.second;\n\t\tfor(int n = 0; n < y; ++n){\n\t\t\tfor(int i = 0; i < x; ++i) {\n\t\t\t\tfor(int j = 0; j < x; ++j) {\n\t\t\t\t\tres[idx+i][idx+j]=mp[x][i][j];\n\t\t\t\t}\n\t\t\t}\n\t\t\tidx+=x;\n\t\t}\n\t}\n\treturn res;\n}\n\nint main() {\n\tmap> mp;\n\tmp[3]={\n\t\t\"aa.\",\n\t\t\"..a\",\n\t\t\"..a\",\n\t\t};\n\tmp[4]={\n\t\t\"abcc\",\n\t\t\"abdd\",\n\t\t\"ccab\",\n\t\t\"ddab\",\n\t\t};\n\tmp[6]={\n\t\t\"aabbaa\",\n\t\t\"b.a.b.\",\n\t\t\"b.a.b.\",\n\t\t\".a.b.a\",\n\t\t\".a.b.a\",\n\t\t\"bbaabb\"\n\t\t};\n\tmp[7]={\n\t\t\"acc..b.\",\n\t\t\"a..aab.\",\n\t\t\"bb..bcc\",\n\t\t\"..ccb.a\",\n\t\t\"a..aa.a\",\n\t\t\"a....cb\",\n\t\t\".aa..cb\"\n\t\t};\n\tmap mv;\n\tint N; cin >> N;\n\tcorner(N==2||N==5,-1);\n\tif(N%3==0){\n\t\tmv[3]=N/3;\n\t}\n\telse{\n\t\tint x,y,z;\n\t\tfor(int i = 0; i*7 <= N; ++i) {\n\t\t\tfor(int j = 0; j*6 + i*7 <= N; ++j) {\n\t\t\t\tint k = N - j*6 - i*7;\n\t\t\t\tif(k<0 || k%4) continue;\n\t\t\t\tk/=4;\n\t\t\t\tx=i,y=j,z=k;\n\t\t\t}\n\t\t}\n\t\tmv[7]=x,mv[6]=y,mv[4]=z;\n\t}\n\tauto ans=f(N,mv,mp);\n\tfor(int i = 0; i < N; ++i) cout << ans[i] << endl;\n return 0;\n}\n", "problem_context": "Score : 900 points\n\nProblem Statement\n\nLet us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid.\nEach domino piece covers two squares that have a common side. Each square can be covered by at most one piece.\n\nFor each row of the grid, let's define its quality as the number of domino pieces that cover at least one square in this row.\nWe define the quality of each column similarly.\n\nFind a way to put at least one domino piece on the grid so that the quality of every row is equal to the quality of every column,\nor determine that such a placement doesn't exist.\n\nConstraints\n\n2 \\le N \\le 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the required domino placement doesn't exist, print a single integer -1.\n\nOtherwise, output your placement as N strings of N characters each.\nIf a square is not covered, the corresponding character must be . (a dot).\nOtherwise, it must contain a lowercase English letter.\nSquares covered by the same domino piece must contain the same letter.\nIf two squares have a common side but belong to different pieces, they must contain different letters.\n\nSample Input 1\n\n6\n\nSample Output 1\n\naabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n\nThe quality of every row and every column is 2.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n"}, "reference_outputs": ["aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n"], "source_document_id": "p02825", "source_text": "Score : 900 points\n\nProblem Statement\n\nLet us consider a grid of squares with N rows and N columns. You want to put some domino pieces on this grid.\nEach domino piece covers two squares that have a common side. Each square can be covered by at most one piece.\n\nFor each row of the grid, let's define its quality as the number of domino pieces that cover at least one square in this row.\nWe define the quality of each column similarly.\n\nFind a way to put at least one domino piece on the grid so that the quality of every row is equal to the quality of every column,\nor determine that such a placement doesn't exist.\n\nConstraints\n\n2 \\le N \\le 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the required domino placement doesn't exist, print a single integer -1.\n\nOtherwise, output your placement as N strings of N characters each.\nIf a square is not covered, the corresponding character must be . (a dot).\nOtherwise, it must contain a lowercase English letter.\nSquares covered by the same domino piece must contain the same letter.\nIf two squares have a common side but belong to different pieces, they must contain different letters.\n\nSample Input 1\n\n6\n\nSample Output 1\n\naabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n\nThe quality of every row and every column is 2.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3574, "cpu_time_ms": 13, "memory_kb": 4640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s384872075", "group_id": "codeNet:p02830", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n string S, T;\n cin >> S >> T;\n \n for(int i=0; i\nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n string S, T;\n cin >> S >> T;\n \n for(int i=0; i\nusing namespace std;\nchar s1[105],s2[105];\nint main()\n{\n\tint n;\n\tcin>>n;\n\tfor (int i=1;i<=n;i++) cin>>s1[i];\n\tfor (int i=1;i<=n;i++) cin>>s2[i];\n\tfor (int i=1;i<=n;i++) cout<\nusing namespace std;\nchar s1[105],s2[105];\nint main()\n{\n\tint n;\n\tcin>>n;\n\tfor (int i=1;i<=n;i++) cin>>s1[i];\n\tfor (int i=1;i<=n;i++) cin>>s2[i];\n\tfor (int i=1;i<=n;i++) cout<\nusing namespace std;\n\nlong gcd(long a, long b) {\n\n if (b == 0) {\n return a;\n }\n\n return gcd(b, a % b);\n}\n\nlong lcm(long a, long b) {\n \n return a / gcd(a, b) * b;\n\n}\n\nint main() {\n\n int A, B;\n cin >> A >> B;\n\n long long answer = lcm(A, B);\n\n cout << answer << endl;\n\n return 0;\n\n}", "language": "C++", "metadata": {"date": 1584141698, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/C++/s394907400.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s394907400", "user_id": "u046482892"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include \nusing namespace std;\n\nlong gcd(long a, long b) {\n\n if (b == 0) {\n return a;\n }\n\n return gcd(b, a % b);\n}\n\nlong lcm(long a, long b) {\n \n return a / gcd(a, b) * b;\n\n}\n\nint main() {\n\n int A, B;\n cin >> A >> B;\n\n long long answer = lcm(A, B);\n\n cout << answer << endl;\n\n return 0;\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s127954471", "group_id": "codeNet:p02831", "input_text": "#include \n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n int a, b;\n cin >> a >> b;\n\n int aa = a, bb = b;\n while (b != 0) {\n int c = a % b;\n a = b, b = c;\n }\n\n cout << (long long) aa / a * bb;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1578878676, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02831/input.txt", "sample_output_relpath": "derived/input_output/data/p02831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02831/C++/s127954471.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127954471", "user_id": "u809013442"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n int a, b;\n cin >> a >> b;\n\n int aa = a, bb = b;\n while (b != 0) {\n int c = a % b;\n a = b, b = c;\n }\n\n cout << (long long) aa / a * bb;\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 2, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s497890081", "group_id": "codeNet:p02832", "input_text": "#include \n#define rep(i,n) for(int i=0; i> n;\n int a[n]; int now=1;\n rep(i,n) cin >> a[i];\n rep(i,n) if(a[i]==now) now++;\n if(now==1) cout << -1 << endl;\n else cout << n-now+1 << endl;\nreturn 0;\n}\n", "language": "C++", "metadata": {"date": 1577068444, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/C++/s497890081.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497890081", "user_id": "u437779154"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#define rep(i,n) for(int i=0; i> n;\n int a[n]; int now=1;\n rep(i,n) cin >> a[i];\n rep(i,n) if(a[i]==now) now++;\n if(now==1) cout << -1 << endl;\n else cout << n-now+1 << endl;\nreturn 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 333, "cpu_time_ms": 80, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s487644866", "group_id": "codeNet:p02832", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define N 200000\n#define M 100\n\nint main(){\n\tint a[N], b,r,x, i,j = 0,n, ans = 0, br = 1;\n\n\tcin >> n;\n\n\tfor (i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\n\tfor (i = 0; i < n; i++) {\n\t\tif (a[i] == br) {\n\t\t\tif (br == 1) {\n\t\t\t\tans += i - j;\n\t\t\t\tj = i;\n\t\t\t\tbr++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans += i - j - 1;\n\t\t\t\tj = i;\n\t\t\t\tbr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (br != 1) {\n\t\tcout << ans << endl;\n\t}\n\telse {\n\t\tcout << -1;\n\t}\n\t\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1577067956, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/C++/s487644866.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s487644866", "user_id": "u049068827"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define N 200000\n#define M 100\n\nint main(){\n\tint a[N], b,r,x, i,j = 0,n, ans = 0, br = 1;\n\n\tcin >> n;\n\n\tfor (i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\n\tfor (i = 0; i < n; i++) {\n\t\tif (a[i] == br) {\n\t\t\tif (br == 1) {\n\t\t\t\tans += i - j;\n\t\t\t\tj = i;\n\t\t\t\tbr++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans += i - j - 1;\n\t\t\t\tj = i;\n\t\t\t\tbr++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (br != 1) {\n\t\tcout << ans << endl;\n\t}\n\telse {\n\t\tcout << -1;\n\t}\n\t\n\treturn 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 504, "cpu_time_ms": 78, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s285209855", "group_id": "codeNet:p02835", "input_text": "#include\nusing namespace std;\n#define int long long\n\nsigned main(void){\n int a,b,c; cin >> a >> b >> c;\n if(a+b+c < 22) cout << \"win\" << endl;\n else cout << \"bust\" << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1575902953, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/C++/s285209855.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285209855", "user_id": "u030848580"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "#include\nusing namespace std;\n#define int long long\n\nsigned main(void){\n int a,b,c; cin >> a >> b >> c;\n if(a+b+c < 22) cout << \"win\" << endl;\n else cout << \"bust\" << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 213, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s051096303", "group_id": "codeNet:p02835", "input_text": "#include \nint main(){\n int a,b,c;\n scanf(\"%d %d %d\",a,b,c);\n if(a+b+c<=21){\n printf(\"win\");\n }else{\n printf(\"bust\");\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1575856966, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/C++/s051096303.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s051096303", "user_id": "u685629265"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "#include \nint main(){\n int a,b,c;\n scanf(\"%d %d %d\",a,b,c);\n if(a+b+c<=21){\n printf(\"win\");\n }else{\n printf(\"bust\");\n }\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 173, "cpu_time_ms": 141, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s797566577", "group_id": "codeNet:p02835", "input_text": "#include\nusing namespace std;\n\n\nint main(){\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tif(a+b+c>=22)puts(\"bust\");\n\telse puts(\"win\");\n\n}\n", "language": "C++", "metadata": {"date": 1575856954, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/C++/s797566577.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797566577", "user_id": "u414275860"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "#include\nusing namespace std;\n\n\nint main(){\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tif(a+b+c>=22)puts(\"bust\");\n\telse puts(\"win\");\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s491191006", "group_id": "codeNet:p02835", "input_text": "#include \nusing namespace std;\n#define rep(i, n) for(int i = 0; i < n; i++)\n\nint main(){\n int A,B,C;\n cin >> A >> B >> C;\n if(A+B+C > 21)cout << \"bust\";\n else cout <<\"win\";\n return 0;\n}", "language": "C++", "metadata": {"date": 1575856914, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02835/input.txt", "sample_output_relpath": "derived/input_output/data/p02835/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02835/C++/s491191006.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491191006", "user_id": "u923676814"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "#include \nusing namespace std;\n#define rep(i, n) for(int i = 0; i < n; i++)\n\nint main(){\n int A,B,C;\n cin >> A >> B >> C;\n if(A+B+C > 21)cout << \"bust\";\n else cout <<\"win\";\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "sample_input": "5 7 9\n"}, "reference_outputs": ["win\n"], "source_document_id": "p02835", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are three integers A_1, A_2, and A_3.\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nConstraints\n\n1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\nSample Input 1\n\n5 7 9\n\nSample Output 1\n\nwin\n\n5+7+9=21, so print win.\n\nSample Input 2\n\n13 7 2\n\nSample Output 2\n\nbust\n\n13+7+2=22, so print bust.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s522742253", "group_id": "codeNet:p02837", "input_text": "#include \nusing namespace std;\n\nvoid solve(int N,vector> &x,vector> &y,vector> &hito,int &ans){\n\tfor(int i=0;i> N;\n\tvector> x(N);\n\tvector> y(N);\n\tint a;\n\tint x1,y1;\n\tfor(int i=0;i> a;\n\t\tfor(int j=0;j> x1>> y1;\n\t\t\tx.at(i).push_back(x1-1);\n\t\t\ty.at(i).push_back(y1);\n\t\t}\n\t}\n\tint p =(1<<16);\n\tvector > hito(p,vector(16,0));\n\t\n\tfor(int t=0;t<(1<<16);t++){\n\t\tbitset<16> s(t);\n\t\tfor(int i=0;i\nusing namespace std;\n\nvoid solve(int N,vector> &x,vector> &y,vector> &hito,int &ans){\n\tfor(int i=0;i> N;\n\tvector> x(N);\n\tvector> y(N);\n\tint a;\n\tint x1,y1;\n\tfor(int i=0;i> a;\n\t\tfor(int j=0;j> x1>> y1;\n\t\t\tx.at(i).push_back(x1-1);\n\t\t\ty.at(i).push_back(y1);\n\t\t}\n\t}\n\tint p =(1<<16);\n\tvector > hito(p,vector(16,0));\n\t\n\tfor(int t=0;t<(1<<16);t++){\n\t\tbitset<16> s(t);\n\t\tfor(int i=0;i\nusing namespace std;\nconst long long MOD = 1e9 + 7;\n\n#include \n#define PI 3.14159265358979323846264338327950L\n\nlong long gcd(long long a, long long b) {\n if (a == 0)\n return b;\n return gcd(b % a, a);\n}\nlong long lcm(long long a, long long b) {\n return (a * b) / gcd(a, b);\n}\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 vector zerobit(61);\n vector onebit(61);\n for (int i = 0; i < n; i++) {\n for (long long bit = 0; bit <= 60; bit++) {\n if (a[i] & (1ll << bit)) onebit[bit]++;\n else zerobit[bit]++;\n }\n }\n long long sum = 0;\n for (long long bit = 0; bit <= 60; bit++) {\n sum += (((long long)zerobit[bit] * onebit[bit]) % MOD) * (1ll << bit); sum %= MOD;\n }\n cout << sum;\n return 0;\n}", "language": "C++", "metadata": {"date": 1593249859, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02838.html", "problem_id": "p02838", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02838/input.txt", "sample_output_relpath": "derived/input_output/data/p02838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02838/C++/s128036937.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s128036937", "user_id": "u221780420"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include \nusing namespace std;\nconst long long MOD = 1e9 + 7;\n\n#include \n#define PI 3.14159265358979323846264338327950L\n\nlong long gcd(long long a, long long b) {\n if (a == 0)\n return b;\n return gcd(b % a, a);\n}\nlong long lcm(long long a, long long b) {\n return (a * b) / gcd(a, b);\n}\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 vector zerobit(61);\n vector onebit(61);\n for (int i = 0; i < n; i++) {\n for (long long bit = 0; bit <= 60; bit++) {\n if (a[i] & (1ll << bit)) onebit[bit]++;\n else zerobit[bit]++;\n }\n }\n long long sum = 0;\n for (long long bit = 0; bit <= 60; bit++) {\n sum += (((long long)zerobit[bit] * onebit[bit]) % MOD) * (1ll << bit); sum %= MOD;\n }\n cout << sum;\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02838", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as follows:\n\nWhen A \\mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.\n\nFor example, 3 \\mbox{ XOR } 5 = 6. (In base two: 011 \\mbox{ XOR } 101 = 110.)\n\nConstraints\n\n2 \\leq N \\leq 3 \\times 10^5\n\n0 \\leq A_i < 2^{60}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the value \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n6\n\nWe have (1\\mbox{ XOR } 2)+(1\\mbox{ XOR } 3)+(2\\mbox{ XOR } 3)=3+2+1=6.\n\nSample Input 2\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 2\n\n237\n\nSample Input 3\n\n10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n\nSample Output 3\n\n103715602\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 880, "cpu_time_ms": 201, "memory_kb": 5624}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s578893699", "group_id": "codeNet:p02839", "input_text": "#include \"bits/stdc++.h\"\n#define in std::cin\n#define out std::cout\n#define rep(i,N) for(LL i=0;i>A, B;\nstd::vector>>memo;\n\nbool dp(LL i, LL j, LL k)\n{\n\tif (i < 0 || j < 0) return false;\n\tif (i == 0 && j == 0) return k == std::abs(A[0][0] - B[0][0]);\n\tif (memo[i][j][k] != -1) return memo[i][j][k];\n\tLL d = std::abs(A[i][j] - B[i][j]);\n\tLL m1 = std::abs(k - d), m2 = k + d;\n\tbool res1 = dp(i - 1, j, m1), res2 = dp(i - 1, j, m2), res3 = dp(i, j - 1, m1), res4 = dp(i, j - 1, m2);\n\treturn memo[i][j][k] = (res1 || res2 || res3 || res4);\n}\n\nint main()\n{\n\tin >> H >> W;\n\tA.resize(H, std::vector(W));\n\tB.resize(H, std::vector(W));\n\trep(i, H) rep(j, W) in >> A[i][j];\n\trep(i, H) rep(j, W) in >> B[i][j];\n\n\tmemo.resize(H, std::vector>(W, std::vector((H + W - 1) * 80, -1)));\n\trep(k, (H + W - 1) * 80)\n\t{\n\t\tif (dp(H - 1, W - 1, k))\n\t\t{\n\t\t\tout << k << std::endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n", "language": "C++", "metadata": {"date": 1576547931, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02839.html", "problem_id": "p02839", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02839/input.txt", "sample_output_relpath": "derived/input_output/data/p02839/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02839/C++/s578893699.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s578893699", "user_id": "u660613376"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n#define in std::cin\n#define out std::cout\n#define rep(i,N) for(LL i=0;i>A, B;\nstd::vector>>memo;\n\nbool dp(LL i, LL j, LL k)\n{\n\tif (i < 0 || j < 0) return false;\n\tif (i == 0 && j == 0) return k == std::abs(A[0][0] - B[0][0]);\n\tif (memo[i][j][k] != -1) return memo[i][j][k];\n\tLL d = std::abs(A[i][j] - B[i][j]);\n\tLL m1 = std::abs(k - d), m2 = k + d;\n\tbool res1 = dp(i - 1, j, m1), res2 = dp(i - 1, j, m2), res3 = dp(i, j - 1, m1), res4 = dp(i, j - 1, m2);\n\treturn memo[i][j][k] = (res1 || res2 || res3 || res4);\n}\n\nint main()\n{\n\tin >> H >> W;\n\tA.resize(H, std::vector(W));\n\tB.resize(H, std::vector(W));\n\trep(i, H) rep(j, W) in >> A[i][j];\n\trep(i, H) rep(j, W) in >> B[i][j];\n\n\tmemo.resize(H, std::vector>(W, std::vector((H + W - 1) * 80, -1)));\n\trep(k, (H + W - 1) * 80)\n\t{\n\t\tif (dp(H - 1, W - 1, k))\n\t\t{\n\t\t\tout << k << std::endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "sample_input": "2 2\n1 2\n3 4\n3 4\n2 1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02839", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1006, "cpu_time_ms": 2123, "memory_kb": 324736}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s870728357", "group_id": "codeNet:p02841", "input_text": "#include \nusing namespace std;\n\n\nint main() {\n int n;\n cin >> n;\n int ans;\n ans = n/2;\n double res;\n int i = 0;\n for(i = 0;i < n;i++) {\n res = i * 1.08;\n if(int(res) == n) {\n cout << i << '\\n';\n return 0;\n }\n }\n cout << \":(\" << '\\n';\n}\n", "language": "C++", "metadata": {"date": 1575253442, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02841.html", "problem_id": "p02841", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02841/input.txt", "sample_output_relpath": "derived/input_output/data/p02841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02841/C++/s870728357.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s870728357", "user_id": "u017829818"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include \nusing namespace std;\n\n\nint main() {\n int n;\n cin >> n;\n int ans;\n ans = n/2;\n double res;\n int i = 0;\n for(i = 0;i < n;i++) {\n res = i * 1.08;\n if(int(res) == n) {\n cout << i << '\\n';\n return 0;\n }\n }\n cout << \":(\" << '\\n';\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "sample_input": "11 16\n11 17\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02841", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s215908622", "group_id": "codeNet:p02842", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N; cin >> N;\n for(int i=1; i<=N; i++){\n if(i*108/100==N){\n cout << i << endl;\n return 0;\n }\n }\n cout << \":(\" << endl;\n}", "language": "C++", "metadata": {"date": 1588378979, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/C++/s215908622.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215908622", "user_id": "u816742421"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int N; cin >> N;\n for(int i=1; i<=N; i++){\n if(i*108/100==N){\n cout << i << endl;\n return 0;\n }\n }\n cout << \":(\" << endl;\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s079594275", "group_id": "codeNet:p02842", "input_text": "#include \nusing namespace std;\n \nint main() {\n int N;\n cin>>N;\n int X=(N+1)*100/108;\n if (X*108/100==N) cout<\nusing namespace std;\n \nint main() {\n int N;\n cin>>N;\n int X=(N+1)*100/108;\n if (X*108/100==N) cout<\nusing namespace std;\n\nint main(){\n int n, a;\n for(int i = 0; i < n + 1; i++){\n a = i * 1.08;\n if(a == n){\n cout << i << endl;\n return 0;\n }\n }\n cout << \":(\" << endl;\n}", "language": "C++", "metadata": {"date": 1586337291, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/C++/s418235510.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s418235510", "user_id": "u917049698"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int n, a;\n for(int i = 0; i < n + 1; i++){\n a = i * 1.08;\n if(a == n){\n cout << i << endl;\n return 0;\n }\n }\n cout << \":(\" << endl;\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s870757945", "group_id": "codeNet:p02843", "input_text": "#include \nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int X;\n cin >> X;\n cout << ((X % 100 <= X / 100 * 5) ? 1 : 0) << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1589148076, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/C++/s870757945.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s870757945", "user_id": "u433685759"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int X;\n cin >> X;\n cout << ((X % 100 <= X / 100 * 5) ? 1 : 0) << endl;\n\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s174479375", "group_id": "codeNet:p02844", "input_text": "#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) { return b ? gcd(b, a % b) : a; }\ntemplate\nT lcm(T a, T b) { return a / gcd(a, b) * b; }\n\ntemplate\nmap primeFactor(T n) {\n\tmap res;\n\tfor (T i = 2; i * i <= n; ++i) {\n\t\twhile (n % i == 0) {\n\t\t\tres[i] ++;\n\t\t\tn /= i;\n\t\t}\n\t}\n\tif (n != 1) res[n] = 1;\n\treturn res;\n}\n\ntemplate\nbool IsPrimeNumber(T num)\n{\n\tif (num <= 2) return true;\n\telse if (num % 2 == 0) return false;\n\n\tdouble sqrtNum = sqrt(num);\n\tfor (int i = 3; i <= sqrtNum; i += 2)\n\t{\n\t\tif (num % i == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nlong long modinv(long long a, long long m) {\n\tlong long b = m, u = 1, v = 0;\n\twhile (b) {\n\t\tlong long t = a / b;\n\t\ta -= t * b; swap(a, b);\n\t\tu -= t * v; swap(u, v);\n\t}\n\tu %= m;\n\tif (u < 0) u += m;\n\treturn u;\n}\n\n\n#define in(x) cin >> x\n#define out(x) cout << x\n#define outn(x) cout << x << '\\n'\n#define outs(x) cout << x << ' '\n#define rep(i,s,e) for(ll i=s;i dic1,dic2,dic3,dic;\n\n\n\trep(i, 0, s.size()) {\n\t\tsi = s.substr(i, 1);\n\t\tif (dic3[si] > 2) {\n\t\t\ts.erase(s.begin() + i);\n\t\t\ti--;\n\t\t}\n\t\telse {\n\t\t\tdic3[si]++;\n\t\t}\n\t}\n\n\tn = s.size();\n\trep(i, 0, n - 2) {\n\t\tsi = s.substr(i, 1);\n\t\tif (dic1[si] == 0) {\n\t\t\tdic2.clear();\n\t\t\trep(j, i + 1, n - 1) {\n\t\t\t\tsj = s.substr(j, 1);\n\t\t\t\tif (dic2[sj] == 0) {\n\t\t\t\t\trep(k, j + 1, n) {\n\t\t\t\t\t\tsk = s.substr(k, 1);\n\t\t\t\t\t\tdic[si + sj + sk]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdic2[sj]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tdic1[si]++;\n\t\t}\n\t}\n\n\toutn(dic.size());\n\treturn 0;\n\n\n}\n", "language": "C++", "metadata": {"date": 1575257284, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/C++/s174479375.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s174479375", "user_id": "u757628628"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#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) { return b ? gcd(b, a % b) : a; }\ntemplate\nT lcm(T a, T b) { return a / gcd(a, b) * b; }\n\ntemplate\nmap primeFactor(T n) {\n\tmap res;\n\tfor (T i = 2; i * i <= n; ++i) {\n\t\twhile (n % i == 0) {\n\t\t\tres[i] ++;\n\t\t\tn /= i;\n\t\t}\n\t}\n\tif (n != 1) res[n] = 1;\n\treturn res;\n}\n\ntemplate\nbool IsPrimeNumber(T num)\n{\n\tif (num <= 2) return true;\n\telse if (num % 2 == 0) return false;\n\n\tdouble sqrtNum = sqrt(num);\n\tfor (int i = 3; i <= sqrtNum; i += 2)\n\t{\n\t\tif (num % i == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nlong long modinv(long long a, long long m) {\n\tlong long b = m, u = 1, v = 0;\n\twhile (b) {\n\t\tlong long t = a / b;\n\t\ta -= t * b; swap(a, b);\n\t\tu -= t * v; swap(u, v);\n\t}\n\tu %= m;\n\tif (u < 0) u += m;\n\treturn u;\n}\n\n\n#define in(x) cin >> x\n#define out(x) cout << x\n#define outn(x) cout << x << '\\n'\n#define outs(x) cout << x << ' '\n#define rep(i,s,e) for(ll i=s;i dic1,dic2,dic3,dic;\n\n\n\trep(i, 0, s.size()) {\n\t\tsi = s.substr(i, 1);\n\t\tif (dic3[si] > 2) {\n\t\t\ts.erase(s.begin() + i);\n\t\t\ti--;\n\t\t}\n\t\telse {\n\t\t\tdic3[si]++;\n\t\t}\n\t}\n\n\tn = s.size();\n\trep(i, 0, n - 2) {\n\t\tsi = s.substr(i, 1);\n\t\tif (dic1[si] == 0) {\n\t\t\tdic2.clear();\n\t\t\trep(j, i + 1, n - 1) {\n\t\t\t\tsj = s.substr(j, 1);\n\t\t\t\tif (dic2[sj] == 0) {\n\t\t\t\t\trep(k, j + 1, n) {\n\t\t\t\t\t\tsk = s.substr(k, 1);\n\t\t\t\t\t\tdic[si + sj + sk]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdic2[sj]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tdic1[si]++;\n\t\t}\n\t}\n\n\toutn(dic.size());\n\treturn 0;\n\n\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1940, "cpu_time_ms": 16, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s837251215", "group_id": "codeNet:p02846", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define chmin(x, y) x = min(x, y)\n#define chmax(x, y) x = max(x, y)\n#define MOD (int) (1e9+7)\n#define INF (int) 2e9\n#define LLINF (ll) 2e18\n\nint main(){\n ll t1, t2;\n ll a1, a2, b1, b2;\n cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;\n\n ll d1 = a1-b1;\n ll d2 = a2-b2;\n\n ll st = d1*t1+d2*t2;\n printf(\"%lld\\n\", st);\n\n if(st==0){\n cout << \"infinity\" << endl;\n return 0;\n }\n\n if(st>0){\n ll l = 0;\n ll r = (ll) 1e10+5;\n ll tmp;\n while(r-l>1){\n tmp = (l+r)/2;\n if(tmp*st+d1*t1>=0){\n r = tmp;\n }else{\n l = tmp;\n }\n }\n tmp = r;\n printf(\"%lld\\n\", tmp);\n\n ll ans = tmp*2-1;\n if(tmp*st+d1*t1==0){\n ans += 1;\n }\n cout << ans << endl;\n }else{\n ll l = 0;\n ll r = (ll) 1e10+5;\n ll tmp;\n while(r-l>1){\n tmp = (l+r)/2;\n if(tmp*st+d1*t1<=0){\n r = tmp;\n }else{\n l = tmp;\n }\n }\n tmp = r;\n ll ans = tmp*2-1;\n if(tmp*st+d1*t1==0){\n ans += 1;\n }\n cout << ans << endl;\n }\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1575257817, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02846.html", "problem_id": "p02846", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02846/input.txt", "sample_output_relpath": "derived/input_output/data/p02846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02846/C++/s837251215.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s837251215", "user_id": "u263654061"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define chmin(x, y) x = min(x, y)\n#define chmax(x, y) x = max(x, y)\n#define MOD (int) (1e9+7)\n#define INF (int) 2e9\n#define LLINF (ll) 2e18\n\nint main(){\n ll t1, t2;\n ll a1, a2, b1, b2;\n cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;\n\n ll d1 = a1-b1;\n ll d2 = a2-b2;\n\n ll st = d1*t1+d2*t2;\n printf(\"%lld\\n\", st);\n\n if(st==0){\n cout << \"infinity\" << endl;\n return 0;\n }\n\n if(st>0){\n ll l = 0;\n ll r = (ll) 1e10+5;\n ll tmp;\n while(r-l>1){\n tmp = (l+r)/2;\n if(tmp*st+d1*t1>=0){\n r = tmp;\n }else{\n l = tmp;\n }\n }\n tmp = r;\n printf(\"%lld\\n\", tmp);\n\n ll ans = tmp*2-1;\n if(tmp*st+d1*t1==0){\n ans += 1;\n }\n cout << ans << endl;\n }else{\n ll l = 0;\n ll r = (ll) 1e10+5;\n ll tmp;\n while(r-l>1){\n tmp = (l+r)/2;\n if(tmp*st+d1*t1<=0){\n r = tmp;\n }else{\n l = tmp;\n }\n }\n tmp = r;\n ll ans = tmp*2-1;\n if(tmp*st+d1*t1==0){\n ans += 1;\n }\n cout << ans << endl;\n }\n\n return 0;\n}", "problem_context": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "sample_input": "1 2\n10 10\n12 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02846", "source_text": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1370, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s972028532", "group_id": "codeNet:p02848", "input_text": "#include \nusing namespace std;\n \nint main() {\n int N;\n cin >> N;\n\n string input;\n cin >> input;\n\n for (int i = 0; i < input.size(); i++)\n {\n /* code */\n cout << (char)((input[i] + N) % (26 + 'A') + 'A');\n // cout << (char)(input[i] + N);\n }\n cout << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1574648234, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02848.html", "problem_id": "p02848", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02848/input.txt", "sample_output_relpath": "derived/input_output/data/p02848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02848/C++/s972028532.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s972028532", "user_id": "u585586208"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "#include \nusing namespace std;\n \nint main() {\n int N;\n cin >> N;\n\n string input;\n cin >> input;\n\n for (int i = 0; i < input.size(); i++)\n {\n /* code */\n cout << (char)((input[i] + N) % (26 + 'A') + 'A');\n // cout << (char)(input[i] + N);\n }\n cout << endl;\n \n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "sample_input": "2\nABCXYZ\n"}, "reference_outputs": ["CDEZAB\n"], "source_document_id": "p02848", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S consisting of uppercase English letters. Additionally, an integer N will be given.\n\nShift each character of S by N in alphabetical order (see below), and print the resulting string.\n\nWe assume that A follows Z. For example, shifting A by 2 results in C (A \\to B \\to C), and shifting Y by 3 results in B (Y \\to Z \\to A \\to B).\n\nConstraints\n\n0 \\leq N \\leq 26\n\n1 \\leq |S| \\leq 10^4\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the string resulting from shifting each character of S by N in alphabetical order.\n\nSample Input 1\n\n2\nABCXYZ\n\nSample Output 1\n\nCDEZAB\n\nNote that A follows Z.\n\nSample Input 2\n\n0\nABCXYZ\n\nSample Output 2\n\nABCXYZ\n\nSample Input 3\n\n13\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nSample Output 3\n\nNOPQRSTUVWXYZABCDEFGHIJKLM", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s400043912", "group_id": "codeNet:p02852", "input_text": "/**\n * author : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏\n * created : 2019-11-24 22:06:13\n**/\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\nusing namespace std;\n\nusing int64 = long long;\n#define debug(_) cerr << #_ << \": \" << (_) << '\\n'\ntemplate inline void chmin(T &a, T b) { if (a > b) a = b; return; }\ntemplate inline void chmax(T &a, T b) { if (a < b) a = b; return; }\ntemplate ostream& operator<<(ostream& os, const vector& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }\ntemplate ostream& operator<<(ostream& os, const pair& p) { return os << '{' << p.first << \" \" << p.second << '}'; }\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n\n int n, m; cin >> n >> m;\n string s; cin >> s;\n\n vector ans;\n\n reverse(s.begin(), s.end());\n //debug(s);\n\n int cur = 0;\n\n while (cur < n) {\n int next = -1;\n int res = (int) s.size() - 1 - cur;\n //debug(res);\n \n for (int i = min(m, res); i >= 1; --i) {\n if (s[cur + i] == '0') {\n next = i;\n break;\n }\n }\n if (next == -1) {\n cout << -1 << endl;\n return 0;\n } else {\n cur += next;\n ans.emplace_back(next);\n }\n }\n\n reverse(ans.begin(), ans.end());\n\n for (int xx : ans) {\n cout << xx << \" \";\n }\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1574651582, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02852/input.txt", "sample_output_relpath": "derived/input_output/data/p02852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02852/C++/s400043912.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s400043912", "user_id": "u095266283"}, "prompt_components": {"gold_output": "1 3 2 3\n", "input_to_evaluate": "/**\n * author : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏\n * created : 2019-11-24 22:06:13\n**/\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\nusing namespace std;\n\nusing int64 = long long;\n#define debug(_) cerr << #_ << \": \" << (_) << '\\n'\ntemplate inline void chmin(T &a, T b) { if (a > b) a = b; return; }\ntemplate inline void chmax(T &a, T b) { if (a < b) a = b; return; }\ntemplate ostream& operator<<(ostream& os, const vector& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }\ntemplate ostream& operator<<(ostream& os, const pair& p) { return os << '{' << p.first << \" \" << p.second << '}'; }\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n\n int n, m; cin >> n >> m;\n string s; cin >> s;\n\n vector ans;\n\n reverse(s.begin(), s.end());\n //debug(s);\n\n int cur = 0;\n\n while (cur < n) {\n int next = -1;\n int res = (int) s.size() - 1 - cur;\n //debug(res);\n \n for (int i = min(m, res); i >= 1; --i) {\n if (s[cur + i] == '0') {\n next = i;\n break;\n }\n }\n if (next == -1) {\n cout << -1 << endl;\n return 0;\n } else {\n cur += next;\n ans.emplace_back(next);\n }\n }\n\n reverse(ans.begin(), ans.end());\n\n for (int xx : ans) {\n cout << xx << \" \";\n }\n\n return 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "sample_input": "9 3\n0001000100\n"}, "reference_outputs": ["1 3 2 3\n"], "source_document_id": "p02852", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1749, "cpu_time_ms": 9, "memory_kb": 1096}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s841518372", "group_id": "codeNet:p02854", "input_text": "#include \n#include \nusing namespace std;\ntypedef long long ll;\n\n\nint main(void){\n int n,i;\n ll a[200005],s=0,ls;\n \n cin >> n;\n for (i=0;i> a[i];\n s+=a[i];\n }\n \n i=1;\n ls=a[0];\n while (i\n#include \nusing namespace std;\ntypedef long long ll;\n\n\nint main(void){\n int n,i;\n ll a[200005],s=0,ls;\n \n cin >> n;\n for (i=0;i> a[i];\n s+=a[i];\n }\n \n i=1;\n ls=a[0];\n while (i= i##_limit; --i)\n#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)\n#ifndef DBG\n#define trace(...)\n#endif\nusing namespace std;\nusing i64 = int_fast64_t;\nusing pii = pair;\ntemplate inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }\ntemplate inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }\ninline i64 sigma(i64 n) { return (n * (n + 1) >> 1); }\ninline i64 updiv(i64 a, i64 b) { return (a + b - 1) / b; }\ninline i64 sqr(i64 n) { return n * n; }\ninline string to_string(char c) { return string(1, c); }\nconstexpr int INF = 0x3f3f3f3f;\nconstexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;\n\ntemplate \ninline vector make_v(const T &initValue, size_t sz) {\n return vector(sz, initValue);\n}\ntemplate \ninline auto make_v(const T &initValue, size_t sz, Args... args) {\n return vector(initValue, args...))>(sz, make_v(initValue, args...));\n}\n\ninline void input() {}\ntemplate \ninline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }\n\ninline void print() { cout << \"\\n\"; }\ntemplate \ninline void print(Head &&head, Tail&&... tail) {\n cout << head;\n if (sizeof...(tail)) cout << ' ';\n print(forward(tail)...);\n}\n\ntemplate \ninline ostream& operator<< (ostream &out, const vector &vec) {\n static constexpr const char *delim[] = { \" \", \"\" };\n for (const auto &e : vec) out << e << delim[&e == &vec.back()];\n return out;\n}\n\ntemplate \nstruct FixPoint : Func {\n inline constexpr FixPoint(Func &&f) noexcept : Func(forward(f)) {}\n\n template \n inline decltype(auto) operator()(Args &&... args) const {\n return Func::operator()(*this, forward(args)...);\n }\n};\n\ntemplate< typename Func >\ninline decltype(auto) makeFixPoint(Func &&f) {\n return FixPoint< Func >{forward< Func >(f)};\n}\n// }}} End Header\n\nsigned main()\n{\n ios::sync_with_stdio(false); cin.tie(nullptr);\n\n var(int, H, W, K);\n vector mat(H);\n auto g = make_v(0, H, W);\n\n rep(i, H) {\n input(mat[i]);\n }\n\n {\n int id = 1;\n rep(i, H) {\n rep(j, W) {\n if (mat[i][j] == '#') {\n g[i][j] = id++;\n }\n }\n }\n }\n\n rep(i, H) {\n rep(_, W) rep(j, W) {\n if (g[i][j]) continue;\n if (j+1 < W && g[i][j+1]) g[i][j] = g[i][j+1];\n if (j-1 >= 0 && g[i][j-1]) g[i][j] = g[i][j-1];\n }\n }\n\n rep(j, W) {\n rep(_, H) rep(i, H) {\n if (g[i][j]) continue;\n if (i+1 < H && g[i+1][j]) g[i][j] = g[i+1][j];\n if (i-1 >= 0 && g[i-1][j]) g[i][j] = g[i-1][j];\n }\n }\n\n rep(i, H) {\n print(g[i]);\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1574565978, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02855.html", "problem_id": "p02855", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02855/input.txt", "sample_output_relpath": "derived/input_output/data/p02855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02855/C++/s756534396.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756534396", "user_id": "u897304429"}, "prompt_components": {"gold_output": "1 2 2\n1 3 4\n5 5 4\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n// Begin Header {{{\n#define all(x) (x).begin(), (x).end()\n#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)\n#define reps(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)\n#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)\n#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)\n#ifndef DBG\n#define trace(...)\n#endif\nusing namespace std;\nusing i64 = int_fast64_t;\nusing pii = pair;\ntemplate inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }\ntemplate inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }\ninline i64 sigma(i64 n) { return (n * (n + 1) >> 1); }\ninline i64 updiv(i64 a, i64 b) { return (a + b - 1) / b; }\ninline i64 sqr(i64 n) { return n * n; }\ninline string to_string(char c) { return string(1, c); }\nconstexpr int INF = 0x3f3f3f3f;\nconstexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;\n\ntemplate \ninline vector make_v(const T &initValue, size_t sz) {\n return vector(sz, initValue);\n}\ntemplate \ninline auto make_v(const T &initValue, size_t sz, Args... args) {\n return vector(initValue, args...))>(sz, make_v(initValue, args...));\n}\n\ninline void input() {}\ntemplate \ninline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }\n\ninline void print() { cout << \"\\n\"; }\ntemplate \ninline void print(Head &&head, Tail&&... tail) {\n cout << head;\n if (sizeof...(tail)) cout << ' ';\n print(forward(tail)...);\n}\n\ntemplate \ninline ostream& operator<< (ostream &out, const vector &vec) {\n static constexpr const char *delim[] = { \" \", \"\" };\n for (const auto &e : vec) out << e << delim[&e == &vec.back()];\n return out;\n}\n\ntemplate \nstruct FixPoint : Func {\n inline constexpr FixPoint(Func &&f) noexcept : Func(forward(f)) {}\n\n template \n inline decltype(auto) operator()(Args &&... args) const {\n return Func::operator()(*this, forward(args)...);\n }\n};\n\ntemplate< typename Func >\ninline decltype(auto) makeFixPoint(Func &&f) {\n return FixPoint< Func >{forward< Func >(f)};\n}\n// }}} End Header\n\nsigned main()\n{\n ios::sync_with_stdio(false); cin.tie(nullptr);\n\n var(int, H, W, K);\n vector mat(H);\n auto g = make_v(0, H, W);\n\n rep(i, H) {\n input(mat[i]);\n }\n\n {\n int id = 1;\n rep(i, H) {\n rep(j, W) {\n if (mat[i][j] == '#') {\n g[i][j] = id++;\n }\n }\n }\n }\n\n rep(i, H) {\n rep(_, W) rep(j, W) {\n if (g[i][j]) continue;\n if (j+1 < W && g[i][j+1]) g[i][j] = g[i][j+1];\n if (j-1 >= 0 && g[i][j-1]) g[i][j] = g[i][j-1];\n }\n }\n\n rep(j, W) {\n rep(_, H) rep(i, H) {\n if (g[i][j]) continue;\n if (i+1 < H && g[i+1][j]) g[i][j] = g[i+1][j];\n if (i-1 >= 0 && g[i-1][j]) g[i][j] = g[i-1][j];\n }\n }\n\n rep(i, H) {\n print(g[i]);\n }\n\n return 0;\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "sample_input": "3 3 5\n#.#\n.#.\n#.#\n"}, "reference_outputs": ["1 2 2\n1 3 4\n5 5 4\n"], "source_document_id": "p02855", "source_text": "Score: 400 points\n\nProblem Statement\n\nChokudai made a rectangular cake for contestants in DDCC 2020 Finals.\n\nThe cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \\times W equal sections. K of these sections has a strawberry on top of each of them.\n\nThe positions of the strawberries are given to you as H \\times W characters s_{i, j} (1 \\leq i \\leq H, 1 \\leq j \\leq W). If s_{i, j} is #, the section at the i-th row from the top and the j-th column from the left contains a strawberry; if s_{i, j} is ., the section does not contain one. There are exactly K occurrences of #s.\n\nTakahashi wants to cut this cake into K pieces and serve them to the contestants. Each of these pieces must satisfy the following conditions:\n\nHas a rectangular shape.\n\nContains exactly one strawberry.\n\nOne possible way to cut the cake is shown below:\n\nFind one way to cut the cake and satisfy the condition. We can show that this is always possible, regardless of the number and positions of the strawberries.\n\nConstraints\n\n1 \\leq H \\leq 300\n\n1 \\leq W \\leq 300\n\n1 \\leq K \\leq H \\times W\n\ns_{i, j} is # or ..\n\nThere are exactly K occurrences of # in s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\ns_{1, 1} s_{1, 2} \\cdots s_{1, W}\ns_{2, 1} s_{2, 2} \\cdots s_{2, W}\n:\ns_{H, 1} s_{H, 2} \\cdots s_{H, W}\n\nOutput\n\nAssign the numbers 1, 2, 3, \\dots, K to the K pieces obtained after the cut, in any order. Then, let a_{i, j} be the number representing the piece containing the section at the i-th row from the top and the j-th column from the left of the cake. Output should be in the following format:\n\na_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}\na_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}\n:\na_{H, 1} \\ a_{H, 2} \\ \\cdots \\ a_{H, W}\n\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3 3 5\n#.#\n.#.\n#.#\n\nSample Output 1\n\n1 2 2\n1 3 4\n5 5 4\n\nOne way to cut this cake is shown below:\n\nSample Input 2\n\n3 7 7\n#...#.#\n..#...#\n.#..#..\n\nSample Output 2\n\n1 1 2 2 3 4 4\n6 6 2 2 3 5 5\n6 6 7 7 7 7 7\n\nOne way to cut this cake is shown below:\n\nSample Input 3\n\n13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n.....................\n\nSample Output 3\n\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 23 34 45 45 60 71 82 93 93 2 13 24 35 35 17 28 39 50 50\n12 12 56 89 89 89 60 104 82 31 31 46 13 24 35 35 61 61 39 50 50\n12 12 67 67 100 100 60 9 9 42 42 57 13 24 6 72 72 72 72 72 72\n12 12 78 5 5 5 20 20 20 53 68 68 90 24 6 83 83 83 83 83 83\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n16 16 27 38 49 49 64 75 86 97 79 79 90 101 6 94 94 105 10 21 21\n32 32 43 54 65 65 80 11 106 95 22 22 33 44 55 55 70 1 96 85 85\n32 32 43 54 76 76 91 11 106 84 84 4 99 66 66 66 81 1 96 74 74\n14 14 3 98 87 87 102 11 73 73 73 4 99 88 77 77 92 92 63 63 63\n25 25 3 98 87 87 7 29 62 62 62 15 99 88 77 77 103 19 30 52 52\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41\n36 36 47 58 69 69 18 29 40 51 51 26 37 48 59 59 8 19 30 41 41", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3250, "cpu_time_ms": 79, "memory_kb": 1280}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s215368493", "group_id": "codeNet:p02855", "input_text": "#include \nusing namespace std;\n\n#define ll long long\n#define p_b push_back\n#define pl pair\n\nll modo = 1000000007;\nll MOD = modo;\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tll t;\n\tt = 1;\n\t//cin >> t;\n\twhile(t--)\n\t{\n\t\tll h,w,k;\n\t\tcin >> h >> w >> k;\n\t\tstring s[h];\n\t\tll i,j;\n\t\tll first = -1;\n\t\tfor(i=0;i> s[i];\n\t\t\tif(first!= -1)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor(j=0;j=0;i--)\n\t\t{\n\n\t\t\tfor(j=0;j\nusing namespace std;\n\n#define ll long long\n#define p_b push_back\n#define pl pair\n\nll modo = 1000000007;\nll MOD = modo;\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tll t;\n\tt = 1;\n\t//cin >> t;\n\twhile(t--)\n\t{\n\t\tll h,w,k;\n\t\tcin >> h >> w >> k;\n\t\tstring s[h];\n\t\tll i,j;\n\t\tll first = -1;\n\t\tfor(i=0;i> s[i];\n\t\t\tif(first!= -1)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor(j=0;j=0;i--)\n\t\t{\n\n\t\t\tfor(j=0;j\nusing namespace std;\n\nint main(){\n\tint r; cin >> r;\n\tcout << r*r << endl;\n}", "language": "C++", "metadata": {"date": 1577772853, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/C++/s408415042.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408415042", "user_id": "u734333003"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\n\tint r; cin >> r;\n\tcout << r*r << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s087453305", "group_id": "codeNet:p02859", "input_text": "#include \nusing namespace std;\n\nint main() {\n\tint a;\n\tcin >> a;\n\tcout << a * a << '\\n';\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1573956082, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/C++/s087453305.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087453305", "user_id": "u690769164"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n\tint a;\n\tcin >> a;\n\tcout << a * a << '\\n';\n\treturn 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s914544013", "group_id": "codeNet:p02859", "input_text": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int r ;\n cin >> r ;\n \n cout << r*r << endl ;\n return 0 ;\n}", "language": "C++", "metadata": {"date": 1573956067, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02859/input.txt", "sample_output_relpath": "derived/input_output/data/p02859/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02859/C++/s914544013.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s914544013", "user_id": "u904995051"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int r ;\n cin >> r ;\n \n cout << r*r << endl ;\n return 0 ;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 159, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s049919791", "group_id": "codeNet:p02860", "input_text": "#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;\nusing ll = long long int;\nconst ll mod = 1e9 + 7;\n\nint main() {\n\n\tint n;\n\tstring s;\n\tcin >> n >> s;\n\n\tif (n % 2 != 0) {\n\t\tcout << \"No\" << endl;\n\t\treturn 0;\n\t}\n\n\tint m = n / 2;\n\tfor (int i = 0; i < n / 2; i++) {\n\t\tif (s[i] != s[i + m]) {\n\t\t\tcout << \"No\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tcout << \"Yes\" << endl;\n\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1582789699, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/C++/s049919791.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s049919791", "user_id": "u870074807"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#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;\nusing ll = long long int;\nconst ll mod = 1e9 + 7;\n\nint main() {\n\n\tint n;\n\tstring s;\n\tcin >> n >> s;\n\n\tif (n % 2 != 0) {\n\t\tcout << \"No\" << endl;\n\t\treturn 0;\n\t}\n\n\tint m = n / 2;\n\tfor (int i = 0; i < n / 2; i++) {\n\t\tif (s[i] != s[i + m]) {\n\t\t\tcout << \"No\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tcout << \"Yes\" << endl;\n\n\treturn 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 563, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s979899179", "group_id": "codeNet:p02860", "input_text": "#include \nusing namespace std;\nint main(void){\n string ans = \"Yes\";\n int n; cin >> n;\n string s; cin >> s;\n if(n % 2 != 0) ans = \"No\";\n int k = n /2;\n for(int i = 0; i < k; i++){\n if(s.at(i) != s.at(i+k)) ans = \"No\";\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1573956867, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02860/input.txt", "sample_output_relpath": "derived/input_output/data/p02860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02860/C++/s979899179.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979899179", "user_id": "u327499140"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\nint main(void){\n string ans = \"Yes\";\n int n; cin >> n;\n string s; cin >> s;\n if(n % 2 != 0) ans = \"No\";\n int k = n /2;\n for(int i = 0; i < k; i++){\n if(s.at(i) != s.at(i+k)) ans = \"No\";\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "sample_input": "6\nabcabc\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02860", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\n\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a string T such that S = T + T.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS consists of lowercase English letters.\n\n|S| = N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nIf S is a concatenation of two copies of some string, print Yes; otherwise, print No.\n\nSample Input 1\n\n6\nabcabc\n\nSample Output 1\n\nYes\n\nLet T = abc, and S = T + T.\n\nSample Input 2\n\n6\nabcadc\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1\nz\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s430329549", "group_id": "codeNet:p02861", "input_text": "#include \nusing namespace std;\n \nint facctorialMethod(int k){\n int sum = 1;\n for (int i = 1; i <= k; ++i)\n {\n sum *= i;\n }\n return sum;\n}\n\nint main(){\n int n;\n cin >> n;\n vectorx(n);\n vectory(n);\n for(int i=0;i> x.at(i) >> y.at(i);\n }\n vectorin(n);\n for(int i=0;i\nusing namespace std;\n \nint facctorialMethod(int k){\n int sum = 1;\n for (int i = 1; i <= k; ++i)\n {\n sum *= i;\n }\n return sum;\n}\n\nint main(){\n int n;\n cin >> n;\n vectorx(n);\n vectory(n);\n for(int i=0;i> x.at(i) >> y.at(i);\n }\n vectorin(n);\n for(int i=0;i\n#define rep(i,n) for (int i=1;i<=n;i++)\n\nusing namespace std;\nlong int d=1000000000+7;\nint main()\n{\nlong int x,y;\ncin>>x>>y;\nif ((x+y)%3!=0)\ncout <<0;\nelse\n{long int a,b;\na=(2*y-x)/3;\nb=(2*x-y)/3;\nlong int a0=1,a1=1;\nrep(i,a)\na1*=i;\nrep(i,a)\na0*=(a+b-i+1);\ncout <<(a0/a1)%d;\n}\n\n\n\n}", "language": "C++", "metadata": {"date": 1574020258, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/C++/s512760593.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s512760593", "user_id": "u437083392"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define rep(i,n) for (int i=1;i<=n;i++)\n\nusing namespace std;\nlong int d=1000000000+7;\nint main()\n{\nlong int x,y;\ncin>>x>>y;\nif ((x+y)%3!=0)\ncout <<0;\nelse\n{long int a,b;\na=(2*y-x)/3;\nb=(2*x-y)/3;\nlong int a0=1,a1=1;\nrep(i,a)\na1*=i;\nrep(i,a)\na0*=(a+b-i+1);\ncout <<(a0/a1)%d;\n}\n\n\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 302, "cpu_time_ms": 116, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s497358256", "group_id": "codeNet:p02866", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair l_l;\ntypedef pair i_i;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define EPS (1e-7)\n#define INF (1e9)\n#define PI (acos(-1))\n\nconst ll mod = 998244353;\n\nll safePow(ll x, ll y){\n ll result = 1;\n rep(i, y){\n result = (result * x) % mod;\n }\n return result;\n}\n\nint main() {\n int n;\n cin >> n;\n vector d(n);\n rep(i, n) cin >> d[i];\n if(d[0] != 0){\n cout << 0 << endl;\n return 0;\n }\n sort(d.begin(), d.end());\n if(d[1] != 1){\n cout << 0 << endl;\n return 0;\n }\n\n ll cnt = 0, cur_d = 0, prev_cnt = 1;\n ll ans = 1;\n rep(i, n){\n if(d[i] == cur_d){\n cnt++;\n } else {\n if(d[i] != cur_d + 1){\n ans = 0;\n break;\n }\n ans = (ans * safePow(prev_cnt, cnt)) % mod;\n prev_cnt = cnt;\n cnt = 1;\n cur_d++;\n }\n if(i == n - 1){\n ans = (ans * safePow(prev_cnt, cnt)) % mod;\n }\n }\n cout << ans << endl;\n\n \n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592113551, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/C++/s497358256.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497358256", "user_id": "u225642513"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair l_l;\ntypedef pair i_i;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define EPS (1e-7)\n#define INF (1e9)\n#define PI (acos(-1))\n\nconst ll mod = 998244353;\n\nll safePow(ll x, ll y){\n ll result = 1;\n rep(i, y){\n result = (result * x) % mod;\n }\n return result;\n}\n\nint main() {\n int n;\n cin >> n;\n vector d(n);\n rep(i, n) cin >> d[i];\n if(d[0] != 0){\n cout << 0 << endl;\n return 0;\n }\n sort(d.begin(), d.end());\n if(d[1] != 1){\n cout << 0 << endl;\n return 0;\n }\n\n ll cnt = 0, cur_d = 0, prev_cnt = 1;\n ll ans = 1;\n rep(i, n){\n if(d[i] == cur_d){\n cnt++;\n } else {\n if(d[i] != cur_d + 1){\n ans = 0;\n break;\n }\n ans = (ans * safePow(prev_cnt, cnt)) % mod;\n prev_cnt = cnt;\n cnt = 1;\n cur_d++;\n }\n if(i == n - 1){\n ans = (ans * safePow(prev_cnt, cnt)) % mod;\n }\n }\n cout << ans << endl;\n\n \n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1186, "cpu_time_ms": 35, "memory_kb": 768}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s361451403", "group_id": "codeNet:p02866", "input_text": "#include \n#include \n\nusing namespace std;\nstatic const int MAX = 100000;\n\nint main(void) {\n long long int N, i, Ds[MAX], Es[MAX];\n long long int ans = 1;\n cin >> N;\n for (i=0;i> Ds[i];\n Es[Ds[i]] ++;\n }\n\n if (Ds[0] != 0 && Es[0] != 1) {\n cout << 0 << endl;\n return 0;\n }\n\n for (i=0;i\n#include \n\nusing namespace std;\nstatic const int MAX = 100000;\n\nint main(void) {\n long long int N, i, Ds[MAX], Es[MAX];\n long long int ans = 1;\n cin >> N;\n for (i=0;i> Ds[i];\n Es[Ds[i]] ++;\n }\n\n if (Ds[0] != 0 && Es[0] != 1) {\n cout << 0 << endl;\n return 0;\n }\n\n for (i=0;i\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define int long long\n#define endl \"\\n\"\n\nconst long long INF = (long long)1e18;\nconst long long MOD = 998244353; \n\nstring yn(bool f){return f?\"Yes\":\"No\";}\nstring YN(bool f){return f?\"YES\":\"NO\";}\n\n\n\nlong long power(long long x, long long n){\n\tlong long ans = 1;\n\tfor(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)\n\t\tif(n&1)ans*=x;\n\treturn ans%MOD;\n}\n\n\n\nsigned main(){\n\tcin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\tcout< D;\n\tvector con;\n\t\n\tcin>>N;\n\t\n\tD.resize(N);\n\tcon.resize(N);\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tcin>>D[i];\n\t\t// if(!D[i])zero++;\n\t\tcon[D[i]]++;\n\t\tmaximum = max(maximum, D[i]);\n\t}\n\t\n\tif(D[0]){\n\t\tcout<<0<= 2){\n\t\tcout<<0<\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define int long long\n#define endl \"\\n\"\n\nconst long long INF = (long long)1e18;\nconst long long MOD = 998244353; \n\nstring yn(bool f){return f?\"Yes\":\"No\";}\nstring YN(bool f){return f?\"YES\":\"NO\";}\n\n\n\nlong long power(long long x, long long n){\n\tlong long ans = 1;\n\tfor(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)\n\t\tif(n&1)ans*=x;\n\treturn ans%MOD;\n}\n\n\n\nsigned main(){\n\tcin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\tcout< D;\n\tvector con;\n\t\n\tcin>>N;\n\t\n\tD.resize(N);\n\tcon.resize(N);\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tcin>>D[i];\n\t\t// if(!D[i])zero++;\n\t\tcon[D[i]]++;\n\t\tmaximum = max(maximum, D[i]);\n\t}\n\t\n\tif(D[0]){\n\t\tcout<<0<= 2){\n\t\tcout<<0<\nusing namespace std;\ntypedef long long ll;\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n\nint main()\n{\nll n ;\ncin >> n ;\nvector> a;\nrep(i, n){\n ll x ;\n cin >> x ;\n a.emplace_back(x,i);\n}\nvector> b;\nrep(i, n){\n ll x ;\n cin >> x ;\n b.emplace_back(x,i);\n}\nsort(a.begin(),a.end());\nsort(b.begin(),b.end());\nrep(i,n){\n if(a[i].first>b[i].first){\n cout << \"No\" << endl;\n return 0;\n }\n}\n\nset s;\ns.insert(b[0].second);\nbool ok=0;\nll ind=0;\nrep(i,n){\n if(i>ind){\n s.clear();\n ind=i;\n }\n while(ind!=n-1){\n if(b[ind].second>=a[ind+1].second){\n ind++;\n s.insert(b[ind+1].second);\n }\n else break;\n }\n if(s.find(a[i].second)!=s.end())ok=1;\n}\nif(ok){\n cout << \"Yes\" << endl;\n}\nelse{\n cout << \"No\" << endl;\n}\nreturn 0;\n}", "language": "C++", "metadata": {"date": 1573360670, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02867.html", "problem_id": "p02867", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02867/input.txt", "sample_output_relpath": "derived/input_output/data/p02867/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02867/C++/s261353045.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s261353045", "user_id": "u419307948"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n\nint main()\n{\nll n ;\ncin >> n ;\nvector> a;\nrep(i, n){\n ll x ;\n cin >> x ;\n a.emplace_back(x,i);\n}\nvector> b;\nrep(i, n){\n ll x ;\n cin >> x ;\n b.emplace_back(x,i);\n}\nsort(a.begin(),a.end());\nsort(b.begin(),b.end());\nrep(i,n){\n if(a[i].first>b[i].first){\n cout << \"No\" << endl;\n return 0;\n }\n}\n\nset s;\ns.insert(b[0].second);\nbool ok=0;\nll ind=0;\nrep(i,n){\n if(i>ind){\n s.clear();\n ind=i;\n }\n while(ind!=n-1){\n if(b[ind].second>=a[ind+1].second){\n ind++;\n s.insert(b[ind+1].second);\n }\n else break;\n }\n if(s.find(a[i].second)!=s.end())ok=1;\n}\nif(ok){\n cout << \"Yes\" << endl;\n}\nelse{\n cout << \"No\" << endl;\n}\nreturn 0;\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "sample_input": "3\n1 3 2\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02867", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 808, "cpu_time_ms": 142, "memory_kb": 8048}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s990460005", "group_id": "codeNet:p02867", "input_text": "#define _CRT_SECURE_NO_WARNINGS\n#include \"bits/stdc++.h\"\n#if defined(_MSC_VER) || defined(ONLINE_JUDGE)\n#define getchar_unlocked _getchar_nolock\n#define putchar_unlocked _putchar_nolock\n#endif\n#define rep(i, n) for(int i=0; i<(n); ++i)\n#define FOR(i, m, n) for(int i=(m); i<(n); ++i)\n#define sz(x) ((int)(x).size())\n#define all(x) (x).begin(),(x).end()\n#define rall(x) (x).rbegin(),(x).rend()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n\nusing namespace std;\nusing LL = long long;\t\tusing VB = vector;\nusing VI = vector;\t\tusing VL = vector;\nusing VS = vector;\tusing VD = vector;\nusing VVI = vector;\t\tusing VVL = vector;\nusing PII = pair;\tusing PLL = pair;\nusing VP = vector;\t\tusing VPL = vector;\nconst int inf = (int)1e9;\nconst LL inf_ll = (LL)1e18, MOD = 1000000007;\nconst double PI = acos(-1.0), EPS = 1e-12;\n\ntemplatevoid Sort(T& a) { sort(all(a)); }\ntemplatevoid RSort(T& a) { sort(rall(a)); }\ntemplatevoid Reverse(T& a) { reverse(all(a)); }\ntemplatevoid Unique(T& a) { a.erase(unique(all(a)), a.end()); }\ntemplateT Sorted(T a) { Sort(a); return a; }\ntemplateT RSorted(T a) { RSort(a); return a; }\ntemplateT Reversed(T a) { Reverse(a); return a; }\ntemplateT Uniqued(T a) { Unique(a); return a; }\ntemplateauto Max(const T& a) { return *max_element(all(a)); }\ntemplateauto Min(const T& a) { return *min_element(all(a)); }\ntemplateint MaxPos(const T& a) { return max_element(all(a)) - a.begin(); }\ntemplateint MinPos(const T& a) { return min_element(all(a)) - a.begin(); }\ntemplateint Count(const T& a, const U& v) { return count(all(a), v); }\ntemplateint Find(const T& a, const U& v) { auto pos = find(all(a), v); return pos == a.end() ? -1 : pos - a.begin(); }\ntemplateU Sum(const T& a, const U& v) { return accumulate(all(a), v); }\ntemplateint Lower(const T& a, const U& v) { return lower_bound(all(a), v) - a.begin(); }\ntemplateint Upper(const T& a, const U& v) { return upper_bound(all(a), v) - a.begin(); }\ntemplatevoid RemoveIf(T& a, P f) { a.erase(remove_if(all(a), f), a.end()); }\ntemplateT Age(T n, T m) { return (n + m - 1) / m; }\ntemplateT Gcd(T n, T m) { return m ? Gcd(m, n % m) : n; }\ntemplateT Lcm(T n, T m) { return n / Gcd(n, m) * m; }\ntemplateT Pow(T a, T n) { T r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }\ntemplateT Powmod(T a, T n, T m = MOD) { T r = 1; while (n > 0) { if (n & 1)r = r * a % m, n--; else a = a * a % m, n /= 2; }return r; }\ntemplatebool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }\ntemplatebool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }\nstring operator*(string s, int n) { string ret; rep(i, n)ret += s; return ret; }\n\n// --- input --- //\ntemplateT InputF() { T ret; cin >> ret; return ret; }\ntemplate<> char InputF() {\n\tchar ret = '\\0', c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n' && c != '\\t' && c != ' ') { ret = c; c = getchar_unlocked(); }\n\treturn ret;\n}\ntemplate<> string InputF() {\n\tstring ret; char c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n' && c != '\\t' && c != ' ') { ret.push_back(c); c = getchar_unlocked(); }\n\treturn ret;\n}\ntemplate<> int InputF() {\n\tint ret = 0; bool neg = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c)) { ret = ret * 10 + (c - '0'); c = getchar_unlocked(); }\n\treturn neg ? -ret : ret;\n}\ntemplate<> LL InputF() {\n\tLL ret = 0; bool neg = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c)) { ret = ret * 10LL + (LL(c) - LL('0')); c = getchar_unlocked(); }\n\treturn neg ? -ret : ret;\n}\ntemplate<> double InputF() {\n\tdouble ret = 0, dp = 1; bool neg = false, adp = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c) || c == '.') {\n\t\tif (c == '.')adp = true;\n\t\telse if (adp)ret += (c - '0') * (dp *= 0.1);\n\t\telse ret = ret * 10.0 + (c - '0');\n\t\tc = getchar_unlocked();\n\t}\n\treturn neg ? -ret : ret;\n}\nstring GetLine() {\n\tstring ret; char c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n') { ret.push_back(c); c = getchar_unlocked(); }\n\treturn ret;\n}\nstruct Input {\n\tstruct InputV {\n\t\tint n, m;\n\t\tInputV(int N) :n(N), m(-1) {}\n\t\tInputV(pair N) { tie(n, m) = N; }\n\t\ttemplateoperator vector() {\n\t\t\tvector ret(n); rep(i, n)ret[i] = InputF(); return ret;\n\t\t}\n\t\ttemplateoperator vector>() {\n\t\t\tassert(m != -1); vector> ret(n, vector(m));\n\t\t\trep(i, n)rep(j, m)ret[i][j] = InputF();\n\t\t\treturn ret;\n\t\t}\n\t};\n\ttemplateoperator T() { return InputF(); }\n\tInputV operator[](int t) { return InputV(t); }\n\tInputV operator[](pair t) { return InputV(t); }\n}in;\n\n// --- output --- //\nstruct BoolStr {\n\tconst char* t, * f; BoolStr(const char* _t, const char* _f) :t(_t), f(_f) {}\n}Yes(\"Yes\", \"No\"), yes(\"yes\", \"no\"), YES(\"YES\", \"NO\"), Int(\"1\", \"0\");\nstruct DivStr {\n\tconst char* d, * l; DivStr(const char* _d, const char* _l) :d(_d), l(_l) {}\n}spc(\" \", \"\\n\"), no_spc(\"\", \"\\n\"), end_line(\"\\n\", \"\\n\"), comma(\",\", \"\\n\"), no_endl(\" \", \"\");\nclass Print {\n\tBoolStr B{ Yes }; DivStr D{ spc };\tvoid p(double v) { printf(\"%.20f\", v); }\n\tvoid p(int v) { printf(\"%d\", v); }\tvoid p(LL v) { printf(\"%lld\", v); }\n\tvoid p(char v) { putchar(v); }\t\tvoid p(bool v) { printf(v ? B.t : B.f); }\n\ttemplatevoid p(const T& v) { cout << v; }\n\ttemplatevoid p(const pair& v) { p(v.first); printf(D.d); p(v.second); }\n\ttemplatevoid p(const vector& v) { rep(i, sz(v)) { if (i)printf(D.d); p(v[i]); } }\n\ttemplatevoid p(const vector>& v) { rep(i, sz(v)) { if (i)printf(D.l); p(v[i]); } }\n\tvoid p(const BoolStr& v) { B = v; } void p(const DivStr& v) { D = v; }\n\ttemplatebool isPrint(const T& v) { return !is_same::value && !is_same::value; }\npublic:\n\tvoid operator()() { printf(D.l); }\n\ttemplatevoid operator()(H&& h) {\n\t\tp(h); if (isPrint(h))printf(D.l); B = Yes; D = spc;\n\t}\n\ttemplatevoid operator()(H&& h, T&& ...t) {\n\t\tp(h); if (isPrint(h))printf(D.d); operator()(forward(t)...);\n\t}\n}out;\n\n// --- step --- //\nclass step {\n\tstruct It {\n\t\tint x, s; It(int _x, int _s) :x(_x), s(_s) { assert(s); }\n\t\tint operator*() { return x; } void operator++() { x += s; }\n\t\tbool operator!=(It& i) { return 0 < s ? x < i.x : x >= i.x; }\n\t}; int x, y, s;\npublic:\n\tstep(int _y, int _s = 1) :x(0 < _s ? 0 : _y), y(0 < _s ? _y : 0), s(_s) {}\n\tstep(int _x, int _y, int _s) :x(_x), y(_y), s(_s) {}\n\tIt begin() { return { x,s }; } It end() { return { y,s }; }\n};\n\n// --- dump --- //\n#if __has_include(\"dump.hpp\")\n#include \"dump.hpp\"\n#else\n#define dump(...) (void(0))\n#endif\n\n\nint main() {\n\tint n = in;\n\tVI a = in[n], b = in[n];\n\n\tVI A = b, B = b; Sort(A); Sort(B);\n\tbool flag = true;\n\trep(i, n) {\n\t\tif (A[i] > B[i])flag = false;\n\t}\n\n\tif (!flag) {\n\t\tout(\"No\");\n\t\treturn 0;\n\t}\n\n\tif (a == b || A != B) {\n\t\tout(\"Yes\");\n\t\treturn 0;\n\t}\n\n\tmap m;\n\trep(i, n)m[A[i]] = i;\n\tVP ab(n);\n\trep(i, n) {\n\t\tab[i] = mp(m[a[i]], m[b[i]]);\n\t}\n\tSort(ab);\n\n\tint pos = 0;\n\tint cnt_e = 0;\n\trep(i, n)cnt_e += ab[i].first == ab[i].second;\n\tfor (int cnt = 0; cnt < n - 2;) {\n\t\tif (ab[pos].first != ab[pos].second) {\n\t\t\tcnt++;\n\t\t\tint pos2 = ab[pos].second;\n\t\t\tswap(ab[pos].second, ab[pos2].second);\n\t\t\tif (ab[pos].second == ab[pos].first)cnt_e++;\n\t\t\tif (ab[pos2].second == ab[pos2].first)cnt_e++;\n\t\t\tif (cnt_e == n)break;\n\t\t}\n\t\tpos = (pos + 1) % n;\n\t}\n\n\tbool flag2 = true;\n\trep(i, n) {\n\t\tif (ab[i].first != ab[i].second)flag2 = false;\n\t}\n\tout(flag2);\n\n}", "language": "C++", "metadata": {"date": 1573357543, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02867.html", "problem_id": "p02867", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02867/input.txt", "sample_output_relpath": "derived/input_output/data/p02867/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02867/C++/s990460005.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s990460005", "user_id": "u172873334"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#define _CRT_SECURE_NO_WARNINGS\n#include \"bits/stdc++.h\"\n#if defined(_MSC_VER) || defined(ONLINE_JUDGE)\n#define getchar_unlocked _getchar_nolock\n#define putchar_unlocked _putchar_nolock\n#endif\n#define rep(i, n) for(int i=0; i<(n); ++i)\n#define FOR(i, m, n) for(int i=(m); i<(n); ++i)\n#define sz(x) ((int)(x).size())\n#define all(x) (x).begin(),(x).end()\n#define rall(x) (x).rbegin(),(x).rend()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n\nusing namespace std;\nusing LL = long long;\t\tusing VB = vector;\nusing VI = vector;\t\tusing VL = vector;\nusing VS = vector;\tusing VD = vector;\nusing VVI = vector;\t\tusing VVL = vector;\nusing PII = pair;\tusing PLL = pair;\nusing VP = vector;\t\tusing VPL = vector;\nconst int inf = (int)1e9;\nconst LL inf_ll = (LL)1e18, MOD = 1000000007;\nconst double PI = acos(-1.0), EPS = 1e-12;\n\ntemplatevoid Sort(T& a) { sort(all(a)); }\ntemplatevoid RSort(T& a) { sort(rall(a)); }\ntemplatevoid Reverse(T& a) { reverse(all(a)); }\ntemplatevoid Unique(T& a) { a.erase(unique(all(a)), a.end()); }\ntemplateT Sorted(T a) { Sort(a); return a; }\ntemplateT RSorted(T a) { RSort(a); return a; }\ntemplateT Reversed(T a) { Reverse(a); return a; }\ntemplateT Uniqued(T a) { Unique(a); return a; }\ntemplateauto Max(const T& a) { return *max_element(all(a)); }\ntemplateauto Min(const T& a) { return *min_element(all(a)); }\ntemplateint MaxPos(const T& a) { return max_element(all(a)) - a.begin(); }\ntemplateint MinPos(const T& a) { return min_element(all(a)) - a.begin(); }\ntemplateint Count(const T& a, const U& v) { return count(all(a), v); }\ntemplateint Find(const T& a, const U& v) { auto pos = find(all(a), v); return pos == a.end() ? -1 : pos - a.begin(); }\ntemplateU Sum(const T& a, const U& v) { return accumulate(all(a), v); }\ntemplateint Lower(const T& a, const U& v) { return lower_bound(all(a), v) - a.begin(); }\ntemplateint Upper(const T& a, const U& v) { return upper_bound(all(a), v) - a.begin(); }\ntemplatevoid RemoveIf(T& a, P f) { a.erase(remove_if(all(a), f), a.end()); }\ntemplateT Age(T n, T m) { return (n + m - 1) / m; }\ntemplateT Gcd(T n, T m) { return m ? Gcd(m, n % m) : n; }\ntemplateT Lcm(T n, T m) { return n / Gcd(n, m) * m; }\ntemplateT Pow(T a, T n) { T r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }\ntemplateT Powmod(T a, T n, T m = MOD) { T r = 1; while (n > 0) { if (n & 1)r = r * a % m, n--; else a = a * a % m, n /= 2; }return r; }\ntemplatebool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }\ntemplatebool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }\nstring operator*(string s, int n) { string ret; rep(i, n)ret += s; return ret; }\n\n// --- input --- //\ntemplateT InputF() { T ret; cin >> ret; return ret; }\ntemplate<> char InputF() {\n\tchar ret = '\\0', c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n' && c != '\\t' && c != ' ') { ret = c; c = getchar_unlocked(); }\n\treturn ret;\n}\ntemplate<> string InputF() {\n\tstring ret; char c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n' && c != '\\t' && c != ' ') { ret.push_back(c); c = getchar_unlocked(); }\n\treturn ret;\n}\ntemplate<> int InputF() {\n\tint ret = 0; bool neg = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c)) { ret = ret * 10 + (c - '0'); c = getchar_unlocked(); }\n\treturn neg ? -ret : ret;\n}\ntemplate<> LL InputF() {\n\tLL ret = 0; bool neg = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c)) { ret = ret * 10LL + (LL(c) - LL('0')); c = getchar_unlocked(); }\n\treturn neg ? -ret : ret;\n}\ntemplate<> double InputF() {\n\tdouble ret = 0, dp = 1; bool neg = false, adp = false; char c = getchar_unlocked();\n\tif (c == '-') { neg = true; c = getchar_unlocked(); }\n\twhile (isdigit(c) || c == '.') {\n\t\tif (c == '.')adp = true;\n\t\telse if (adp)ret += (c - '0') * (dp *= 0.1);\n\t\telse ret = ret * 10.0 + (c - '0');\n\t\tc = getchar_unlocked();\n\t}\n\treturn neg ? -ret : ret;\n}\nstring GetLine() {\n\tstring ret; char c = getchar_unlocked();\n\twhile (c != '\\0' && c != '\\n') { ret.push_back(c); c = getchar_unlocked(); }\n\treturn ret;\n}\nstruct Input {\n\tstruct InputV {\n\t\tint n, m;\n\t\tInputV(int N) :n(N), m(-1) {}\n\t\tInputV(pair N) { tie(n, m) = N; }\n\t\ttemplateoperator vector() {\n\t\t\tvector ret(n); rep(i, n)ret[i] = InputF(); return ret;\n\t\t}\n\t\ttemplateoperator vector>() {\n\t\t\tassert(m != -1); vector> ret(n, vector(m));\n\t\t\trep(i, n)rep(j, m)ret[i][j] = InputF();\n\t\t\treturn ret;\n\t\t}\n\t};\n\ttemplateoperator T() { return InputF(); }\n\tInputV operator[](int t) { return InputV(t); }\n\tInputV operator[](pair t) { return InputV(t); }\n}in;\n\n// --- output --- //\nstruct BoolStr {\n\tconst char* t, * f; BoolStr(const char* _t, const char* _f) :t(_t), f(_f) {}\n}Yes(\"Yes\", \"No\"), yes(\"yes\", \"no\"), YES(\"YES\", \"NO\"), Int(\"1\", \"0\");\nstruct DivStr {\n\tconst char* d, * l; DivStr(const char* _d, const char* _l) :d(_d), l(_l) {}\n}spc(\" \", \"\\n\"), no_spc(\"\", \"\\n\"), end_line(\"\\n\", \"\\n\"), comma(\",\", \"\\n\"), no_endl(\" \", \"\");\nclass Print {\n\tBoolStr B{ Yes }; DivStr D{ spc };\tvoid p(double v) { printf(\"%.20f\", v); }\n\tvoid p(int v) { printf(\"%d\", v); }\tvoid p(LL v) { printf(\"%lld\", v); }\n\tvoid p(char v) { putchar(v); }\t\tvoid p(bool v) { printf(v ? B.t : B.f); }\n\ttemplatevoid p(const T& v) { cout << v; }\n\ttemplatevoid p(const pair& v) { p(v.first); printf(D.d); p(v.second); }\n\ttemplatevoid p(const vector& v) { rep(i, sz(v)) { if (i)printf(D.d); p(v[i]); } }\n\ttemplatevoid p(const vector>& v) { rep(i, sz(v)) { if (i)printf(D.l); p(v[i]); } }\n\tvoid p(const BoolStr& v) { B = v; } void p(const DivStr& v) { D = v; }\n\ttemplatebool isPrint(const T& v) { return !is_same::value && !is_same::value; }\npublic:\n\tvoid operator()() { printf(D.l); }\n\ttemplatevoid operator()(H&& h) {\n\t\tp(h); if (isPrint(h))printf(D.l); B = Yes; D = spc;\n\t}\n\ttemplatevoid operator()(H&& h, T&& ...t) {\n\t\tp(h); if (isPrint(h))printf(D.d); operator()(forward(t)...);\n\t}\n}out;\n\n// --- step --- //\nclass step {\n\tstruct It {\n\t\tint x, s; It(int _x, int _s) :x(_x), s(_s) { assert(s); }\n\t\tint operator*() { return x; } void operator++() { x += s; }\n\t\tbool operator!=(It& i) { return 0 < s ? x < i.x : x >= i.x; }\n\t}; int x, y, s;\npublic:\n\tstep(int _y, int _s = 1) :x(0 < _s ? 0 : _y), y(0 < _s ? _y : 0), s(_s) {}\n\tstep(int _x, int _y, int _s) :x(_x), y(_y), s(_s) {}\n\tIt begin() { return { x,s }; } It end() { return { y,s }; }\n};\n\n// --- dump --- //\n#if __has_include(\"dump.hpp\")\n#include \"dump.hpp\"\n#else\n#define dump(...) (void(0))\n#endif\n\n\nint main() {\n\tint n = in;\n\tVI a = in[n], b = in[n];\n\n\tVI A = b, B = b; Sort(A); Sort(B);\n\tbool flag = true;\n\trep(i, n) {\n\t\tif (A[i] > B[i])flag = false;\n\t}\n\n\tif (!flag) {\n\t\tout(\"No\");\n\t\treturn 0;\n\t}\n\n\tif (a == b || A != B) {\n\t\tout(\"Yes\");\n\t\treturn 0;\n\t}\n\n\tmap m;\n\trep(i, n)m[A[i]] = i;\n\tVP ab(n);\n\trep(i, n) {\n\t\tab[i] = mp(m[a[i]], m[b[i]]);\n\t}\n\tSort(ab);\n\n\tint pos = 0;\n\tint cnt_e = 0;\n\trep(i, n)cnt_e += ab[i].first == ab[i].second;\n\tfor (int cnt = 0; cnt < n - 2;) {\n\t\tif (ab[pos].first != ab[pos].second) {\n\t\t\tcnt++;\n\t\t\tint pos2 = ab[pos].second;\n\t\t\tswap(ab[pos].second, ab[pos2].second);\n\t\t\tif (ab[pos].second == ab[pos].first)cnt_e++;\n\t\t\tif (ab[pos2].second == ab[pos2].first)cnt_e++;\n\t\t\tif (cnt_e == n)break;\n\t\t}\n\t\tpos = (pos + 1) % n;\n\t}\n\n\tbool flag2 = true;\n\trep(i, n) {\n\t\tif (ab[i].first != ab[i].second)flag2 = false;\n\t}\n\tout(flag2);\n\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "sample_input": "3\n1 3 2\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02867", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7919, "cpu_time_ms": 136, "memory_kb": 11904}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s865269319", "group_id": "codeNet:p02869", "input_text": "// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_e\n#define CIN_ONLY\n#define DECIMAL_DIGITS 10\n#define STATIC_MOD 1e9 + 7\n\n#ifdef BTK\n/**/\n# include \"Template.hpp\"\n/**/\n#else\n/**/\n/* #region auto includes */\n/* #region stl */\n/**/\n# include \n# include \n# include \nusing namespace std;\n/**/\n/* #endregion */\n/* #region template/IncludeSTL.hpp*/\n/**\n * @file IncludeSTL.hpp\n * @author btk\n * @brief 標準ライブラリをincludeするだけ\n * @version 0.1\n * @date 2019-07-21\n * @todo 何故か2回includeされる(展開scriptに\n * @copyright Copyright (c) 2019\n *\n */\n\n\n/* #endregion */\n/* #region template/Macro.hpp*/\n/**\n * @file Macro.hpp\n * @author btk\n * @brief マクロとか,LLとか\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n\n//! LL\nusing LL = long long;\n\n/**\n * @def DEBUG\n * @brief デバッグ用のif文 提出時はif(0)で実行されない\n */\n\n/**/\n# ifdef BTK\n# define DEBUG if (1)\n# else\n# ifdef CIN_ONLY\n# define FAST_IO\n# endif\n# define DEBUG if (0)\n# endif\n/**\n * @def ALL(v)\n * @brief\n * ALLマクロ\n */\n# define ALL(v) (v).begin(), (v).end()\n\n/**\n * @def REC(ret, ...)\n * @brief\n * 再帰ラムダをするためのマクロ\n */\n# define REC(ret, ...) std::function\n\n/**\n * @def VAR_NAME(var)\n * @brief 変数名を取得する\n */\n# define VAR_NAME(var) # var\n\n/**\n * @brief\n * rangeで生まれる使わない変数を消す用(警告消し)\n */\ntemplate \ninline T& unused_var(T& v) {\n return v;\n}\n/* #endregion */\n/* #region template/IO.hpp*/\n/**\n * @file IO.hpp\n * @author btk\n * @brief cin高速化とか,出力の小数桁固定とか\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n */\n\n\n/**\n * @brief 入出力の設定を行うための構造体\n */\nstruct cww {\n /**\n * @brief Construct a new cww::cww object\n * @details\n * CIN_ONLYを定義すると,submit時にcinとscanfの同期を切る設定が走る\n * DECIMAL_DIGITSを定義すると,doubleの出力時指定した桁数分小数部を吐くようになる\n */\n cww() {\n# ifdef FAST_IO\n ios::sync_with_stdio(false);\n cin.tie(0);\n# endif\n# ifdef DECIMAL_DIGITS\n cout << fixed;\n cout << setprecision(DECIMAL_DIGITS);\n# endif\n }\n};\n\n//! 入出力設定構造体を実体化\ncww star;\n\n/**\n * @brief\n * vectorに直接cin流すためのやつ\n * @tparam T\n * @param is\n * @param v\n * @return istream&\n */\ntemplate \nstd::istream& operator>>(std::istream& is, std::vector& v) {\n for (auto& it : v) is >> it;\n return is;\n}\n/* #endregion */\n/* #region template/Loop.hpp*/\n/**\n * @file Loop.hpp\n * @author btk\n * @brief rangeとかループ系のクラス\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n\n/**\n * @brief\n * rangeを逆向きに操作したいとき用\n * @details\n * ループの範囲は[bg,ed)なので注意\n * @see range\n */\nclass reverse_range {\n private:\n struct I {\n int x;\n int operator*() { return x - 1; }\n bool operator!=(I& lhs) { return x > lhs.x; }\n void operator++() { --x; }\n };\n I i, n;\n\n public:\n /**\n * @brief Construct a new reverse range object\n *\n * @param n\n */\n reverse_range(int n) : i({0}), n({n}) {}\n /**\n * @brief Construct a new reverse range object\n *\n * @param i\n * @param n\n */\n reverse_range(int i, int n) : i({i}), n({n}) {}\n /**\n * @brief\n * begin iterator\n * @return I&\n */\n I& begin() { return n; }\n /**\n * @brief\n * end iterator\n * @return I&\n */\n I& end() { return i; }\n};\n/**\n * @brief\n * python みたいな range-based for を実現\n * @details\n * ループの範囲は[bg,ed)なので注意\n * !つけると逆向きにループが回る (reverse_range)\n * 空間計算量はO(1)\n * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい\n */\nclass range {\n private:\n struct I {\n int x;\n int operator*() { return x; }\n bool operator!=(I& lhs) { return x < lhs.x; }\n void operator++() { ++x; }\n };\n I i, n;\n\n public:\n /**\n * @brief Construct a new range object\n *\n * @param n\n */\n range(int n) : i({0}), n({n}) {}\n /**\n * @brief Construct a new range object\n *\n * @param i\n * @param n\n */\n range(int i, int n) : i({i}), n({n}) {}\n /**\n * @brief\n * begin iterator\n * @return I&\n */\n I& begin() { return i; }\n /**\n * @brief\n * end iterator\n * @return I&\n */\n I& end() { return n; }\n /**\n * @brief\n * 逆向きに参照するrange(reverse_rangeを取得できるs)\n * @return reverse_range\n */\n reverse_range operator!() { return reverse_range(*i, *n); }\n};\n/* #endregion */\n/* #region template/MinMaxOperation.hpp*/\n/**\n * @file MinMaxOperation.hpp\n * @author btk\n * @brief 最大値とか最小値を求める\n * @version 0.1\n * @date 2019-07-04\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n/**\n * @brief 2項の最小値求める\n *\n * @tparam T\n */\ntemplate \nstruct min_op {\n /**\n * @brief 本体\n *\n * @param l\n * @param r\n * @return T\n */\n static T exec(const T l, const T r) { return l < r ? l : r; }\n};\n\n/**\n * @brief 2項の最大値求める\n *\n * @tparam T\n */\ntemplate \nstruct max_op {\n /**\n * @brief 本体\n *\n * @param l\n * @param r\n * @return T\n */\n static T exec(const T l, const T r) { return l > r ? l : r; }\n};\n\n/**\n * @brief テンプレート再帰の末尾\n *\n * @tparam F 二項演算\n * @tparam T\n * @param v\n * @return T\n */\ntemplate \ninline T multi_op(T&& v) {\n return v;\n}\n\n/**\n * @brief 複数項における演算の結果を返す\n *\n * @tparam F\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_op(const T head, Ts&&... tail) {\n return F::exec(head, multi_op(tail...));\n}\n\n/**\n * @brief 複数項の最小値\n * @see multi_op\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_min(T&& head, Ts&&... tail) {\n return multi_op>(head, tail...);\n}\n\n/**\n * @brief 複数項の最大値\n * @see multi_op\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_max(T&& head, Ts&&... tail) {\n return multi_op>(head, tail...);\n}\n\n/**\n * @brief\n * \b先頭の値をFで参照する関数に基づいて変更できたらする\n * @tparam F\n * @tparam T\n * @tparam Ts\n * @param target\n * @param candidates\n * @return true\n * @return false\n */\ntemplate \ninline bool ch_op(T& target, Ts&&... candidates) {\n const T old = target;\n target = multi_op(target, candidates...);\n return old != target;\n}\n\n/**\n * @brief change min\n * @tparam T 型\n * @param target 変更する値\n * @param candidates\n * @return 更新があればtrue\n */\ntemplate \ninline bool chmin(T& target, Ts&&... candidates) {\n return ch_op>(target, candidates...);\n}\n\n/**\n * @brief chminのmax版\n * @see chmin\n * @tparam T 型\n * @param target 変更する値\n * @param candidates\n * @return 更新があればtrue\n */\ntemplate \ninline bool chmax(T& target, Ts&&... candidates) {\n return ch_op>(target, candidates...);\n}\n/* #endregion */\n/* #region template/Random.hpp*/\n/**\n * @file Random.hpp\n * @author btk\n * @brief 乱数生成系\n * @version 0.1\n * @date 2019-07-13\n * @copyright Copyright (c) 2019\n */\n\n\n//! 乱数のシード値をプロセスIDとして取得\nconst pid_t pid = getpid();\n\n/**\n * @brief XorShift32の実装\n */\nclass XorShift32 {\n private:\n //! XorShiftの現在の値\n unsigned value;\n\n /**\n * @brief XorShift32のアルゴリズムに基づいて value を更新\n */\n inline void update() {\n value = value ^ (value << 13);\n value = value ^ (value >> 17);\n value = value ^ (value << 5);\n }\n\n /**\n * @brief 値を更新し,更新前の値を返却\n * @return unsigned 呼び出し時の value を用いる\n */\n inline unsigned get() {\n unsigned v = value;\n update();\n return v;\n }\n\n public:\n /**\n * @brief [0, 2^bit) の範囲の乱数値を取り出す\n * @tparam デフォルトは31\n * @return int\n */\n template \n inline int next_int() {\n return (int)(get() >> (32 - bit));\n }\n\n /**\n * @brief [-2^bit,2^bit)の範囲の乱数値を取り出す\n * @tparam デフォルトは31\n * @return int\n */\n template \n inline int next_signed() {\n unsigned v = get();\n return (int)((v >> (31 - bit)) - (1 << (bit)));\n }\n\n /**\n * @brief next_int呼び出し時の最大値を取得\n * @tparam 31\n * @return int\n */\n template \n inline int range_max() {\n return (int)((1u << bit) - 1);\n };\n\n /**\n * @brief Construct a new XorShift32 object\n * @param seed\n * @details 初期シードをvalueとするXorShift32のインスタンスを生成\n */\n XorShift32(const unsigned seed) {\n value = seed;\n update();\n }\n\n /**\n * @brief Construct a new XorShift 32 object\n * @details 初期シードをプロセスIDとするXorShift32のインスタンスを生成\n */\n XorShift32() : XorShift32(pid) {}\n};\n/* #endregion */\n/* #region Template.hpp*/\n/**\n * @file Template.hpp\n * @brief 競技プログラミング用テンプレート\n * @author btk15049\n * @date 2019/05/02\n */\n\n\n/* #endregion */\n/* #endregion */\n/**/\n#endif\n\nLL N;\nLL K;\nLL a[112345];\nLL b[112345];\nLL c[112345];\n\n\nbool solve() {\n set s;\n for (int i : range(N)) {\n s.insert(K + N + i);\n }\n for (int i : range(N)) {\n a[i] = K + i;\n c[i] = K + 2 * N + i;\n auto it = s.upper_bound(c[i] - a[i]);\n if (it == s.begin()) {\n return false;\n }\n --it;\n b[i] = *it;\n s.erase(b[i]);\n }\n return true;\n}\n\nint main() {\n /* write here */\n if (K == 1) {\n return -1;\n }\n cin >> N >> K;\n if (solve()) {\n for (int i : range(N)) {\n cout << a[i] << \" \" << b[i] << \" \" << c[i] << endl;\n }\n }\n else {\n cout << -1 << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1573356055, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02869.html", "problem_id": "p02869", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02869/input.txt", "sample_output_relpath": "derived/input_output/data/p02869/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02869/C++/s865269319.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s865269319", "user_id": "u613658617"}, "prompt_components": {"gold_output": "1 2 3\n", "input_to_evaluate": "// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_e\n#define CIN_ONLY\n#define DECIMAL_DIGITS 10\n#define STATIC_MOD 1e9 + 7\n\n#ifdef BTK\n/**/\n# include \"Template.hpp\"\n/**/\n#else\n/**/\n/* #region auto includes */\n/* #region stl */\n/**/\n# include \n# include \n# include \nusing namespace std;\n/**/\n/* #endregion */\n/* #region template/IncludeSTL.hpp*/\n/**\n * @file IncludeSTL.hpp\n * @author btk\n * @brief 標準ライブラリをincludeするだけ\n * @version 0.1\n * @date 2019-07-21\n * @todo 何故か2回includeされる(展開scriptに\n * @copyright Copyright (c) 2019\n *\n */\n\n\n/* #endregion */\n/* #region template/Macro.hpp*/\n/**\n * @file Macro.hpp\n * @author btk\n * @brief マクロとか,LLとか\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n\n//! LL\nusing LL = long long;\n\n/**\n * @def DEBUG\n * @brief デバッグ用のif文 提出時はif(0)で実行されない\n */\n\n/**/\n# ifdef BTK\n# define DEBUG if (1)\n# else\n# ifdef CIN_ONLY\n# define FAST_IO\n# endif\n# define DEBUG if (0)\n# endif\n/**\n * @def ALL(v)\n * @brief\n * ALLマクロ\n */\n# define ALL(v) (v).begin(), (v).end()\n\n/**\n * @def REC(ret, ...)\n * @brief\n * 再帰ラムダをするためのマクロ\n */\n# define REC(ret, ...) std::function\n\n/**\n * @def VAR_NAME(var)\n * @brief 変数名を取得する\n */\n# define VAR_NAME(var) # var\n\n/**\n * @brief\n * rangeで生まれる使わない変数を消す用(警告消し)\n */\ntemplate \ninline T& unused_var(T& v) {\n return v;\n}\n/* #endregion */\n/* #region template/IO.hpp*/\n/**\n * @file IO.hpp\n * @author btk\n * @brief cin高速化とか,出力の小数桁固定とか\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n */\n\n\n/**\n * @brief 入出力の設定を行うための構造体\n */\nstruct cww {\n /**\n * @brief Construct a new cww::cww object\n * @details\n * CIN_ONLYを定義すると,submit時にcinとscanfの同期を切る設定が走る\n * DECIMAL_DIGITSを定義すると,doubleの出力時指定した桁数分小数部を吐くようになる\n */\n cww() {\n# ifdef FAST_IO\n ios::sync_with_stdio(false);\n cin.tie(0);\n# endif\n# ifdef DECIMAL_DIGITS\n cout << fixed;\n cout << setprecision(DECIMAL_DIGITS);\n# endif\n }\n};\n\n//! 入出力設定構造体を実体化\ncww star;\n\n/**\n * @brief\n * vectorに直接cin流すためのやつ\n * @tparam T\n * @param is\n * @param v\n * @return istream&\n */\ntemplate \nstd::istream& operator>>(std::istream& is, std::vector& v) {\n for (auto& it : v) is >> it;\n return is;\n}\n/* #endregion */\n/* #region template/Loop.hpp*/\n/**\n * @file Loop.hpp\n * @author btk\n * @brief rangeとかループ系のクラス\n * @version 0.1\n * @date 2019-07-13\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n\n/**\n * @brief\n * rangeを逆向きに操作したいとき用\n * @details\n * ループの範囲は[bg,ed)なので注意\n * @see range\n */\nclass reverse_range {\n private:\n struct I {\n int x;\n int operator*() { return x - 1; }\n bool operator!=(I& lhs) { return x > lhs.x; }\n void operator++() { --x; }\n };\n I i, n;\n\n public:\n /**\n * @brief Construct a new reverse range object\n *\n * @param n\n */\n reverse_range(int n) : i({0}), n({n}) {}\n /**\n * @brief Construct a new reverse range object\n *\n * @param i\n * @param n\n */\n reverse_range(int i, int n) : i({i}), n({n}) {}\n /**\n * @brief\n * begin iterator\n * @return I&\n */\n I& begin() { return n; }\n /**\n * @brief\n * end iterator\n * @return I&\n */\n I& end() { return i; }\n};\n/**\n * @brief\n * python みたいな range-based for を実現\n * @details\n * ループの範囲は[bg,ed)なので注意\n * !つけると逆向きにループが回る (reverse_range)\n * 空間計算量はO(1)\n * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい\n */\nclass range {\n private:\n struct I {\n int x;\n int operator*() { return x; }\n bool operator!=(I& lhs) { return x < lhs.x; }\n void operator++() { ++x; }\n };\n I i, n;\n\n public:\n /**\n * @brief Construct a new range object\n *\n * @param n\n */\n range(int n) : i({0}), n({n}) {}\n /**\n * @brief Construct a new range object\n *\n * @param i\n * @param n\n */\n range(int i, int n) : i({i}), n({n}) {}\n /**\n * @brief\n * begin iterator\n * @return I&\n */\n I& begin() { return i; }\n /**\n * @brief\n * end iterator\n * @return I&\n */\n I& end() { return n; }\n /**\n * @brief\n * 逆向きに参照するrange(reverse_rangeを取得できるs)\n * @return reverse_range\n */\n reverse_range operator!() { return reverse_range(*i, *n); }\n};\n/* #endregion */\n/* #region template/MinMaxOperation.hpp*/\n/**\n * @file MinMaxOperation.hpp\n * @author btk\n * @brief 最大値とか最小値を求める\n * @version 0.1\n * @date 2019-07-04\n *\n * @copyright Copyright (c) 2019\n *\n */\n\n/**\n * @brief 2項の最小値求める\n *\n * @tparam T\n */\ntemplate \nstruct min_op {\n /**\n * @brief 本体\n *\n * @param l\n * @param r\n * @return T\n */\n static T exec(const T l, const T r) { return l < r ? l : r; }\n};\n\n/**\n * @brief 2項の最大値求める\n *\n * @tparam T\n */\ntemplate \nstruct max_op {\n /**\n * @brief 本体\n *\n * @param l\n * @param r\n * @return T\n */\n static T exec(const T l, const T r) { return l > r ? l : r; }\n};\n\n/**\n * @brief テンプレート再帰の末尾\n *\n * @tparam F 二項演算\n * @tparam T\n * @param v\n * @return T\n */\ntemplate \ninline T multi_op(T&& v) {\n return v;\n}\n\n/**\n * @brief 複数項における演算の結果を返す\n *\n * @tparam F\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_op(const T head, Ts&&... tail) {\n return F::exec(head, multi_op(tail...));\n}\n\n/**\n * @brief 複数項の最小値\n * @see multi_op\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_min(T&& head, Ts&&... tail) {\n return multi_op>(head, tail...);\n}\n\n/**\n * @brief 複数項の最大値\n * @see multi_op\n * @tparam T\n * @tparam Ts\n * @param head\n * @param tail\n * @return T\n */\ntemplate \ninline T multi_max(T&& head, Ts&&... tail) {\n return multi_op>(head, tail...);\n}\n\n/**\n * @brief\n * \b先頭の値をFで参照する関数に基づいて変更できたらする\n * @tparam F\n * @tparam T\n * @tparam Ts\n * @param target\n * @param candidates\n * @return true\n * @return false\n */\ntemplate \ninline bool ch_op(T& target, Ts&&... candidates) {\n const T old = target;\n target = multi_op(target, candidates...);\n return old != target;\n}\n\n/**\n * @brief change min\n * @tparam T 型\n * @param target 変更する値\n * @param candidates\n * @return 更新があればtrue\n */\ntemplate \ninline bool chmin(T& target, Ts&&... candidates) {\n return ch_op>(target, candidates...);\n}\n\n/**\n * @brief chminのmax版\n * @see chmin\n * @tparam T 型\n * @param target 変更する値\n * @param candidates\n * @return 更新があればtrue\n */\ntemplate \ninline bool chmax(T& target, Ts&&... candidates) {\n return ch_op>(target, candidates...);\n}\n/* #endregion */\n/* #region template/Random.hpp*/\n/**\n * @file Random.hpp\n * @author btk\n * @brief 乱数生成系\n * @version 0.1\n * @date 2019-07-13\n * @copyright Copyright (c) 2019\n */\n\n\n//! 乱数のシード値をプロセスIDとして取得\nconst pid_t pid = getpid();\n\n/**\n * @brief XorShift32の実装\n */\nclass XorShift32 {\n private:\n //! XorShiftの現在の値\n unsigned value;\n\n /**\n * @brief XorShift32のアルゴリズムに基づいて value を更新\n */\n inline void update() {\n value = value ^ (value << 13);\n value = value ^ (value >> 17);\n value = value ^ (value << 5);\n }\n\n /**\n * @brief 値を更新し,更新前の値を返却\n * @return unsigned 呼び出し時の value を用いる\n */\n inline unsigned get() {\n unsigned v = value;\n update();\n return v;\n }\n\n public:\n /**\n * @brief [0, 2^bit) の範囲の乱数値を取り出す\n * @tparam デフォルトは31\n * @return int\n */\n template \n inline int next_int() {\n return (int)(get() >> (32 - bit));\n }\n\n /**\n * @brief [-2^bit,2^bit)の範囲の乱数値を取り出す\n * @tparam デフォルトは31\n * @return int\n */\n template \n inline int next_signed() {\n unsigned v = get();\n return (int)((v >> (31 - bit)) - (1 << (bit)));\n }\n\n /**\n * @brief next_int呼び出し時の最大値を取得\n * @tparam 31\n * @return int\n */\n template \n inline int range_max() {\n return (int)((1u << bit) - 1);\n };\n\n /**\n * @brief Construct a new XorShift32 object\n * @param seed\n * @details 初期シードをvalueとするXorShift32のインスタンスを生成\n */\n XorShift32(const unsigned seed) {\n value = seed;\n update();\n }\n\n /**\n * @brief Construct a new XorShift 32 object\n * @details 初期シードをプロセスIDとするXorShift32のインスタンスを生成\n */\n XorShift32() : XorShift32(pid) {}\n};\n/* #endregion */\n/* #region Template.hpp*/\n/**\n * @file Template.hpp\n * @brief 競技プログラミング用テンプレート\n * @author btk15049\n * @date 2019/05/02\n */\n\n\n/* #endregion */\n/* #endregion */\n/**/\n#endif\n\nLL N;\nLL K;\nLL a[112345];\nLL b[112345];\nLL c[112345];\n\n\nbool solve() {\n set s;\n for (int i : range(N)) {\n s.insert(K + N + i);\n }\n for (int i : range(N)) {\n a[i] = K + i;\n c[i] = K + 2 * N + i;\n auto it = s.upper_bound(c[i] - a[i]);\n if (it == s.begin()) {\n return false;\n }\n --it;\n b[i] = *it;\n s.erase(b[i]);\n }\n return true;\n}\n\nint main() {\n /* write here */\n if (K == 1) {\n return -1;\n }\n cin >> N >> K;\n if (solve()) {\n for (int i : range(N)) {\n cout << a[i] << \" \" << b[i] << \" \" << c[i] << endl;\n }\n }\n else {\n cout << -1 << endl;\n }\n return 0;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nGiven are positive integers N and K.\n\nDetermine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples.\n\nFor every integer i from 1 to N, a_i + b_i \\leq c_i holds.\n\nIf the answer is yes, construct one such partition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the following format:\n\na_1 b_1 c_1\n:\na_N b_N c_N\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1 2 3\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1", "sample_input": "1 1\n"}, "reference_outputs": ["1 2 3\n"], "source_document_id": "p02869", "source_text": "Score : 700 points\n\nProblem Statement\n\nGiven are positive integers N and K.\n\nDetermine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples.\n\nFor every integer i from 1 to N, a_i + b_i \\leq c_i holds.\n\nIf the answer is yes, construct one such partition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the following format:\n\na_1 b_1 c_1\n:\na_N b_N c_N\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n1 2 3\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 10849, "cpu_time_ms": 29, "memory_kb": 7168}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s776817602", "group_id": "codeNet:p02873", "input_text": "/*\n\n author : s@if\n\n*/\n\n#include\n#include\nusing namespace __gnu_pbds;\nusing namespace std;\n\n#define \t\tNIL \t\t\t-1\n#define\t\t \tfi\t \t\t first\n#define \t\tsec \t\t\tsecond\n#define \t\tMAX \t\t\tINT_MAX\n#define\t\t\tINF \t\t\t99999999\n#define \t\tll \t\t\t long long\n#define \t\tPI \t\t\t acos(-1.0)\n#define\t\t\tMOD \t\t\t1000000007\n#define \t\tPLL \t\t\tpair\n#define \t\tPII\t\t\t pair\n#define \t\tull \t\t\tunsigned long long\n#define \t\tFor(i,a,b) \t\tfor(int i=a;i<=(int)b;i++)\ntypedef tree, rb_tree_tag,\n tree_order_statistics_node_update> new_data_set;\n\n//*find_by_order(k) gives the kth element;\n//order_of_key(item) gives the index(number of element strictly less than item) of item;\n\n\ninline int in() {int x; scanf(\"%d\", &x); return x; }\nbool Check(int N , int pos)\t{\treturn (bool) (N & (1<>s; n = s.size();\n\n int ara[n+9]; ara[n] = 0;\n\n for(i=n-1; i>=0; )\n {\n int cnt1 = 0, cnt2 = 0; j = i;\n\n while(j>=0 && s[j]=='>'){\n j--; cnt1++;\n }\n\n while(j>=0 && s[j]=='<'){\n j--; cnt2++;\n }\n\n k = i;\n\n for(p=k, q=1; q\n#include\nusing namespace __gnu_pbds;\nusing namespace std;\n\n#define \t\tNIL \t\t\t-1\n#define\t\t \tfi\t \t\t first\n#define \t\tsec \t\t\tsecond\n#define \t\tMAX \t\t\tINT_MAX\n#define\t\t\tINF \t\t\t99999999\n#define \t\tll \t\t\t long long\n#define \t\tPI \t\t\t acos(-1.0)\n#define\t\t\tMOD \t\t\t1000000007\n#define \t\tPLL \t\t\tpair\n#define \t\tPII\t\t\t pair\n#define \t\tull \t\t\tunsigned long long\n#define \t\tFor(i,a,b) \t\tfor(int i=a;i<=(int)b;i++)\ntypedef tree, rb_tree_tag,\n tree_order_statistics_node_update> new_data_set;\n\n//*find_by_order(k) gives the kth element;\n//order_of_key(item) gives the index(number of element strictly less than item) of item;\n\n\ninline int in() {int x; scanf(\"%d\", &x); return x; }\nbool Check(int N , int pos)\t{\treturn (bool) (N & (1<>s; n = s.size();\n\n int ara[n+9]; ara[n] = 0;\n\n for(i=n-1; i>=0; )\n {\n int cnt1 = 0, cnt2 = 0; j = i;\n\n while(j>=0 && s[j]=='>'){\n j--; cnt1++;\n }\n\n while(j>=0 && s[j]=='<'){\n j--; cnt2++;\n }\n\n k = i;\n\n for(p=k, q=1; q.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "sample_input": "<>>\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02873", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2176, "cpu_time_ms": 24, "memory_kb": 2820}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s832693252", "group_id": "codeNet:p02880", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n \n for (double i = 9.0; i > 0.0; i--){\n N /= i;\n }\n \n if (N == 1.0){\n cout << \"Yes\" << endl;\n }\n else{\n cout << \"No\" << endl;\n }\n}\n", "language": "C++", "metadata": {"date": 1588919837, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/C++/s832693252.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s832693252", "user_id": "u302636975"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n \n for (double i = 9.0; i > 0.0; i--){\n N /= i;\n }\n \n if (N == 1.0){\n cout << \"Yes\" << endl;\n }\n else{\n cout << \"No\" << endl;\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s148223716", "group_id": "codeNet:p02880", "input_text": "#include\nint main()\n{\n \tint n;\n \tscanf(\"%d\",&n);\n \tint a[100];\n int p = -1;\n \tfor(int i = 1 ; i <= 9 ; i++)\n for(int j = 1 ; j <=9 ; j++)\n a[++p] = i * j;\n int count = 0;\n for(int i = 1 ; i <= p ; i++)\n {\n \tif(a[i] == n)\n {\n count = 1;\n break;\n }\n \n }\n if(count) printf(\"Yes\");\n else printf(\"No\");\n return 0;\n}", "language": "C++", "metadata": {"date": 1572248092, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/C++/s148223716.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s148223716", "user_id": "u665785827"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include\nint main()\n{\n \tint n;\n \tscanf(\"%d\",&n);\n \tint a[100];\n int p = -1;\n \tfor(int i = 1 ; i <= 9 ; i++)\n for(int j = 1 ; j <=9 ; j++)\n a[++p] = i * j;\n int count = 0;\n for(int i = 1 ; i <= p ; i++)\n {\n \tif(a[i] == n)\n {\n count = 1;\n break;\n }\n \n }\n if(count) printf(\"Yes\");\n else printf(\"No\");\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 365, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s105932577", "group_id": "codeNet:p02881", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n\tint64_t A;\n\tcin >> A;\n\n\tvector>v;\n\tfor (int64_t i = 1; i*i <= A; i++) {\n\t\tif (A%i==0 ) {\n\t\t\tv.push_back(pair(i, A / i));\n\t\t}\n\t}\n\n\tint64_t min=1e12;\n\tint64_t tmp = 0;\n\tfor (int64_t j = 0; j < v.size(); j++) {\n\t\ttmp = v[j].first + v[j].second - 2;\n\t\tif (tmp < min) min = tmp;\n\t}\n\tcout << min << endl;\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1576636717, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/C++/s105932577.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s105932577", "user_id": "u123550214"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n\tint64_t A;\n\tcin >> A;\n\n\tvector>v;\n\tfor (int64_t i = 1; i*i <= A; i++) {\n\t\tif (A%i==0 ) {\n\t\t\tv.push_back(pair(i, A / i));\n\t\t}\n\t}\n\n\tint64_t min=1e12;\n\tint64_t tmp = 0;\n\tfor (int64_t j = 0; j < v.size(); j++) {\n\t\ttmp = v[j].first + v[j].second - 2;\n\t\tif (tmp < min) min = tmp;\n\t}\n\tcout << min << endl;\n\treturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 11, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s685196864", "group_id": "codeNet:p02881", "input_text": "#include \nusing namespace std;\n\nint main(){\n long long int N;\n cin >> N;\n \n long long int ans = N-1;\n int a;\n for(int i=2; i < int(sqrt(float(N)))+2 ;i++){\n if(N%i==0){\n ans = min( ans , (i+N/i-2) );\n }\n }\n \n cout << ans << endl;\n\n}", "language": "C++", "metadata": {"date": 1572438146, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/C++/s685196864.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s685196864", "user_id": "u783911129"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n long long int N;\n cin >> N;\n \n long long int ans = N-1;\n int a;\n for(int i=2; i < int(sqrt(float(N)))+2 ;i++){\n if(N%i==0){\n ans = min( ans , (i+N/i-2) );\n }\n }\n \n cout << ans << endl;\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 267, "cpu_time_ms": 12, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s059226750", "group_id": "codeNet:p02881", "input_text": "#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\nconst int MAXN=int(1e5+5);\nLL n;\nint main()\n{\n scanf(\"%lld\",&n);\n for(LL i=sqrt(n)+1;i>=1;i--)\n if(n%i==0) {\n printf(\"%lld\",i+(n/i)-2);\n return 0;\n }\n}\n", "language": "C++", "metadata": {"date": 1572224753, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/C++/s059226750.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s059226750", "user_id": "u601167480"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\nconst int MAXN=int(1e5+5);\nLL n;\nint main()\n{\n scanf(\"%lld\",&n);\n for(LL i=sqrt(n)+1;i>=1;i--)\n if(n%i==0) {\n printf(\"%lld\",i+(n/i)-2);\n return 0;\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 10, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s283756039", "group_id": "codeNet:p02882", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include // pair make_pair\n#include \n#include \n#include \n#include \n#include // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX\n#include \n\n#define m0(x) memset(x,0,sizeof(x))\n#define m1(x) memset(x,63,sizeof(x))\n#define fill(x,y) memset(x,y,sizeof(x))\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define ll long long\n//#define int ll\n#define INF INT_MAX/10\n#define MOD 1000000007\n#define PI 3.14159265359\n\nusing namespace std;\nusing Pi = pair;\nusing Graph = vector >;\nusing WeightGraph = vector >;\n\nint Input[100100];\n\nint main() {\n long double N, M, X; cin >> N >> M >> X;\n if (X == (1.0 / 2.0) * pow(N, 2) * M) {\n cout << 45.0 << endl;\n } else if ( X > (1.0 / 2.0) * pow(N, 2) * M) {\n long double ans = atan((pow(N, 2) * M - X) / ((pow(N, 3) * (1.0 / 2.0)))) * 180 / PI;\n cout << setprecision(12) << ans << endl;\n } else {\n long double ans = atan( (N * pow(M, 2))/ (X*2)) * 180 / PI;\n cout << setprecision(12) << ans << endl;\n }\n}\n", "language": "C++", "metadata": {"date": 1572226685, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02882/input.txt", "sample_output_relpath": "derived/input_output/data/p02882/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02882/C++/s283756039.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s283756039", "user_id": "u703205079"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include // pair make_pair\n#include \n#include \n#include \n#include \n#include // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX\n#include \n\n#define m0(x) memset(x,0,sizeof(x))\n#define m1(x) memset(x,63,sizeof(x))\n#define fill(x,y) memset(x,y,sizeof(x))\n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define ll long long\n//#define int ll\n#define INF INT_MAX/10\n#define MOD 1000000007\n#define PI 3.14159265359\n\nusing namespace std;\nusing Pi = pair;\nusing Graph = vector >;\nusing WeightGraph = vector >;\n\nint Input[100100];\n\nint main() {\n long double N, M, X; cin >> N >> M >> X;\n if (X == (1.0 / 2.0) * pow(N, 2) * M) {\n cout << 45.0 << endl;\n } else if ( X > (1.0 / 2.0) * pow(N, 2) * M) {\n long double ans = atan((pow(N, 2) * M - X) / ((pow(N, 3) * (1.0 / 2.0)))) * 180 / PI;\n cout << setprecision(12) << ans << endl;\n } else {\n long double ans = atan( (N * pow(M, 2))/ (X*2)) * 180 / PI;\n cout << setprecision(12) << ans << endl;\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "sample_input": "2 2 4\n"}, "reference_outputs": ["45.0000000000\n"], "source_document_id": "p02882", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1233, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s287371868", "group_id": "codeNet:p02885", "input_text": "#include \nusing namespace std;\n\nint main() {\n int a, b;\n cin >> a >> b;\n\n cout << (a > 2 * b ? a - 2 * b : 0) << endl;\n}", "language": "C++", "metadata": {"date": 1579034600, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02885/input.txt", "sample_output_relpath": "derived/input_output/data/p02885/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02885/C++/s287371868.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s287371868", "user_id": "u164352406"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int a, b;\n cin >> a >> b;\n\n cout << (a > 2 * b ? a - 2 * b : 0) << endl;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "sample_input": "12 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02885", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s605819257", "group_id": "codeNet:p02887", "input_text": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n\nusing namespace std;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define printfloat(x) cout << setprecision(7) << (x) << endl;\n\nlong double pi = 3.14159265359;\nint n,cnt=0;\nstring s;\n\nint main(){\n cin >> n;\n cin >> s;\n rep(i,s.size()-1){\n if(s[i] != s[i+1]){\n cnt++;\n }\n }\n cout << cnt+1 << endl;\n\n\nreturn 0;\n}", "language": "C++", "metadata": {"date": 1593982086, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/C++/s605819257.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605819257", "user_id": "u482454662"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n\nusing namespace std;\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define printfloat(x) cout << setprecision(7) << (x) << endl;\n\nlong double pi = 3.14159265359;\nint n,cnt=0;\nstring s;\n\nint main(){\n cin >> n;\n cin >> s;\n rep(i,s.size()-1){\n if(s[i] != s[i+1]){\n cnt++;\n }\n }\n cout << cnt+1 << endl;\n\n\nreturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 526, "cpu_time_ms": 10, "memory_kb": 3760}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s608043909", "group_id": "codeNet:p02888", "input_text": "#include \n\n#define rep(i, n) for(int i = 0; i<(n); i++)\n\nusing namespace std;\n\nconst int MAX = 310;\nconst long long INF = 1LL << 50;\n\nlong long G[MAX][MAX];\nusing pll = pair;\n\nint main(void) {\n int N, M;\n long long L;\n cin >> N >> M >> L;\n\n rep(i, MAX) {\n rep(j, MAX) G[i][j] = INF;\n G[i][i] = 0;\n }\n\n rep(i, M) {\n int a, b;\n long long c;\n cin >> a >> b >> c;\n --a;\n --b;\n G[a][b] = G[b][a] = c;\n }\n\n vector> dist(N, vector(N, {INF, INF}));\n rep(s, N) {\n dist[s][s] = {0, 0};\n priority_queue<\n pair,\n vector>,\n greater>> que;\n\n que.push(make_pair(pll(0, 0), s));\n while (!que.empty()) {\n auto p = que.top();\n que.pop();\n\n long long v = p.second;\n long long kaisuu = p.first.first;\n long long used = p.first.second;\n\n if (p.first > dist[s][v])continue;\n\n rep(nv, N) {\n if (nv == v) continue;\n if (G[v][nv] > L) continue;\n\n long long nused = used + G[v][nv];\n pll np = {0, 0};\n if (nused > L) {\n np = {kaisuu + 1, G[v][nv]};\n } else {\n np = {kaisuu, nused};\n }\n\n if (dist[s][nv] > np) {\n dist[s][nv] = np;\n que.push(make_pair(np, nv));\n }\n }\n\n }\n }\n\n int Q;\n cin >> Q;\n while (Q--) {\n int a, b;\n cin >> a >> b;\n --a;\n --b;\n\n long long res = dist[a][b].first;\n if (res >= INF) {\n cout << -1 << endl;\n } else {\n cout << res << endl;\n }\n }\n}\n", "language": "C++", "metadata": {"date": 1571706423, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02888/input.txt", "sample_output_relpath": "derived/input_output/data/p02888/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02888/C++/s608043909.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s608043909", "user_id": "u976045502"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\n#define rep(i, n) for(int i = 0; i<(n); i++)\n\nusing namespace std;\n\nconst int MAX = 310;\nconst long long INF = 1LL << 50;\n\nlong long G[MAX][MAX];\nusing pll = pair;\n\nint main(void) {\n int N, M;\n long long L;\n cin >> N >> M >> L;\n\n rep(i, MAX) {\n rep(j, MAX) G[i][j] = INF;\n G[i][i] = 0;\n }\n\n rep(i, M) {\n int a, b;\n long long c;\n cin >> a >> b >> c;\n --a;\n --b;\n G[a][b] = G[b][a] = c;\n }\n\n vector> dist(N, vector(N, {INF, INF}));\n rep(s, N) {\n dist[s][s] = {0, 0};\n priority_queue<\n pair,\n vector>,\n greater>> que;\n\n que.push(make_pair(pll(0, 0), s));\n while (!que.empty()) {\n auto p = que.top();\n que.pop();\n\n long long v = p.second;\n long long kaisuu = p.first.first;\n long long used = p.first.second;\n\n if (p.first > dist[s][v])continue;\n\n rep(nv, N) {\n if (nv == v) continue;\n if (G[v][nv] > L) continue;\n\n long long nused = used + G[v][nv];\n pll np = {0, 0};\n if (nused > L) {\n np = {kaisuu + 1, G[v][nv]};\n } else {\n np = {kaisuu, nused};\n }\n\n if (dist[s][nv] > np) {\n dist[s][nv] = np;\n que.push(make_pair(np, nv));\n }\n }\n\n }\n }\n\n int Q;\n cin >> Q;\n while (Q--) {\n int a, b;\n cin >> a >> b;\n --a;\n --b;\n\n long long res = dist[a][b].first;\n if (res >= INF) {\n cout << -1 << endl;\n } else {\n cout << res << endl;\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1886, "cpu_time_ms": 98, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s625342470", "group_id": "codeNet:p02889", "input_text": "#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#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst double EPS = 1e-9;\ntypedef vector vint;\ntypedef vector> v2int;\ntypedef vector vll;\ntypedef vector> v2ll;\ntypedef list liint;\ntypedef pair pint;\nconst int INF = int(2e9);\nconst ll LINF = ll(2e9) * ll(2e9);\n#define rep(i, n) REP(i, 0, n)\n#define ALL(v) v.begin(), v.end()\n#define MSG(a) cout << #a << \" \" << a << endl;\n#define REP(i, x, n) for(int i = x; i < n; i++)\ntemplate void chmax(T& a, C b) { a > b ? : a = b; }\ntemplate void chmin(T& a, C b) { a < b ? : a = b; }\n\n\n\n#include \n#include \n#include \n#include \n\nclass warshall_floyd\n{\nprivate:\n int node_num;\n bool is_negative_graph;\n std::vector> cost_matrix;//隣接行列を構築\n std::vector> pred;//経路(遷移元)を保持\n\npublic:\n warshall_floyd(const int node_num, const std::vector> &adj_matrix);\n long long get_cost(int start, int end) const;\n std::vector get_min_path(int start, int end) const;\n};\n\nwarshall_floyd::warshall_floyd(const int node_num,\n const std::vector> &adj_matrix) :\n cost_matrix(adj_matrix),\n node_num(node_num),\n is_negative_graph(false),\n pred(node_num + 1, std::vector(node_num + 1, INT_MAX))\n{\n //predの初期化\n for (int i = 0; i <= node_num; i++) {\n for (int j = 0; j <= node_num; j++) {\n if (i == j) pred[i][j] = -1;\n else if (adj_matrix[i][j] < LLONG_MAX) {\n pred[i][j] = i;\n }\n }\n }\n //ワーシャルフロイドの更新式\n for (int k = 0; k <= node_num; k++) {\n for (int i = 0; i <= node_num; i++) {\n for (int j = 0; j <= node_num; j++) {\n if (cost_matrix[i][k] < LLONG_MAX && cost_matrix[k][j] < LLONG_MAX) {\n if (cost_matrix[i][k] + cost_matrix[k][j] < cost_matrix[i][j]) {\n cost_matrix[i][j] = cost_matrix[i][k] + cost_matrix[k][j];\n //経路復元用\n //pred[i][j]にはi→jの最短経路におけるjの1つ前の頂点が入る。\n //pred[k][j]にはk→jの最短経路におけるjの1つ前の頂点が入っている。\n //この処理を通るということは最短経路がkを使った経路に変わる\n //ということでありi→jへの経路の中にk→jの最短経路を含むことになる。\n //従って新しいi→jにおけるjの1つ前の頂点は\n //k→jにおけるjの1つ前の頂点、すなわちpred[k][j]となる。\n pred[i][j] = pred[k][j];\n }\n }\n }\n }\n }\n\n}\n\n\n\n\nlong long warshall_floyd::get_cost(int start, int end) const {\n return cost_matrix[start][end];\n}\n\nstd::vector warshall_floyd::get_min_path(int start, int end) const {\n int node = end;\n std::vector vec;\n vec.push_back(node);\n //終点から始点までの経路をたどる\n while (1) {\n //負のサイクルを含む頂点or\n //始点から辿れない頂点or\n //始点であれば終了\n if (node == start) break;\n if (cost_matrix[node][node] < 0 ||\n pred[start][node] >= INT_MAX ||\n pred[start][node] == -1) break;\n node = pred[start][node];\n vec.push_back(node);\n }\n std::reverse(vec.begin(), vec.end());\n return vec;\n}\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int N, M;\n ll L;\n cin >> N >> M >> L;\n v2ll adj_matrix(N + 1, vll(N + 1, LLONG_MAX));\n rep(i, M) {\n int a, b, c;\n cin >> a >> b >> c;\n if (c <= L)\n {\n adj_matrix[a][b] = c;\n adj_matrix[b][a] = c;\n }\n }\n warshall_floyd wf(N, adj_matrix);\n int Q;\n cin >> Q;\n vint s(Q), t(Q);\n vll ans(Q);\n rep(i, Q) {\n cin >> s[i] >> t[i];\n if (wf.get_cost(s[i], t[i]) >= LLONG_MAX) {\n cout << -1 << endl;\n continue;\n }\n auto min_path = wf.get_min_path(s[i], t[i]);\n int ans = 0;\n \n int fill_point = min_path[0];\n \n REP(j, 1, min_path.size()) {\n if (wf.get_cost(fill_point, min_path[j]) > ll(L)) {\n fill_point = min_path[j - 1];\n ans++;\n }\n\n }\n int add = 0;\n if (wf.get_cost(s[i], t[i]) % L != 0) add = 1;\n cout << max(ll(ans), wf.get_cost(s[i], t[i])/L + add - 1) << endl;\n }\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1571540824, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02889.html", "problem_id": "p02889", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02889/input.txt", "sample_output_relpath": "derived/input_output/data/p02889/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02889/C++/s625342470.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s625342470", "user_id": "u391331433"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "#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#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst double EPS = 1e-9;\ntypedef vector vint;\ntypedef vector> v2int;\ntypedef vector vll;\ntypedef vector> v2ll;\ntypedef list liint;\ntypedef pair pint;\nconst int INF = int(2e9);\nconst ll LINF = ll(2e9) * ll(2e9);\n#define rep(i, n) REP(i, 0, n)\n#define ALL(v) v.begin(), v.end()\n#define MSG(a) cout << #a << \" \" << a << endl;\n#define REP(i, x, n) for(int i = x; i < n; i++)\ntemplate void chmax(T& a, C b) { a > b ? : a = b; }\ntemplate void chmin(T& a, C b) { a < b ? : a = b; }\n\n\n\n#include \n#include \n#include \n#include \n\nclass warshall_floyd\n{\nprivate:\n int node_num;\n bool is_negative_graph;\n std::vector> cost_matrix;//隣接行列を構築\n std::vector> pred;//経路(遷移元)を保持\n\npublic:\n warshall_floyd(const int node_num, const std::vector> &adj_matrix);\n long long get_cost(int start, int end) const;\n std::vector get_min_path(int start, int end) const;\n};\n\nwarshall_floyd::warshall_floyd(const int node_num,\n const std::vector> &adj_matrix) :\n cost_matrix(adj_matrix),\n node_num(node_num),\n is_negative_graph(false),\n pred(node_num + 1, std::vector(node_num + 1, INT_MAX))\n{\n //predの初期化\n for (int i = 0; i <= node_num; i++) {\n for (int j = 0; j <= node_num; j++) {\n if (i == j) pred[i][j] = -1;\n else if (adj_matrix[i][j] < LLONG_MAX) {\n pred[i][j] = i;\n }\n }\n }\n //ワーシャルフロイドの更新式\n for (int k = 0; k <= node_num; k++) {\n for (int i = 0; i <= node_num; i++) {\n for (int j = 0; j <= node_num; j++) {\n if (cost_matrix[i][k] < LLONG_MAX && cost_matrix[k][j] < LLONG_MAX) {\n if (cost_matrix[i][k] + cost_matrix[k][j] < cost_matrix[i][j]) {\n cost_matrix[i][j] = cost_matrix[i][k] + cost_matrix[k][j];\n //経路復元用\n //pred[i][j]にはi→jの最短経路におけるjの1つ前の頂点が入る。\n //pred[k][j]にはk→jの最短経路におけるjの1つ前の頂点が入っている。\n //この処理を通るということは最短経路がkを使った経路に変わる\n //ということでありi→jへの経路の中にk→jの最短経路を含むことになる。\n //従って新しいi→jにおけるjの1つ前の頂点は\n //k→jにおけるjの1つ前の頂点、すなわちpred[k][j]となる。\n pred[i][j] = pred[k][j];\n }\n }\n }\n }\n }\n\n}\n\n\n\n\nlong long warshall_floyd::get_cost(int start, int end) const {\n return cost_matrix[start][end];\n}\n\nstd::vector warshall_floyd::get_min_path(int start, int end) const {\n int node = end;\n std::vector vec;\n vec.push_back(node);\n //終点から始点までの経路をたどる\n while (1) {\n //負のサイクルを含む頂点or\n //始点から辿れない頂点or\n //始点であれば終了\n if (node == start) break;\n if (cost_matrix[node][node] < 0 ||\n pred[start][node] >= INT_MAX ||\n pred[start][node] == -1) break;\n node = pred[start][node];\n vec.push_back(node);\n }\n std::reverse(vec.begin(), vec.end());\n return vec;\n}\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int N, M;\n ll L;\n cin >> N >> M >> L;\n v2ll adj_matrix(N + 1, vll(N + 1, LLONG_MAX));\n rep(i, M) {\n int a, b, c;\n cin >> a >> b >> c;\n if (c <= L)\n {\n adj_matrix[a][b] = c;\n adj_matrix[b][a] = c;\n }\n }\n warshall_floyd wf(N, adj_matrix);\n int Q;\n cin >> Q;\n vint s(Q), t(Q);\n vll ans(Q);\n rep(i, Q) {\n cin >> s[i] >> t[i];\n if (wf.get_cost(s[i], t[i]) >= LLONG_MAX) {\n cout << -1 << endl;\n continue;\n }\n auto min_path = wf.get_min_path(s[i], t[i]);\n int ans = 0;\n \n int fill_point = min_path[0];\n \n REP(j, 1, min_path.size()) {\n if (wf.get_cost(fill_point, min_path[j]) > ll(L)) {\n fill_point = min_path[j - 1];\n ans++;\n }\n\n }\n int add = 0;\n if (wf.get_cost(s[i], t[i]) % L != 0) add = 1;\n cout << max(ll(ans), wf.get_cost(s[i], t[i])/L + add - 1) << endl;\n }\n \n return 0;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "sample_input": "3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"}, "reference_outputs": ["0\n1\n"], "source_document_id": "p02889", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5286, "cpu_time_ms": 292, "memory_kb": 3712}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s719151432", "group_id": "codeNet:p02889", "input_text": "#include \nusing namespace std;\n\nint main() {\n int n, m, l;\n cin>>n>>m>>l;\n long long cost[n][n];\n long long inf = 300 * 1e9;\n for (int i=0; i>a>>b>>c;\n --a;\n --b;\n cost[a][b] = c;\n cost[b][a] = c;\n }\n for (int k=0; k>q;\n for (int i=0; i>s>>t;\n --s;\n --t;\n if (num[s][t] == n) {\n cout<<-1<\nusing namespace std;\n\nint main() {\n int n, m, l;\n cin>>n>>m>>l;\n long long cost[n][n];\n long long inf = 300 * 1e9;\n for (int i=0; i>a>>b>>c;\n --a;\n --b;\n cost[a][b] = c;\n cost[b][a] = c;\n }\n for (int k=0; k>q;\n for (int i=0; i>s>>t;\n --s;\n --t;\n if (num[s][t] == n) {\n cout<<-1<\n#include \n#define int long long\n#define il inline\n#define rgi register long long\n#define sp putchar(' ')\n#define el putchar('\\n')\nusing namespace std;\nil int ri()\n{\n\tregister int o1=0;\n\tregister bool o2=0;\n\tregister char o3;\n\twhile(!isdigit(o3=getchar()))\n\t\to2|=o3=='-';\n\twhile(isdigit(o3))\n\t\to1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();\n\treturn o2?-o1:o1;\n}\nil void wi(int o1)\n{\n\tif(o1<0)\n\t\tputchar('-'),o1=-o1;\n\trgi o2=o1/10;\n\tif(o2)\n\t\twi(o2);\n\tputchar((o1-(o2<<1)-(o2<<3))^48);\n}\nint a,b,c;\nil int gcd(int p,int q)\n{\n\tif(q==0)\n\t\treturn p;\n\treturn gcd(q,p%q);\n}\nil int divide(int n)\n{\n\tint ret=0;\n\tfor(rgi i=2;i*i<=n;++i)\n\t\tif(n%i==0)\n\t\t{\n\t\t\t++ret;\n\t\t\twhile(n%i==0)\n\t\t\t\tn/=i;\n\t\t}\n\tif(n>1)\n\t\t++ret;\n\treturn ret+1;\n}\nsigned main()\n{\n\ta=ri(),b=ri();\n\tc=gcd(a,b);\n\tint ans=divide(c);\n\twi(ans);\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1569720005, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02900/input.txt", "sample_output_relpath": "derived/input_output/data/p02900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02900/C++/s564812969.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s564812969", "user_id": "u862024582"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include \n#define int long long\n#define il inline\n#define rgi register long long\n#define sp putchar(' ')\n#define el putchar('\\n')\nusing namespace std;\nil int ri()\n{\n\tregister int o1=0;\n\tregister bool o2=0;\n\tregister char o3;\n\twhile(!isdigit(o3=getchar()))\n\t\to2|=o3=='-';\n\twhile(isdigit(o3))\n\t\to1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();\n\treturn o2?-o1:o1;\n}\nil void wi(int o1)\n{\n\tif(o1<0)\n\t\tputchar('-'),o1=-o1;\n\trgi o2=o1/10;\n\tif(o2)\n\t\twi(o2);\n\tputchar((o1-(o2<<1)-(o2<<3))^48);\n}\nint a,b,c;\nil int gcd(int p,int q)\n{\n\tif(q==0)\n\t\treturn p;\n\treturn gcd(q,p%q);\n}\nil int divide(int n)\n{\n\tint ret=0;\n\tfor(rgi i=2;i*i<=n;++i)\n\t\tif(n%i==0)\n\t\t{\n\t\t\t++ret;\n\t\t\twhile(n%i==0)\n\t\t\t\tn/=i;\n\t\t}\n\tif(n>1)\n\t\t++ret;\n\treturn ret+1;\n}\nsigned main()\n{\n\ta=ri(),b=ri();\n\tc=gcd(a,b);\n\tint ans=divide(c);\n\twi(ans);\n\treturn 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 827, "cpu_time_ms": 10, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s539784353", "group_id": "codeNet:p02903", "input_text": "#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 INFint (1<<30)\n#define BOUND 27182818284\n#define MAT 2\n\ntypedef long long ll;\ntypedef long long int lli;\ntypedef pair P;\n\nll MOD = 1000000007;\nconst ll INF = (1ll<<60);\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\nbool umax(T &a, const T &b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\n\ntemplate\nbool umin(T &a, const T &b) {\n if (b < a) {\n a = b;\n return true;\n }\n return false;\n}\n\n// gcd\ntemplate\nT gcd(T a, T b) {\n if (a == 0)\n return b;\n return gcd(b % a, a);\n}\n\nint findGCD(int arr[], int n) {\n int result = arr[0];\n for (int i = 1; i < n; i++)\n result = gcd(arr[i], result);\n return result;\n}\n\ntemplate\nT lcm(T m, T n) {\n // 引数に0がある場合は0を返す\n if ((0 == m) || (0 == n))\n return 0;\n return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)\n}\n\ntemplate\nvoid Fill(A (&array)[N], const T &val) {\n fill((T *) array, (T *) (array + N), val);\n}\n\n\nint dx[5] = {1, 0, -1, 0};\nint dy[5] = {0, 1, 0, -1};\n\n// v.front() = -BOUND;\n// v.back() = BOUND;\n\n//struct edge{\n// int cost, to;\n//\n// edge(int in_cost, int in_to){\n// cost=in_cost;\n// to=in_to;\n// }\n// bool operator<(const edge &a) const\n// {\n// return cost > a.cost;\n// }\n//};\nint main() {\n int H,W,A,B; cin >> H >> W >> A >> B;\n int a[1010][1010];\n Fill(a,0);\n\n for(int i=0; i=B && j>=A) ){\n a[i][j]=1;\n }\n }\n }\n\n for(int i=0; i\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 INFint (1<<30)\n#define BOUND 27182818284\n#define MAT 2\n\ntypedef long long ll;\ntypedef long long int lli;\ntypedef pair P;\n\nll MOD = 1000000007;\nconst ll INF = (1ll<<60);\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\nbool umax(T &a, const T &b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\n\ntemplate\nbool umin(T &a, const T &b) {\n if (b < a) {\n a = b;\n return true;\n }\n return false;\n}\n\n// gcd\ntemplate\nT gcd(T a, T b) {\n if (a == 0)\n return b;\n return gcd(b % a, a);\n}\n\nint findGCD(int arr[], int n) {\n int result = arr[0];\n for (int i = 1; i < n; i++)\n result = gcd(arr[i], result);\n return result;\n}\n\ntemplate\nT lcm(T m, T n) {\n // 引数に0がある場合は0を返す\n if ((0 == m) || (0 == n))\n return 0;\n return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)\n}\n\ntemplate\nvoid Fill(A (&array)[N], const T &val) {\n fill((T *) array, (T *) (array + N), val);\n}\n\n\nint dx[5] = {1, 0, -1, 0};\nint dy[5] = {0, 1, 0, -1};\n\n// v.front() = -BOUND;\n// v.back() = BOUND;\n\n//struct edge{\n// int cost, to;\n//\n// edge(int in_cost, int in_to){\n// cost=in_cost;\n// to=in_to;\n// }\n// bool operator<(const edge &a) const\n// {\n// return cost > a.cost;\n// }\n//};\nint main() {\n int H,W,A,B; cin >> H >> W >> A >> B;\n int a[1010][1010];\n Fill(a,0);\n\n for(int i=0; i=B && j>=A) ){\n a[i][j]=1;\n }\n }\n }\n\n for(int i=0; i\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;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\nusing vll = vector;\nusing vvll = vector;\nusing pll = pair;\nusing tll = tuple;\n#define all(v) (v).begin(), (v).end()\n#define for1(i, n) for (ll i = 0; i < (n); i++)\n#define for2(i, m, n) for (ll i = (m); i < (n); i++)\n#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))\n#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)\n#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))\n#define INF 1111111111111111111LL\n#define MOD 1000000007LL // 10**9 + 7\n#define print(...) print_1(__VA_ARGS__)\n#define in(...) in_1(__VA_ARGS__)\n#if DEBUG\n#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)\n#else\n#define dump(...)\n#endif\ntemplate \nvoid dump_1(const char* str, Head&& h)\n{\n cerr << str << \": \" << h << '\\n';\n}\ntemplate \nvoid dump_1(const char* str, Head&& h, Tail&&... t)\n{\n while (*str != ',') {\n cerr << *str++;\n }\n cerr << \": \" << h << ' ';\n dump_1(str + 1, t...);\n}\ntemplate \nostream& operator<<(ostream& os, const pair& v)\n{\n os << '(' << v.first << \", \" << v.second << ')';\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const tuple& v)\n{\n os << '(' << get<0>(v) << \", \" << get<1>(v) << \", \" << get<2>(v) << ')';\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const vector& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const set& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const multiset& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const map& v)\n{\n os << '{';\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << \", \";\n }\n os << it->first << ':' << it->second;\n }\n os << '}';\n return os;\n}\nvoid Yes(void) { cout << \"Yes\" << '\\n'; }\nvoid No(void) { cout << \"No\" << '\\n'; }\nvoid YES(void) { cout << \"YES\" << '\\n'; }\nvoid NO(void) { cout << \"NO\" << '\\n'; }\ntemplate \nvoid chmax(T& a, const T& b)\n{\n if (a < b) {\n a = b;\n }\n}\ntemplate \nvoid chmin(T& a, const T& b)\n{\n if (a > b) {\n a = b;\n }\n}\ntemplate \nvoid vin(vector& v, ll len)\n{\n for1 (i, len) {\n cin >> v[i];\n }\n}\ntemplate \nvoid in_1(Head& h)\n{\n cin >> h;\n}\ntemplate \nvoid in_1(Head& h, Tail&... t)\n{\n cin >> h;\n in_1(t...);\n}\ntemplate \nvoid print_1(Head&& h)\n{\n cout << h << '\\n';\n}\ntemplate \nvoid print_1(Head&& h, Tail&&... t)\n{\n cout << h << ' ';\n print_1(t...);\n}\n//---------------------------------------------------------\nvoid solve()\n{\n ll H, W, A, B;\n in(H, W, A, B);\n if (A == 0 && B == 0) {\n for1 (h, H) {\n for1 (w, W) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if (B == 0) {\n for1 (h, H) {\n for1 (w, A) {\n cout << \"1\";\n }\n for1 (w, W - A) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if (A == 0) {\n for1 (h, B) {\n for1 (w, W) {\n cout << \"1\";\n }\n cout << \"\\n\";\n }\n for1 (h, H - B) {\n for1 (w, W) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if ((W % A == 0) && (H % B == 0) && (W / A == H / B)) {\n for1 (h, H) {\n for1 (w, W) {\n if (w / A == h / B) {\n cout << \"1\";\n }\n else {\n cout << \"0\";\n }\n }\n cout << \"\\n\";\n }\n return;\n }\n ll ans[1001][1001];\n ll total[1001];\n\n for2 (wd, 1, A + 1) {\n for1 (h, H) {\n for1 (w, W) {\n if ((w + wd * h) % W < A) {\n ans[h][w] = 1;\n }\n else {\n ans[h][w] = 0;\n }\n }\n }\n for1 (w, W) {\n total[w] = 0;\n }\n for1 (h, H) {\n for1 (w, W) {\n total[w] += ans[h][w];\n }\n }\n bool ok = true;\n for1 (w, W) {\n if (total[w] != B) {\n ok = false;\n break;\n }\n }\n if (ok) {\n for1 (h, H) {\n for1 (w, W) {\n if (ans[h][w] != 0) {\n cout << '1';\n } else {\n cout << '0';\n }\n }\n cout << '\\n';\n }\n return;\n }\n }\n No();\n}\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(16);\n cerr << fixed << setprecision(16);\n solve();\n}\n", "language": "C++", "metadata": {"date": 1569117709, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02903.html", "problem_id": "p02903", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02903/input.txt", "sample_output_relpath": "derived/input_output/data/p02903/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02903/C++/s313351196.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s313351196", "user_id": "u426683236"}, "prompt_components": {"gold_output": "100\n010\n001\n", "input_to_evaluate": "#define DEBUG 1\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;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\nusing vll = vector;\nusing vvll = vector;\nusing pll = pair;\nusing tll = tuple;\n#define all(v) (v).begin(), (v).end()\n#define for1(i, n) for (ll i = 0; i < (n); i++)\n#define for2(i, m, n) for (ll i = (m); i < (n); i++)\n#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))\n#define rfor2(i, m, n) for (ll i = (m); i > (n); i--)\n#define rfor3(i, m, n, d) for (ll i = (m); i > (n); i += (d))\n#define INF 1111111111111111111LL\n#define MOD 1000000007LL // 10**9 + 7\n#define print(...) print_1(__VA_ARGS__)\n#define in(...) in_1(__VA_ARGS__)\n#if DEBUG\n#define dump(...) dump_1(#__VA_ARGS__, __VA_ARGS__)\n#else\n#define dump(...)\n#endif\ntemplate \nvoid dump_1(const char* str, Head&& h)\n{\n cerr << str << \": \" << h << '\\n';\n}\ntemplate \nvoid dump_1(const char* str, Head&& h, Tail&&... t)\n{\n while (*str != ',') {\n cerr << *str++;\n }\n cerr << \": \" << h << ' ';\n dump_1(str + 1, t...);\n}\ntemplate \nostream& operator<<(ostream& os, const pair& v)\n{\n os << '(' << v.first << \", \" << v.second << ')';\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const tuple& v)\n{\n os << '(' << get<0>(v) << \", \" << get<1>(v) << \", \" << get<2>(v) << ')';\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const vector& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const set& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const multiset& v)\n{\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << ' ';\n }\n os << *it;\n }\n return os;\n}\ntemplate \nostream& operator<<(ostream& os, const map& v)\n{\n os << '{';\n for (auto it = v.begin(); it != v.end(); it++) {\n if (it != v.begin()) {\n os << \", \";\n }\n os << it->first << ':' << it->second;\n }\n os << '}';\n return os;\n}\nvoid Yes(void) { cout << \"Yes\" << '\\n'; }\nvoid No(void) { cout << \"No\" << '\\n'; }\nvoid YES(void) { cout << \"YES\" << '\\n'; }\nvoid NO(void) { cout << \"NO\" << '\\n'; }\ntemplate \nvoid chmax(T& a, const T& b)\n{\n if (a < b) {\n a = b;\n }\n}\ntemplate \nvoid chmin(T& a, const T& b)\n{\n if (a > b) {\n a = b;\n }\n}\ntemplate \nvoid vin(vector& v, ll len)\n{\n for1 (i, len) {\n cin >> v[i];\n }\n}\ntemplate \nvoid in_1(Head& h)\n{\n cin >> h;\n}\ntemplate \nvoid in_1(Head& h, Tail&... t)\n{\n cin >> h;\n in_1(t...);\n}\ntemplate \nvoid print_1(Head&& h)\n{\n cout << h << '\\n';\n}\ntemplate \nvoid print_1(Head&& h, Tail&&... t)\n{\n cout << h << ' ';\n print_1(t...);\n}\n//---------------------------------------------------------\nvoid solve()\n{\n ll H, W, A, B;\n in(H, W, A, B);\n if (A == 0 && B == 0) {\n for1 (h, H) {\n for1 (w, W) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if (B == 0) {\n for1 (h, H) {\n for1 (w, A) {\n cout << \"1\";\n }\n for1 (w, W - A) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if (A == 0) {\n for1 (h, B) {\n for1 (w, W) {\n cout << \"1\";\n }\n cout << \"\\n\";\n }\n for1 (h, H - B) {\n for1 (w, W) {\n cout << \"0\";\n }\n cout << \"\\n\";\n }\n return;\n }\n if ((W % A == 0) && (H % B == 0) && (W / A == H / B)) {\n for1 (h, H) {\n for1 (w, W) {\n if (w / A == h / B) {\n cout << \"1\";\n }\n else {\n cout << \"0\";\n }\n }\n cout << \"\\n\";\n }\n return;\n }\n ll ans[1001][1001];\n ll total[1001];\n\n for2 (wd, 1, A + 1) {\n for1 (h, H) {\n for1 (w, W) {\n if ((w + wd * h) % W < A) {\n ans[h][w] = 1;\n }\n else {\n ans[h][w] = 0;\n }\n }\n }\n for1 (w, W) {\n total[w] = 0;\n }\n for1 (h, H) {\n for1 (w, W) {\n total[w] += ans[h][w];\n }\n }\n bool ok = true;\n for1 (w, W) {\n if (total[w] != B) {\n ok = false;\n break;\n }\n }\n if (ok) {\n for1 (h, H) {\n for1 (w, W) {\n if (ans[h][w] != 0) {\n cout << '1';\n } else {\n cout << '0';\n }\n }\n cout << '\\n';\n }\n return;\n }\n }\n No();\n}\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout << fixed << setprecision(16);\n cerr << fixed << setprecision(16);\n solve();\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "sample_input": "3 3 1 1\n"}, "reference_outputs": ["100\n010\n001\n"], "source_document_id": "p02903", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5856, "cpu_time_ms": 2103, "memory_kb": 8064}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s778889273", "group_id": "codeNet:p02904", "input_text": "#include \nusing namespace std;\n\nusing ll = long long;\nconst int INF = 1e9;\n\nstruct segtree {\n\t\n\tvector tree;\n\tint size;\n\t\n\tvoid init (int n) {\n\t\tsize = 1;\n\t\twhile (size < n) {\n\t\t\tsize <<= 1;\n\t\t}\n\t\ttree.assign(size<<1, INF);\n\t}\n\t\n\tint son (int v, int num) {\n\t\treturn (v<<1)+(num-1);\n\t}\n\t\n\tvoid set (int v, int lv, int rv, int i, int x) {\n\t\tif (lv == rv) {\n\t\t\ttree[v] = x;\n\t\t\treturn;\n\t\t}\n\t\tint mid = (lv+rv)>>1;\n\t\tif (mid >= i) {\n\t\t\tset (son(v, 1), lv, mid, i, x);\n\t\t} else {\n\t\t\tset (son(v, 2), mid+1, rv, i, x);\n\t\t}\n\t\ttree[v] = min(tree[son(v, 1)], tree[son(v, 2)]);\n\t}\n\t\n\tvoid set (int i, int x) {\n\t\tif (!x) x = INF;\n\t\tset (1, 1, size, i, x);\n\t}\n\t\n\tint inv (int v, int lv, int rv, int l, int r) {\n\t\tif (lv > r || rv < l) {\n\t\t\treturn INF;\n\t\t}\n\t\tif (lv >= l && rv <= r) {\n\t\t\treturn tree[v];\n\t\t}\n\t\tint mid = (lv+rv)>>1;\n\t\tint left = inv(son(v, 1), lv, mid, l, min(r, mid));\n\t\tint right = inv(son(v, 2), mid+1, rv, max(mid+1, l), r);\n\t\treturn min(right, left);\n\t}\n\t\n\tint inv (int l, int r) {\n\t\treturn inv (1, 1, size, l, r);\n\t}\n\t\n};\n\nint main()\n{\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tint n, k, ans = 0;\n\tsegtree t;\n\tcin >> n >> k;\n\tt.init(n);\n\tvector a(n+1);\n\tfor (int i=1; i<=n; i++) {\n\t\tcin >> a[i];\n\t\ta[i] ++;\n\t}\n\tint tec = 1;\n\tfor (int i=2; i<=n; i++) {\n\t\tif (a[i] > a[i-1]) {\n\t\t\ttec ++;\n\t\t} else {\n\t\t\tif (tec >= k) break;\n\t\t\ttec = 1;\n\t\t}\n\t}\n\tif (tec >= k) {\n\t\tans ++;\n\t}\n\ttec = 0; // will use for the leftmost inversion with current element\n\tset > s;\n\tfor (int i=1; i<=n; i++) {\n\t\tif (i > k) {\n\t\t\tt.set(a[i-k], INF);\n\t\t}\n\t\tbool check = 0;\n\t\ttec = t.inv(a[i], n);\n\t\tif (tec < INF) {\n\t\t\ts.insert({tec, i});\n\t\t\tcheck = 1;\n\t\t}\n\t\twhile (!s.empty()) {\n\t\t\tpair m = *s.begin();\n\t\t\tif (m.first <= i-k) {\n\t\t\t\ts.erase(m);\n\t\t\t\tcheck = 1;\n\t\t\t} else break;\n\t\t}\n\t\tif (check && i >= k) {\n\t\t\tans ++;\n\t\t}\n\t\tt.set(a[i], i);\n\t}\n\tcout << ans;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1588987933, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02904.html", "problem_id": "p02904", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02904/input.txt", "sample_output_relpath": "derived/input_output/data/p02904/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02904/C++/s778889273.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s778889273", "user_id": "u627941097"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nusing ll = long long;\nconst int INF = 1e9;\n\nstruct segtree {\n\t\n\tvector tree;\n\tint size;\n\t\n\tvoid init (int n) {\n\t\tsize = 1;\n\t\twhile (size < n) {\n\t\t\tsize <<= 1;\n\t\t}\n\t\ttree.assign(size<<1, INF);\n\t}\n\t\n\tint son (int v, int num) {\n\t\treturn (v<<1)+(num-1);\n\t}\n\t\n\tvoid set (int v, int lv, int rv, int i, int x) {\n\t\tif (lv == rv) {\n\t\t\ttree[v] = x;\n\t\t\treturn;\n\t\t}\n\t\tint mid = (lv+rv)>>1;\n\t\tif (mid >= i) {\n\t\t\tset (son(v, 1), lv, mid, i, x);\n\t\t} else {\n\t\t\tset (son(v, 2), mid+1, rv, i, x);\n\t\t}\n\t\ttree[v] = min(tree[son(v, 1)], tree[son(v, 2)]);\n\t}\n\t\n\tvoid set (int i, int x) {\n\t\tif (!x) x = INF;\n\t\tset (1, 1, size, i, x);\n\t}\n\t\n\tint inv (int v, int lv, int rv, int l, int r) {\n\t\tif (lv > r || rv < l) {\n\t\t\treturn INF;\n\t\t}\n\t\tif (lv >= l && rv <= r) {\n\t\t\treturn tree[v];\n\t\t}\n\t\tint mid = (lv+rv)>>1;\n\t\tint left = inv(son(v, 1), lv, mid, l, min(r, mid));\n\t\tint right = inv(son(v, 2), mid+1, rv, max(mid+1, l), r);\n\t\treturn min(right, left);\n\t}\n\t\n\tint inv (int l, int r) {\n\t\treturn inv (1, 1, size, l, r);\n\t}\n\t\n};\n\nint main()\n{\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tint n, k, ans = 0;\n\tsegtree t;\n\tcin >> n >> k;\n\tt.init(n);\n\tvector a(n+1);\n\tfor (int i=1; i<=n; i++) {\n\t\tcin >> a[i];\n\t\ta[i] ++;\n\t}\n\tint tec = 1;\n\tfor (int i=2; i<=n; i++) {\n\t\tif (a[i] > a[i-1]) {\n\t\t\ttec ++;\n\t\t} else {\n\t\t\tif (tec >= k) break;\n\t\t\ttec = 1;\n\t\t}\n\t}\n\tif (tec >= k) {\n\t\tans ++;\n\t}\n\ttec = 0; // will use for the leftmost inversion with current element\n\tset > s;\n\tfor (int i=1; i<=n; i++) {\n\t\tif (i > k) {\n\t\t\tt.set(a[i-k], INF);\n\t\t}\n\t\tbool check = 0;\n\t\ttec = t.inv(a[i], n);\n\t\tif (tec < INF) {\n\t\t\ts.insert({tec, i});\n\t\t\tcheck = 1;\n\t\t}\n\t\twhile (!s.empty()) {\n\t\t\tpair m = *s.begin();\n\t\t\tif (m.first <= i-k) {\n\t\t\t\ts.erase(m);\n\t\t\t\tcheck = 1;\n\t\t\t} else break;\n\t\t}\n\t\tif (check && i >= k) {\n\t\t\tans ++;\n\t\t}\n\t\tt.set(a[i], i);\n\t}\n\tcout << ans;\n\treturn 0;\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "sample_input": "5 3\n0 2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02904", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1911, "cpu_time_ms": 138, "memory_kb": 12416}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s571823302", "group_id": "codeNet:p02910", "input_text": "#include \nusing namespace std;\nint main()\n{\n\n\nstring s;\ncin>>s;\nif(s[0] || s[2]||s[4] == 'R'||'U' ||'D')\n{\n cout<<\"YES\"<\nusing namespace std;\nint main()\n{\n\n\nstring s;\ncin>>s;\nif(s[0] || s[2]||s[4] == 'R'||'U' ||'D')\n{\n cout<<\"YES\"<\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 M 1000000007\n#define pb push_back\n#define mp make_pair\n#define int long long\nusing namespace std;\nint32_t main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint n,k,q;\n\tcin>>n>>k>>q;\n\tint a[n]={0},i;\n\tfor(i=0;i>x;\n\t\tx--;\n\t\ta[x]++;\n\t}\n\tfor(i=0;i=k)\n\t\t\tcout<<\"No\\n\";\n\t\telse\n\t\t\tcout<<\"Yes\\n\";\n\t}\n}", "language": "C++", "metadata": {"date": 1568597217, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02911/input.txt", "sample_output_relpath": "derived/input_output/data/p02911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02911/C++/s620173940.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620173940", "user_id": "u131230001"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "#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 M 1000000007\n#define pb push_back\n#define mp make_pair\n#define int long long\nusing namespace std;\nint32_t main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint n,k,q;\n\tcin>>n>>k>>q;\n\tint a[n]={0},i;\n\tfor(i=0;i>x;\n\t\tx--;\n\t\ta[x]++;\n\t}\n\tfor(i=0;i=k)\n\t\t\tcout<<\"No\\n\";\n\t\telse\n\t\t\tcout<<\"Yes\\n\";\n\t}\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 12, "memory_kb": 1408}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s041729549", "group_id": "codeNet:p02915", "input_text": "#include\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n cout << n*n*n << \"\\n\";\n}", "language": "C++", "metadata": {"date": 1568749839, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/C++/s041729549.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041729549", "user_id": "u106635407"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#include\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n cout << n*n*n << \"\\n\";\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 156, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s079328471", "group_id": "codeNet:p02915", "input_text": "#include\nusing namespace std;\nint main() {\n\tint n, ans = 0;\n\tscanf(\"%d\", &n);\n\tif (n > 9)n = 9;\n\tans += n;\n\tint k = n * (n - 1);\n\tif(k)ans += (k << 1) + k;\n\tk = 0;\n\tfor (int i = 1; i < n-1; ++i) {\n\t\tfor (int j = i + 1; j < n; ++j) \n\t\t\tk += n - j;\n\t}\n\tif (k)ans += (k << 2) + (k<<1);\n\tprintf(\"%d\", ans);\n}", "language": "C++", "metadata": {"date": 1567906258, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/C++/s079328471.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079328471", "user_id": "u538014595"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#include\nusing namespace std;\nint main() {\n\tint n, ans = 0;\n\tscanf(\"%d\", &n);\n\tif (n > 9)n = 9;\n\tans += n;\n\tint k = n * (n - 1);\n\tif(k)ans += (k << 1) + k;\n\tk = 0;\n\tfor (int i = 1; i < n-1; ++i) {\n\t\tfor (int j = i + 1; j < n; ++j) \n\t\t\tk += n - j;\n\t}\n\tif (k)ans += (k << 2) + (k<<1);\n\tprintf(\"%d\", ans);\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s790606873", "group_id": "codeNet:p02915", "input_text": "// Contest.cpp : アプリケー��ョンのエントリ ポイントを定義します。\n//\n\n#include\"iostream\"\n#include\"string\"\n#include\"vector\"\n#include\"algorithm\"\n\nusing namespace std;\n\nint main()\n{\n\t/*int n,k;\n\tcin >> n;\n\tvectors(n);\n\tfor (int j = 0; j < n; j++) cin >> s[j];\n\tcin >> k;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (s[i] != s[k-1]) {\n\t\t\ts[i] = '*';\n\t\t}\n\t}\n\n\tfor (int l = 0; l < n; l++)\n\t{\n\t\tcout << s[l] ;\n\t}*/\n\t\n\tint n;\n\tcin >> n;\n\tint sum = 1;\n\tfor (int i = 0; i < n; i++) {\n\t\tsum = sum * n;\n\t}\n\t\n\tcout << sum;\n\t\n}\n\n\n\n", "language": "C++", "metadata": {"date": 1567904788, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/C++/s790606873.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s790606873", "user_id": "u157146122"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "// Contest.cpp : アプリケーションのエントリ ポイントを定義します。\n//\n\n#include\"iostream\"\n#include\"string\"\n#include\"vector\"\n#include\"algorithm\"\n\nusing namespace std;\n\nint main()\n{\n\t/*int n,k;\n\tcin >> n;\n\tvectors(n);\n\tfor (int j = 0; j < n; j++) cin >> s[j];\n\tcin >> k;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (s[i] != s[k-1]) {\n\t\t\ts[i] = '*';\n\t\t}\n\t}\n\n\tfor (int l = 0; l < n; l++)\n\t{\n\t\tcout << s[l] ;\n\t}*/\n\t\n\tint n;\n\tcin >> n;\n\tint sum = 1;\n\tfor (int i = 0; i < n; i++) {\n\t\tsum = sum * n;\n\t}\n\t\n\tcout << sum;\n\t\n}\n\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 542, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s413074903", "group_id": "codeNet:p02916", "input_text": "#include \nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n vector a(n);\n vector b(n);\n vector c(n);\n for (int i = 0; i < n; i++){\n cin >> a.at(i);\n }\n for (int i = 0; i < n; i++){\n cin >> b.at(i);\n }\n for (int i = 0; i < n; i++){\n cin >> c.at(i);\n }\n\n int ans = 0;\n for (int i = 0; i < n; i++){\n ans += b.at(a.at(i));\n if (i != n-1){\n if (a.at(i + 1) - a.at(i) == 1){\n ans += c.at(a.at(i));\n }\n }\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1587326149, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02916/input.txt", "sample_output_relpath": "derived/input_output/data/p02916/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02916/C++/s413074903.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s413074903", "user_id": "u164352406"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n vector a(n);\n vector b(n);\n vector c(n);\n for (int i = 0; i < n; i++){\n cin >> a.at(i);\n }\n for (int i = 0; i < n; i++){\n cin >> b.at(i);\n }\n for (int i = 0; i < n; i++){\n cin >> c.at(i);\n }\n\n int ans = 0;\n for (int i = 0; i < n; i++){\n ans += b.at(a.at(i));\n if (i != n-1){\n if (a.at(i + 1) - a.at(i) == 1){\n ans += c.at(a.at(i));\n }\n }\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 585, "cpu_time_ms": 104, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s910760562", "group_id": "codeNet:p02916", "input_text": "#include \nusing namespace std;\nstruct edge {\n int to; // 辺の行き先\n int weight; // 辺の重み\n edge(int t, int w) : to(t), weight(w) { }\n};\nusing Graph = vector>;\nusing dou =long double;\nstring Yes=\"Yes\";\nstring YES=\"YES\";\nstring NO=\"NO\";\nstring No=\"No\";\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define brep(n) for(int bit=0;bit<(1<= (int)0; i--)\n#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)\n#define reprep(i,j,h,w) rep(i,h)rep(j,w)\n#define all(x) (x).begin(),(x).end()\n#define aall(x,n) (x).begin(),(x).begin()+(n)\n#define VEC(type,name,n) std::vector name(n);rep(i,n)std::cin >> name[i];\n#define pb push_back\n#define pf push_front\n#define lb lower_bound\n#define ub upper_bound\n#define res resize\n#define as assign\n#define fi first\n#define se second\n#define itn int\n#define mp make_pair\n#define sum(a) accumulate(all(a),0)\n#define keta fixed< > name(m,vector (n,a))\n#define vvvector(name,t,l,m,n,a) vector > > name(l, vector >(m, vector(n,a)));\n#define vvvvector(name,t,k,l,m,n,a) vector > > > name(k,vector > >(l, vector >(m, vector(n,a)) ));\n \ntypedef long long ll;\nconst int INF = 2000000000;\nconst ll INF64 = 9223372036854775806ll;\nconst int mod = 1000000007ll;\nconst ll MOD = 1000000007LL;\nconst double pi=3.1415926535897932384626;\nint main(){\n int n;\n std::cin >> n;\n VEC(int,a,n);\n rep(i,n)a[i]--;\n VEC(int,b,n);\n VEC(int,c,n-1);\n int ans=0;\n ans+=b[a[0]];\n rrep(i,1,n){\n ans+=b[a[i]];\n if(a[i]-a[i-1]==1)ans+=c[a[i-1]];\n }\n std::cout << ans << std::endl;\n}\n", "language": "C++", "metadata": {"date": 1584224351, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02916/input.txt", "sample_output_relpath": "derived/input_output/data/p02916/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02916/C++/s910760562.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910760562", "user_id": "u539011156"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "#include \nusing namespace std;\nstruct edge {\n int to; // 辺の行き先\n int weight; // 辺の重み\n edge(int t, int w) : to(t), weight(w) { }\n};\nusing Graph = vector>;\nusing dou =long double;\nstring Yes=\"Yes\";\nstring YES=\"YES\";\nstring NO=\"NO\";\nstring No=\"No\";\n#define rep(i, n) for(int i = 0; i < (int)(n); i++)\n#define brep(n) for(int bit=0;bit<(1<= (int)0; i--)\n#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)\n#define reprep(i,j,h,w) rep(i,h)rep(j,w)\n#define all(x) (x).begin(),(x).end()\n#define aall(x,n) (x).begin(),(x).begin()+(n)\n#define VEC(type,name,n) std::vector name(n);rep(i,n)std::cin >> name[i];\n#define pb push_back\n#define pf push_front\n#define lb lower_bound\n#define ub upper_bound\n#define res resize\n#define as assign\n#define fi first\n#define se second\n#define itn int\n#define mp make_pair\n#define sum(a) accumulate(all(a),0)\n#define keta fixed< > name(m,vector (n,a))\n#define vvvector(name,t,l,m,n,a) vector > > name(l, vector >(m, vector(n,a)));\n#define vvvvector(name,t,k,l,m,n,a) vector > > > name(k,vector > >(l, vector >(m, vector(n,a)) ));\n \ntypedef long long ll;\nconst int INF = 2000000000;\nconst ll INF64 = 9223372036854775806ll;\nconst int mod = 1000000007ll;\nconst ll MOD = 1000000007LL;\nconst double pi=3.1415926535897932384626;\nint main(){\n int n;\n std::cin >> n;\n VEC(int,a,n);\n rep(i,n)a[i]--;\n VEC(int,b,n);\n VEC(int,c,n-1);\n int ans=0;\n ans+=b[a[0]];\n rrep(i,1,n){\n ans+=b[a[i]];\n if(a[i]-a[i-1]==1)ans+=c[a[i-1]];\n }\n std::cout << ans << std::endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1867, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s019316445", "group_id": "codeNet:p02917", "input_text": "#include\nusing namespace std;\n\nint main(){\n int N;\n cin>>N;\n vector B(N-1);\n for(int i=0;i>B.at(i);\n }\n int sum=0;\n for(int i=0;i\nusing namespace std;\n\nint main(){\n int N;\n cin>>N;\n vector B(N-1);\n for(int i=0;i>B.at(i);\n }\n int sum=0;\n for(int i=0;i\n#include \nusing namespace std;\n\nint main()\n{\n int n, k;\n cin >> n;\n cin >> k;\n string s;\n cin >> s;\n \n int gap = 0;\n for (int i = 0; i < n - 1; ++i)\n {\n if (s[i] == 'R' && s[i + 1] == 'L') ++gap;\n }\n \n int eGap = 0;\n if (s[0] == 'L') ++eGap;\n if (s[n-1] == 'R') ++eGap;\n \n int unhappy;\n if (k < gap)\n {\n unhappy = 2 * (gap - k) + eGap;\n }\n else if (k == gap)\n {\n unhappy = eGap == 0 ? 1 : eGap;\n }\n else\n {\n unhappy = 1;\n }\n cout << (n - unhappy) << endl;\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1569104613, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02918.html", "problem_id": "p02918", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02918/input.txt", "sample_output_relpath": "derived/input_output/data/p02918/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02918/C++/s213062670.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213062670", "user_id": "u269517448"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int n, k;\n cin >> n;\n cin >> k;\n string s;\n cin >> s;\n \n int gap = 0;\n for (int i = 0; i < n - 1; ++i)\n {\n if (s[i] == 'R' && s[i + 1] == 'L') ++gap;\n }\n \n int eGap = 0;\n if (s[0] == 'L') ++eGap;\n if (s[n-1] == 'R') ++eGap;\n \n int unhappy;\n if (k < gap)\n {\n unhappy = 2 * (gap - k) + eGap;\n }\n else if (k == gap)\n {\n unhappy = eGap == 0 ? 1 : eGap;\n }\n else\n {\n unhappy = 1;\n }\n cout << (n - unhappy) << endl;\n \n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "sample_input": "6 1\nLRLRRL\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02918", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing in a queue from west to east.\n\nGiven is a string S of length N representing the directions of the people.\nThe i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.\n\nA person is happy if the person in front of him/her is facing the same direction.\nIf no person is standing in front of a person, however, he/she is not happy.\n\nYou can perform the following operation any number of times between 0 and K (inclusive):\n\nOperation: Choose integers l and r such that 1 \\leq l \\leq r \\leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.\n\nWhat is the maximum possible number of happy people you can have?\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\n|S| = N\n\nEach character of S is L or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of happy people after at most K operations.\n\nSample Input 1\n\n6 1\nLRLRRL\n\nSample Output 1\n\n3\n\nIf we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.\n\nSample Input 2\n\n13 3\nLRRLRLRRLRLLR\n\nSample Output 2\n\n9\n\nSample Input 3\n\n10 1\nLLLLLRRRRR\n\nSample Output 3\n\n9\n\nSample Input 4\n\n9 2\nRRRLRLRLL\n\nSample Output 4\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 538, "cpu_time_ms": 5, "memory_kb": 512}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s730898912", "group_id": "codeNet:p02919", "input_text": "#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#define pi pair\n#define pl pair\n#define chmax(a,b) (ab ? a=b:0)\n#define en cout << endl //セミコロンつけろ\n//#define MM 1000000000\n//#define MOD MM+7\ntypedef long long ll;\nconst int MM = 1e9;\nconst int MOD = MM+7;\nconst long double PI = acos(-1);\nconst long long INF = 1e15;\nint dx[8] = {-1,0,1,0,-1,-1,1,1};\nint dy[8] = {0,-1,0,1,-1,1,1,-1};\n// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122\ntemplate\nT GCD(T u,T v){\n return v ? GCD(v,u%v) : u;\n}\ntemplate\nT LCM(T x,T y){\n T gc = GCD(x,y);\n return x*y/gc;\n}\nstruct edge {\n ll to,cost;\n};\n/*\nconst int COM_MAX = 500500;\nlong long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];\nvoid init(){\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for(int i = 2; i < COM_MAX; 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}\nlong long COM(int n,int k){\n if(n < k || n < 0 || k < 0) return 0;\n return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;\n}\n*/\n\nint main(){\n int N; cin >> N;\n vector p(N),inv(N);\n for (int i = 0; i < N; i++){\n cin >> p[i];\n inv[p[i]-1] = i;\n }\n set s;\n ll ans = 0;\n for (int i = -2; i < N+2; i++){\n s.insert(i);\n }\n for (int i = 0; i < N; i++){\n int k = inv[k];\n s.erase(k);\n auto it1 = s.upper_bound(k);\n auto it2 = it1;\n int r1 = *it1;\n int r2 = *++it1;\n int l1 = *--it2;\n int l2 = *--it2;\n if (r1 < N){\n ans += (ll)(r2-r1)*(k-l1)*(i+1);\n }\n if (l1 >= 0){\n ans += (ll)(l1-l2)*(r1-k)*(i+1);\n }\n s.erase(k);\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1567895627, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/C++/s730898912.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s730898912", "user_id": "u342051078"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#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#define pi pair\n#define pl pair\n#define chmax(a,b) (ab ? a=b:0)\n#define en cout << endl //セミコロンつけろ\n//#define MM 1000000000\n//#define MOD MM+7\ntypedef long long ll;\nconst int MM = 1e9;\nconst int MOD = MM+7;\nconst long double PI = acos(-1);\nconst long long INF = 1e15;\nint dx[8] = {-1,0,1,0,-1,-1,1,1};\nint dy[8] = {0,-1,0,1,-1,1,1,-1};\n// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122\ntemplate\nT GCD(T u,T v){\n return v ? GCD(v,u%v) : u;\n}\ntemplate\nT LCM(T x,T y){\n T gc = GCD(x,y);\n return x*y/gc;\n}\nstruct edge {\n ll to,cost;\n};\n/*\nconst int COM_MAX = 500500;\nlong long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];\nvoid init(){\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for(int i = 2; i < COM_MAX; 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}\nlong long COM(int n,int k){\n if(n < k || n < 0 || k < 0) return 0;\n return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;\n}\n*/\n\nint main(){\n int N; cin >> N;\n vector p(N),inv(N);\n for (int i = 0; i < N; i++){\n cin >> p[i];\n inv[p[i]-1] = i;\n }\n set s;\n ll ans = 0;\n for (int i = -2; i < N+2; i++){\n s.insert(i);\n }\n for (int i = 0; i < N; i++){\n int k = inv[k];\n s.erase(k);\n auto it1 = s.upper_bound(k);\n auto it2 = it1;\n int r1 = *it1;\n int r2 = *++it1;\n int l1 = *--it2;\n int l2 = *--it2;\n if (r1 < N){\n ans += (ll)(r2-r1)*(k-l1)*(i+1);\n }\n if (l1 >= 0){\n ans += (ll)(l1-l2)*(r1-k)*(i+1);\n }\n s.erase(k);\n }\n cout << ans << endl;\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2139, "cpu_time_ms": 111, "memory_kb": 5760}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s936699632", "group_id": "codeNet:p02921", "input_text": "/*\n Read problem and understand it 100%\n Make observation\n SOLVE THE PROBLEM\n*/\n#include \n#define fr first\n#define sc second\n#define pii pair\n#define int long long\n#define szof(s) (int)s.size()\n#define all(s) (int)s.begin(), s.end()\nusing namespace std;\n \nconst int N = (int)1e6 + 5;\nconst int INF = (int)1e9 + 9;\nconst int MOD = (int)1e9 + 7;\n \nmain() {\n\tstring s, t;\n\tcin >> s >> t;\n\tint ans = 0;\n\tfor (int i = 0; i < 3; i++) {\n\t\tans += (s[i] == t[i]);\n\t}\n\tcout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1571177185, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02921/input.txt", "sample_output_relpath": "derived/input_output/data/p02921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02921/C++/s936699632.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s936699632", "user_id": "u361596783"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "/*\n Read problem and understand it 100%\n Make observation\n SOLVE THE PROBLEM\n*/\n#include \n#define fr first\n#define sc second\n#define pii pair\n#define int long long\n#define szof(s) (int)s.size()\n#define all(s) (int)s.begin(), s.end()\nusing namespace std;\n \nconst int N = (int)1e6 + 5;\nconst int INF = (int)1e9 + 9;\nconst int MOD = (int)1e9 + 7;\n \nmain() {\n\tstring s, t;\n\tcin >> s >> t;\n\tint ans = 0;\n\tfor (int i = 0; i < 3; i++) {\n\t\tans += (s[i] == t[i]);\n\t}\n\tcout << ans << endl;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s139065649", "group_id": "codeNet:p02922", "input_text": "#include \nusing namespace std;\n\nint a, b;\nint nr, s;\n\nint main() {\n cin >> a >> b;\n s = a;\n nr = 1;\n if(b == 1) {\n cout << 0;\n return 0;\n }\n while(s < b) {\n nr++;\n s = s + a - 1;\n }\n cout << nr;\n return 0;\n}", "language": "C++", "metadata": {"date": 1594255127, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02922/input.txt", "sample_output_relpath": "derived/input_output/data/p02922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02922/C++/s139065649.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139065649", "user_id": "u644497121"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint a, b;\nint nr, s;\n\nint main() {\n cin >> a >> b;\n s = a;\n nr = 1;\n if(b == 1) {\n cout << 0;\n return 0;\n }\n while(s < b) {\n nr++;\n s = s + a - 1;\n }\n cout << nr;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 6, "memory_kb": 3636}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s283351129", "group_id": "codeNet:p02922", "input_text": "#include \n#include \n# include \n#define FOR(i,l,r) for(int i=(l);i<(r);++i)\n#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)\n#define rep(i,n) FOR(i,0,n)\n#define rrep(i,n) RFOR(i,n-1,0)\n\n// #define int long long\nusing namespace std;\nconst int MX = 1e6;\nconst int inf = 1e9;\n\nusing P = pair;\n\n\nvector to[100005];\nint cost[100005];\nsigned main(){\n int a,b;\n cin >> a>> b;\n int ans = 1;\n while(ans*a \n#include \n# include \n#define FOR(i,l,r) for(int i=(l);i<(r);++i)\n#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)\n#define rep(i,n) FOR(i,0,n)\n#define rrep(i,n) RFOR(i,n-1,0)\n\n// #define int long long\nusing namespace std;\nconst int MX = 1e6;\nconst int inf = 1e9;\n\nusing P = pair;\n\n\nvector to[100005];\nint cost[100005];\nsigned main(){\n int a,b;\n cin >> a>> b;\n int ans = 1;\n while(ans*a \n#define st first\n#define nd second\n\nusing namespace std;\n\nvoid debug_out() { cerr << endl; }\ntemplate ostream& prnt(ostream& out, T v) { out << v.size() << '\\n'; for(auto e : v) out << e << ' '; return out;}\ntemplate ostream& operator<<(ostream& out, vector v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, set v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, map v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, pair p) { return out << '(' << p.st << ' ' << p.nd << ')'; }\ntemplate void debug_out(Head H, Tail... T) { cerr << \" \" << H; debug_out(T...);}\n\n#define dbg(...) cerr << #__VA_ARGS__ << \" ->\", debug_out(__VA_ARGS__)\n#define dbg_v(x, n) do{cerr<<#x\"[]: \";for(int _=0;_> a >> b;\n\tint req = b - 1;\n\ta--;\n\tcout << (req + a - 1) / a;\n}\t\n\n\t", "language": "C++", "metadata": {"date": 1567809594, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02922/input.txt", "sample_output_relpath": "derived/input_output/data/p02922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02922/C++/s200991441.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200991441", "user_id": "u541161485"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#define st first\n#define nd second\n\nusing namespace std;\n\nvoid debug_out() { cerr << endl; }\ntemplate ostream& prnt(ostream& out, T v) { out << v.size() << '\\n'; for(auto e : v) out << e << ' '; return out;}\ntemplate ostream& operator<<(ostream& out, vector v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, set v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, map v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, pair p) { return out << '(' << p.st << ' ' << p.nd << ')'; }\ntemplate void debug_out(Head H, Tail... T) { cerr << \" \" << H; debug_out(T...);}\n\n#define dbg(...) cerr << #__VA_ARGS__ << \" ->\", debug_out(__VA_ARGS__)\n#define dbg_v(x, n) do{cerr<<#x\"[]: \";for(int _=0;_> a >> b;\n\tint req = b - 1;\n\ta--;\n\tcout << (req + a - 1) / a;\n}\t\n\n\t", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1124, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s903323978", "group_id": "codeNet:p02922", "input_text": "#include \nusing namespace std;\nlong long int sum_of_digits(long long int n){\n long long int sum=0;\n long long int dd=0;\nwhile(n!=0){\n dd=n%10;\nsum=sum+dd;\n n=n/10;\n}\nreturn sum;\n}\nint main() {\nint a,b;\ncin>>a>>b;\nint i=0;\nfor(int i=1;i<200;i++){\n int d=a*i;\n if(d>=b){\n cout<\nusing namespace std;\nlong long int sum_of_digits(long long int n){\n long long int sum=0;\n long long int dd=0;\nwhile(n!=0){\n dd=n%10;\nsum=sum+dd;\n n=n/10;\n}\nreturn sum;\n}\nint main() {\nint a,b;\ncin>>a>>b;\nint i=0;\nfor(int i=1;i<200;i++){\n int d=a*i;\n if(d>=b){\n cout<\n#include \nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n vector h(n+1);\n for(int i = 0; i < n; i++) cin >> h[i];\n h[n] = h[n-1]+1;\n int ans = 0;\n for(int i = 1, start = 0; i <= n; i++){\n if(h[i-1] >= h[i]){\n ;\n }else{\n if(i-start-1 > ans) ans = i-start-1;\n start = i;\n }\n }\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1594594906, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02923/input.txt", "sample_output_relpath": "derived/input_output/data/p02923/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02923/C++/s646301070.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s646301070", "user_id": "u828593789"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n vector h(n+1);\n for(int i = 0; i < n; i++) cin >> h[i];\n h[n] = h[n-1]+1;\n int ans = 0;\n for(int i = 1, start = 0; i <= n; i++){\n if(h[i-1] >= h[i]){\n ;\n }else{\n if(i-start-1 > ans) ans = i-start-1;\n start = i;\n }\n }\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "sample_input": "5\n10 4 8 7 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02923", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 432, "cpu_time_ms": 45, "memory_kb": 3768}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s519840097", "group_id": "codeNet:p02923", "input_text": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n int N,max=0;\n cin>>N;\n vector H(N);\n for(int i=0;i>H[i];\n }\n for(int i=0;iN-i-2){\n break;\n }\n int count=0;\n for(int j=i;j=H[j+1]){\n count++;\n }else{\n break;\n }\n }\n if(max\n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n int N,max=0;\n cin>>N;\n vector H(N);\n for(int i=0;i>H[i];\n }\n for(int i=0;iN-i-2){\n break;\n }\n int count=0;\n for(int j=i;j=H[j+1]){\n count++;\n }else{\n break;\n }\n }\n if(max\n\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n int ans = 0;\n int curLen = 0;\n int prev = (int) 1e9 + 5;\n for (int i = 0; i < n; i++)\n {\n int x;\n cin >> x;\n if (x <= prev)\n {\n curLen++;\n }\n else\n {\n curLen = 1;\n }\n prev = x;\n ans = max(ans, curLen);\n }\n cout << ans - 1 << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1567365221, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02923/input.txt", "sample_output_relpath": "derived/input_output/data/p02923/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02923/C++/s537573464.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537573464", "user_id": "u828346292"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n int ans = 0;\n int curLen = 0;\n int prev = (int) 1e9 + 5;\n for (int i = 0; i < n; i++)\n {\n int x;\n cin >> x;\n if (x <= prev)\n {\n curLen++;\n }\n else\n {\n curLen = 1;\n }\n prev = x;\n ans = max(ans, curLen);\n }\n cout << ans - 1 << endl;\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "sample_input": "5\n10 4 8 7 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02923", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 57, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s923688279", "group_id": "codeNet:p02924", "input_text": "/*input\n*/\n#include \nusing namespace std;\n \n#define all(a) a.begin(), a.end()\n#define ff first\n#define ss second\n#define pb push_back\n \nusing ll = long long;\nusing pii = pair;\n \ntemplate using V = vector;\n\nint main() {\n\tios::sync_with_stdio(false);cin.tie(nullptr);\n\tll n; cin >> n;\n\t--n;\n\tcout << (n*(n+1))/2;\n}", "language": "C++", "metadata": {"date": 1567366550, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02924.html", "problem_id": "p02924", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02924/input.txt", "sample_output_relpath": "derived/input_output/data/p02924/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02924/C++/s923688279.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923688279", "user_id": "u704703586"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "/*input\n*/\n#include \nusing namespace std;\n \n#define all(a) a.begin(), a.end()\n#define ff first\n#define ss second\n#define pb push_back\n \nusing ll = long long;\nusing pii = pair;\n \ntemplate using V = vector;\n\nint main() {\n\tios::sync_with_stdio(false);cin.tie(nullptr);\n\tll n; cin >> n;\n\t--n;\n\tcout << (n*(n+1))/2;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s945180166", "group_id": "codeNet:p02925", "input_text": "#include\n#define N (1005)\n#define ll long long\n#define debug(x) cerr<<#x<<\" : \"< inline T Min(T x, T y) {\n\treturn x inline T Max(T x, T y) {\n\treturn x>y?x:y;\n}\nbool MOP1;\nint n,A[N][N],p[N];\nint read() {\n\tint v=0;\n\tchar c;\n\tfor(c=getchar(); c<48; c=getchar());\n\tfor(; c>47; c=getchar())v=(v<<3)+(v<<1)+(c^48);\n\treturn v;\n}\nint cnt=0;\nint tot=0;\nbool mark[N];\nbool flag;\nbool MOP2;\nint q[2][N];\nbool cur;\nint main() {\n\tn=read();\n\tfor(int i=1; i<=n; i++) {\n\t\tp[i]=1;\n\t\tfor(int j=1; j\n#define N (1005)\n#define ll long long\n#define debug(x) cerr<<#x<<\" : \"< inline T Min(T x, T y) {\n\treturn x inline T Max(T x, T y) {\n\treturn x>y?x:y;\n}\nbool MOP1;\nint n,A[N][N],p[N];\nint read() {\n\tint v=0;\n\tchar c;\n\tfor(c=getchar(); c<48; c=getchar());\n\tfor(; c>47; c=getchar())v=(v<<3)+(v<<1)+(c^48);\n\treturn v;\n}\nint cnt=0;\nint tot=0;\nbool mark[N];\nbool flag;\nbool MOP2;\nint q[2][N];\nbool cur;\nint main() {\n\tn=read();\n\tfor(int i=1; i<=n; i++) {\n\t\tp[i]=1;\n\t\tfor(int j=1; j\n\n#define long long long int\n\nusing namespace std;\n\n// @author: pashka\n\nint main() {\n ios::sync_with_stdio(false);\n\n int n;\n cin >> n;\n vector>> a(2 * n);\n for (int i = 0; i < n; i++) {\n cin >> a[i].second.first >> a[i].second.second;\n a[i + n].second.first = -a[i].second.first;\n a[i + n].second.second = -a[i].second.second;\n }\n for (int i = 0; i < 2 * n; i++) {\n a[i].first = atan2(a[i].second.second, a[i].second.first);\n }\n\n sort(a.begin(), a.end());\n\n double y0 = 0;\n double x0 = 0;\n for (int i = 0; i < 2 * n; i++) {\n double x = a[i].second.first;\n double y = a[i].second.second;\n if (y > 0 || (y == 0 && x < 0)) {\n x0 += x;\n y0 += y;\n }\n }\n \n double res = 0;\n\n for (int i = 0; i < 2 * n; i++) {\n double x = a[i].second.first;\n double y = a[i].second.second;\n x0 += x;\n y0 += y;\n res = max(res, hypot(x0, y0)); \n }\n cout << setprecision(20) << res;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1572754027, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02926.html", "problem_id": "p02926", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02926/input.txt", "sample_output_relpath": "derived/input_output/data/p02926/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02926/C++/s281759389.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s281759389", "user_id": "u136509923"}, "prompt_components": {"gold_output": "10.000000000000000000000000000000000000000000000000\n", "input_to_evaluate": "#include \n\n#define long long long int\n\nusing namespace std;\n\n// @author: pashka\n\nint main() {\n ios::sync_with_stdio(false);\n\n int n;\n cin >> n;\n vector>> a(2 * n);\n for (int i = 0; i < n; i++) {\n cin >> a[i].second.first >> a[i].second.second;\n a[i + n].second.first = -a[i].second.first;\n a[i + n].second.second = -a[i].second.second;\n }\n for (int i = 0; i < 2 * n; i++) {\n a[i].first = atan2(a[i].second.second, a[i].second.first);\n }\n\n sort(a.begin(), a.end());\n\n double y0 = 0;\n double x0 = 0;\n for (int i = 0; i < 2 * n; i++) {\n double x = a[i].second.first;\n double y = a[i].second.second;\n if (y > 0 || (y == 0 && x < 0)) {\n x0 += x;\n y0 += y;\n }\n }\n \n double res = 0;\n\n for (int i = 0; i < 2 * n; i++) {\n double x = a[i].second.first;\n double y = a[i].second.second;\n x0 += x;\n y0 += y;\n res = max(res, hypot(x0, y0)); \n }\n cout << setprecision(20) << res;\n\n return 0;\n}", "problem_context": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n: :\nx_N y_N\n\nOutput\n\nPrint the maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "sample_input": "3\n0 10\n5 -5\n-5 -5\n"}, "reference_outputs": ["10.000000000000000000000000000000000000000000000000\n"], "source_document_id": "p02926", "source_text": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n: :\nx_N y_N\n\nOutput\n\nPrint the maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1104, "cpu_time_ms": 2, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s949569373", "group_id": "codeNet:p02926", "input_text": "#include \n#include \n#include \n\nusing namespace std;\n\nint N;\nlong long v[8][2];\nint st[8];\n\ndouble res;\n\nvoid CheckSol()\n{\n long long x = 0, y = 0;\n\n for(int i = 0; i <= 8; i++)\n if(st[i] == 1)\n x += v[i][0], y += v[i][1];\n\n res = max(res, sqrt(1LL * x * x + y * y));\n}\n\nvoid bk(int p)\n{\n if(p == 8)\n {\n CheckSol();\n return ;\n }\n\n for(int i = 0; i <= 1; i++)\n {\n st[p] = i;\n bk(p + 1);\n }\n}\n\nint main()\n{\n cin >> N;\n\n for(int i = 1; i <= N; i++)\n {\n long long x, y; cin >> x >> y;\n int index;\n\n if(x > 0 && y > 0) index = 0;\n else if(x > 0 && y < 0) index = 1;\n else if(x < 0 && y > 0) index = 2;\n else if(x < 0 && y < 0) index = 3;\n else if(x == 0 && y > 0) index = 4;\n else if(x == 0 && y < 0) index = 5;\n else if(x > 0 && y == 0) index = 6;\n else if(x < 0 && y == 0) index = 7;\n\n v[index][0] += x;\n v[index][1] += y;\n }\n\n bk(0);\n\n cout << fixed << setprecision(45) << res << '\\n';\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1567369238, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02926.html", "problem_id": "p02926", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02926/input.txt", "sample_output_relpath": "derived/input_output/data/p02926/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02926/C++/s949569373.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s949569373", "user_id": "u323394394"}, "prompt_components": {"gold_output": "10.000000000000000000000000000000000000000000000000\n", "input_to_evaluate": "#include \n#include \n#include \n\nusing namespace std;\n\nint N;\nlong long v[8][2];\nint st[8];\n\ndouble res;\n\nvoid CheckSol()\n{\n long long x = 0, y = 0;\n\n for(int i = 0; i <= 8; i++)\n if(st[i] == 1)\n x += v[i][0], y += v[i][1];\n\n res = max(res, sqrt(1LL * x * x + y * y));\n}\n\nvoid bk(int p)\n{\n if(p == 8)\n {\n CheckSol();\n return ;\n }\n\n for(int i = 0; i <= 1; i++)\n {\n st[p] = i;\n bk(p + 1);\n }\n}\n\nint main()\n{\n cin >> N;\n\n for(int i = 1; i <= N; i++)\n {\n long long x, y; cin >> x >> y;\n int index;\n\n if(x > 0 && y > 0) index = 0;\n else if(x > 0 && y < 0) index = 1;\n else if(x < 0 && y > 0) index = 2;\n else if(x < 0 && y < 0) index = 3;\n else if(x == 0 && y > 0) index = 4;\n else if(x == 0 && y < 0) index = 5;\n else if(x > 0 && y == 0) index = 6;\n else if(x < 0 && y == 0) index = 7;\n\n v[index][0] += x;\n v[index][1] += y;\n }\n\n bk(0);\n\n cout << fixed << setprecision(45) << res << '\\n';\n\n return 0;\n}\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n: :\nx_N y_N\n\nOutput\n\nPrint the maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "sample_input": "3\n0 10\n5 -5\n-5 -5\n"}, "reference_outputs": ["10.000000000000000000000000000000000000000000000000\n"], "source_document_id": "p02926", "source_text": "Score: 600 points\n\nProblem Statement\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\n\nHe has N engines, which can be used as follows:\n\nWhen E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).\n\nE869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.\n\nHe wants to go as far as possible from the origin.\nLet (X, Y) be his final coordinates. Find the maximum possible value of \\sqrt{X^2 + Y^2}, the distance from the origin.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n-1 \\ 000 \\ 000 \\leq x_i \\leq 1 \\ 000 \\ 000\n\n-1 \\ 000 \\ 000 \\leq y_i \\leq 1 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n: :\nx_N y_N\n\nOutput\n\nPrint the maximum possible final distance from the origin, as a real value.\nYour output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.\n\nSample Input 1\n\n3\n0 10\n5 -5\n-5 -5\n\nSample Output 1\n\n10.000000000000000000000000000000000000000000000000\n\nThe final distance from the origin can be 10 if we use the engines in one of the following three ways:\n\nUse Engine 1 to move to (0, 10).\n\nUse Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).\n\nUse Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).\n\nThe distance cannot be greater than 10, so the maximum possible distance is 10.\n\nSample Input 2\n\n5\n1 1\n1 0\n0 1\n-1 0\n0 -1\n\nSample Output 2\n\n2.828427124746190097603377448419396157139343750753\n\nThe maximum possible final distance is 2 \\sqrt{2} = 2.82842....\nOne of the ways to achieve it is:\n\nUse Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).\n\nSample Input 3\n\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\nSample Output 3\n\n21.213203435596425732025330863145471178545078130654\n\nIf we use all the engines in the order 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5, we will end up at (15, 15), with the distance 15 \\sqrt{2} = 21.2132... from the origin.\n\nSample Input 4\n\n3\n0 0\n0 1\n1 0\n\nSample Output 4\n\n1.414213562373095048801688724209698078569671875376\n\nThere can be useless engines with (x_i, y_i) = (0, 0).\n\nSample Input 5\n\n1\n90447 91000\n\nSample Output 5\n\n128303.000000000000000000000000000000000000000000000000\n\nNote that there can be only one engine.\n\nSample Input 6\n\n2\n96000 -72000\n-72000 54000\n\nSample Output 6\n\n120000.000000000000000000000000000000000000000000000000\n\nThere can be only two engines, too.\n\nSample Input 7\n\n10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n\nSample Output 7\n\n148.660687473185055226120082139313966514489855137208", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1117, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s875689067", "group_id": "codeNet:p02928", "input_text": "// #define _GLIBCXX_DEBUG // for STL debug (optional)\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 \nusing namespace std;\nusing ll = long long int;\nusing int64 = long long int;\n \ntemplate void chmax(T &a, T b) {a = max(a, b);}\ntemplate void chmin(T &a, T b) {a = min(a, b);}\ntemplate void chadd(T &a, T b) {a = a + b;}\n \nint dx[] = {0, 0, 1, -1};\nint dy[] = {1, -1, 0, 0};\nconst ll INF = 1001001001001001LL;\nconst ll MOD = 1000000007LL;\n\n// ModInt begin\n\nusing ll = long long;\ntemplate\nstruct ModInt {\n ll v;\n ll mod_pow(ll x, ll n) const {\n return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;\n }\n ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}\n ModInt operator+ ( const ModInt& b ) const {\n return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));\n }\n ModInt operator- () const {\n return ModInt(-v);\n }\n ModInt operator- ( const ModInt& b ) const {\n return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));\n }\n ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}\n ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}\n \n bool operator== ( const ModInt &b ) const {return v == b.v;}\n bool operator!= ( const ModInt &b ) const {return !(*this == b); }\n ModInt& operator+= ( const ModInt &b ) {\n v += b.v;\n if(v >= mod) v -= mod;\n return *this;\n }\n ModInt& operator-= ( const ModInt &b ) {\n v -= b.v;\n if(v < 0) v += mod;\n return *this;\n }\n ModInt& operator*= ( const ModInt &b ) {\n (v *= b.v) %= mod;\n return *this;\n }\n ModInt& operator/= ( const ModInt &b ) {\n (v *= mod_pow(b.v, mod-2)) %= mod;\n return *this;\n }\n ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }\n // operator int() const { return int(v); }\n // operator long long int() const { return v; }\n};\n\ntemplate\nostream& operator<< (ostream& out, ModInt a) {return out << a.v;}\ntemplate\nistream& operator>> (istream& in, ModInt& a) {\n in >> a.v;\n return in;\n}\n\n// ModInt end\nusing mint = ModInt<1000000007>;\n \nint main() {\n int N, K; cin >> N >> K;\n vector A(N);\n for(int i=0; i> A[i];\n\n mint ans(0);\n for(int i=0; i A[j]) ans += mint(K) * mint(K+1) / mint(2);\n }\n }\n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1566695270, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02928.html", "problem_id": "p02928", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02928/input.txt", "sample_output_relpath": "derived/input_output/data/p02928/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02928/C++/s875689067.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875689067", "user_id": "u119460590"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "// #define _GLIBCXX_DEBUG // for STL debug (optional)\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 \nusing namespace std;\nusing ll = long long int;\nusing int64 = long long int;\n \ntemplate void chmax(T &a, T b) {a = max(a, b);}\ntemplate void chmin(T &a, T b) {a = min(a, b);}\ntemplate void chadd(T &a, T b) {a = a + b;}\n \nint dx[] = {0, 0, 1, -1};\nint dy[] = {1, -1, 0, 0};\nconst ll INF = 1001001001001001LL;\nconst ll MOD = 1000000007LL;\n\n// ModInt begin\n\nusing ll = long long;\ntemplate\nstruct ModInt {\n ll v;\n ll mod_pow(ll x, ll n) const {\n return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;\n }\n ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}\n ModInt operator+ ( const ModInt& b ) const {\n return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));\n }\n ModInt operator- () const {\n return ModInt(-v);\n }\n ModInt operator- ( const ModInt& b ) const {\n return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));\n }\n ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}\n ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}\n \n bool operator== ( const ModInt &b ) const {return v == b.v;}\n bool operator!= ( const ModInt &b ) const {return !(*this == b); }\n ModInt& operator+= ( const ModInt &b ) {\n v += b.v;\n if(v >= mod) v -= mod;\n return *this;\n }\n ModInt& operator-= ( const ModInt &b ) {\n v -= b.v;\n if(v < 0) v += mod;\n return *this;\n }\n ModInt& operator*= ( const ModInt &b ) {\n (v *= b.v) %= mod;\n return *this;\n }\n ModInt& operator/= ( const ModInt &b ) {\n (v *= mod_pow(b.v, mod-2)) %= mod;\n return *this;\n }\n ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }\n // operator int() const { return int(v); }\n // operator long long int() const { return v; }\n};\n\ntemplate\nostream& operator<< (ostream& out, ModInt a) {return out << a.v;}\ntemplate\nistream& operator>> (istream& in, ModInt& a) {\n in >> a.v;\n return in;\n}\n\n// ModInt end\nusing mint = ModInt<1000000007>;\n \nint main() {\n int N, K; cin >> N >> K;\n vector A(N);\n for(int i=0; i> A[i];\n\n mint ans(0);\n for(int i=0; i A[j]) ans += mint(K) * mint(K+1) / mint(2);\n }\n }\n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "sample_input": "2 2\n2 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02928", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.\n\nLet B be a sequence of K \\times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.\n\nFind the inversion number of B, modulo 10^9 + 7.\n\nHere the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \\leq i < j \\leq K \\times N - 1) such that B_i > B_j.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 ... A_{N - 1}\n\nOutput\n\nPrint the inversion number of B, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n2 1\n\nSample Output 1\n\n3\n\nIn this case, B~=~2,~1,~2,~1. We have:\n\nB_0 > B_1\n\nB_0 > B_3\n\nB_2 > B_3\n\nThus, the inversion number of B is 3.\n\nSample Input 2\n\n3 5\n1 1 1\n\nSample Output 2\n\n0\n\nA may contain multiple occurrences of the same number.\n\nSample Input 3\n\n10 998244353\n10 9 8 7 5 6 3 4 2 1\n\nSample Output 3\n\n185297239\n\nBe sure to print the output modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3027, "cpu_time_ms": 451, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s489650433", "group_id": "codeNet:p02929", "input_text": "#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 N (1000000000+7)\n#define INF 1e16\ntypedef long long ll;\ntypedef pair P;\n \n\n\n\n\n\nint main(void){\n ll n;\n string s;\n cin>>n;\n cin>>s;\n ll ans = 1;\n ll num = 0;\n for(ll i=0;i<2*n;i++){\n if((2*n-1-i)%2==1){\n if(s[i]=='B')num++;\n else{\n ans = ans*num;\n ans = ans%N;\n num--;\n }\n }\n else{\n if(s[i]=='W')num++;\n else{\n ans = ans*num;\n ans = ans%N;\n num--;\n }\n }\n }\n for(ll i=1;i<=n;i++){\n ans = ans*i;\n ans = ans%N;\n }\n cout<\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 N (1000000000+7)\n#define INF 1e16\ntypedef long long ll;\ntypedef pair P;\n \n\n\n\n\n\nint main(void){\n ll n;\n string s;\n cin>>n;\n cin>>s;\n ll ans = 1;\n ll num = 0;\n for(ll i=0;i<2*n;i++){\n if((2*n-1-i)%2==1){\n if(s[i]=='B')num++;\n else{\n ans = ans*num;\n ans = ans%N;\n num--;\n }\n }\n else{\n if(s[i]=='W')num++;\n else{\n ans = ans*num;\n ans = ans%N;\n num--;\n }\n }\n }\n for(ll i=1;i<=n;i++){\n ans = ans*i;\n ans = ans%N;\n }\n cout<\nusing namespace std;\ntypedef long long ll;\nll mod=1e9+7;\n\n\nint main(){\n ll n;\n string s;\n cin >> n >> s;\n int check=0;\n int x[2*n];\n for(int i=0;i<2*n;i++){\n if(s[i]=='B'&&check%2==0||s[i]=='W'&&check%2==1){\n check++; x[i]=0;\n }\n else{\n check--; x[i]=1;\n }\n cerr << check << endl;\n }\n if(check){\n cout << 0 << endl;\n return 0;\n }\n ll ans=1;\n for(ll i=1;i<=n;i++){\n ans*=i; ans%=mod;\n }\n ll cnt=0;\n for(ll i=2*n-1;i>=0;i--){\n if(x[i]) cnt++;\n else{\n ans*=cnt; ans%=mod; cnt--;\n }\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1566696384, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02929.html", "problem_id": "p02929", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02929/input.txt", "sample_output_relpath": "derived/input_output/data/p02929/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02929/C++/s148220163.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s148220163", "user_id": "u179970156"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\nll mod=1e9+7;\n\n\nint main(){\n ll n;\n string s;\n cin >> n >> s;\n int check=0;\n int x[2*n];\n for(int i=0;i<2*n;i++){\n if(s[i]=='B'&&check%2==0||s[i]=='W'&&check%2==1){\n check++; x[i]=0;\n }\n else{\n check--; x[i]=1;\n }\n cerr << check << endl;\n }\n if(check){\n cout << 0 << endl;\n return 0;\n }\n ll ans=1;\n for(ll i=1;i<=n;i++){\n ans*=i; ans%=mod;\n }\n ll cnt=0;\n for(ll i=2*n-1;i>=0;i--){\n if(x[i]) cnt++;\n else{\n ans*=cnt; ans%=mod; cnt--;\n }\n }\n cout << ans << endl;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "sample_input": "2\nBWWB\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02929", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 589, "cpu_time_ms": 173, "memory_kb": 1412}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s488489934", "group_id": "codeNet:p02934", "input_text": "#include\n#define pb push_back\n#define pair pair\n#define ll long long\n#define f first\n#define se second\nusing namespace std;\ndouble pi=acos(-1.0);\nint main(){\n int n;\n scanf(\"%d\",&n);\n double ans=0;\n double x;\n while(n--)\n {\n scanf(\"%lf\",&x);\n ans+=(1.0/x);\n }\n ans=(1.0/ans);\n printf(\"%.5lf\",ans);\n}", "language": "C++", "metadata": {"date": 1575728891, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02934/input.txt", "sample_output_relpath": "derived/input_output/data/p02934/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02934/C++/s488489934.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488489934", "user_id": "u768104057"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "#include\n#define pb push_back\n#define pair pair\n#define ll long long\n#define f first\n#define se second\nusing namespace std;\ndouble pi=acos(-1.0);\nint main(){\n int n;\n scanf(\"%d\",&n);\n double ans=0;\n double x;\n while(n--)\n {\n scanf(\"%lf\",&x);\n ans+=(1.0/x);\n }\n ans=(1.0/ans);\n printf(\"%.5lf\",ans);\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s188684535", "group_id": "codeNet:p02934", "input_text": "//#include \"stdc++.h\"\n#include\n#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double db;\ntypedef long double ldb;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pdd;\ntypedef vector vi;\n#define m1 make_pair\n#define pb push_back\n#define flush fflush(stdout)\n#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);\n#define reset(x,v) memset(x,v,sizeof(x))\n#define sz(x) (int)(x.size())\n#define ff first\n#define ss second\n#define endl \"\\n\"\n#define int long long int\ninline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}\ninline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}\nconst ll MOD = 1000000007;\nconst ll mod=1000000006;\nconst int INF = 0x3f3f3f3f;\nconst ll LL_INF = 0x3f3f3f3f3f3f3f3f;\n/*\n shuffle(x,x+n,rng) // shuffling elements of x in random order\n */\n\nint32_t main()\n{\n IOS;\n int n;\n cin>>n;\n int a[n];long double ans,sum=0.0;\n for(int i=0;i>a[i];\n sum=sum+(long double)1/a[i];\n }\n ans=1.0/sum;\n cout<\n#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double db;\ntypedef long double ldb;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pdd;\ntypedef vector vi;\n#define m1 make_pair\n#define pb push_back\n#define flush fflush(stdout)\n#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);\n#define reset(x,v) memset(x,v,sizeof(x))\n#define sz(x) (int)(x.size())\n#define ff first\n#define ss second\n#define endl \"\\n\"\n#define int long long int\ninline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}\ninline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}\nconst ll MOD = 1000000007;\nconst ll mod=1000000006;\nconst int INF = 0x3f3f3f3f;\nconst ll LL_INF = 0x3f3f3f3f3f3f3f3f;\n/*\n shuffle(x,x+n,rng) // shuffling elements of x in random order\n */\n\nint32_t main()\n{\n IOS;\n int n;\n cin>>n;\n int a[n];long double ans,sum=0.0;\n for(int i=0;i>a[i];\n sum=sum+(long double)1/a[i];\n }\n ans=1.0/sum;\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair l_l;\ntypedef pair i_i;\ntypedef pair s_i;\ntypedef vector vel;\ntypedef vector vei;\ntypedef vector vec;\ntypedef vector veb;\ntypedef vector ves;\ntypedef vector> ve_vel;\ntypedef vector> ve_vei;\ntypedef vector> ve_vec;\ntypedef vector> ve_veb;\ntypedef vector> ve_ves;\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n#define rep1(i,n) for(int i=1;i<(int)(n);i++)\n#define rep2(i,n) for(int i=2;i<(int)(n);i++)\n#define repk(i,k,n) for(int i=k;i<(int)(n);i++)\n#define fs first\n#define sc second\n#define pub push_back\n#define puf push_front\n#define pob pop_back\n#define all(a) a.begin(),a.end()\n#define rall(a) a.rbegin(),a.rend()\n#define maxel(a) *max_element(all(a))\n#define minel(a) *min_element(all(a))\n#define acc accumulate\n#define EPS (1e-7)\n//#define INF (1e9)\n#define PI (acos(-1))\n#define mod (1000000007)\ntypedef long long int64;\nconst int64 INF = 1LL << 58;\ntemplate bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }\ntemplate void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\n\tint N; cin >> N;\n\tvector A(N); rep(i,N) cin >> A[i];\n\n\tld bunbo = 0;\n\trep(i,N) bunbo += 1.0 / A[i];\n\tld ans = 1.0 / bunbo;\n\tcout << fixed << setprecision(10) << ans << endl;\n\treturn 0;\n\n \n}", "language": "C++", "metadata": {"date": 1566177022, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02934/input.txt", "sample_output_relpath": "derived/input_output/data/p02934/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02934/C++/s102926409.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s102926409", "user_id": "u263715385"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair l_l;\ntypedef pair i_i;\ntypedef pair s_i;\ntypedef vector vel;\ntypedef vector vei;\ntypedef vector vec;\ntypedef vector veb;\ntypedef vector ves;\ntypedef vector> ve_vel;\ntypedef vector> ve_vei;\ntypedef vector> ve_vec;\ntypedef vector> ve_veb;\ntypedef vector> ve_ves;\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n#define rep1(i,n) for(int i=1;i<(int)(n);i++)\n#define rep2(i,n) for(int i=2;i<(int)(n);i++)\n#define repk(i,k,n) for(int i=k;i<(int)(n);i++)\n#define fs first\n#define sc second\n#define pub push_back\n#define puf push_front\n#define pob pop_back\n#define all(a) a.begin(),a.end()\n#define rall(a) a.rbegin(),a.rend()\n#define maxel(a) *max_element(all(a))\n#define minel(a) *min_element(all(a))\n#define acc accumulate\n#define EPS (1e-7)\n//#define INF (1e9)\n#define PI (acos(-1))\n#define mod (1000000007)\ntypedef long long int64;\nconst int64 INF = 1LL << 58;\ntemplate bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }\ntemplate void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\n\tint N; cin >> N;\n\tvector A(N); rep(i,N) cin >> A[i];\n\n\tld bunbo = 0;\n\trep(i,N) bunbo += 1.0 / A[i];\n\tld ans = 1.0 / bunbo;\n\tcout << fixed << setprecision(10) << ans << endl;\n\treturn 0;\n\n \n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1622, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s414603809", "group_id": "codeNet:p02937", "input_text": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstring tre;\n\nbool moze(int n, string k){\n int j = 0;\n for (int i=0; i < n && j < k.length(); i++) \n if (k[j] == tre[i]) \n j++; \n \n return (j==k.length()); \n}\n\nint main() {\n string t;\n cin >> tre >> t;\n map ima;\n for (int i = 0; i < tre.length(); i++) \n ima[tre[i]] = true;\n for (int i = 0; i < t.length(); i++)\n if (!ima[t[i]]){\n cout << \"-1\";\n return 0;\n }\n int l = 1, r = 10000000;\n while (tre.size() < 10000000) tre += tre;\n while (l < r){\n int mid = (l+r)/2;\n if (!moze(mid,t)) l = mid + 1;\n else r = mid;\n }\n cout << l;\n}", "language": "C++", "metadata": {"date": 1566279026, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/C++/s414603809.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s414603809", "user_id": "u065859967"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstring tre;\n\nbool moze(int n, string k){\n int j = 0;\n for (int i=0; i < n && j < k.length(); i++) \n if (k[j] == tre[i]) \n j++; \n \n return (j==k.length()); \n}\n\nint main() {\n string t;\n cin >> tre >> t;\n map ima;\n for (int i = 0; i < tre.length(); i++) \n ima[tre[i]] = true;\n for (int i = 0; i < t.length(); i++)\n if (!ima[t[i]]){\n cout << \"-1\";\n return 0;\n }\n int l = 1, r = 10000000;\n while (tre.size() < 10000000) tre += tre;\n while (l < r){\n int mid = (l+r)/2;\n if (!moze(mid,t)) l = mid + 1;\n else r = mid;\n }\n cout << l;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 692, "cpu_time_ms": 389, "memory_kb": 19480}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s251527443", "group_id": "codeNet:p02942", "input_text": "#include \n#define st first\n#define nd second\n\nusing namespace std;\n\nvoid debug_out() { cerr << endl; }\ntemplate ostream& prnt(ostream& out, T v) { out << v.size() << '\\n'; for(auto e : v) out << e << ' '; return out;}\ntemplate ostream& operator<<(ostream& out, vector v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, set v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, map v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, pair p) { return out << '(' << p.st << ' ' << p.nd << ')'; }\ntemplate void debug_out(Head H, Tail... T) { cerr << \" \" << H; debug_out(T...);}\n\n#define dbg(...) cerr << #__VA_ARGS__ << \" ->\", debug_out(__VA_ARGS__)\n#define dbg_v(x, n) do{cerr<<#x\"[]: \";for(int _=0;_> G;\n\tvector L, R, Viz;\n \n\tBipartiteMatcher(int n, int m) {\n\t\tG.resize(n);\n\t\tL.resize(n, -1);\n\t\tR.resize(m, -1);\n\t\tViz.resize(n);\n\t}\n \n\tvoid AddEdge(int a, int b) {\n\t\tG[a].push_back(b);\n\t}\n \n\tbool Match(int node) {\n\t\tif(Viz[node]) \n\t\t\treturn false;\n\t\tViz[node] = true;\n\t\n\t\tfor(auto vec : G[node]) {\n\t\t\tif(R[vec] == -1 || Match(R[vec])) {\n\t\t\t\tL[node] = vec;\n\t\t\t\tR[vec] = node;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n \n\t\treturn false;\n\t}\n\tvoid Solve() {\n\t\tbool ok = true;\n\t\twhile(ok) {\n\t\t\tok = false;\n\t\t\tfill(Viz.begin(), Viz.end(), 0);\n\t\t\tfor(int i = 0; i < L.size(); ++i)\n\t\t\t\tif(L[i] == -1)\n\t\t\t\t\tok |= Match(i);\n\t\t}\n\t}\n};\n \n\nint main() {\n\tios_base::sync_with_stdio(false);\n\n\tcin >> n >> m;\n\tfor(int i= 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++) {\n\t\t\tcin >> a[i][j];\n\t\t\ta[i][j]--;\n\t\t}\n\n\tfor(int j = 0; j < m; j++) {\n\t\tBipartiteMatcher bm(n, n);\n\t\tdbg(j);\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tfor(int k = j; k < m; k++)\n\t\t\t\tbm.AddEdge(i, a[i][k] / m);\n\t\t// dbg_ok;\n\t\tbm.Solve();\n\t\t// dbg_ok;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tint sch = bm.L[i];\n\t\t\tdbg(i, sch);\n\t\t\tfor(int k = j; k < m; k++)\n\t\t\t\tif(a[i][k] / m == sch) {\n\t\t\t\t\tswap(a[i][k], a[i][j]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t}\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++)\n\t\t\tcout << a[i][j] << \" \\n\"[j == m - 1];\n\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++) {\n\t\t\tswap(a[i][j], a[a[i][j] / m][j]);\n\t\t}\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++)\n\t\t\tcout << a[i][j] << \" \\n\"[j == m - 1];\n}\t\n\n\t", "language": "C++", "metadata": {"date": 1567715873, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02942.html", "problem_id": "p02942", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02942/input.txt", "sample_output_relpath": "derived/input_output/data/p02942/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02942/C++/s251527443.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s251527443", "user_id": "u541161485"}, "prompt_components": {"gold_output": "2 6\n4 3\n5 1\n2 1\n4 3\n5 6\n", "input_to_evaluate": "#include \n#define st first\n#define nd second\n\nusing namespace std;\n\nvoid debug_out() { cerr << endl; }\ntemplate ostream& prnt(ostream& out, T v) { out << v.size() << '\\n'; for(auto e : v) out << e << ' '; return out;}\ntemplate ostream& operator<<(ostream& out, vector v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, set v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, map v) { return prnt(out, v); }\ntemplate ostream& operator<<(ostream& out, pair p) { return out << '(' << p.st << ' ' << p.nd << ')'; }\ntemplate void debug_out(Head H, Tail... T) { cerr << \" \" << H; debug_out(T...);}\n\n#define dbg(...) cerr << #__VA_ARGS__ << \" ->\", debug_out(__VA_ARGS__)\n#define dbg_v(x, n) do{cerr<<#x\"[]: \";for(int _=0;_> G;\n\tvector L, R, Viz;\n \n\tBipartiteMatcher(int n, int m) {\n\t\tG.resize(n);\n\t\tL.resize(n, -1);\n\t\tR.resize(m, -1);\n\t\tViz.resize(n);\n\t}\n \n\tvoid AddEdge(int a, int b) {\n\t\tG[a].push_back(b);\n\t}\n \n\tbool Match(int node) {\n\t\tif(Viz[node]) \n\t\t\treturn false;\n\t\tViz[node] = true;\n\t\n\t\tfor(auto vec : G[node]) {\n\t\t\tif(R[vec] == -1 || Match(R[vec])) {\n\t\t\t\tL[node] = vec;\n\t\t\t\tR[vec] = node;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n \n\t\treturn false;\n\t}\n\tvoid Solve() {\n\t\tbool ok = true;\n\t\twhile(ok) {\n\t\t\tok = false;\n\t\t\tfill(Viz.begin(), Viz.end(), 0);\n\t\t\tfor(int i = 0; i < L.size(); ++i)\n\t\t\t\tif(L[i] == -1)\n\t\t\t\t\tok |= Match(i);\n\t\t}\n\t}\n};\n \n\nint main() {\n\tios_base::sync_with_stdio(false);\n\n\tcin >> n >> m;\n\tfor(int i= 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++) {\n\t\t\tcin >> a[i][j];\n\t\t\ta[i][j]--;\n\t\t}\n\n\tfor(int j = 0; j < m; j++) {\n\t\tBipartiteMatcher bm(n, n);\n\t\tdbg(j);\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tfor(int k = j; k < m; k++)\n\t\t\t\tbm.AddEdge(i, a[i][k] / m);\n\t\t// dbg_ok;\n\t\tbm.Solve();\n\t\t// dbg_ok;\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tint sch = bm.L[i];\n\t\t\tdbg(i, sch);\n\t\t\tfor(int k = j; k < m; k++)\n\t\t\t\tif(a[i][k] / m == sch) {\n\t\t\t\t\tswap(a[i][k], a[i][j]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t}\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++)\n\t\t\tcout << a[i][j] << \" \\n\"[j == m - 1];\n\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++) {\n\t\t\tswap(a[i][j], a[a[i][j] / m][j]);\n\t\t}\n\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = 0; j < m; j++)\n\t\t\tcout << a[i][j] << \" \\n\"[j == m - 1];\n}\t\n\n\t", "problem_context": "Score : 1100 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares.\nEach integer from 1 to NM is written in this grid once.\nThe number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.\n\nYou need to rearrange these numbers as follows:\n\nFirst, for each of the N rows, rearrange the numbers written in it as you like.\n\nSecond, for each of the M columns, rearrange the numbers written in it as you like.\n\nFinally, for each of the N rows, rearrange the numbers written in it as you like.\n\nAfter rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\\times (i-1)+j.\nConstruct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.\n\nConstraints\n\n1 \\leq N,M \\leq 100\n\n1 \\leq A_{ij} \\leq NM\n\nA_{ij} are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_{11} A_{12} ... A_{1M}\n:\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint one way to rearrange the numbers in the following format:\n\nB_{11} B_{12} ... B_{1M}\n:\nB_{N1} B_{N2} ... B_{NM}\nC_{11} C_{12} ... C_{1M}\n:\nC_{N1} C_{N2} ... C_{NM}\n\nHere B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.\n\nSample Input 1\n\n3 2\n2 6\n4 3\n1 5\n\nSample Output 1\n\n2 6\n4 3\n5 1\n2 1\n4 3\n5 6\n\nSample Input 2\n\n3 4\n1 4 7 10\n2 5 8 11\n3 6 9 12\n\nSample Output 2\n\n1 4 7 10\n5 8 11 2\n9 12 3 6\n1 4 3 2\n5 8 7 6\n9 12 11 10", "sample_input": "3 2\n2 6\n4 3\n1 5\n"}, "reference_outputs": ["2 6\n4 3\n5 1\n2 1\n4 3\n5 6\n"], "source_document_id": "p02942", "source_text": "Score : 1100 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares.\nEach integer from 1 to NM is written in this grid once.\nThe number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.\n\nYou need to rearrange these numbers as follows:\n\nFirst, for each of the N rows, rearrange the numbers written in it as you like.\n\nSecond, for each of the M columns, rearrange the numbers written in it as you like.\n\nFinally, for each of the N rows, rearrange the numbers written in it as you like.\n\nAfter rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\\times (i-1)+j.\nConstruct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.\n\nConstraints\n\n1 \\leq N,M \\leq 100\n\n1 \\leq A_{ij} \\leq NM\n\nA_{ij} are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_{11} A_{12} ... A_{1M}\n:\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint one way to rearrange the numbers in the following format:\n\nB_{11} B_{12} ... B_{1M}\n:\nB_{N1} B_{N2} ... B_{NM}\nC_{11} C_{12} ... C_{1M}\n:\nC_{N1} C_{N2} ... C_{NM}\n\nHere B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.\n\nSample Input 1\n\n3 2\n2 6\n4 3\n1 5\n\nSample Output 1\n\n2 6\n4 3\n5 1\n2 1\n4 3\n5 6\n\nSample Input 2\n\n3 4\n1 4 7 10\n2 5 8 11\n3 6 9 12\n\nSample Output 2\n\n1 4 7 10\n5 8 11 2\n9 12 3 6\n1 4 3 2\n5 8 7 6\n9 12 11 10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2519, "cpu_time_ms": 36, "memory_kb": 512}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s713322334", "group_id": "codeNet:p02943", "input_text": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define R register\n\nint N, K;\nstring s, rev, tmp, str;\n\nint main() {\n\tcin >> N >> K >> s;\n\trev = s, reverse(rev.begin(), rev.end());\n\ttmp = s + rev, reverse(tmp.begin(), tmp.end());\n//cout << tmp << endl;\n\tstr = tmp.substr(0, N);\n\tfor(R int i = 1; i < N; ++i) {\n\t\trev = tmp.substr(i, N);\n\t\tif(rev < str) str = rev;\n\t}\n\treverse(str.begin(), str.end());\n//cout << str << endl;\n\tfor(R int i = 1, j; i < K; ++i) {\n\t\tfor(j = N - 2; ~j; --j) if(str[j] != str[N - 1]) break;\n\t\tstr = str + str.substr(j + 1, N);\n//cout << str << endl;\n\t\tj = str.length();\n\t\tstr = str.substr(j - N, N);\n//cout << str << endl;\n\t}\n\treverse(str.begin(), str.end());\n \tcout << str;\n \treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1566097652, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02943.html", "problem_id": "p02943", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02943/input.txt", "sample_output_relpath": "derived/input_output/data/p02943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02943/C++/s713322334.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s713322334", "user_id": "u907369450"}, "prompt_components": {"gold_output": "aabca\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define R register\n\nint N, K;\nstring s, rev, tmp, str;\n\nint main() {\n\tcin >> N >> K >> s;\n\trev = s, reverse(rev.begin(), rev.end());\n\ttmp = s + rev, reverse(tmp.begin(), tmp.end());\n//cout << tmp << endl;\n\tstr = tmp.substr(0, N);\n\tfor(R int i = 1; i < N; ++i) {\n\t\trev = tmp.substr(i, N);\n\t\tif(rev < str) str = rev;\n\t}\n\treverse(str.begin(), str.end());\n//cout << str << endl;\n\tfor(R int i = 1, j; i < K; ++i) {\n\t\tfor(j = N - 2; ~j; --j) if(str[j] != str[N - 1]) break;\n\t\tstr = str + str.substr(j + 1, N);\n//cout << str << endl;\n\t\tj = str.length();\n\t\tstr = str.substr(j - N, N);\n//cout << str << endl;\n\t}\n\treverse(str.begin(), str.end());\n \tcout << str;\n \treturn 0;\n}\n", "problem_context": "Score : 1300 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of lowercase English letters.\nOn this string, he will perform the following operation K times:\n\nLet T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order.\n\nLet S' be some contiguous substring of U with length N, and replace S with S'.\n\nAmong the strings that can be the string S after the K operations, find the lexicographically smallest possible one.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n|S|=N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the lexicographically smallest possible string that can be the string S after the K operations.\n\nSample Input 1\n\n5 1\nbacba\n\nSample Output 1\n\naabca\n\nWhen S=bacba, T=abcab, U=bacbaabcab, and the optimal choice of S' is S'=aabca.\n\nSample Input 2\n\n10 2\nbbaabbbaab\n\nSample Output 2\n\naaaabbaabb", "sample_input": "5 1\nbacba\n"}, "reference_outputs": ["aabca\n"], "source_document_id": "p02943", "source_text": "Score : 1300 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of lowercase English letters.\nOn this string, he will perform the following operation K times:\n\nLet T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order.\n\nLet S' be some contiguous substring of U with length N, and replace S with S'.\n\nAmong the strings that can be the string S after the K operations, find the lexicographically smallest possible one.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n|S|=N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the lexicographically smallest possible string that can be the string S after the K operations.\n\nSample Input 1\n\n5 1\nbacba\n\nSample Output 1\n\naabca\n\nWhen S=bacba, T=abcab, U=bacbaabcab, and the optimal choice of S' is S'=aabca.\n\nSample Input 2\n\n10 2\nbbaabbbaab\n\nSample Output 2\n\naaaabbaabb", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 765, "cpu_time_ms": 2103, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s549461439", "group_id": "codeNet:p02945", "input_text": "//\n// Created by 伊東麻沙美 on 2019/10/22.\n//\n\n#include\n#include\nusing namespace std;\n\n\nint main(){\n\n int a,b;\n cin>>a>>b;\n\n int num1,num2,num3,max;\n num1 = a+b;\n num2 = a-b;\n num3 = a*b;\n\n max = num1;\n if(max\n#include\nusing namespace std;\n\n\nint main(){\n\n int a,b;\n cin>>a>>b;\n\n int num1,num2,num3,max;\n num1 = a+b;\n num2 = a-b;\n num3 = a*b;\n\n max = num1;\n if(max\nusing namespace std;\n\nint main() {\n int k,x;cin>>k>>x;\n int tmp;\n \n for(int i=0;i<2*(k-1);++i){\n tmp=x-k+1+i;\n cout<\nusing namespace std;\n\nint main() {\n int k,x;cin>>k>>x;\n int tmp;\n \n for(int i=0;i<2*(k-1);++i){\n tmp=x-k+1+i;\n cout<\nusing namespace std;\n \nint main() {\n int n;\n cin >> n;\n \n vector>x(n,vector(10));\n for(int i=0; i> x[i][j];\n }\n sort(x.at(i).begin(),x.at(i).end());\n }\n \n int ans=0;\n \n for(int i=0; i\nusing namespace std;\n \nint main() {\n int n;\n cin >> n;\n \n vector>x(n,vector(10));\n for(int i=0; i> x[i][j];\n }\n sort(x.at(i).begin(),x.at(i).end());\n }\n \n int ans=0;\n \n for(int i=0; i\n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint N; cin >> N;\n\tstring s[N];\n\tint cc[N][26];\n\tfor(int i=0; i> s[i];\n\t\tfor (char c : s[i]) {\n\t\t\tint num = c - 'a';\n\t\t\tcc[i][num]++;\n\t\t}\n\t}\n\n\tlong long int ans = 0;\n\tfor (int i=0; i\n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint N; cin >> N;\n\tstring s[N];\n\tint cc[N][26];\n\tfor(int i=0; i> s[i];\n\t\tfor (char c : s[i]) {\n\t\t\tint num = c - 'a';\n\t\t\tcc[i][num]++;\n\t\t}\n\t}\n\n\tlong long int ans = 0;\n\tfor (int i=0; i\nusing namespace std;\n\n#define Q int t; scanf(\"%d\", &t); for(int q=1; q<=t; q++)\ntypedef long long int lli;\ntypedef pair pi;\n\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n priority_queuepq;\n vector v;\n for(int i=0; i> a >> b;\n v.push_back({a, b});\n }\n sort(v.begin(), v.end());\n int j=0;\n lli ans = 0;\n for(int i=1; i<=m; i++){\n while(j\nusing namespace std;\n\n#define Q int t; scanf(\"%d\", &t); for(int q=1; q<=t; q++)\ntypedef long long int lli;\ntypedef pair pi;\n\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n priority_queuepq;\n vector v;\n for(int i=0; i> a >> b;\n v.push_back({a, b});\n }\n sort(v.begin(), v.end());\n int j=0;\n lli ans = 0;\n for(int i=1; i<=m; i++){\n while(j\n#define int long long\nusing namespace std;\n\nsigned main(){\n\tint N,M; cin>>N>>M;\n\tvector> AB(N);\n\tfor(int i=0;i>AB[i].first>>AB[i].second;\n\t}\n\tsort(AB.begin(),AB.end());\n\tint p=0,ans=0;\n\tpriority_queue> que;\n\tfor(int i=1;i<=M;i++){\n\t\twhile(AB[p].first<=i and p tmp=make_pair(AB[p].second,AB[p].first);\n\t\t\tque.push(tmp);\n\t\t\tp++;\n\t\t}\n\t\tif(not que.empty()){\n\t\t\tpair tmp=que.top();\n\t\t\tque.pop();\n\t\t\tans+=tmp.first;\n\t\t}\n\t}\n\tcout<\n#define int long long\nusing namespace std;\n\nsigned main(){\n\tint N,M; cin>>N>>M;\n\tvector> AB(N);\n\tfor(int i=0;i>AB[i].first>>AB[i].second;\n\t}\n\tsort(AB.begin(),AB.end());\n\tint p=0,ans=0;\n\tpriority_queue> que;\n\tfor(int i=1;i<=M;i++){\n\t\twhile(AB[p].first<=i and p tmp=make_pair(AB[p].second,AB[p].first);\n\t\t\tque.push(tmp);\n\t\t\tp++;\n\t\t}\n\t\tif(not que.empty()){\n\t\t\tpair tmp=que.top();\n\t\t\tque.pop();\n\t\t\tans+=tmp.first;\n\t\t}\n\t}\n\tcout<\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\nusing namespace std;\n\n#define mod 1000000007\n\nint main() {\n\tint n, m;\n\tcin >> n >> m;\n\tvector > ab;\n\tfor (int i = 0; i < n; i++) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\tab.push_back(make_pair(a, b));\n\t}\n\tsort(ab.begin(), ab.end());\n\tlong long int ans = 0;\n\tint cnt = 0;\n\tpriority_queue qu;\n\tfor (int i = 0; i <= m; i++) {\n\t\tif (!qu.empty()) {\n\t\t\tans += qu.top();\n\t\t\tqu.pop();\n\t\t}\n\t\twhile (cnt < n && ab[cnt].first <= i + 1) {\n\t\t\tqu.push(ab[cnt].second);\n\t\t\tcnt++;\n\t\t}\n\t}\n\tcout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1584675295, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/C++/s357158814.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357158814", "user_id": "u261965335"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#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\nusing namespace std;\n\n#define mod 1000000007\n\nint main() {\n\tint n, m;\n\tcin >> n >> m;\n\tvector > ab;\n\tfor (int i = 0; i < n; i++) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\tab.push_back(make_pair(a, b));\n\t}\n\tsort(ab.begin(), ab.end());\n\tlong long int ans = 0;\n\tint cnt = 0;\n\tpriority_queue qu;\n\tfor (int i = 0; i <= m; i++) {\n\t\tif (!qu.empty()) {\n\t\t\tans += qu.top();\n\t\t\tqu.pop();\n\t\t}\n\t\twhile (cnt < n && ab[cnt].first <= i + 1) {\n\t\t\tqu.push(ab[cnt].second);\n\t\t\tcnt++;\n\t\t}\n\t}\n\tcout << ans << endl;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 852, "cpu_time_ms": 68, "memory_kb": 1908}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s903198876", "group_id": "codeNet:p02948", "input_text": "#include\n#include\n#include\nusing lint=int64_t;\nusing namespace std;\n\nbool cmp(pair l,pair r)\n{\n\tif(l.first!=r.first)\n\t\treturn l.first>r.first;\n\treturn l.second>r.second;\n}\n\nint main()\n{\n\tlint N,M;\n\tpair p[100010]{};\n\n\tcin >> N >> M;\n\tfor(lint i=0;i> p[i].first;\n\t\tcin >> p[i].second;\n\t}\n\n\tsort(p,p+N);\n\n\tpriority_queue que;\n\tlint index=0;\n\tlint ans=0;\n\tfor(lint i=1;i<=M;i++)\n\t{\n\t\twhile(index\n#include\n#include\nusing lint=int64_t;\nusing namespace std;\n\nbool cmp(pair l,pair r)\n{\n\tif(l.first!=r.first)\n\t\treturn l.first>r.first;\n\treturn l.second>r.second;\n}\n\nint main()\n{\n\tlint N,M;\n\tpair p[100010]{};\n\n\tcin >> N >> M;\n\tfor(lint i=0;i> p[i].first;\n\t\tcin >> p[i].second;\n\t}\n\n\tsort(p,p+N);\n\n\tpriority_queue que;\n\tlint index=0;\n\tlint ans=0;\n\tfor(lint i=1;i<=M;i++)\n\t{\n\t\twhile(index\nusing namespace std;\nusing ll = long long;\nusing pii = pair;\nusing vi = vector;\nusing vl = vector;\n#define rep(i, n) for(ll i = 0;i < n;i++)\n#define all(i) i.begin(), i.end()\ntemplate bool cmax(T& a, U b) { if (a bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }\n\nint n, m;\n\nbool comp(const pii &l, const pii &r){\n return l.second > r.second;\n}\n\nint main() {\n cin.tie(0); ios::sync_with_stdio(false);\n\n cin >> n >> m;\n vector> a(n);\n rep(i, n) {\n cin >> a[i].first >> a[i].second;\n }\n\n sort(all(a), comp);\n\n// cerr << endl;\n// rep(i, n) {\n// cerr << a[i].first << \" \" << a[i].second << endl;\n// }\n// cerr << endl;\n\n multimap d;\n int i = 0;\n int j = 0;\n ll ans = 0;\n while(j < n && i <= m) {\n //cerr << i << \" \" << j << endl;\n if (m >= i+a[j].first) {\n ans += a[j].second;\n d.insert({m-a[i].first, i});\n i++;\n j++;\n } else {\n auto ite = d.lower_bound(i);\n if (ite != d.end() && (*ite).second <= m-a[j].first) {\n auto tmp = *ite;\n d.erase(ite);\n d.insert({tmp.first, i});\n ans += a[j].second;\n i++;\n j++;\n } else {\n j++;\n }\n }\n }\n\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1565490709, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/C++/s016979875.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s016979875", "user_id": "u366644013"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\nusing pii = pair;\nusing vi = vector;\nusing vl = vector;\n#define rep(i, n) for(ll i = 0;i < n;i++)\n#define all(i) i.begin(), i.end()\ntemplate bool cmax(T& a, U b) { if (a bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }\n\nint n, m;\n\nbool comp(const pii &l, const pii &r){\n return l.second > r.second;\n}\n\nint main() {\n cin.tie(0); ios::sync_with_stdio(false);\n\n cin >> n >> m;\n vector> a(n);\n rep(i, n) {\n cin >> a[i].first >> a[i].second;\n }\n\n sort(all(a), comp);\n\n// cerr << endl;\n// rep(i, n) {\n// cerr << a[i].first << \" \" << a[i].second << endl;\n// }\n// cerr << endl;\n\n multimap d;\n int i = 0;\n int j = 0;\n ll ans = 0;\n while(j < n && i <= m) {\n //cerr << i << \" \" << j << endl;\n if (m >= i+a[j].first) {\n ans += a[j].second;\n d.insert({m-a[i].first, i});\n i++;\n j++;\n } else {\n auto ite = d.lower_bound(i);\n if (ite != d.end() && (*ite).second <= m-a[j].first) {\n auto tmp = *ite;\n d.erase(ite);\n d.insert({tmp.first, i});\n ans += a[j].second;\n i++;\n j++;\n } else {\n j++;\n }\n }\n }\n\n cout << ans << endl;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1360, "cpu_time_ms": 49, "memory_kb": 8064}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s452436352", "group_id": "codeNet:p02948", "input_text": "\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 ll long long\n#define ld long double\n#define EPS 1e-9\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< vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef pair ppi;\ntypedef pair pip;\ntypedef vector vp;\ntypedef vector vvi;\n\nint gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}\nint lcm(int a, int b){return a/gcd(a,b)*b;}\n\n\nsigned main(void) {\n int n,m;\n cin >> n >> m;\n vvi v(m);\n rep(i,n){\n int a,b;\n cin >> a >> b;\n if(m-a >= 0 && m-a < m)v[m-a].push_back(b);\n }\n int ans = 0;\n priority_queue q;\n rep(i,m){\n int now = m-i-1;\n rep(j,v[now].size()){\n //cout << \"!\" << v[now][j] << endl;\n q.push(v[now][j]);\n }\n if(q.size()){\n ans += q.top();\n q.pop();\n }\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1565486236, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/C++/s452436352.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s452436352", "user_id": "u471289663"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\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 ll long long\n#define ld long double\n#define EPS 1e-9\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< vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef pair ppi;\ntypedef pair pip;\ntypedef vector vp;\ntypedef vector vvi;\n\nint gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}\nint lcm(int a, int b){return a/gcd(a,b)*b;}\n\n\nsigned main(void) {\n int n,m;\n cin >> n >> m;\n vvi v(m);\n rep(i,n){\n int a,b;\n cin >> a >> b;\n if(m-a >= 0 && m-a < m)v[m-a].push_back(b);\n }\n int ans = 0;\n priority_queue q;\n rep(i,m){\n int now = m-i-1;\n rep(j,v[now].size()){\n //cout << \"!\" << v[now][j] << endl;\n q.push(v[now][j]);\n }\n if(q.size()){\n ans += q.top();\n q.pop();\n }\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1452, "cpu_time_ms": 69, "memory_kb": 5632}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s708914205", "group_id": "codeNet:p02951", "input_text": "#include \n\nint main()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n int ans=c-a+b;\n printf(\"%d\",ans);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1565841546, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02951/input.txt", "sample_output_relpath": "derived/input_output/data/p02951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02951/C++/s708914205.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s708914205", "user_id": "u493708099"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\nint main()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n int ans=c-a+b;\n printf(\"%d\",ans);\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s361178050", "group_id": "codeNet:p02955", "input_text": "#include\nusing namespace std;\n#define ll long long\nconst ll p=1000000007ll;\nconst int N=200005;\ntemplateinline void cmin(IT &a,IT b){if(binline void cmax(IT &a,IT b){if(a\nusing namespace std;\n#define ll long long\nconst ll p=1000000007ll;\nconst int N=200005;\ntemplateinline void cmin(IT &a,IT b){if(binline void cmax(IT &a,IT b){if(a\nusing namespace std;\n#define _GLIBCXX_DEBUG\n#define rep(i,n) for(long long i = 0; i < (n); ++i)\n#define ll long long\n#define P pair\n#define all(v) (v).begin(),(v).end()\n\nconst ll mod = 1e9+7;\nconst ll INF = 1e18;\nconst double pi = acos(-1.0);\n\nint main(void)\n{\n ll n, ans=0;\n cin >> n;\n vector a(n+1), b(n);\n rep(i,n+1) cin >> a[i];\n rep(i,n) cin >> b[i];\n rep(i,n){\n ll l = min(a[i], b[i]);\n ans += l;\n a[i] -= l;\n b[i] -= l;\n ll r = min(a[i+1], b[i]);\n ans += r;\n a[i] -= r;\n b[i] -= r;\n }\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1598724694, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02959.html", "problem_id": "p02959", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02959/input.txt", "sample_output_relpath": "derived/input_output/data/p02959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02959/C++/s262016904.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s262016904", "user_id": "u025469035"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#include \nusing namespace std;\n#define _GLIBCXX_DEBUG\n#define rep(i,n) for(long long i = 0; i < (n); ++i)\n#define ll long long\n#define P pair\n#define all(v) (v).begin(),(v).end()\n\nconst ll mod = 1e9+7;\nconst ll INF = 1e18;\nconst double pi = acos(-1.0);\n\nint main(void)\n{\n ll n, ans=0;\n cin >> n;\n vector a(n+1), b(n);\n rep(i,n+1) cin >> a[i];\n rep(i,n) cin >> b[i];\n rep(i,n){\n ll l = min(a[i], b[i]);\n ans += l;\n a[i] -= l;\n b[i] -= l;\n ll r = min(a[i+1], b[i]);\n ans += r;\n a[i] -= r;\n b[i] -= r;\n }\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 645, "cpu_time_ms": 72, "memory_kb": 4852}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s628362788", "group_id": "codeNet:p02959", "input_text": "#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n long long a[n+1];\n for(int i=0;i>a[i];\n long long b[n];\n long long monster=0;\n for(int i=0;i>b[i];\n for(int i=0;i\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n long long a[n+1];\n for(int i=0;i>a[i];\n long long b[n];\n long long monster=0;\n for(int i=0;i>b[i];\n for(int i=0;i\n#define all(vec) vec.begin(), vec.end()\n#define pb push_back\n#define eb emplace_back\nusing namespace std;\nusing ll = long long;\nusing P = pair;\ntemplate \nusing V = vector;\nconstexpr ll INF = (1LL << 30) - 1LL;\nconstexpr ll MOD = 1e9 + 7;\nconstexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};\ntemplate \nvoid chmin(T &a, T b) { a = min(a, b); }\ntemplate \nvoid chmax(T &a, T b) { a = max(a, b); }\nvoid ok() { cerr << \"ok\" << endl; }\nusing ull = uint64_t;\nconst int bases[64] = {257, 262, 266, 275, 276, 281, 285, 290, 296, 302, 306,\n 310, 311, 313, 323, 333, 344, 345, 350, 357, 367, 370,\n 373, 402, 423, 425, 431, 440, 442, 443, 454, 457, 458,\n 462, 471, 478, 481, 487, 489, 492, 499, 501, 502, 503,\n 506, 514, 524, 532, 535, 541, 550, 552, 557, 559, 562,\n 563, 567, 570, 571, 580, 592, 597, 604, 612};\nconst ull rmod = 0x1fffffffffffffff;\nconst ull base = bases[chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count() & 63];\nconst ull mask30 = (1UL << 30) - 1, mask31 = (1UL << 31) - 1;\nstruct RollingHash {\n vector hash, pow;\n inline ull mul(const ull &a, const ull &b) const {\n ull mid = (a & mask31) * (b >> 31) + (a >> 31) * (b & mask31);\n ull res = (a >> 31) * (b >> 31) * 2 + (mid >> 30) + ((mid & mask30) << 31);\n res += (a & mask31) * (b & mask31);\n res = (res >> 61) + (res & rmod);\n if (res >= rmod) res -= rmod;\n return res;\n }\n RollingHash(const string &s) {\n hash.resize(s.length() + 1);\n pow.resize(s.length() + 1);\n pow[0] = 1;\n for (int i = 0; i < s.length(); i++) {\n hash[i + 1] = mul(hash[i], base) + s[i];\n pow[i + 1] = mul(pow[i], base);\n if (hash[i + 1] >= rmod) hash[i + 1] -= rmod;\n }\n }\n ull get(int l, int r) { //[l,r]\n ull res = hash[r + 1] + rmod - mul(hash[l], pow[r + 1 - l]);\n if (res >= rmod) res -= rmod;\n return res;\n }\n};\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n string s, t;\n cin >> s >> t;\n int n = s.length(), m = t.length();\n while (s.length() < n + m) {\n s += s;\n }\n RollingHash hs(s), ht(t);\n vector f(n), vis(n, -1);\n for (int i = 0; i < n; i++) {\n if (hs.get(i, i + m - 1) == ht.get(0, m - 1)) {\n f[i] = 1;\n }\n }\n int ans = 0;\n for (int i = 0; i < n; i++) {\n if (!f[i] || vis[i] != -1) {\n continue;\n }\n int co = 0, id = i;\n vector v;\n while (1) {\n v.push_back(id);\n co++;\n id += m;\n id %= n;\n if (f[id]) {\n if (id == i) {\n cout << -1 << endl;\n return 0;\n }\n if (vis[id] != -1) {\n co += vis[id];\n break;\n }\n vis[id] = 0;\n } else {\n break;\n }\n }\n vis[i] = co;\n chmax(ans, co);\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1586658305, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02962.html", "problem_id": "p02962", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02962/input.txt", "sample_output_relpath": "derived/input_output/data/p02962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02962/C++/s301845067.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301845067", "user_id": "u924339359"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#define all(vec) vec.begin(), vec.end()\n#define pb push_back\n#define eb emplace_back\nusing namespace std;\nusing ll = long long;\nusing P = pair;\ntemplate \nusing V = vector;\nconstexpr ll INF = (1LL << 30) - 1LL;\nconstexpr ll MOD = 1e9 + 7;\nconstexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};\ntemplate \nvoid chmin(T &a, T b) { a = min(a, b); }\ntemplate \nvoid chmax(T &a, T b) { a = max(a, b); }\nvoid ok() { cerr << \"ok\" << endl; }\nusing ull = uint64_t;\nconst int bases[64] = {257, 262, 266, 275, 276, 281, 285, 290, 296, 302, 306,\n 310, 311, 313, 323, 333, 344, 345, 350, 357, 367, 370,\n 373, 402, 423, 425, 431, 440, 442, 443, 454, 457, 458,\n 462, 471, 478, 481, 487, 489, 492, 499, 501, 502, 503,\n 506, 514, 524, 532, 535, 541, 550, 552, 557, 559, 562,\n 563, 567, 570, 571, 580, 592, 597, 604, 612};\nconst ull rmod = 0x1fffffffffffffff;\nconst ull base = bases[chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count() & 63];\nconst ull mask30 = (1UL << 30) - 1, mask31 = (1UL << 31) - 1;\nstruct RollingHash {\n vector hash, pow;\n inline ull mul(const ull &a, const ull &b) const {\n ull mid = (a & mask31) * (b >> 31) + (a >> 31) * (b & mask31);\n ull res = (a >> 31) * (b >> 31) * 2 + (mid >> 30) + ((mid & mask30) << 31);\n res += (a & mask31) * (b & mask31);\n res = (res >> 61) + (res & rmod);\n if (res >= rmod) res -= rmod;\n return res;\n }\n RollingHash(const string &s) {\n hash.resize(s.length() + 1);\n pow.resize(s.length() + 1);\n pow[0] = 1;\n for (int i = 0; i < s.length(); i++) {\n hash[i + 1] = mul(hash[i], base) + s[i];\n pow[i + 1] = mul(pow[i], base);\n if (hash[i + 1] >= rmod) hash[i + 1] -= rmod;\n }\n }\n ull get(int l, int r) { //[l,r]\n ull res = hash[r + 1] + rmod - mul(hash[l], pow[r + 1 - l]);\n if (res >= rmod) res -= rmod;\n return res;\n }\n};\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n string s, t;\n cin >> s >> t;\n int n = s.length(), m = t.length();\n while (s.length() < n + m) {\n s += s;\n }\n RollingHash hs(s), ht(t);\n vector f(n), vis(n, -1);\n for (int i = 0; i < n; i++) {\n if (hs.get(i, i + m - 1) == ht.get(0, m - 1)) {\n f[i] = 1;\n }\n }\n int ans = 0;\n for (int i = 0; i < n; i++) {\n if (!f[i] || vis[i] != -1) {\n continue;\n }\n int co = 0, id = i;\n vector v;\n while (1) {\n v.push_back(id);\n co++;\n id += m;\n id %= n;\n if (f[id]) {\n if (id == i) {\n cout << -1 << endl;\n return 0;\n }\n if (vis[id] != -1) {\n co += vis[id];\n break;\n }\n vis[id] = 0;\n } else {\n break;\n }\n }\n vis[i] = co;\n chmax(ans, co);\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "sample_input": "abcabab\nab\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02962", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3236, "cpu_time_ms": 49, "memory_kb": 50524}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s931836121", "group_id": "codeNet:p02962", "input_text": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pullull;\ntypedef pair plli;\ntypedef pair pipii;\ntypedef vector > mati;\ntypedef vector > matd;\ntypedef vector vll;\ntypedef vector> vvll;\ntypedef vector>> vvvll;\ntypedef vector vb;\ntypedef vector> vvb;\ntypedef vector>> vvvb;\ntypedef vector vpll;\n\n#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)\n#define REP(i,y) FOR(i, 0, y)\n#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)\n#define RREP(i,x) RFOR(i, x, 0)\n#define ALL(a) a.begin(), a.end()\n#define pb push_back\n\ninline void IN(void){\n return;\n}\n\ntemplate \nvoid IN(First& first, Rest&... rest){\n cin >> first;\n IN(rest...);\n return;\n}\n\ninline void OUT(void){\n cout << \"\\n\";\n return;\n}\n\ntemplate \nvoid OUT(First first, Rest... rest){\n cout << first << \" \";\n OUT(rest...);\n return;\n}\n\nconstexpr int INF = (1<<30);\nconstexpr ll INFLL = 1LL<<62;\nconstexpr long double EPS = 1e-12;\nconstexpr ll MOD = (ll)((1E+9)+7);\n\n/*\nclass KMP{\n private:\n string S;\n string W;\n vector T;\n vector flag;\n\n public:\n void make_table(void){\n T.resize(W.size());\n ll i = 2;\n ll j = 0;\n T[0] = -1;\n T[1] = 0;\n\n while(i0){\n j = T[j];\n }else{\n T[i] = 0;\n i++;\n }\n }\n return;\n }\n\n KMP(string s, string w){\n S = s;\n W = w;\n make_table();\n flag.resize(S.size(), false);\n return;\n };\n\n ~KMP(void){\n return;\n };\n\n ll local_search(ll start){\n ll m = 0; // the start position in S\n ll i = start; // the start position in W\n\n while(m+i0) i=T[i];\n }\n }\n return -1;\n };\n\n void total_search(void){\n ll m = 0; // the start position in S\n ll i = 0; // the start position in W\n\n while(m+i0) i=T[i];\n }\n }\n return;\n };\n\n bool start_check(ll start){\n return flag[start];\n };\n};\n*/\n\nclass Z_algorithm{\n public:\n string S;\n vector A;\n Z_algorithm(string s){\n S = s;\n A.resize(S.size());\n return;\n };\n\n ~Z_algorithm(void){\n return;\n };\n\n void calc(void){\n A[0] = S.size();\n ll i=1, j=0;\n while(i=0) return dp[pos];\n return dp[pos] = calc(n_pos, init) + 1;\n}\n\nint main(){\n string s_base, t_base;\n IN(s_base);\n IN(t_base);\n\n string s = s_base;\n string t = t_base;\n\n while(s.size()<2*t.size()){\n s += s_base;\n }\n\n jump.resize(s_base.size());\n REP(i,s_base.size()) jump[i] = -1;\n\n /*\n REP(s_start, s_base.size()){\n bool flag = true;\n REP(t_diff,t.size()){\n if(s[t_diff+s_start] != t[t_diff]){\n flag = false;\n break;\n }\n }\n if(!flag) continue;\n\n jump[s_start] = (s_start + t.size())%s_base.size();\n }\n */\n\n /*\n KMP kmp(s, t);\n kmp.total_search();\n REP(i,s_base.size()){\n if(!kmp.start_check(i)) jump[i] = -1;\n else jump[i] = (i+t.size())%s_base.size();\n }\n */\n\n Z_algorithm ZA(s);\n ZA.calc(t);\n REP(i,s_base.size()){\n if(ZA.A[t.size()+i] < t.size()) continue;\n jump[i] = (i+t.size())%s_base.size();\n }\n\n REP(i,s_base.size()){\n //printf(\"%lld %lld\\n\", i, jump[i]);\n }\n\n dp.resize(jump.size());\n REP(i,dp.size()){\n dp[i] = -1;\n }\n\n REP(i,dp.size()){\n calc(i, i);\n if(!total_flag) break;\n }\n\n ll ans = 0;\n REP(i,dp.size()){\n ans = max(ans, dp[i]);\n //printf(\"%lld %lld\\n\", i, dp[i]);\n }\n\n if(total_flag){\n printf(\"%lld\\n\", ans);\n }else{\n printf(\"-1\\n\");\n }\n\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1564471844, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02962.html", "problem_id": "p02962", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02962/input.txt", "sample_output_relpath": "derived/input_output/data/p02962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02962/C++/s931836121.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s931836121", "user_id": "u355335354"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pullull;\ntypedef pair plli;\ntypedef pair pipii;\ntypedef vector > mati;\ntypedef vector > matd;\ntypedef vector vll;\ntypedef vector> vvll;\ntypedef vector>> vvvll;\ntypedef vector vb;\ntypedef vector> vvb;\ntypedef vector>> vvvb;\ntypedef vector vpll;\n\n#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)\n#define REP(i,y) FOR(i, 0, y)\n#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)\n#define RREP(i,x) RFOR(i, x, 0)\n#define ALL(a) a.begin(), a.end()\n#define pb push_back\n\ninline void IN(void){\n return;\n}\n\ntemplate \nvoid IN(First& first, Rest&... rest){\n cin >> first;\n IN(rest...);\n return;\n}\n\ninline void OUT(void){\n cout << \"\\n\";\n return;\n}\n\ntemplate \nvoid OUT(First first, Rest... rest){\n cout << first << \" \";\n OUT(rest...);\n return;\n}\n\nconstexpr int INF = (1<<30);\nconstexpr ll INFLL = 1LL<<62;\nconstexpr long double EPS = 1e-12;\nconstexpr ll MOD = (ll)((1E+9)+7);\n\n/*\nclass KMP{\n private:\n string S;\n string W;\n vector T;\n vector flag;\n\n public:\n void make_table(void){\n T.resize(W.size());\n ll i = 2;\n ll j = 0;\n T[0] = -1;\n T[1] = 0;\n\n while(i0){\n j = T[j];\n }else{\n T[i] = 0;\n i++;\n }\n }\n return;\n }\n\n KMP(string s, string w){\n S = s;\n W = w;\n make_table();\n flag.resize(S.size(), false);\n return;\n };\n\n ~KMP(void){\n return;\n };\n\n ll local_search(ll start){\n ll m = 0; // the start position in S\n ll i = start; // the start position in W\n\n while(m+i0) i=T[i];\n }\n }\n return -1;\n };\n\n void total_search(void){\n ll m = 0; // the start position in S\n ll i = 0; // the start position in W\n\n while(m+i0) i=T[i];\n }\n }\n return;\n };\n\n bool start_check(ll start){\n return flag[start];\n };\n};\n*/\n\nclass Z_algorithm{\n public:\n string S;\n vector A;\n Z_algorithm(string s){\n S = s;\n A.resize(S.size());\n return;\n };\n\n ~Z_algorithm(void){\n return;\n };\n\n void calc(void){\n A[0] = S.size();\n ll i=1, j=0;\n while(i=0) return dp[pos];\n return dp[pos] = calc(n_pos, init) + 1;\n}\n\nint main(){\n string s_base, t_base;\n IN(s_base);\n IN(t_base);\n\n string s = s_base;\n string t = t_base;\n\n while(s.size()<2*t.size()){\n s += s_base;\n }\n\n jump.resize(s_base.size());\n REP(i,s_base.size()) jump[i] = -1;\n\n /*\n REP(s_start, s_base.size()){\n bool flag = true;\n REP(t_diff,t.size()){\n if(s[t_diff+s_start] != t[t_diff]){\n flag = false;\n break;\n }\n }\n if(!flag) continue;\n\n jump[s_start] = (s_start + t.size())%s_base.size();\n }\n */\n\n /*\n KMP kmp(s, t);\n kmp.total_search();\n REP(i,s_base.size()){\n if(!kmp.start_check(i)) jump[i] = -1;\n else jump[i] = (i+t.size())%s_base.size();\n }\n */\n\n Z_algorithm ZA(s);\n ZA.calc(t);\n REP(i,s_base.size()){\n if(ZA.A[t.size()+i] < t.size()) continue;\n jump[i] = (i+t.size())%s_base.size();\n }\n\n REP(i,s_base.size()){\n //printf(\"%lld %lld\\n\", i, jump[i]);\n }\n\n dp.resize(jump.size());\n REP(i,dp.size()){\n dp[i] = -1;\n }\n\n REP(i,dp.size()){\n calc(i, i);\n if(!total_flag) break;\n }\n\n ll ans = 0;\n REP(i,dp.size()){\n ans = max(ans, dp[i]);\n //printf(\"%lld %lld\\n\", i, dp[i]);\n }\n\n if(total_flag){\n printf(\"%lld\\n\", ans);\n }else{\n printf(\"-1\\n\");\n }\n\n\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "sample_input": "abcabab\nab\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02962", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n\nThere exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.\n\nNotes\n\nA string a is a substring of another string b if and only if there exists an integer x (0 \\leq x \\leq |b| - |a|) such that, for any y (1 \\leq y \\leq |a|), a_y = b_{x+y} holds.\n\nWe assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.\n\nConstraints\n\n1 \\leq |s| \\leq 5 \\times 10^5\n\n1 \\leq |t| \\leq 5 \\times 10^5\n\ns and t consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.\n\nSample Input 1\n\nabcabab\nab\n\nSample Output 1\n\n3\n\nThe concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.\n\nOn the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.\n\nSimilarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.\n\nSample Input 2\n\naa\naaaaaaa\n\nSample Output 2\n\n-1\n\nFor any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.\n\nSample Input 3\n\naba\nbaaab\n\nSample Output 3\n\n0\n\nAs stated in Notes, i = 0 always satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4830, "cpu_time_ms": 152, "memory_kb": 32180}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s598107180", "group_id": "codeNet:p02963", "input_text": "#include \n#define rep(i,n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst ll e9 = 1000000000;\n\nint main() {\n ll s;\n cin >> s;\n ll x1 = 0, y1 = 0;\n ll x2 = e9, y2 = 1;\n ll x3 = (s % e9) + e9;\n ll y3 = s / e9 + 1;\n cout << x1 << ' ' << y1 << ' ';\n cout << x2 << ' ' << y2 << ' ';\n cout << x3 << ' ' << y3;\n return 0;\n}", "language": "C++", "metadata": {"date": 1600137813, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/C++/s598107180.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s598107180", "user_id": "u171336585"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "#include \n#define rep(i,n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst ll e9 = 1000000000;\n\nint main() {\n ll s;\n cin >> s;\n ll x1 = 0, y1 = 0;\n ll x2 = e9, y2 = 1;\n ll x3 = (s % e9) + e9;\n ll y3 = s / e9 + 1;\n cout << x1 << ' ' << y1 << ' ';\n cout << x2 << ' ' << y2 << ' ';\n cout << x3 << ' ' << y3;\n return 0;\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 419, "cpu_time_ms": 10, "memory_kb": 3520}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s453454310", "group_id": "codeNet:p02963", "input_text": "#include\nint main(){\n unsigned long long int s;\n scanf(\"%ulld\",&s);\n if(s%2==0){\n printf(\"0 0 2 0 0 %ulld\",s/2);\n }\n else{\n printf(\"1 0 0 %ld 2 %ulld\",s/2+1,s/2);\n }\n}\n", "language": "C++", "metadata": {"date": 1563760094, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/C++/s453454310.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s453454310", "user_id": "u222643545"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "#include\nint main(){\n unsigned long long int s;\n scanf(\"%ulld\",&s);\n if(s%2==0){\n printf(\"0 0 2 0 0 %ulld\",s/2);\n }\n else{\n printf(\"1 0 0 %ld 2 %ulld\",s/2+1,s/2);\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s207700475", "group_id": "codeNet:p02964", "input_text": "#include \nusing namespace std;\nusing ll = long long;\nll INF = 1e9+7;\nint main()\n{\n ll n, k;\n cin >> n >> k;\n vector a(n);\n for(int i = 0; i < n; i++) cin >> a[i];\n vector ar = a;\n reverse(ar.begin(), ar.end());\n vector> pos(2*1e5+10);\n for(int i = 0; i < n; i++)\n {\n pos[ar[i]].insert(i+1);\n if(pos[ar[i]].size() == 1)\n {\n pos[ar[i]].insert(i+1+n);\n }\n }\n\n vector start(n+1);\n int p = 1;\n ll v = ar[0];\n ll ans = 0;\n while(true)\n {\n ll next = *(pos[v].lower_bound(p+1));\n if(next == n)\n {\n start[ans] = next; \n break;\n }\n else if(next == 2*n)\n {\n ans++;\n start[ans] = next - n;\n break;\n }\n else if(next > n)\n {\n p = next+1-n;\n ans++;\n start[ans] = p-1;\n }\n else\n {\n p = next+1;\n start[ans] = next;\n }\n v = ar[p-1];\n }\n ans++;\n ll count = k % ans;\n if(count == 0) return 0;\n ll s = start[ans-count];\n stack sta;\n set tmp;\n for(int i = n-s; i < n; i++)\n {\n if(tmp.find(a[i]) == tmp.end())\n {\n tmp.insert(a[i]);\n sta.push(a[i]);\n }\n else\n {\n while(true)\n {\n ll cand = sta.top();\n sta.pop();\n tmp.erase(cand);\n if(cand == a[i])\n {\n break;\n }\n }\n }\n }\n stack ansq;\n ll size = sta.size();\n for(int i = 0; i < size; i++)\n {\n ll cand = sta.top();\n sta.pop();\n ansq.push(cand);\n }\n ll anss = ansq.size();\n for(int i = 0; i < anss; i++)\n {\n ll cand = ansq.top();\n ansq.pop();\n cout << cand << \" \";\n }\n}\n", "language": "C++", "metadata": {"date": 1571506098, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02964.html", "problem_id": "p02964", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02964/input.txt", "sample_output_relpath": "derived/input_output/data/p02964/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02964/C++/s207700475.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207700475", "user_id": "u410878763"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\nll INF = 1e9+7;\nint main()\n{\n ll n, k;\n cin >> n >> k;\n vector a(n);\n for(int i = 0; i < n; i++) cin >> a[i];\n vector ar = a;\n reverse(ar.begin(), ar.end());\n vector> pos(2*1e5+10);\n for(int i = 0; i < n; i++)\n {\n pos[ar[i]].insert(i+1);\n if(pos[ar[i]].size() == 1)\n {\n pos[ar[i]].insert(i+1+n);\n }\n }\n\n vector start(n+1);\n int p = 1;\n ll v = ar[0];\n ll ans = 0;\n while(true)\n {\n ll next = *(pos[v].lower_bound(p+1));\n if(next == n)\n {\n start[ans] = next; \n break;\n }\n else if(next == 2*n)\n {\n ans++;\n start[ans] = next - n;\n break;\n }\n else if(next > n)\n {\n p = next+1-n;\n ans++;\n start[ans] = p-1;\n }\n else\n {\n p = next+1;\n start[ans] = next;\n }\n v = ar[p-1];\n }\n ans++;\n ll count = k % ans;\n if(count == 0) return 0;\n ll s = start[ans-count];\n stack sta;\n set tmp;\n for(int i = n-s; i < n; i++)\n {\n if(tmp.find(a[i]) == tmp.end())\n {\n tmp.insert(a[i]);\n sta.push(a[i]);\n }\n else\n {\n while(true)\n {\n ll cand = sta.top();\n sta.pop();\n tmp.erase(cand);\n if(cand == a[i])\n {\n break;\n }\n }\n }\n }\n stack ansq;\n ll size = sta.size();\n for(int i = 0; i < size; i++)\n {\n ll cand = sta.top();\n sta.pop();\n ansq.push(cand);\n }\n ll anss = ansq.size();\n for(int i = 0; i < anss; i++)\n {\n ll cand = ansq.top();\n ansq.pop();\n cout << cand << \" \";\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a sequence of N \\times K integers: X=(X_0,X_1,\\cdots,X_{N \\times K-1}).\nIts elements are represented by another sequence of N integers: A=(A_0,A_1,\\cdots,A_{N-1}). For each pair i, j (0 \\leq i \\leq K-1,\\ 0 \\leq j \\leq N-1), X_{i \\times N + j}=A_j holds.\n\nSnuke has an integer sequence s, which is initially empty.\nFor each i=0,1,2,\\cdots,N \\times K-1, in this order, he will perform the following operation:\n\nIf s does not contain X_i: add X_i to the end of s.\n\nIf s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do not add X_i to the end of s.\n\nFind the elements of s after Snuke finished the operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 10^{12}\n\n1 \\leq A_i \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 \\cdots A_{N-1}\n\nOutput\n\nPrint the elements of s after Snuke finished the operations, in order from beginning to end, with spaces in between.\n\nSample Input 1\n\n3 2\n1 2 3\n\nSample Output 1\n\n2 3\n\nIn this case, X=(1,2,3,1,2,3).\nWe will perform the operations as follows:\n\ni=0: s does not contain 1, so we add 1 to the end of s, resulting in s=(1).\n\ni=1: s does not contain 2, so we add 2 to the end of s, resulting in s=(1,2).\n\ni=2: s does not contain 3, so we add 3 to the end of s, resulting in s=(1,2,3).\n\ni=3: s does contain 1, so we repeatedly delete the element at the end of s as long as s contains 1, which causes the following changes to s: (1,2,3)→(1,2)→(1)→().\n\ni=4: s does not contain 2, so we add 2 to the end of s, resulting in s=(2).\n\ni=5: s does not contain 3, so we add 3 to the end of s, resulting in s=(2,3).\n\nSample Input 2\n\n5 10\n1 2 3 2 3\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6 1000000000000\n1 1 2 2 3 3\n\nSample Output 3\n\ns may be empty in the end.\n\nSample Input 4\n\n11 97\n3 1 4 1 5 9 2 6 5 3 5\n\nSample Output 4\n\n9 2 6", "sample_input": "3 2\n1 2 3\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02964", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a sequence of N \\times K integers: X=(X_0,X_1,\\cdots,X_{N \\times K-1}).\nIts elements are represented by another sequence of N integers: A=(A_0,A_1,\\cdots,A_{N-1}). For each pair i, j (0 \\leq i \\leq K-1,\\ 0 \\leq j \\leq N-1), X_{i \\times N + j}=A_j holds.\n\nSnuke has an integer sequence s, which is initially empty.\nFor each i=0,1,2,\\cdots,N \\times K-1, in this order, he will perform the following operation:\n\nIf s does not contain X_i: add X_i to the end of s.\n\nIf s does contain X_i: repeatedly delete the element at the end of s until s no longer contains X_i. Note that, in this case, we do not add X_i to the end of s.\n\nFind the elements of s after Snuke finished the operations.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq 10^{12}\n\n1 \\leq A_i \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_0 A_1 \\cdots A_{N-1}\n\nOutput\n\nPrint the elements of s after Snuke finished the operations, in order from beginning to end, with spaces in between.\n\nSample Input 1\n\n3 2\n1 2 3\n\nSample Output 1\n\n2 3\n\nIn this case, X=(1,2,3,1,2,3).\nWe will perform the operations as follows:\n\ni=0: s does not contain 1, so we add 1 to the end of s, resulting in s=(1).\n\ni=1: s does not contain 2, so we add 2 to the end of s, resulting in s=(1,2).\n\ni=2: s does not contain 3, so we add 3 to the end of s, resulting in s=(1,2,3).\n\ni=3: s does contain 1, so we repeatedly delete the element at the end of s as long as s contains 1, which causes the following changes to s: (1,2,3)→(1,2)→(1)→().\n\ni=4: s does not contain 2, so we add 2 to the end of s, resulting in s=(2).\n\ni=5: s does not contain 3, so we add 3 to the end of s, resulting in s=(2,3).\n\nSample Input 2\n\n5 10\n1 2 3 2 3\n\nSample Output 2\n\n3\n\nSample Input 3\n\n6 1000000000000\n1 1 2 2 3 3\n\nSample Output 3\n\ns may be empty in the end.\n\nSample Input 4\n\n11 97\n3 1 4 1 5 9 2 6 5 3 5\n\nSample Output 4\n\n9 2 6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1940, "cpu_time_ms": 232, "memory_kb": 45440}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s935226814", "group_id": "codeNet:p02966", "input_text": "/*\n * Author : YangDavid\n * Created Time : 2019年07月22日 星期一 11时13分09秒\n */\n\n#include\n#define rep(i, n) for(int i = 1; i <= n; ++i)\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\n\nconst int maxn = 555;\nconst ll INF = 0x3f3f3f3f3f3f3f3f;\nint n, a[maxn][maxn];\nll dp[maxn][maxn], pre1[maxn][maxn], pre2[maxn][maxn];\nvoid upd(ll &x, ll y) { if(x > y) x = y; }\n\nint main() {\n scanf(\"%d\", &n);\n rep(i, n) rep(j, n) if(i != j) scanf(\"%d\", &a[i][j]);\n rep(i, n) rep(j, n) {\n pre1[i][j] = pre1[i - 1][j] + pre1[i][j - 1] - pre1[i - 1][j - 1] + a[i][j];\n pre2[i][j] = pre2[i - 1][j] + pre2[i][j - 1] - pre2[i - 1][j - 1] + (i\n#define rep(i, n) for(int i = 1; i <= n; ++i)\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\n\nconst int maxn = 555;\nconst ll INF = 0x3f3f3f3f3f3f3f3f;\nint n, a[maxn][maxn];\nll dp[maxn][maxn], pre1[maxn][maxn], pre2[maxn][maxn];\nvoid upd(ll &x, ll y) { if(x > y) x = y; }\n\nint main() {\n scanf(\"%d\", &n);\n rep(i, n) rep(j, n) if(i != j) scanf(\"%d\", &a[i][j]);\n rep(i, n) rep(j, n) {\n pre1[i][j] = pre1[i - 1][j] + pre1[i][j - 1] - pre1[i - 1][j - 1] + a[i][j];\n pre2[i][j] = pre2[i - 1][j] + pre2[i][j - 1] - pre2[i - 1][j - 1] + (i\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)<(int)(n);++(i))\n#define Sort(a) sort(a.begin(), a.end())\n#define Reverse(a) reverse(a.begin(), a.end())\n\n#define eb emplace_back\n#define dbg(x) cout<<#x\" = \"<<((x))< P;\n \n \nint main(){\n ll N;\n\n cin >> N;\n\n#ifdef DEBUG\n cout << \"N=\" << endl;\n#endif\n\n ll arr[N];\n ll max = 0;\n ll max2 = 0;\n int max_index = 0;\n for(int i = 0; i < N; i++){\n cin >> arr[i];\n if(arr[i] > max){\n max2 = max;\n max = arr[i];\n max_index = i;\n } else if (arr[i] > max2){\n max2 = arr[i];\n }\n }\n\n for(int i = 0; i < N; i++){\n if(i == max_index) cout << max2 << endl;\n else cout << max << endl;\n }\n \n return 0;\n}\n", "language": "C++", "metadata": {"date": 1563671539, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02971.html", "problem_id": "p02971", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02971/input.txt", "sample_output_relpath": "derived/input_output/data/p02971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02971/C++/s357719254.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357719254", "user_id": "u714724786"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "#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)<(int)(n);++(i))\n#define Sort(a) sort(a.begin(), a.end())\n#define Reverse(a) reverse(a.begin(), a.end())\n\n#define eb emplace_back\n#define dbg(x) cout<<#x\" = \"<<((x))< P;\n \n \nint main(){\n ll N;\n\n cin >> N;\n\n#ifdef DEBUG\n cout << \"N=\" << endl;\n#endif\n\n ll arr[N];\n ll max = 0;\n ll max2 = 0;\n int max_index = 0;\n for(int i = 0; i < N; i++){\n cin >> arr[i];\n if(arr[i] > max){\n max2 = max;\n max = arr[i];\n max_index = i;\n } else if (arr[i] > max2){\n max2 = arr[i];\n }\n }\n\n for(int i = 0; i < N; i++){\n if(i == max_index) cout << max2 << endl;\n else cout << max << endl;\n }\n \n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1102, "cpu_time_ms": 364, "memory_kb": 3200}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s406428675", "group_id": "codeNet:p02973", "input_text": "#include \nusing namespace std;\n\nbool chmax(long long &a, long long b){\n if(a <= b){\n a = b;\n return true;\n }else{\n return false;\n }\n}\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 reverse(A.begin(), A.end());\n long long now = A[0];\n int cnt = 1;\n for(int i = 1; i < N; i++){\n if(chmax(now, A[i])){\n cnt++;\n }\n }\n cout << cnt << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1571319515, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02973.html", "problem_id": "p02973", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02973/input.txt", "sample_output_relpath": "derived/input_output/data/p02973/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02973/C++/s406428675.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s406428675", "user_id": "u615258936"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nbool chmax(long long &a, long long b){\n if(a <= b){\n a = b;\n return true;\n }else{\n return false;\n }\n}\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 reverse(A.begin(), A.end());\n long long now = A[0];\n int cnt = 1;\n for(int i = 1; i < N; i++){\n if(chmax(now, A[i])){\n cnt++;\n }\n }\n cout << cnt << endl;\n return 0;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "sample_input": "5\n2\n1\n4\n5\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02973", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n\nIf A_i and A_j (i < j) are painted with the same color, A_i < A_j.\n\nFind the minimum number of colors required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint the minimum number of colors required to satisfy the condition.\n\nSample Input 1\n\n5\n2\n1\n4\n5\n3\n\nSample Output 1\n\n2\n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.\n\nSample Input 2\n\n4\n0\n0\n0\n0\n\nSample Output 2\n\n4\n\nWe have to paint all the integers with distinct colors.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 501, "cpu_time_ms": 43, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s109717720", "group_id": "codeNet:p02975", "input_text": "#include \nusing namespace std;\n\ntemplate using V = vector;\ntemplate using VV = V>;\ntemplate using VVV = V>;\ntemplate using P = pair;\ntemplate using TP = tuple;\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing dbl = double;\nusing str = string;\nusing vll = V;\nusing vvll = V;\nusing vvvll = V;\nusing pl = P;\nusing tl = TP;\nusing vpl = V;\nusing vvpl = V;\nusing vtl = V;\nusing vvtl = V;\nusing vs = V;\nusing vvs = V;\nusing vd = V;\nusing vvd = V;\nusing qll = queue;\nusing qpl = queue;\nusing stll = stack;\nusing stpl = stack;\nusing mapll = map;\nusing setll = set;\nusing pqll = priority_queue;\n\n#define int ll\n#define fi first\n#define se second\n#define mp make_pair\n#define mt make_tuple\n#define pb push_back\n#define pob pop_back()\n#define pf push_front\n#define pof pop_front()\n#define sz size()\n#define bgn begin()\n#define en end()\n#define asn assign\n#define emp empty()\n#define fr front()\n#define bk back()\n#define clr clear()\n#define ins insert\n#define ers erase\n#define res resize\n#define tp top()\n#define p_q priority_queue\n#define inv inverse()\n\n#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)\n#define rFOR(i,a,b) for(ll i=(b);i>=(ll)(a);i--)\n#define REP(i,a) FOR((i),0,(ll)(a)-1)\n#define REP0(i,a) FOR((i),0,(ll)(a))\n#define REP1(i,a) FOR((i),1,(ll)(a))\n#define rREP(i,a) rFOR((i),0,(ll)(a)-1)\n#define rREP0(i,a) rFOR((i),0,(ll)(a))\n#define rREP1(i,a) rFOR((i),1,(ll)(a))\n#define ROR(v,i) for(auto &(i):(v))\n#define IOTA(a,n) iota((a).bgn,(a).en,(n))\n#define SORT(a) sort((a).bgn,(a).en)\n#define rSORT(a) sort((a).rbegin(),(a).rend())\n#define UNIQUE(a) (a).erase(unique((a).bgn,(a).en),(a).en)\n#define PREVP(a) prev_permutation((a).bgn,(a).en)\n#define NEXTP(a) next_permutation((a).bgn,(a).en)\n#define BINS(a,b) binary_search((a).bgn,(a).en,(b))\n#define LOWB(a,b) (lower_bound((a).bgn,(a).en,(b))-(a).bgn)\n#define UPB(a,b) (upper_bound((a).bgn,(a).en,(b))-(a).bgn)\n#define CNT(a,b) count((a).bgn,(a).en,b)\n#define SUM(a) accumulate((a).bgn,(a).en,0)\n#define REV(a) reverse((a).bgn,(a).en)\n#define REGS(a,b) regex_search((a),regex(b))\n#define REGM(a,b) regex_match((a),regex(b))\n#define yn(a) cout <<((a)?\"yes\":\"no\")<<\"\\n\";\n#define Yn(a) cout <<((a)?\"Yes\":\"No\")<<\"\\n\";\n#define YN(a) cout <<((a)?\"YES\":\"NO\")<<\"\\n\";\n#define imp(a) cout <<((a)?\"possible\":\"impossible\")<<\"\\n\";\n#define Imp(a) cout <<((a)?\"Possible\":\"Impossible\")<<\"\\n\";\n#define IMP(a) cout <<((a)?\"POSSIBLE\":\"IMPOSSIBLE\")<<\"\\n\";\n#define fs(a) cout <<((a)?\"second\":\"first\")<<\"\\n\";\n#define Fs(a) cout <<((a)?\"Second\":\"First\")<<\"\\n\";\n#define FS(a) cout <<((a)?\"SECOND\":\"FIRST\")<<\"\\n\";\n#define sak cout <<\"\\n\";\n#define sas cout <<\" \";\n#define sat cout <<\"\\t\";\n#define dbg(a) cerr <<(#a)<<\": \"<<(a)<<\"\\n\";\n#define dbgs(...) dal(#__VA_ARGS__);dal(__VA_ARGS__);\n#define c2l(a) ((ll)(a-48))\n#define a2l(a) ((ll)(a-97))\n#define A2l(a) ((ll)(a-65))\n#define l2c(a) ((char)(a+48))\n#define l2a(a) ((char)(a+97))\n#define l2A(a) ((char)(a+65))\n#define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1))\n#define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1))\n#define Dig2(a,b) (((a)>>(b))&1)\n#define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10)\n#define Pow2(a) ((ll)(1)<<(a))\n#define Pow10(a) ((ll)(pow(10.0,double(a))))\n#define LSB(a) ((a)&(-(a)))\n#define vin(v) ROR((v),(i)){cin >>(i);};\n#define vllin(v,N) vll (v)((N));vin(v);\n#define vllin2(a,b,N) vll (a)(N),(b)(N);REP(i,N){cin>>(a)[i]>>(b)[i];};\n#define vsin(v,N) vs (v)((N));vin(v);\n#define rdn(a,b) ((a)/(b))\n#define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1))\n#define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1))\n#define min(...) Min(__VA_ARGS__)\n#define max(...) Max(__VA_ARGS__)\n#define emin(a, ...) ((a)=Min((a),__VA_ARGS__))\n#define emax(a, ...) ((a)=Max((a),__VA_ARGS__))\n#define egcd(a, ...) ((a)=gcd((a),__VA_ARGS__))\n#define elcm(a, ...) ((a)=lcm((a),__VA_ARGS__))\n#define powll(a,b) (ll)(pow((double)(a),(double)(b)))\n#define Triangle(x1,y1,x2,y2,x3,y3) (((x1)-(x2))*((y1)-(y3))-((x1)-(x3))*((y1)-(y2)))\n\n#define svll SumV\n#define svvll SumV2\n\n#define li(...) ll __VA_ARGS__;Input(__VA_ARGS__);\n#define si(...) str __VA_ARGS__;Input(__VA_ARGS__);\n#define vli(size, ...) vll __VA_ARGS__;vInput(size,__VA_ARGS__);\n#define vsi(size, ...) vs __VA_ARGS__;vInput(size,__VA_ARGS__);\n\nconst ll MOD = 1e9 + 7;\n//const ll MOD = 998244353;\n//const ll MOD = 924844033;\n//const ll MOD = 9007199254740881;\nconst ll INF = 1LL << 60;//1.15e18\nconst double PI = acos(-1.0);\nconst vll DX = { 0,-1,0,1,0,-1,1,1,-1 };\nconst vll DY = { 0,0,-1,0,1,-1,-1,1,1 };\nconst str alp = \"abcdefghijklmnopqrstuvwxyz\";\nconst str ALP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n\nvoid Input() {}\ntemplate void Input(Var& var, Args&... args) {\n cin >> var;\n Input(args...);\n}\n\nvoid vInit(ll size) {}\ntemplate void vInit(ll size, V& v, Args&... args) {\n v.res(size);\n vInit(size, args...);\n}\nvoid vInputNum(ll num) {}\ntemplate void vInputNum(ll num, V& v, Args&... args) {\n cin >> v[num];\n vInputNum(num, args...);\n}\nvoid vInput(ll size) {}\ntemplate void vInput(ll size, Args&... args) {\n vInit(size, args...);\n REP(i, size) vInputNum(i, args...);\n}\n\ntemplate ostream &operator<<(ostream &out, const P &p) {\n return out << \"[\" << p.fi << \", \" << p.se << \"]\";\n}\n\ntemplate ostream &operator<<(ostream &out, V &v) {\n if (v.emp) return out << \"{}\";\n else {\n auto itr = v.bgn;\n out << \"{\" << *itr;\n itr++;\n while (itr != v.en) {\n out << \", \" << *itr;\n itr++;\n }\n out << \"}\";\n return out;\n }\n}\n\ntemplate ostream &operator<<(ostream &out, const map &m) {\n if (m.emp) return out << \"<[]>\";\n else {\n auto itr = m.bgn;\n out << \"< [\" << (itr->fi) << \": \" << (itr->se);\n itr++;\n while (itr != m.en) {\n out << \"], [\" << (itr->fi) << \": \" << (itr->se);\n itr++;\n }\n out << \"] >\";\n return out;\n }\n}\n\ntemplate ostream &operator<<(ostream &out, const set &s) {\n if (s.emp) return out << \"<>\";\n else {\n auto itr = s.bgn;\n out << \"<\" << *itr;\n itr++;\n while (itr != s.en) {\n out << \", \" << *itr;\n itr++;\n }\n out << \">\";\n return out;\n }\n}\n\nvoid say() {}\ntemplate void say(T t) { cout << t; }\ntemplate void say(Head head, Body... body) {\n cout << head << \" \";\n say(body...);\n}\nvoid sal() { cout << \"\\n\"; }\ntemplate void sal(Args... args) {\n say(args...);\n cout << \"\\n\";\n}\n\nvoid day() {}\ntemplate void day(T t) { cerr << t; }\ntemplate void day(Head head, Body... body) {\n cerr << head << \" \";\n day(body...);\n}\nvoid dal() { cerr << \"\\n\"; }\ntemplate void dal(Args... args) {\n day(args...);\n cerr << \"\\n\";\n}\n\nvoid salv() {}\ntemplate void salv(V v) {\n if (v.emp) sal();\n else {\n auto itr = v.bgn;\n say(*itr);\n itr++;\n while (itr != v.en) {\n sas;\n say(*itr);\n itr++;\n }\n sak;\n }\n}\ntemplate void salv(V v, Args... args) {\n salv(v);\n salv(args...);\n}\n\nvoid salv2() {}\ntemplate void salv2(V> v) {\n if (v.emp) sal();\n else {\n ROR(v, i) salv(i);\n }\n}\ntemplate void salv2(V> v, Args... args) {\n salv2(v);\n salv2(args...);\n}\n\ntemplate struct Action {\npublic:\n Monoid I;\n function A;\n Action(Monoid I, function A) : I(I), A(A) {}\n Monoid operator()() { return I; }\n Monoid operator()(Monoid x) { return x; }\n Monoid operator()(Monoid l, Monoid r) { return A(l, r); }\n template Monoid operator()(Monoid x, Args... args) {\n Monoid tmp = operator()(args...); \n return A(x, tmp);\n }\n};\n\ntemplate Action ADD = Action(0, [](T l, T r) { return l + r; });\ntemplate <> Action ADD = Action(\"\", [](str l, str r) { return l + r; });\ntemplate Action> ADD> = Action>(mp(ADD.I, ADD.I), [](P l, P r) { return mp(l.fi + r.fi, l.se + r.se); });\n\ntemplate Action MUL = Action(1, [](T l, T r) { return l * r; });\ntemplate Action OR = Action(0, [](T l, T r) { return l | r; });\ntemplate Action XOR = Action(0, [](T l, T r) { return l ^ r; });\n\ntemplate Action AND = Action(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; });\ntemplate <> Action AND = Action(true, [](bool l, bool r) { return l & r; });\ntemplate <> Action AND = Action(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; });\n\ntemplate Action MIN = Action(INF, [](T l, T r) { return (l < r) ? l : r; });\ntemplate Action MAX = Action(-INF, [](T l, T r) { return (l > r) ? l : r; });\n\ntemplate Action GCD = Action(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD(r, l%r) : l); });\ntemplate Action LCM = Action(1, [](T l, T r) { return (l * r) / GCD(l, r); });\n\n\ntemplate Head Min(Head head) { return head; }\ntemplate Head Min(Head head, Body... body) {\n auto tmp = Min(body...);\n return (head < tmp) ? head : tmp;\n}\n\ntemplate Head Max(Head head) { return head; }\ntemplate auto Max(Head head, Body... body) {\n auto tmp = Max(body...);\n return (head > tmp) ? head : tmp;\n}\n\nll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a%b) : a; }\nll lcm(ll a, ll b) { return a / gcd(a, b)*b; }\n\nll gcd(ll head) { return head; }\ntemplate ll gcd(ll head, Body... body) {\n return gcd(head, gcd(body...));\n}\n\nll lcm(ll head) { return head; }\ntemplate ll lcm(ll head, Body... body) {\n return lcm(head, lcm(body...));\n}\n\n\nll Bset(ll a, ll b, ll c) {\n if (c) a |= b;\n else a &= ~b;\n return a;\n}\n\n\nstruct UFT {\n\npublic:\n ll tsize;\n ll mode;\n vll par;\n vll rank;\n UFT() {}\n UFT(const UFT &uft) {}\n UFT(ll tsizeget, ll modeget = 0){\n tsize = tsizeget;\n mode = modeget;\n par.asn(tsize, -1);\n if (!mode) rank.res(tsize, 0);\n }\n ll root(ll x) {\n return par[x] < 0 ? x : par[x] = root(par[x]);\n }\n bool isRoot(ll x) {\n return x == root(x);\n }\n bool same(ll x, ll y) {\n return root(x) == root(y);\n }\n void merge(ll x, ll y) {\n x = root(x);\n y = root(y);\n if (x == y) return;\n if (mode) {\n par[x] += par[y];\n par[y] = x;\n }\n else {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = y;\n }\n else {\n par[x] += par[y];\n par[y] = x;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n }\n ll size(ll x) {\n return -par[root(x)];\n }\n};\n\nstruct pUFT {\n\npublic:\n\n ll tsize;\n ll now;\n vll par;\n vll rank;\n vll mtime;\n vvll sizepi;\n vvll sizepv;\n\n pUFT(){}\n pUFT(const pUFT &puft) {}\n\n pUFT(ll tsizeget) {\n tsize = tsizeget;\n now = 0;\n par.asn(tsize, -1);\n rank.asn(tsize, 0);\n mtime.asn(tsize, INF);\n sizepi.asn(tsize, { 0 });\n sizepv.asn(tsize, { 1 });\n }\n ll root(ll x, ll t) {\n return (mtime[x] > t) ? x : root(par[x], t);\n }\n bool same(ll x, ll y, ll t) {\n return root(x, t) == root(y, t);\n }\n ll merge(ll x, ll y) {\n now++;\n x = root(x, now);\n y = root(y, now);\n if (x != y) {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n sizepi[y].pb(now);\n sizepv[y].pb(-par[y]);\n par[x] = y;\n mtime[x] = now;\n }\n else {\n par[x] += par[y];\n sizepi[x].pb(now);\n sizepv[x].pb(-par[x]);\n par[y] = x;\n mtime[y] = now;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n return now;\n }\n ll size(ll x, ll t) {\n x = root(x, t);\n return sizepv[x][UPB(sizepi[x], t) - 1];\n }\n\n};\n\nstruct wUFT {\npublic:\n ll tsize;\n ll mode;\n vll par;\n vll rank;\n vll dweight;\n wUFT() {}\n wUFT(const wUFT &wuft) {}\n wUFT(ll tsizeget, ll modeget = 0) {\n tsize = tsizeget;\n mode = modeget;\n par.asn(tsize, -1);\n if (!mode) rank.res(tsize, 0);\n dweight.asn(tsize, 0);\n }\n ll root(ll x) {\n if (par[x] < 0) return x;\n else {\n ll r = root(par[x]);\n dweight[x] += dweight[par[x]];\n return par[x] = r;\n }\n }\n ll weight(ll x) {\n root(x);\n return dweight[x];\n }\n ll diff(ll x, ll y) {\n return weight(y) - weight(x);\n }\n bool isRoot(ll x) {\n return x == root(x);\n }\n bool same(ll x, ll y) {\n return root(x) == root(y);\n }\n void merge(ll x, ll y, ll w) {\n w += weight(x);\n w -= weight(y);\n x = root(x);\n y = root(y);\n if (x == y) return;\n if (mode) {\n par[x] += par[y];\n par[y] = x;\n }\n else {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = y;\n dweight[x] = -w;\n }\n else {\n par[x] += par[y];\n par[y] = x;\n if (rank[x] == rank[y]) rank[x]++;\n dweight[y] = w;\n }\n }\n }\n ll size(ll x) {\n return -par[root(x)];\n }\n};\n\ntemplate class SegT {\n\npublic:\n\n ll size;\n vector v;\n\n valtype initv;\n function calc;\n\n SegT() {}\n SegT(const SegT &segt) {}\n\n SegT(ll sizeget, ll modeget = 0) {\n sizeset(sizeget);\n modeset(modeget);\n init();\n }\n SegT(vector cpyvec, ll modeget = 0) {\n sizeset(cpyvec.sz);\n modeset(modeget);\n init();\n copy(cpyvec);\n }\n SegT(ll sizeget, valtype initvget, function calcget) {\n sizeset(sizeget);\n initv = initvget;\n calc = calcget;\n init();\n }\n SegT(vector cpyvec, valtype initvget, function calcget) {\n sizeset(cpyvec.sz);\n initv = initvget;\n calc = calcget;\n init();\n copy(cpyvec);\n }\n void sizeset(ll rsize) {\n size = DigN2(rsize);\n if (rsize == Pow2(size - 1)) size--;\n return;\n }\n void modeset(ll mode) {\n switch (mode) {\n case 0:\n initv = 0;\n calc = [](valtype x, valtype y) {return x + y; };\n break;\n case 1:\n initv = INF;\n calc = [](valtype x, valtype y) {return min(x, y); };\n break;\n case 2:\n initv = -INF;\n calc = [](valtype x, valtype y) {return max(x, y); };\n break;\n }\n return;\n }\n void init() {\n v.asn(Pow2(size + 1) - 1, initv);\n }\n void copy(vector cpyvec) {\n REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]);\n }\n ll i2v(ll i) const{\n if (i < 0 || i >= Pow2(size)) return -1;\n return Pow2(size) + i - 1;\n }\n ll top(ll i) const{\n if (i == 0) return -1;\n return (i - 1) / 2;\n }\n pl bot(ll i) const{\n if (i + 1 >= Pow2(size)) return mp(-1, -1);\n return mp(2 * i + 1, 2 * i + 2);\n }\n void set(ll i, valtype x) {\n i = i2v(i);\n v[i] = x;\n while (i > 0) {\n i = top(i);\n v[i] = calc(v[bot(i).fi], v[bot(i).se]);\n }\n return;\n }\n void add(ll i, valtype x) {\n set(i, v[i2v(i)] + x);\n return;\n }\n valtype operator[](const ll &i) const {\n return v[i2v(i)];\n }\n// valtype que(ll a = 0, ll b = Pow2(size) - 1) {\n valtype que(ll a, ll b) {\n if (a == b) return v[i2v(a)];\n if (a > b) return initv;//swap(a, b);\n valtype ans = initv;\n ll ai = i2v(a);\n ll bi = i2v(b);\n FOR(i, 1, size + 1) {\n if (a > b) break;\n if (a%Pow2(i)) {\n ans = calc(ans, v[ai]);\n a += Pow2(i - 1);\n ai = top(ai) + 1;\n }\n else {\n ai = top(ai);\n }\n if (a > b) break;\n if ((b + 1) % Pow2(i)) {\n ans = calc(ans, v[bi]);\n b -= Pow2(i - 1);\n bi = top(bi) - 1;\n }\n else {\n bi = top(bi);\n }\n if (a > b) break;\n }\n return ans;\n }\n valtype que(ll b) {\n return que(0, b);\n }\n valtype que() {\n return que(0, Pow2(size) - 1);\n }\n\n\n};\n\ntemplate class Graph {\n\npublic:\n \n ll size;\n ll mode;\n ll mapmode;\n lentype zlen;\n lentype ilen;\n vector> v2n;\n vvll n2v;\n vector> Edge;\n vector> Primresult;\n\n Graph() {}\n Graph(const Graph &graph) {}\n\n Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) {\n size = sizeget;\n mapmode = mapmodeget;\n mode = modeget;\n zlen = zlenget;\n ilen = ilenget;\n init();\n }\n void init() {\n Edge.res(size);\n v2n.res(size);\n n2v.res(size);\n Primresult.asn(size, mp(ilen, -1));\n }\n lentype lenplus(lentype l, lentype r) {\n return l + r;\n }\n lentype lenequal(lentype l, lentype r) {\n return l == r;\n }\n lentype lenlcr(lentype l, lentype r) {\n return l < r;\n }\n ll addV(ll vs) {\n size += vs;\n init();\n return size;\n }\n void caddE(ll x, ll y, lentype c) {\n if (mapmode) v2n[x][y] = Edge[x].sz;\n Edge[x].pb(c);\n n2v[x].pb(y);\n }\n void csetE(ll x, ll y, lentype c) {\n if (mapmode) Edge[x][v2n[x][y]] = c;\n }\n void cersE(ll x, ll y) {\n if (mapmode) {\n ll n = v2n[x][y];\n Edge[x][n] = ilen;\n n2v[x][n] = -1;\n v2n[x].ers(y);\n }\n }\n void addE(ll x, ll y, lentype c) {\n caddE(x, y, c);\n if (!mode) caddE(y, x, c);\n }\n void setE(ll x, ll y, lentype c) {\n csetE(x, y, c);\n if (!mode) csetE(y, x, c);\n }\n void ersE(ll x, ll y, lentype c) {\n cersE(x, y, c);\n if (!mode) cersE(y, x, c);\n }\n lentype getE(ll x, ll y) {\n if (mapmode) {\n if (v2n[x].count(y)) {\n return Edge[x][v2n[x][y]];\n }\n }\n return ilen;\n }\n ll getVsz(ll x) {\n return Edge[x].sz;\n }\n pair getV(ll x, ll n) {\n if (n >= getVsz(x)) return mp(ilen, -1);\n return mp(Edge[x][n], n2v[x][n]);\n }\n\n vector> Dijk(ll x) {\n vector> result(size);\n REP(i, size) {\n result[i].fi = ilen;\n result[i].se = { -1 };\n }\n vll stat(size, 0);\n pair now;\n pair nowlv;\n SegT> Q(size, mp(ilen, -1), [](pair l, pair r) {\n if (l.se == -1) return r;\n if (r.se == -1) return l;\n return l.fi < r.fi ? l : r;\n });\n Q.set(x, mp(zlen, x));\n result[x].fi = zlen;\n result[x].se = { -1 };\n while (Q.que(0, size - 1).se != -1) {\n now = Q.que(0, size - 1);\n Q.set(now.se, mp(ilen, -1));\n stat[now.se] = 1;\n REP(i, getVsz(now.se)) {\n nowlv = getV(now.se, i);\n if (stat[nowlv.se]) continue;\n if (Q[nowlv.se].se == -1) {\n result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi);\n result[nowlv.se].se = { now.se };\n Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se));\n }\n else {\n if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) {\n result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi);\n result[nowlv.se].se = { now.se };\n Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se));\n }\n else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) {\n result[nowlv.se].se.pb(now.se);\n }\n }\n }\n }\n return result;\n }\n\n lentype Prim(ll x = 0) {\n lentype ans = zlen;\n vll stat(size, 0);\n pair now;\n pair nowlv;\n SegT> Q(size, mp(ilen, -1), [](pair l, pair r) {\n if (l.se == -1) return r;\n if (r.se == -1) return l;\n return l.fi < r.fi ? l : r;\n });\n Q.set(x, mp(zlen, x));\n Primresult[x] = mp(zlen, -1);\n while (Q.que(0, size - 1).se != -1) {\n now = Q.que(0, size - 1);\n Q.set(now.se, mp(ilen, -1));\n stat[now.se] = 1;\n ans = lenplus(ans, Primresult[now.se].fi);\n REP(i, getVsz(now.se)) {\n nowlv = getV(now.se, i);\n if (stat[nowlv.se]) continue;\n if (Q[nowlv.se].se == -1) {\n Primresult[nowlv.se] = mp(nowlv.fi, now.se);\n Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se));\n }\n else {\n if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) {\n Primresult[nowlv.se] = mp(nowlv.fi, now.se);\n Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se));\n }\n }\n }\n }\n return ans;\n }\n\n};\n\n\n/*template class DP {\n\npublic:\n\n vector v;\n Type initv;\n vll size, block;\n\n DP() {}\n DP(const DP &dp) {}\n\n template DP(Args... args) {\n block.asn(1, 1);\n Initialize(args...);\n }\n\n void Initialize(Type initv_) {\n initv = initv_;\n v.asn(block.bk, initv);\n }\n template void Initialize(ll val, Args... args) {\n size.pb(val);\n block.pb(block.bk*val);\n Initialize(args...);\n }\n\n\n\n};*/\n\n\npl Bezout(ll a, ll b) {\n if (b != 0) {\n pl xy;\n xy = Bezout(b, a%b);\n return mp(xy.se, xy.fi - ((a / b)*xy.se));\n }\n else {\n return mp(1, 0);\n }\n}\npl Bez(ll a, ll b, ll c) {\n pl xy;\n ll x, y, z, gc;\n xy = Bezout(a, b);\n gc = gcd(a, b);\n if (c%gc != 0) return mp(-1, -1);\n x = xy.fi*(c / gc); y = xy.se*(c / gc);\n if (x < 0) z = rup(-x, (b / gc));\n if (x >= 0) z = -x / (b / gc);\n x += z * (b / gc);\n y -= z * (a / gc);\n return mp(x, y);\n}\n\nll DigS10(ll n) {\n ll ans = 0;\n while(1) {\n ans += n % 10;\n n /= 10;\n if (!n) break;\n }\n return ans;\n}\n\nll isP(ll n) {\n if (n <= 1) return 0;\n FOR(i, 2, (ll)sqrt(n) + 1) {\n if (n%i == 0) return 0;\n }\n return 1;\n}\n\nll Tot(ll n) {\n if (n <= 0) return 0;\n ll ans = n, x = 2;\n while (x*x <= n) {\n if (n%x == 0) {\n ans -= ans / x;\n while (n%x == 0) n /= x;\n }\n x++;\n }\n if (n > 1) ans -= ans / n;\n return ans;\n}\n\ntemplate struct Sum {\npublic:\n V v, s;\n ll size;\n Action Add;\n Sum(V v, Action Add = ADD) : v(v), size(v.sz), Add(Add) { Init(); Calc(); }\n void Init() {\n s.asn(size + 1, Add.I);\n }\n void Calc() {\n REP(i, size) s[i + 1] = Add(s[i], v[i]);\n\n }\n T operator()(ll x) {\n return operator()(0, x);\n }\n T operator()(ll l, ll r) {\n if (l < 0) l = 0;\n if (r >= size) r = size - 1;\n if (l > r) return Add.I;\n return s[r + 1] - s[l];//for ADD\n }\n};\nusing sumll = Sum;\n\ntemplate struct Sum2 {\npublic:\n V> v, s;\n ll RowSize, ColumnSize;\n Action Add;\n Sum2(V> v, Action Add = ADD) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); }\n void Init() {\n s.asn(RowSize + 1, V(ColumnSize, Add.I));\n }\n void Calc() {\n REP1(r, RowSize) {\n REP1(c, ColumnSize) {\n s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1);\n }\n }\n }\n T operator()(ll r, ll c) {\n return operator()(0, 0, r, c);\n }\n T operator()(ll r1, ll c1, ll r2, ll c2) {\n if (r1 < 0) r1 = 0;\n if (c1 < 0) c1 = 0;\n if (r2 >= RowSize) r2 = RowSize - 1;\n if (c2 >= ColumnSize) c2 = ColumnSize - 1;\n if (r1 > r2) return Add.I;\n if (c1 > c2) return Add.I;\n return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1];\n }\n};\nusing sum2ll = Sum2;\n\ntemplate struct Point2 {\npublic:\n V> v;\n ll h, w;\n Point2() : h(0), w(0) {}\n Point2(ll h, ll w) : h(h), w(w) { asn(h, w); }\n Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); }\n void assign(ll h, ll w) { v.asn(h, V(w)); }\n void assign(ll h, ll w, ll val) { v.asn(h, V(w, val)); }\n T& operator()(ll h, ll w) { return v[h][w]; }\n T& operator()(pl p) { return v[p.fi][p.se]; }\n};\ntemplate using P2 = Point2;\n\ntemplate struct Modll {\npublic:\n ll v;\n Modll() : v(0) {}\n Modll(ll _v) { set(_v % Mod + Mod); }\n Modll& set(ll _v) {\n v = (_v < Mod) ? _v : (_v - Mod);\n return *this;\n }\n Modll pow(ll n) const {\n Modll x = *this, ans = 1;\n while (n) {\n if (n & 1) ans *= x;\n x *= x;\n n >>= 1;\n }\n return ans;\n }\n Modll inverse() const { return (*this).pow(Mod - 2); }\n Modll operator+(const Modll& m) const { return Modll().set(v + m.v); }\n Modll operator-(const Modll& m) const { return Modll().set(Mod + v - m.v); }\n Modll operator*(const Modll& m) const { return Modll().set((ull(v) * m.v) % Mod); }\n Modll operator/(const Modll& m) const { return *this * m.inv; }\n Modll& operator+=(const Modll& m) { return *this = *this + m; }\n Modll& operator-=(const Modll& m) { return *this = *this - m; }\n Modll& operator*=(const Modll& m) { return *this = *this * m; }\n Modll& operator/=(const Modll& m) { return *this = *this / m; }\n Modll operator-() const { return Modll(0) - *this; }\n explicit operator bool() const { return v != 0; }\n friend ostream& operator<<(ostream& out, const Modll& m) { return out << m.v; }\n};\nusing mll = Modll;\nusing vmll = V;\nusing vvmll = V;\nusing vvvmll = V;\n\ntemplate T vmin(V v) {\n T tmp = MIN.I;\n ROR(v, i) emin(tmp, i);\n return tmp;\n}\ntemplate T vmin(V v, Args... args) {\n T tmp = vmin(args...);\n return min(vmin(v), tmp);\n}\n\ntemplate T vmax(V v) {\n T tmp = MAX.I;\n ROR(v, i) emax(tmp, i);\n return tmp;\n}\ntemplate T vmax(V v, Args... args) {\n T tmp = vmax(args...);\n return max(vmax(v), tmp);\n}\n\ntemplate T vgcd(V v) {\n T tmp = GCD.I;\n ROR(v, i) egcd(tmp, i);\n return tmp;\n}\ntemplate T vgcd(V v, Args... args) {\n T tmp = vgcd(args...);\n return gcd(vgcd(v), tmp);\n}\n\ntemplate T vlcm(V v) {\n T tmp = LCM.I;\n ROR(v, i) elcm(tmp, i);\n return tmp;\n}\ntemplate T vlcm(V v, Args... args) {\n T tmp = vlcm(args...);\n return lcm(vlcm(v), tmp);\n}\n\nvmll MFactMemo(2, 1);\nvmll MIFactMemo(2, 1);\n\nmll mFact(ll n) {\n if (MFactMemo.sz <= n) {\n ll oldsize = MFactMemo.sz;\n MFactMemo.res(n + 1, 1);\n FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i;\n }\n return MFactMemo[n];\n}\nmll miFact(ll n) {\n if (MIFactMemo.sz <= n) {\n ll oldsize = MIFactMemo.sz;\n MIFactMemo.res(n + 1, 1);\n MIFactMemo.bk = mFact(n).inv;\n rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i;\n }\n return MIFactMemo[n];\n}\nmll mComb(ll n, ll k) {\n if (n < 0 || k < 0 || n < k) return 0;\n return mFact(n) * miFact(k) * miFact(n - k);\n}\n\nll LIS(vll v, ll m = 0) {\n\n if (v.sz > 0) {\n ll ans = 0;\n vll dp(v.sz, INF);\n FOR(i, 0, v.sz - 1) {\n dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i];\n }\n FOR(i, 0, v.sz - 1) {\n if (dp[i] == INF) break;\n ans++;\n }\n return ans;\n }\n else {\n return 0;\n }\n\n}\n\nvoid PCmprs(vll& v) {\n if (v.sz == 0) return;\n vll vv(v);\n IOTA(vv, 0);\n sort(vv.bgn, vv.en, [&](ll v1, ll v2) {return v[v1] < v[v2]; });\n IOTA(v, 0);\n sort(v.bgn, v.en, [&](ll v1, ll v2) {return vv[v1] < vv[v2]; });\n return;\n}\n\nll BblCnt(vll v) {\n PCmprs(v);\n SegT b(v.sz, 0);\n ll ans = 0;\n REP(i, v.sz) {\n ans += (i - b.que(0, v[i]));\n b.add(v[i], 1);\n }\n return ans;\n}\n\nll Bsrch(function f, ll mi, ll ma) {\n ll ng = mi - 1, ok = ma, mid;\n while (ok - ng > 1) {\n mid = (ng + ok) / 2;\n (f(mid) ? ok : ng) = mid;\n }\n return ok;\n}\n\ntemplate V> MultiMatrix(V> A, V> B, Action Mul = MUL, Action Add = ADD) {\n V> ans;\n ll ii = A.sz;\n if (!ii) return ans;\n ll jj = A[0].sz;\n if (!jj) return ans;\n ll jj2 = B.sz;\n if (!jj2) return ans;\n if (jj != jj2) return ans;\n ll kk = B[0].sz;\n if (!kk) return ans;\n ans.asn(ii, V(kk, 0));\n REP(i, ii) {\n REP(k, kk) {\n REP(j, jj) {\n ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k]));\n }\n }\n }\n return ans;\n}\n\nvvll CombMemo(1000, vll(1000, -1));\n\nll Comb(ll n, ll k) {\n if ((n < 0) || (k < 0)) return 0;\n if (CombMemo[n][k] == -1) {\n if (n < k) CombMemo[n][k] = 0;\n else {\n if (n == 0) CombMemo[n][k] = 1;\n else if (k == 0) CombMemo[n][k] = 1;\n else if (n == k) CombMemo[n][k] = 1;\n else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k);\n }\n }\n return CombMemo[n][k];\n}\n\ntemplate map Dict(V v) {\n map m;\n if (!v.sz) return m;\n SORT(v);\n UNIQUE(v);\n REP(i, v.sz) {\n m[v[i]] = i;\n }\n return m;\n}\n\ntemplate vll Cmprs(V v) {\n auto m = Dict(v);\n vll ans(v.sz);\n REP(i,v.sz) {\n ans[i] = m[v[i]];\n }\n return ans;\n}\n\ntemplate auto vecn(T val) { return val; }\ntemplate auto vecn(ll val, Args... args) {\n auto tmp = vecn(args...);\n return V(val, tmp);\n}\n\nvoid Solve();\n\nsigned main() { \n cin.tie(0);\n ios::sync_with_stdio(false);\n cout << setprecision(20) << fixed;\n Solve();\n}\n\nvoid Solve() {\n li(n);vli(n,a);\n SORT(a);\n ll zero=0,type=0,f;\n vll note,count;\n REP(i,n){\n if(a[i]==0){\n zero++;\n } else {\n f=-1;\n REP(j,note.sz){\n if(note[j]==a[i]){\n f=j;\n }\n }\n if(f==-1){\n note.pb(a[i]);\n count.pb(1);\n } else {\n count[f]++;\n }\n }\n }\n \n if(a.sz==zero){\n cout << \"Yes\";\n return;\n }\n \n if(a.sz%3){\n cout << \"No\";\n return;\n }\n \n \n \n if(note.sz>=4){\n cout << \"No\";\n return;\n }\n \n if(zero){\n if (a.sz/3==zero && a.sz/3==count[0]/2) {\n cout << \"Yes\";\n return;\n } else {\n cout << \"No\";\n return;\n }\n } else {\n if (count[0]==count[1]&&count[0]==count[2]){\n if((note[0]^note[1]==note[2])&&(note[1]^note[2]==note[0])){\n cout << \"Yes\";\n return;\n }\n }\n }\n cout << \"No\";\n return;\n}\n\n\n\n\n\n\n\n\n\n\n", "language": "C++", "metadata": {"date": 1563156675, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02975/input.txt", "sample_output_relpath": "derived/input_output/data/p02975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02975/C++/s109717720.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s109717720", "user_id": "u172929647"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\n\ntemplate using V = vector;\ntemplate using VV = V>;\ntemplate using VVV = V>;\ntemplate using P = pair;\ntemplate using TP = tuple;\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing dbl = double;\nusing str = string;\nusing vll = V;\nusing vvll = V;\nusing vvvll = V;\nusing pl = P;\nusing tl = TP;\nusing vpl = V;\nusing vvpl = V;\nusing vtl = V;\nusing vvtl = V;\nusing vs = V;\nusing vvs = V;\nusing vd = V;\nusing vvd = V;\nusing qll = queue;\nusing qpl = queue;\nusing stll = stack;\nusing stpl = stack;\nusing mapll = map;\nusing setll = set;\nusing pqll = priority_queue;\n\n#define int ll\n#define fi first\n#define se second\n#define mp make_pair\n#define mt make_tuple\n#define pb push_back\n#define pob pop_back()\n#define pf push_front\n#define pof pop_front()\n#define sz size()\n#define bgn begin()\n#define en end()\n#define asn assign\n#define emp empty()\n#define fr front()\n#define bk back()\n#define clr clear()\n#define ins insert\n#define ers erase\n#define res resize\n#define tp top()\n#define p_q priority_queue\n#define inv inverse()\n\n#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)\n#define rFOR(i,a,b) for(ll i=(b);i>=(ll)(a);i--)\n#define REP(i,a) FOR((i),0,(ll)(a)-1)\n#define REP0(i,a) FOR((i),0,(ll)(a))\n#define REP1(i,a) FOR((i),1,(ll)(a))\n#define rREP(i,a) rFOR((i),0,(ll)(a)-1)\n#define rREP0(i,a) rFOR((i),0,(ll)(a))\n#define rREP1(i,a) rFOR((i),1,(ll)(a))\n#define ROR(v,i) for(auto &(i):(v))\n#define IOTA(a,n) iota((a).bgn,(a).en,(n))\n#define SORT(a) sort((a).bgn,(a).en)\n#define rSORT(a) sort((a).rbegin(),(a).rend())\n#define UNIQUE(a) (a).erase(unique((a).bgn,(a).en),(a).en)\n#define PREVP(a) prev_permutation((a).bgn,(a).en)\n#define NEXTP(a) next_permutation((a).bgn,(a).en)\n#define BINS(a,b) binary_search((a).bgn,(a).en,(b))\n#define LOWB(a,b) (lower_bound((a).bgn,(a).en,(b))-(a).bgn)\n#define UPB(a,b) (upper_bound((a).bgn,(a).en,(b))-(a).bgn)\n#define CNT(a,b) count((a).bgn,(a).en,b)\n#define SUM(a) accumulate((a).bgn,(a).en,0)\n#define REV(a) reverse((a).bgn,(a).en)\n#define REGS(a,b) regex_search((a),regex(b))\n#define REGM(a,b) regex_match((a),regex(b))\n#define yn(a) cout <<((a)?\"yes\":\"no\")<<\"\\n\";\n#define Yn(a) cout <<((a)?\"Yes\":\"No\")<<\"\\n\";\n#define YN(a) cout <<((a)?\"YES\":\"NO\")<<\"\\n\";\n#define imp(a) cout <<((a)?\"possible\":\"impossible\")<<\"\\n\";\n#define Imp(a) cout <<((a)?\"Possible\":\"Impossible\")<<\"\\n\";\n#define IMP(a) cout <<((a)?\"POSSIBLE\":\"IMPOSSIBLE\")<<\"\\n\";\n#define fs(a) cout <<((a)?\"second\":\"first\")<<\"\\n\";\n#define Fs(a) cout <<((a)?\"Second\":\"First\")<<\"\\n\";\n#define FS(a) cout <<((a)?\"SECOND\":\"FIRST\")<<\"\\n\";\n#define sak cout <<\"\\n\";\n#define sas cout <<\" \";\n#define sat cout <<\"\\t\";\n#define dbg(a) cerr <<(#a)<<\": \"<<(a)<<\"\\n\";\n#define dbgs(...) dal(#__VA_ARGS__);dal(__VA_ARGS__);\n#define c2l(a) ((ll)(a-48))\n#define a2l(a) ((ll)(a-97))\n#define A2l(a) ((ll)(a-65))\n#define l2c(a) ((char)(a+48))\n#define l2a(a) ((char)(a+97))\n#define l2A(a) ((char)(a+65))\n#define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1))\n#define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1))\n#define Dig2(a,b) (((a)>>(b))&1)\n#define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10)\n#define Pow2(a) ((ll)(1)<<(a))\n#define Pow10(a) ((ll)(pow(10.0,double(a))))\n#define LSB(a) ((a)&(-(a)))\n#define vin(v) ROR((v),(i)){cin >>(i);};\n#define vllin(v,N) vll (v)((N));vin(v);\n#define vllin2(a,b,N) vll (a)(N),(b)(N);REP(i,N){cin>>(a)[i]>>(b)[i];};\n#define vsin(v,N) vs (v)((N));vin(v);\n#define rdn(a,b) ((a)/(b))\n#define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1))\n#define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1))\n#define min(...) Min(__VA_ARGS__)\n#define max(...) Max(__VA_ARGS__)\n#define emin(a, ...) ((a)=Min((a),__VA_ARGS__))\n#define emax(a, ...) ((a)=Max((a),__VA_ARGS__))\n#define egcd(a, ...) ((a)=gcd((a),__VA_ARGS__))\n#define elcm(a, ...) ((a)=lcm((a),__VA_ARGS__))\n#define powll(a,b) (ll)(pow((double)(a),(double)(b)))\n#define Triangle(x1,y1,x2,y2,x3,y3) (((x1)-(x2))*((y1)-(y3))-((x1)-(x3))*((y1)-(y2)))\n\n#define svll SumV\n#define svvll SumV2\n\n#define li(...) ll __VA_ARGS__;Input(__VA_ARGS__);\n#define si(...) str __VA_ARGS__;Input(__VA_ARGS__);\n#define vli(size, ...) vll __VA_ARGS__;vInput(size,__VA_ARGS__);\n#define vsi(size, ...) vs __VA_ARGS__;vInput(size,__VA_ARGS__);\n\nconst ll MOD = 1e9 + 7;\n//const ll MOD = 998244353;\n//const ll MOD = 924844033;\n//const ll MOD = 9007199254740881;\nconst ll INF = 1LL << 60;//1.15e18\nconst double PI = acos(-1.0);\nconst vll DX = { 0,-1,0,1,0,-1,1,1,-1 };\nconst vll DY = { 0,0,-1,0,1,-1,-1,1,1 };\nconst str alp = \"abcdefghijklmnopqrstuvwxyz\";\nconst str ALP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n\nvoid Input() {}\ntemplate void Input(Var& var, Args&... args) {\n cin >> var;\n Input(args...);\n}\n\nvoid vInit(ll size) {}\ntemplate void vInit(ll size, V& v, Args&... args) {\n v.res(size);\n vInit(size, args...);\n}\nvoid vInputNum(ll num) {}\ntemplate void vInputNum(ll num, V& v, Args&... args) {\n cin >> v[num];\n vInputNum(num, args...);\n}\nvoid vInput(ll size) {}\ntemplate void vInput(ll size, Args&... args) {\n vInit(size, args...);\n REP(i, size) vInputNum(i, args...);\n}\n\ntemplate ostream &operator<<(ostream &out, const P &p) {\n return out << \"[\" << p.fi << \", \" << p.se << \"]\";\n}\n\ntemplate ostream &operator<<(ostream &out, V &v) {\n if (v.emp) return out << \"{}\";\n else {\n auto itr = v.bgn;\n out << \"{\" << *itr;\n itr++;\n while (itr != v.en) {\n out << \", \" << *itr;\n itr++;\n }\n out << \"}\";\n return out;\n }\n}\n\ntemplate ostream &operator<<(ostream &out, const map &m) {\n if (m.emp) return out << \"<[]>\";\n else {\n auto itr = m.bgn;\n out << \"< [\" << (itr->fi) << \": \" << (itr->se);\n itr++;\n while (itr != m.en) {\n out << \"], [\" << (itr->fi) << \": \" << (itr->se);\n itr++;\n }\n out << \"] >\";\n return out;\n }\n}\n\ntemplate ostream &operator<<(ostream &out, const set &s) {\n if (s.emp) return out << \"<>\";\n else {\n auto itr = s.bgn;\n out << \"<\" << *itr;\n itr++;\n while (itr != s.en) {\n out << \", \" << *itr;\n itr++;\n }\n out << \">\";\n return out;\n }\n}\n\nvoid say() {}\ntemplate void say(T t) { cout << t; }\ntemplate void say(Head head, Body... body) {\n cout << head << \" \";\n say(body...);\n}\nvoid sal() { cout << \"\\n\"; }\ntemplate void sal(Args... args) {\n say(args...);\n cout << \"\\n\";\n}\n\nvoid day() {}\ntemplate void day(T t) { cerr << t; }\ntemplate void day(Head head, Body... body) {\n cerr << head << \" \";\n day(body...);\n}\nvoid dal() { cerr << \"\\n\"; }\ntemplate void dal(Args... args) {\n day(args...);\n cerr << \"\\n\";\n}\n\nvoid salv() {}\ntemplate void salv(V v) {\n if (v.emp) sal();\n else {\n auto itr = v.bgn;\n say(*itr);\n itr++;\n while (itr != v.en) {\n sas;\n say(*itr);\n itr++;\n }\n sak;\n }\n}\ntemplate void salv(V v, Args... args) {\n salv(v);\n salv(args...);\n}\n\nvoid salv2() {}\ntemplate void salv2(V> v) {\n if (v.emp) sal();\n else {\n ROR(v, i) salv(i);\n }\n}\ntemplate void salv2(V> v, Args... args) {\n salv2(v);\n salv2(args...);\n}\n\ntemplate struct Action {\npublic:\n Monoid I;\n function A;\n Action(Monoid I, function A) : I(I), A(A) {}\n Monoid operator()() { return I; }\n Monoid operator()(Monoid x) { return x; }\n Monoid operator()(Monoid l, Monoid r) { return A(l, r); }\n template Monoid operator()(Monoid x, Args... args) {\n Monoid tmp = operator()(args...); \n return A(x, tmp);\n }\n};\n\ntemplate Action ADD = Action(0, [](T l, T r) { return l + r; });\ntemplate <> Action ADD = Action(\"\", [](str l, str r) { return l + r; });\ntemplate Action> ADD> = Action>(mp(ADD.I, ADD.I), [](P l, P r) { return mp(l.fi + r.fi, l.se + r.se); });\n\ntemplate Action MUL = Action(1, [](T l, T r) { return l * r; });\ntemplate Action OR = Action(0, [](T l, T r) { return l | r; });\ntemplate Action XOR = Action(0, [](T l, T r) { return l ^ r; });\n\ntemplate Action AND = Action(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; });\ntemplate <> Action AND = Action(true, [](bool l, bool r) { return l & r; });\ntemplate <> Action AND = Action(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; });\n\ntemplate Action MIN = Action(INF, [](T l, T r) { return (l < r) ? l : r; });\ntemplate Action MAX = Action(-INF, [](T l, T r) { return (l > r) ? l : r; });\n\ntemplate Action GCD = Action(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD(r, l%r) : l); });\ntemplate Action LCM = Action(1, [](T l, T r) { return (l * r) / GCD(l, r); });\n\n\ntemplate Head Min(Head head) { return head; }\ntemplate Head Min(Head head, Body... body) {\n auto tmp = Min(body...);\n return (head < tmp) ? head : tmp;\n}\n\ntemplate Head Max(Head head) { return head; }\ntemplate auto Max(Head head, Body... body) {\n auto tmp = Max(body...);\n return (head > tmp) ? head : tmp;\n}\n\nll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a%b) : a; }\nll lcm(ll a, ll b) { return a / gcd(a, b)*b; }\n\nll gcd(ll head) { return head; }\ntemplate ll gcd(ll head, Body... body) {\n return gcd(head, gcd(body...));\n}\n\nll lcm(ll head) { return head; }\ntemplate ll lcm(ll head, Body... body) {\n return lcm(head, lcm(body...));\n}\n\n\nll Bset(ll a, ll b, ll c) {\n if (c) a |= b;\n else a &= ~b;\n return a;\n}\n\n\nstruct UFT {\n\npublic:\n ll tsize;\n ll mode;\n vll par;\n vll rank;\n UFT() {}\n UFT(const UFT &uft) {}\n UFT(ll tsizeget, ll modeget = 0){\n tsize = tsizeget;\n mode = modeget;\n par.asn(tsize, -1);\n if (!mode) rank.res(tsize, 0);\n }\n ll root(ll x) {\n return par[x] < 0 ? x : par[x] = root(par[x]);\n }\n bool isRoot(ll x) {\n return x == root(x);\n }\n bool same(ll x, ll y) {\n return root(x) == root(y);\n }\n void merge(ll x, ll y) {\n x = root(x);\n y = root(y);\n if (x == y) return;\n if (mode) {\n par[x] += par[y];\n par[y] = x;\n }\n else {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = y;\n }\n else {\n par[x] += par[y];\n par[y] = x;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n }\n ll size(ll x) {\n return -par[root(x)];\n }\n};\n\nstruct pUFT {\n\npublic:\n\n ll tsize;\n ll now;\n vll par;\n vll rank;\n vll mtime;\n vvll sizepi;\n vvll sizepv;\n\n pUFT(){}\n pUFT(const pUFT &puft) {}\n\n pUFT(ll tsizeget) {\n tsize = tsizeget;\n now = 0;\n par.asn(tsize, -1);\n rank.asn(tsize, 0);\n mtime.asn(tsize, INF);\n sizepi.asn(tsize, { 0 });\n sizepv.asn(tsize, { 1 });\n }\n ll root(ll x, ll t) {\n return (mtime[x] > t) ? x : root(par[x], t);\n }\n bool same(ll x, ll y, ll t) {\n return root(x, t) == root(y, t);\n }\n ll merge(ll x, ll y) {\n now++;\n x = root(x, now);\n y = root(y, now);\n if (x != y) {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n sizepi[y].pb(now);\n sizepv[y].pb(-par[y]);\n par[x] = y;\n mtime[x] = now;\n }\n else {\n par[x] += par[y];\n sizepi[x].pb(now);\n sizepv[x].pb(-par[x]);\n par[y] = x;\n mtime[y] = now;\n if (rank[x] == rank[y]) rank[x]++;\n }\n }\n return now;\n }\n ll size(ll x, ll t) {\n x = root(x, t);\n return sizepv[x][UPB(sizepi[x], t) - 1];\n }\n\n};\n\nstruct wUFT {\npublic:\n ll tsize;\n ll mode;\n vll par;\n vll rank;\n vll dweight;\n wUFT() {}\n wUFT(const wUFT &wuft) {}\n wUFT(ll tsizeget, ll modeget = 0) {\n tsize = tsizeget;\n mode = modeget;\n par.asn(tsize, -1);\n if (!mode) rank.res(tsize, 0);\n dweight.asn(tsize, 0);\n }\n ll root(ll x) {\n if (par[x] < 0) return x;\n else {\n ll r = root(par[x]);\n dweight[x] += dweight[par[x]];\n return par[x] = r;\n }\n }\n ll weight(ll x) {\n root(x);\n return dweight[x];\n }\n ll diff(ll x, ll y) {\n return weight(y) - weight(x);\n }\n bool isRoot(ll x) {\n return x == root(x);\n }\n bool same(ll x, ll y) {\n return root(x) == root(y);\n }\n void merge(ll x, ll y, ll w) {\n w += weight(x);\n w -= weight(y);\n x = root(x);\n y = root(y);\n if (x == y) return;\n if (mode) {\n par[x] += par[y];\n par[y] = x;\n }\n else {\n if (rank[x] < rank[y]) {\n par[y] += par[x];\n par[x] = y;\n dweight[x] = -w;\n }\n else {\n par[x] += par[y];\n par[y] = x;\n if (rank[x] == rank[y]) rank[x]++;\n dweight[y] = w;\n }\n }\n }\n ll size(ll x) {\n return -par[root(x)];\n }\n};\n\ntemplate class SegT {\n\npublic:\n\n ll size;\n vector v;\n\n valtype initv;\n function calc;\n\n SegT() {}\n SegT(const SegT &segt) {}\n\n SegT(ll sizeget, ll modeget = 0) {\n sizeset(sizeget);\n modeset(modeget);\n init();\n }\n SegT(vector cpyvec, ll modeget = 0) {\n sizeset(cpyvec.sz);\n modeset(modeget);\n init();\n copy(cpyvec);\n }\n SegT(ll sizeget, valtype initvget, function calcget) {\n sizeset(sizeget);\n initv = initvget;\n calc = calcget;\n init();\n }\n SegT(vector cpyvec, valtype initvget, function calcget) {\n sizeset(cpyvec.sz);\n initv = initvget;\n calc = calcget;\n init();\n copy(cpyvec);\n }\n void sizeset(ll rsize) {\n size = DigN2(rsize);\n if (rsize == Pow2(size - 1)) size--;\n return;\n }\n void modeset(ll mode) {\n switch (mode) {\n case 0:\n initv = 0;\n calc = [](valtype x, valtype y) {return x + y; };\n break;\n case 1:\n initv = INF;\n calc = [](valtype x, valtype y) {return min(x, y); };\n break;\n case 2:\n initv = -INF;\n calc = [](valtype x, valtype y) {return max(x, y); };\n break;\n }\n return;\n }\n void init() {\n v.asn(Pow2(size + 1) - 1, initv);\n }\n void copy(vector cpyvec) {\n REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]);\n }\n ll i2v(ll i) const{\n if (i < 0 || i >= Pow2(size)) return -1;\n return Pow2(size) + i - 1;\n }\n ll top(ll i) const{\n if (i == 0) return -1;\n return (i - 1) / 2;\n }\n pl bot(ll i) const{\n if (i + 1 >= Pow2(size)) return mp(-1, -1);\n return mp(2 * i + 1, 2 * i + 2);\n }\n void set(ll i, valtype x) {\n i = i2v(i);\n v[i] = x;\n while (i > 0) {\n i = top(i);\n v[i] = calc(v[bot(i).fi], v[bot(i).se]);\n }\n return;\n }\n void add(ll i, valtype x) {\n set(i, v[i2v(i)] + x);\n return;\n }\n valtype operator[](const ll &i) const {\n return v[i2v(i)];\n }\n// valtype que(ll a = 0, ll b = Pow2(size) - 1) {\n valtype que(ll a, ll b) {\n if (a == b) return v[i2v(a)];\n if (a > b) return initv;//swap(a, b);\n valtype ans = initv;\n ll ai = i2v(a);\n ll bi = i2v(b);\n FOR(i, 1, size + 1) {\n if (a > b) break;\n if (a%Pow2(i)) {\n ans = calc(ans, v[ai]);\n a += Pow2(i - 1);\n ai = top(ai) + 1;\n }\n else {\n ai = top(ai);\n }\n if (a > b) break;\n if ((b + 1) % Pow2(i)) {\n ans = calc(ans, v[bi]);\n b -= Pow2(i - 1);\n bi = top(bi) - 1;\n }\n else {\n bi = top(bi);\n }\n if (a > b) break;\n }\n return ans;\n }\n valtype que(ll b) {\n return que(0, b);\n }\n valtype que() {\n return que(0, Pow2(size) - 1);\n }\n\n\n};\n\ntemplate class Graph {\n\npublic:\n \n ll size;\n ll mode;\n ll mapmode;\n lentype zlen;\n lentype ilen;\n vector> v2n;\n vvll n2v;\n vector> Edge;\n vector> Primresult;\n\n Graph() {}\n Graph(const Graph &graph) {}\n\n Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) {\n size = sizeget;\n mapmode = mapmodeget;\n mode = modeget;\n zlen = zlenget;\n ilen = ilenget;\n init();\n }\n void init() {\n Edge.res(size);\n v2n.res(size);\n n2v.res(size);\n Primresult.asn(size, mp(ilen, -1));\n }\n lentype lenplus(lentype l, lentype r) {\n return l + r;\n }\n lentype lenequal(lentype l, lentype r) {\n return l == r;\n }\n lentype lenlcr(lentype l, lentype r) {\n return l < r;\n }\n ll addV(ll vs) {\n size += vs;\n init();\n return size;\n }\n void caddE(ll x, ll y, lentype c) {\n if (mapmode) v2n[x][y] = Edge[x].sz;\n Edge[x].pb(c);\n n2v[x].pb(y);\n }\n void csetE(ll x, ll y, lentype c) {\n if (mapmode) Edge[x][v2n[x][y]] = c;\n }\n void cersE(ll x, ll y) {\n if (mapmode) {\n ll n = v2n[x][y];\n Edge[x][n] = ilen;\n n2v[x][n] = -1;\n v2n[x].ers(y);\n }\n }\n void addE(ll x, ll y, lentype c) {\n caddE(x, y, c);\n if (!mode) caddE(y, x, c);\n }\n void setE(ll x, ll y, lentype c) {\n csetE(x, y, c);\n if (!mode) csetE(y, x, c);\n }\n void ersE(ll x, ll y, lentype c) {\n cersE(x, y, c);\n if (!mode) cersE(y, x, c);\n }\n lentype getE(ll x, ll y) {\n if (mapmode) {\n if (v2n[x].count(y)) {\n return Edge[x][v2n[x][y]];\n }\n }\n return ilen;\n }\n ll getVsz(ll x) {\n return Edge[x].sz;\n }\n pair getV(ll x, ll n) {\n if (n >= getVsz(x)) return mp(ilen, -1);\n return mp(Edge[x][n], n2v[x][n]);\n }\n\n vector> Dijk(ll x) {\n vector> result(size);\n REP(i, size) {\n result[i].fi = ilen;\n result[i].se = { -1 };\n }\n vll stat(size, 0);\n pair now;\n pair nowlv;\n SegT> Q(size, mp(ilen, -1), [](pair l, pair r) {\n if (l.se == -1) return r;\n if (r.se == -1) return l;\n return l.fi < r.fi ? l : r;\n });\n Q.set(x, mp(zlen, x));\n result[x].fi = zlen;\n result[x].se = { -1 };\n while (Q.que(0, size - 1).se != -1) {\n now = Q.que(0, size - 1);\n Q.set(now.se, mp(ilen, -1));\n stat[now.se] = 1;\n REP(i, getVsz(now.se)) {\n nowlv = getV(now.se, i);\n if (stat[nowlv.se]) continue;\n if (Q[nowlv.se].se == -1) {\n result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi);\n result[nowlv.se].se = { now.se };\n Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se));\n }\n else {\n if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) {\n result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi);\n result[nowlv.se].se = { now.se };\n Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se));\n }\n else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) {\n result[nowlv.se].se.pb(now.se);\n }\n }\n }\n }\n return result;\n }\n\n lentype Prim(ll x = 0) {\n lentype ans = zlen;\n vll stat(size, 0);\n pair now;\n pair nowlv;\n SegT> Q(size, mp(ilen, -1), [](pair l, pair r) {\n if (l.se == -1) return r;\n if (r.se == -1) return l;\n return l.fi < r.fi ? l : r;\n });\n Q.set(x, mp(zlen, x));\n Primresult[x] = mp(zlen, -1);\n while (Q.que(0, size - 1).se != -1) {\n now = Q.que(0, size - 1);\n Q.set(now.se, mp(ilen, -1));\n stat[now.se] = 1;\n ans = lenplus(ans, Primresult[now.se].fi);\n REP(i, getVsz(now.se)) {\n nowlv = getV(now.se, i);\n if (stat[nowlv.se]) continue;\n if (Q[nowlv.se].se == -1) {\n Primresult[nowlv.se] = mp(nowlv.fi, now.se);\n Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se));\n }\n else {\n if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) {\n Primresult[nowlv.se] = mp(nowlv.fi, now.se);\n Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se));\n }\n }\n }\n }\n return ans;\n }\n\n};\n\n\n/*template class DP {\n\npublic:\n\n vector v;\n Type initv;\n vll size, block;\n\n DP() {}\n DP(const DP &dp) {}\n\n template DP(Args... args) {\n block.asn(1, 1);\n Initialize(args...);\n }\n\n void Initialize(Type initv_) {\n initv = initv_;\n v.asn(block.bk, initv);\n }\n template void Initialize(ll val, Args... args) {\n size.pb(val);\n block.pb(block.bk*val);\n Initialize(args...);\n }\n\n\n\n};*/\n\n\npl Bezout(ll a, ll b) {\n if (b != 0) {\n pl xy;\n xy = Bezout(b, a%b);\n return mp(xy.se, xy.fi - ((a / b)*xy.se));\n }\n else {\n return mp(1, 0);\n }\n}\npl Bez(ll a, ll b, ll c) {\n pl xy;\n ll x, y, z, gc;\n xy = Bezout(a, b);\n gc = gcd(a, b);\n if (c%gc != 0) return mp(-1, -1);\n x = xy.fi*(c / gc); y = xy.se*(c / gc);\n if (x < 0) z = rup(-x, (b / gc));\n if (x >= 0) z = -x / (b / gc);\n x += z * (b / gc);\n y -= z * (a / gc);\n return mp(x, y);\n}\n\nll DigS10(ll n) {\n ll ans = 0;\n while(1) {\n ans += n % 10;\n n /= 10;\n if (!n) break;\n }\n return ans;\n}\n\nll isP(ll n) {\n if (n <= 1) return 0;\n FOR(i, 2, (ll)sqrt(n) + 1) {\n if (n%i == 0) return 0;\n }\n return 1;\n}\n\nll Tot(ll n) {\n if (n <= 0) return 0;\n ll ans = n, x = 2;\n while (x*x <= n) {\n if (n%x == 0) {\n ans -= ans / x;\n while (n%x == 0) n /= x;\n }\n x++;\n }\n if (n > 1) ans -= ans / n;\n return ans;\n}\n\ntemplate struct Sum {\npublic:\n V v, s;\n ll size;\n Action Add;\n Sum(V v, Action Add = ADD) : v(v), size(v.sz), Add(Add) { Init(); Calc(); }\n void Init() {\n s.asn(size + 1, Add.I);\n }\n void Calc() {\n REP(i, size) s[i + 1] = Add(s[i], v[i]);\n\n }\n T operator()(ll x) {\n return operator()(0, x);\n }\n T operator()(ll l, ll r) {\n if (l < 0) l = 0;\n if (r >= size) r = size - 1;\n if (l > r) return Add.I;\n return s[r + 1] - s[l];//for ADD\n }\n};\nusing sumll = Sum;\n\ntemplate struct Sum2 {\npublic:\n V> v, s;\n ll RowSize, ColumnSize;\n Action Add;\n Sum2(V> v, Action Add = ADD) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); }\n void Init() {\n s.asn(RowSize + 1, V(ColumnSize, Add.I));\n }\n void Calc() {\n REP1(r, RowSize) {\n REP1(c, ColumnSize) {\n s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1);\n }\n }\n }\n T operator()(ll r, ll c) {\n return operator()(0, 0, r, c);\n }\n T operator()(ll r1, ll c1, ll r2, ll c2) {\n if (r1 < 0) r1 = 0;\n if (c1 < 0) c1 = 0;\n if (r2 >= RowSize) r2 = RowSize - 1;\n if (c2 >= ColumnSize) c2 = ColumnSize - 1;\n if (r1 > r2) return Add.I;\n if (c1 > c2) return Add.I;\n return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1];\n }\n};\nusing sum2ll = Sum2;\n\ntemplate struct Point2 {\npublic:\n V> v;\n ll h, w;\n Point2() : h(0), w(0) {}\n Point2(ll h, ll w) : h(h), w(w) { asn(h, w); }\n Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); }\n void assign(ll h, ll w) { v.asn(h, V(w)); }\n void assign(ll h, ll w, ll val) { v.asn(h, V(w, val)); }\n T& operator()(ll h, ll w) { return v[h][w]; }\n T& operator()(pl p) { return v[p.fi][p.se]; }\n};\ntemplate using P2 = Point2;\n\ntemplate struct Modll {\npublic:\n ll v;\n Modll() : v(0) {}\n Modll(ll _v) { set(_v % Mod + Mod); }\n Modll& set(ll _v) {\n v = (_v < Mod) ? _v : (_v - Mod);\n return *this;\n }\n Modll pow(ll n) const {\n Modll x = *this, ans = 1;\n while (n) {\n if (n & 1) ans *= x;\n x *= x;\n n >>= 1;\n }\n return ans;\n }\n Modll inverse() const { return (*this).pow(Mod - 2); }\n Modll operator+(const Modll& m) const { return Modll().set(v + m.v); }\n Modll operator-(const Modll& m) const { return Modll().set(Mod + v - m.v); }\n Modll operator*(const Modll& m) const { return Modll().set((ull(v) * m.v) % Mod); }\n Modll operator/(const Modll& m) const { return *this * m.inv; }\n Modll& operator+=(const Modll& m) { return *this = *this + m; }\n Modll& operator-=(const Modll& m) { return *this = *this - m; }\n Modll& operator*=(const Modll& m) { return *this = *this * m; }\n Modll& operator/=(const Modll& m) { return *this = *this / m; }\n Modll operator-() const { return Modll(0) - *this; }\n explicit operator bool() const { return v != 0; }\n friend ostream& operator<<(ostream& out, const Modll& m) { return out << m.v; }\n};\nusing mll = Modll;\nusing vmll = V;\nusing vvmll = V;\nusing vvvmll = V;\n\ntemplate T vmin(V v) {\n T tmp = MIN.I;\n ROR(v, i) emin(tmp, i);\n return tmp;\n}\ntemplate T vmin(V v, Args... args) {\n T tmp = vmin(args...);\n return min(vmin(v), tmp);\n}\n\ntemplate T vmax(V v) {\n T tmp = MAX.I;\n ROR(v, i) emax(tmp, i);\n return tmp;\n}\ntemplate T vmax(V v, Args... args) {\n T tmp = vmax(args...);\n return max(vmax(v), tmp);\n}\n\ntemplate T vgcd(V v) {\n T tmp = GCD.I;\n ROR(v, i) egcd(tmp, i);\n return tmp;\n}\ntemplate T vgcd(V v, Args... args) {\n T tmp = vgcd(args...);\n return gcd(vgcd(v), tmp);\n}\n\ntemplate T vlcm(V v) {\n T tmp = LCM.I;\n ROR(v, i) elcm(tmp, i);\n return tmp;\n}\ntemplate T vlcm(V v, Args... args) {\n T tmp = vlcm(args...);\n return lcm(vlcm(v), tmp);\n}\n\nvmll MFactMemo(2, 1);\nvmll MIFactMemo(2, 1);\n\nmll mFact(ll n) {\n if (MFactMemo.sz <= n) {\n ll oldsize = MFactMemo.sz;\n MFactMemo.res(n + 1, 1);\n FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i;\n }\n return MFactMemo[n];\n}\nmll miFact(ll n) {\n if (MIFactMemo.sz <= n) {\n ll oldsize = MIFactMemo.sz;\n MIFactMemo.res(n + 1, 1);\n MIFactMemo.bk = mFact(n).inv;\n rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i;\n }\n return MIFactMemo[n];\n}\nmll mComb(ll n, ll k) {\n if (n < 0 || k < 0 || n < k) return 0;\n return mFact(n) * miFact(k) * miFact(n - k);\n}\n\nll LIS(vll v, ll m = 0) {\n\n if (v.sz > 0) {\n ll ans = 0;\n vll dp(v.sz, INF);\n FOR(i, 0, v.sz - 1) {\n dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i];\n }\n FOR(i, 0, v.sz - 1) {\n if (dp[i] == INF) break;\n ans++;\n }\n return ans;\n }\n else {\n return 0;\n }\n\n}\n\nvoid PCmprs(vll& v) {\n if (v.sz == 0) return;\n vll vv(v);\n IOTA(vv, 0);\n sort(vv.bgn, vv.en, [&](ll v1, ll v2) {return v[v1] < v[v2]; });\n IOTA(v, 0);\n sort(v.bgn, v.en, [&](ll v1, ll v2) {return vv[v1] < vv[v2]; });\n return;\n}\n\nll BblCnt(vll v) {\n PCmprs(v);\n SegT b(v.sz, 0);\n ll ans = 0;\n REP(i, v.sz) {\n ans += (i - b.que(0, v[i]));\n b.add(v[i], 1);\n }\n return ans;\n}\n\nll Bsrch(function f, ll mi, ll ma) {\n ll ng = mi - 1, ok = ma, mid;\n while (ok - ng > 1) {\n mid = (ng + ok) / 2;\n (f(mid) ? ok : ng) = mid;\n }\n return ok;\n}\n\ntemplate V> MultiMatrix(V> A, V> B, Action Mul = MUL, Action Add = ADD) {\n V> ans;\n ll ii = A.sz;\n if (!ii) return ans;\n ll jj = A[0].sz;\n if (!jj) return ans;\n ll jj2 = B.sz;\n if (!jj2) return ans;\n if (jj != jj2) return ans;\n ll kk = B[0].sz;\n if (!kk) return ans;\n ans.asn(ii, V(kk, 0));\n REP(i, ii) {\n REP(k, kk) {\n REP(j, jj) {\n ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k]));\n }\n }\n }\n return ans;\n}\n\nvvll CombMemo(1000, vll(1000, -1));\n\nll Comb(ll n, ll k) {\n if ((n < 0) || (k < 0)) return 0;\n if (CombMemo[n][k] == -1) {\n if (n < k) CombMemo[n][k] = 0;\n else {\n if (n == 0) CombMemo[n][k] = 1;\n else if (k == 0) CombMemo[n][k] = 1;\n else if (n == k) CombMemo[n][k] = 1;\n else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k);\n }\n }\n return CombMemo[n][k];\n}\n\ntemplate map Dict(V v) {\n map m;\n if (!v.sz) return m;\n SORT(v);\n UNIQUE(v);\n REP(i, v.sz) {\n m[v[i]] = i;\n }\n return m;\n}\n\ntemplate vll Cmprs(V v) {\n auto m = Dict(v);\n vll ans(v.sz);\n REP(i,v.sz) {\n ans[i] = m[v[i]];\n }\n return ans;\n}\n\ntemplate auto vecn(T val) { return val; }\ntemplate auto vecn(ll val, Args... args) {\n auto tmp = vecn(args...);\n return V(val, tmp);\n}\n\nvoid Solve();\n\nsigned main() { \n cin.tie(0);\n ios::sync_with_stdio(false);\n cout << setprecision(20) << fixed;\n Solve();\n}\n\nvoid Solve() {\n li(n);vli(n,a);\n SORT(a);\n ll zero=0,type=0,f;\n vll note,count;\n REP(i,n){\n if(a[i]==0){\n zero++;\n } else {\n f=-1;\n REP(j,note.sz){\n if(note[j]==a[i]){\n f=j;\n }\n }\n if(f==-1){\n note.pb(a[i]);\n count.pb(1);\n } else {\n count[f]++;\n }\n }\n }\n \n if(a.sz==zero){\n cout << \"Yes\";\n return;\n }\n \n if(a.sz%3){\n cout << \"No\";\n return;\n }\n \n \n \n if(note.sz>=4){\n cout << \"No\";\n return;\n }\n \n if(zero){\n if (a.sz/3==zero && a.sz/3==count[0]/2) {\n cout << \"Yes\";\n return;\n } else {\n cout << \"No\";\n return;\n }\n } else {\n if (count[0]==count[1]&&count[0]==count[2]){\n if((note[0]^note[1]==note[2])&&(note[1]^note[2]==note[0])){\n cout << \"Yes\";\n return;\n }\n }\n }\n cout << \"No\";\n return;\n}\n\n\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 32722, "cpu_time_ms": 1993, "memory_kb": 10484}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s546812909", "group_id": "codeNet:p02981", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n int N,A,B;\n cin >> N >> A >> B;\n \n int train = 0;\n train = A*N;\n \n cout << min(train,B) << endl;\n return 0;\n}\n\n", "language": "C++", "metadata": {"date": 1562547703, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02981/input.txt", "sample_output_relpath": "derived/input_output/data/p02981/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02981/C++/s546812909.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s546812909", "user_id": "u451206510"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n int N,A,B;\n cin >> N >> A >> B;\n \n int train = 0;\n train = A*N;\n \n cout << min(train,B) << endl;\n return 0;\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s058484366", "group_id": "codeNet:p02986", "input_text": "#include \nusing namespace std;\nconst int maxn = 200100, lg = 22;\nstruct query {\n\tint i, x, y, sig;\n};\nvector > e[maxn];\nvector que[maxn];\nint par[lg][maxn], dep[maxn];\nvoid dfs(int u, int p){\n\tpar[0][u] = p;\n\tfor(auto ee : e[u]){\n\t\tint to, b, c; tie(to, b, c);\n\t\tif(to != p){\n\t\t\tdep[to] = dep[u] + 1;\n\t\t\tdfs(to, u);\n\t\t}\n\t}\n}\nint lca(int u, int v){\n\tif(dep[u] < dep[v]) swap(u, v);\n\tfor(int i = lg - 1; i >= 0; i--) if((dep[u] - dep[v])&(1<= 0; i--) if(par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];\n\treturn par[0][u];\n}\nlong long ans[maxn], tot[maxn], amn[maxn];\nvoid solve(int u, int p, long long d){\n\tfor(auto q : que[u]){\n\t\tans[q.i] += q.sig * (d - tot[q.x] + q.y * amn[q.x]);\n\t}\n\tfor(auto ee : e[u]){\n\t\tint to, c, di; tie(to, c, di) = ee;\n\t\tif(to == p) continue;\n\t\ttot[c] += di;\n\t\tamn[c] += 1;\n\t\tsolve(to, u, d + di);\n\t\ttot[c] -= di;\n\t\tamn[c] -= 1;\n\t}\n}\nint main(){\n\tint n, q; cin >> n >> q;\n\tfor(int i = 0; i < n - 1; i++){\n\t\tint a, b, c, d; cin >> a >> b >> c >> d;\n\t\te[a].push_back(make_tuple(b, c, d));\n\t\te[b].push_back(make_tuple(a, c, d));\n\t}\n\tdfs(1, 0);\n\tfor(int i = 1; i < lg; i++){\n\t\tfor(int j = 1; j <= n; j++)\n\t\t\tif(par[i - 1][j])\n\t\t\t\tpar[i][j] = par[i - 1][par[i - 1][j]];\n\t}\n\tfor(int i = 0; i < q; i++){\n\t\tint x, y, u, v; cin >> x >> y >> u >> v;\n\t\tque[u].push_back({i, x, y, 1});\n\t\tque[v].push_back({i, x, y, 1});\n\t\tque[lca(u, v)].push_back({i, x, y, -2});\n\t}\n\tsolve(1, 0, 0);\n\tfor(int i = 0; i < q; i++) cout << ans[i] << endl;\n\treturn 0;\n}\n\n", "language": "C++", "metadata": {"date": 1562553174, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02986.html", "problem_id": "p02986", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02986/input.txt", "sample_output_relpath": "derived/input_output/data/p02986/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02986/C++/s058484366.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s058484366", "user_id": "u251828455"}, "prompt_components": {"gold_output": "130\n200\n60\n", "input_to_evaluate": "#include \nusing namespace std;\nconst int maxn = 200100, lg = 22;\nstruct query {\n\tint i, x, y, sig;\n};\nvector > e[maxn];\nvector que[maxn];\nint par[lg][maxn], dep[maxn];\nvoid dfs(int u, int p){\n\tpar[0][u] = p;\n\tfor(auto ee : e[u]){\n\t\tint to, b, c; tie(to, b, c);\n\t\tif(to != p){\n\t\t\tdep[to] = dep[u] + 1;\n\t\t\tdfs(to, u);\n\t\t}\n\t}\n}\nint lca(int u, int v){\n\tif(dep[u] < dep[v]) swap(u, v);\n\tfor(int i = lg - 1; i >= 0; i--) if((dep[u] - dep[v])&(1<= 0; i--) if(par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];\n\treturn par[0][u];\n}\nlong long ans[maxn], tot[maxn], amn[maxn];\nvoid solve(int u, int p, long long d){\n\tfor(auto q : que[u]){\n\t\tans[q.i] += q.sig * (d - tot[q.x] + q.y * amn[q.x]);\n\t}\n\tfor(auto ee : e[u]){\n\t\tint to, c, di; tie(to, c, di) = ee;\n\t\tif(to == p) continue;\n\t\ttot[c] += di;\n\t\tamn[c] += 1;\n\t\tsolve(to, u, d + di);\n\t\ttot[c] -= di;\n\t\tamn[c] -= 1;\n\t}\n}\nint main(){\n\tint n, q; cin >> n >> q;\n\tfor(int i = 0; i < n - 1; i++){\n\t\tint a, b, c, d; cin >> a >> b >> c >> d;\n\t\te[a].push_back(make_tuple(b, c, d));\n\t\te[b].push_back(make_tuple(a, c, d));\n\t}\n\tdfs(1, 0);\n\tfor(int i = 1; i < lg; i++){\n\t\tfor(int j = 1; j <= n; j++)\n\t\t\tif(par[i - 1][j])\n\t\t\t\tpar[i][j] = par[i - 1][par[i - 1][j]];\n\t}\n\tfor(int i = 0; i < q; i++){\n\t\tint x, y, u, v; cin >> x >> y >> u >> v;\n\t\tque[u].push_back({i, x, y, 1});\n\t\tque[v].push_back({i, x, y, 1});\n\t\tque[lca(u, v)].push_back({i, x, y, -2});\n\t}\n\tsolve(1, 0, 0);\n\tfor(int i = 0; i < q; i++) cout << ans[i] << endl;\n\treturn 0;\n}\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "sample_input": "5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n"}, "reference_outputs": ["130\n200\n60\n"], "source_document_id": "p02986", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1576, "cpu_time_ms": 516, "memory_kb": 31344}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s323404344", "group_id": "codeNet:p02988", "input_text": "#include \n#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)\n\nusing namespace std;\ntypedef long long ll;\n\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N;\n\n vector p(N);\n for(int i=0; i> p[i];\n\n int count;\n for(int i=0; i\n#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)\n\nusing namespace std;\ntypedef long long ll;\n\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N;\n\n vector p(N);\n for(int i=0; i> p[i];\n\n int count;\n for(int i=0; i\nusing namespace std;\n\nint main()\n{\n int N;\n cin >> N;\n\n vector p(N);\n\n for (int i = 0; i < N; i++)\n {\n cin >> p.at(i);\n }\n\n int ans = 0;\n\n for (int i = 1; i < N - 1; i++)\n {\n if (p.at(i) != max({p.at(i - 1), p.at(i), p.at(i + 1)}) && p.at(i) != min({p.at(i - 1), p.at(i), p.at(i + 1)}))\n {\n ans++;\n }\n }\n\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1582478081, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/C++/s606473791.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s606473791", "user_id": "u455876837"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main()\n{\n int N;\n cin >> N;\n\n vector p(N);\n\n for (int i = 0; i < N; i++)\n {\n cin >> p.at(i);\n }\n\n int ans = 0;\n\n for (int i = 1; i < N - 1; i++)\n {\n if (p.at(i) != max({p.at(i - 1), p.at(i), p.at(i + 1)}) && p.at(i) != min({p.at(i - 1), p.at(i), p.at(i + 1)}))\n {\n ans++;\n }\n }\n\n cout << ans << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 387, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s860963272", "group_id": "codeNet:p02988", "input_text": "#include\nusing namespace std;\nint main()\n{\n int N;\n cin>>N;\n vector vec(N);\n int count=0;\n for(int i=0;i>vec.at(i);\n }\n for(int i=1;ivec.at(i)&&vec.at(i)>vec.at(i+1)))\n {\n count++;\n }\n }\n cout<\nusing namespace std;\nint main()\n{\n int N;\n cin>>N;\n vector vec(N);\n int count=0;\n for(int i=0;i>vec.at(i);\n }\n for(int i=1;ivec.at(i)&&vec.at(i)>vec.at(i+1)))\n {\n count++;\n }\n }\n cout<\nusing namespace std;\nint main()\n{\n int n;\n cin >>n;\n int p[n];\n for(int i=0;i> p[i];\n int count = 0;\n for(int i=1;ip[i])&&(p[i]>p[i+1])))\n count++;\n }\n cout << count <\nusing namespace std;\nint main()\n{\n int n;\n cin >>n;\n int p[n];\n for(int i=0;i> p[i];\n int count = 0;\n for(int i=1;ip[i])&&(p[i]>p[i+1])))\n count++;\n }\n cout << count <\nusing namespace std;\nusing ll = long long;\n\nsigned\nmain(){\n\tint n;\n\tcin >> n;\n\tvector p(n);\n\tfor(int i=0;i> p[i];\n\n\tint cnt = 0;\n\tfor(int x=0;x p[x+1] and p[x+1] > p[x+2])\n\t\t{\n\t\t\tcnt++;\n\t\t}\n\t}\n\tcout << cnt << endl;\n}", "language": "C++", "metadata": {"date": 1561858094, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/C++/s926632251.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926632251", "user_id": "u003019316"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\n\nsigned\nmain(){\n\tint n;\n\tcin >> n;\n\tvector p(n);\n\tfor(int i=0;i> p[i];\n\n\tint cnt = 0;\n\tfor(int x=0;x p[x+1] and p[x+1] > p[x+2])\n\t\t{\n\t\t\tcnt++;\n\t\t}\n\t}\n\tcout << cnt << endl;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s745278965", "group_id": "codeNet:p02988", "input_text": "#include\n\nusing namespace std;\nusing ll = long long;\nusing ii = pair < int , int >;\nusing i3 = pair < int , ii >;\nusing vi = vector < int >;\nusing vii = vector < ii >;\nusing vi3 = vector < i3 >;\n\nconst int N = 25;\nconst ll INF = 1e12;\nconst double eps = 1e-9 , PI = acos(-1);\n\nint n , m;\nint a[N];\n\nvoid solve(){\n scanf(\"%d\" , &n);\n for(int i = 0 ; i < n ; i ++){\n scanf(\"%d\" , &a[i]);\n }\n int ans = 0;\n for(int i = 1 ; i < n-1 ; i ++){\n vi tmp({a[i-1] , a[i] , a[i+1]});\n sort(tmp.begin() , tmp.end());\n if(tmp[1] == a[i])ans ++;\n }\n printf(\"%d\\n\" , ans);\n\n}\n\nmain(){\n int t = 1;\n //scanf(\"%d\" , &t);\n\n while( t -- ){\n solve();\n }\n\n return 0;\n}\n\n\n", "language": "C++", "metadata": {"date": 1561856867, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/C++/s745278965.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745278965", "user_id": "u284539389"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\n\nusing namespace std;\nusing ll = long long;\nusing ii = pair < int , int >;\nusing i3 = pair < int , ii >;\nusing vi = vector < int >;\nusing vii = vector < ii >;\nusing vi3 = vector < i3 >;\n\nconst int N = 25;\nconst ll INF = 1e12;\nconst double eps = 1e-9 , PI = acos(-1);\n\nint n , m;\nint a[N];\n\nvoid solve(){\n scanf(\"%d\" , &n);\n for(int i = 0 ; i < n ; i ++){\n scanf(\"%d\" , &a[i]);\n }\n int ans = 0;\n for(int i = 1 ; i < n-1 ; i ++){\n vi tmp({a[i-1] , a[i] , a[i+1]});\n sort(tmp.begin() , tmp.end());\n if(tmp[1] == a[i])ans ++;\n }\n printf(\"%d\\n\" , ans);\n\n}\n\nmain(){\n int t = 1;\n //scanf(\"%d\" , &t);\n\n while( t -- ){\n solve();\n }\n\n return 0;\n}\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 742, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s747717894", "group_id": "codeNet:p02989", "input_text": "#include \nusing namespace std;\n\nint main(){\n int n; cin>>n;\n vector d(n);\n for(int &x: d) cin>>x;\n sort(d.begin(),d.end());\n cout<\nusing namespace std;\n\nint main(){\n int n; cin>>n;\n vector d(n);\n for(int &x: d) cin>>x;\n sort(d.begin(),d.end());\n cout<\n#include \n#include \n#include \nusing namespace std;\n\nuintmax_t combination(unsigned int n, unsigned int r) {\n if ( r * 2 > n ) r = n - r;\n uintmax_t dividend = 1;\n uintmax_t divisor = 1;\n for ( unsigned int i = 1; i <= r; ++i ) {\n dividend *= (n-i+1);\n divisor *= i;\n }\n return dividend / divisor;\n}\n\nint main() {\n int K, N;\n cin >> N >> K;\n for (int i = 1; i <= K; i++) {\n // cout << K-1 << \",\" << i-1 << \"|\" << N-K+1 << \",\" << i << endl;\n if (N-K+1 < i || K-1 < i-1) cout << \"0\" << endl;\n else cout << (combination(K-1, i-1) * combination(N-K+1, i)) % 1000000007 << endl;\n }\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1561861068, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/C++/s475454151.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s475454151", "user_id": "u370509310"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "#include \n#include \n#include \n#include \nusing namespace std;\n\nuintmax_t combination(unsigned int n, unsigned int r) {\n if ( r * 2 > n ) r = n - r;\n uintmax_t dividend = 1;\n uintmax_t divisor = 1;\n for ( unsigned int i = 1; i <= r; ++i ) {\n dividend *= (n-i+1);\n divisor *= i;\n }\n return dividend / divisor;\n}\n\nint main() {\n int K, N;\n cin >> N >> K;\n for (int i = 1; i <= K; i++) {\n // cout << K-1 << \",\" << i-1 << \"|\" << N-K+1 << \",\" << i << endl;\n if (N-K+1 < i || K-1 < i-1) cout << \"0\" << endl;\n else cout << (combination(K-1, i-1) * combination(N-K+1, i)) % 1000000007 << endl;\n }\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 664, "cpu_time_ms": 146, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s461400011", "group_id": "codeNet:p02991", "input_text": "#include \"bits/stdc++.h\"\n#define _overload3(_1,_2,_3,name,...) name\n#define _rep(i,n) repi(i,0,n)\n#define repi(i,a,b) for(int i=int(a),i##_len=(b);i vi; typedef vector vll;\ntemplateusing vv = vector>; templateauto vvec(int n, int m, T v) { return vv(n, vector(m, v)); }\ntemplatebool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }\ntemplatebool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }\nconstexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;\nstruct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;\n\nusing TP = pair, int>;\n//using Q = pair, TP>;\n\nint N, M;\nvv graph, kkpGraph;\nvector dist;\n\n//vector in;\nvv visited;\n\nvoid dfs(int v, TP hist, int d) {\n //visited[v]++;\n\n if (/*d % 3 == 0 && */hist.first.first != -1) {\n kkpGraph[hist.first.first].push_back(v);\n }\n\n for (int u : graph[v]) {\n if (!visited[u][d]) {\n visited[u][d] = true;\n dfs(u, TP(mp(hist.first.second, hist.second), v), d + 1);\n }\n //if (used[v][u] < 3) {\n // used[v][u]++;\n // dfs(u, TP(mp(hist.first.second, hist.second), v), d + 1);\n //}\n }\n}\n\n//void bfs(int s) {\n// queue que;\n// que.emplace(mp(s, 0), TP({ -1, -1 }, -1));\n//\n// while (!que.empty()) {\n// auto q = que.front();\n// que.pop();\n// int v = q.first.first;\n// int d = q.first.second;\n// auto& hist = q.second;\n//\n// if (/*d % 3 == 0 && */hist.first.first != -1) {\n// kkpGraph[hist.first.first].push_back(v);\n// }\n//\n// for (int u : graph[v]) {\n// if (find(all(used[v]), mp(u, d)) == used[v].end()) {\n// used[v].insert(mp(u, d));\n// que.emplace(mp(u, (d + 1) % 3), TP(mp(hist.first.second, hist.second), v));\n// }\n// }\n// }\n//}\n\nvoid bfs_kkp(int s) {\n dist.assign(kkpGraph.size(), LINF);\n dist[s] = 0;\n queue que;\n que.push(s);\n\n while (!que.empty()) {\n int v = que.front(); que.pop();\n\n for (int e : kkpGraph[v]) {\n if (dist[e] == LINF/*&& other condition*/) {\n dist[e] = dist[v] + 1;\n que.push(e);\n }\n }\n }\n}\n\nint main() {\n cin >> N >> M;\n graph.resize(N);\n //in.resize(N);\n rep(i, M) {\n int u, v;\n cin >> u >> v;\n graph[u - 1].push_back(v - 1);\n //in[v - 1]++;\n }\n int S, T;\n cin >> S >> T;\n\n kkpGraph.resize(N);\n visited = vvec(N, 3, false);\n //used.resize(N);\n dfs(S - 1, TP(mp(-1, -1), -1), 0);\n //bfs(S - 1);\n\n rep(i, N) {\n sort(all(kkpGraph[i]));\n kkpGraph[i].erase(unique(all(kkpGraph[i])), kkpGraph[i].end());\n }\n\n bfs_kkp(S - 1);\n if (dist[T - 1] == LINF) {\n write(-1);\n }\n else {\n write(dist[T - 1]);\n }\n}", "language": "C++", "metadata": {"date": 1561864864, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02991/input.txt", "sample_output_relpath": "derived/input_output/data/p02991/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02991/C++/s461400011.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s461400011", "user_id": "u751488284"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n#define _overload3(_1,_2,_3,name,...) name\n#define _rep(i,n) repi(i,0,n)\n#define repi(i,a,b) for(int i=int(a),i##_len=(b);i vi; typedef vector vll;\ntemplateusing vv = vector>; templateauto vvec(int n, int m, T v) { return vv(n, vector(m, v)); }\ntemplatebool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }\ntemplatebool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }\nconstexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;\nstruct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;\n\nusing TP = pair, int>;\n//using Q = pair, TP>;\n\nint N, M;\nvv graph, kkpGraph;\nvector dist;\n\n//vector in;\nvv visited;\n\nvoid dfs(int v, TP hist, int d) {\n //visited[v]++;\n\n if (/*d % 3 == 0 && */hist.first.first != -1) {\n kkpGraph[hist.first.first].push_back(v);\n }\n\n for (int u : graph[v]) {\n if (!visited[u][d]) {\n visited[u][d] = true;\n dfs(u, TP(mp(hist.first.second, hist.second), v), d + 1);\n }\n //if (used[v][u] < 3) {\n // used[v][u]++;\n // dfs(u, TP(mp(hist.first.second, hist.second), v), d + 1);\n //}\n }\n}\n\n//void bfs(int s) {\n// queue que;\n// que.emplace(mp(s, 0), TP({ -1, -1 }, -1));\n//\n// while (!que.empty()) {\n// auto q = que.front();\n// que.pop();\n// int v = q.first.first;\n// int d = q.first.second;\n// auto& hist = q.second;\n//\n// if (/*d % 3 == 0 && */hist.first.first != -1) {\n// kkpGraph[hist.first.first].push_back(v);\n// }\n//\n// for (int u : graph[v]) {\n// if (find(all(used[v]), mp(u, d)) == used[v].end()) {\n// used[v].insert(mp(u, d));\n// que.emplace(mp(u, (d + 1) % 3), TP(mp(hist.first.second, hist.second), v));\n// }\n// }\n// }\n//}\n\nvoid bfs_kkp(int s) {\n dist.assign(kkpGraph.size(), LINF);\n dist[s] = 0;\n queue que;\n que.push(s);\n\n while (!que.empty()) {\n int v = que.front(); que.pop();\n\n for (int e : kkpGraph[v]) {\n if (dist[e] == LINF/*&& other condition*/) {\n dist[e] = dist[v] + 1;\n que.push(e);\n }\n }\n }\n}\n\nint main() {\n cin >> N >> M;\n graph.resize(N);\n //in.resize(N);\n rep(i, M) {\n int u, v;\n cin >> u >> v;\n graph[u - 1].push_back(v - 1);\n //in[v - 1]++;\n }\n int S, T;\n cin >> S >> T;\n\n kkpGraph.resize(N);\n visited = vvec(N, 3, false);\n //used.resize(N);\n dfs(S - 1, TP(mp(-1, -1), -1), 0);\n //bfs(S - 1);\n\n rep(i, N) {\n sort(all(kkpGraph[i]));\n kkpGraph[i].erase(unique(all(kkpGraph[i])), kkpGraph[i].end());\n }\n\n bfs_kkp(S - 1);\n if (dist[T - 1] == LINF) {\n write(-1);\n }\n else {\n write(dist[T - 1]);\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02991", "source_text": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3255, "cpu_time_ms": 1228, "memory_kb": 50816}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s744440428", "group_id": "codeNet:p02993", "input_text": "#include\n#include\n#include\nusing namespace std;\n\nint main(){\n\tstring num;\n\twhile(getline(cin,num)){\n\t\tint x,a,b;\n\t\tstringstream ss;\n\t\tss<>x;\n\t\twhile(ss>>x){\n\t\t\ta=x/1000;\n\t\t\tb=(x%1000)/100;\n\t\t\tif(a==b){\n\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ta=(x%100)/10;\n\t\t\t\tif(b==a){\n\t\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\t\tbreak;\n\t\t\t\t} \n\t\t\t\telse{\n\t\t\t\t\tb=x%10;\n\t\t\t\t\tif(a==b){\n\t\t\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} \n\t\t\t\t\telse{\n\t\t\t\t\t\tcout<<\"Good\"<<\"\\n\";\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\t\t\n}", "language": "C++", "metadata": {"date": 1561759291, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02993/input.txt", "sample_output_relpath": "derived/input_output/data/p02993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02993/C++/s744440428.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744440428", "user_id": "u564278825"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "#include\n#include\n#include\nusing namespace std;\n\nint main(){\n\tstring num;\n\twhile(getline(cin,num)){\n\t\tint x,a,b;\n\t\tstringstream ss;\n\t\tss<>x;\n\t\twhile(ss>>x){\n\t\t\ta=x/1000;\n\t\t\tb=(x%1000)/100;\n\t\t\tif(a==b){\n\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ta=(x%100)/10;\n\t\t\t\tif(b==a){\n\t\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\t\tbreak;\n\t\t\t\t} \n\t\t\t\telse{\n\t\t\t\t\tb=x%10;\n\t\t\t\t\tif(a==b){\n\t\t\t\t\t\tcout<<\"Bad\"<<\"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} \n\t\t\t\t\telse{\n\t\t\t\t\t\tcout<<\"Good\"<<\"\\n\";\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\t\t\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 539, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s258376852", "group_id": "codeNet:p02994", "input_text": "#include\nusing namespace std;\nint main()\n{\n int n,l;\n cin>>n>>l;\n int sum=0;\n int pie[n+1];\n int m1,m2;\n for(int i=1;i<=n;i++){\n pie[i]=l+i-1;\n sum+=pie[i];\n }\n for(int i=1;i<=n;i++){\n if(i==1){\n m2=sum-pie[i];\n m1=abs(pie[i]);\n //cout<\nusing namespace std;\nint main()\n{\n int n,l;\n cin>>n>>l;\n int sum=0;\n int pie[n+1];\n int m1,m2;\n for(int i=1;i<=n;i++){\n pie[i]=l+i-1;\n sum+=pie[i];\n }\n for(int i=1;i<=n;i++){\n if(i==1){\n m2=sum-pie[i];\n m1=abs(pie[i]);\n //cout<\nusing namespace std;\nint main()\n{\n int n, l, s, m;\n cin >> n;\n cin >> l;\n s = l+1;\n m = l+n;\n if(l>0){\n for(int i=0;i<=n;i++){\n l= l +1;\n }\n cout << l-s<< '\\n';\n\n }\n if(l<0){\n if(l-n>0){\n for(int i=0;i<=n;i++){\n l= l + 1;\n }\n cout << l << '\\n';\n\n }\n if(l-n>0){\n for(int i=0;i\nusing namespace std;\nint main()\n{\n int n, l, s, m;\n cin >> n;\n cin >> l;\n s = l+1;\n m = l+n;\n if(l>0){\n for(int i=0;i<=n;i++){\n l= l +1;\n }\n cout << l-s<< '\\n';\n\n }\n if(l<0){\n if(l-n>0){\n for(int i=0;i<=n;i++){\n l= l + 1;\n }\n cout << l << '\\n';\n\n }\n if(l-n>0){\n for(int i=0;i> a >> b >> c >> d;\n\tcout << f(b) - f(a-1) << endl;\n}\n\nint main()\n{\n\tsolve();\n\t//cout << \"yui(*-v・)yui\" << endl;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1561236477, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/C++/s331740612.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331740612", "user_id": "u344412812"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n\nusing namespace std;\n\nlong a, b, c, d;\n\nlong f(long x)\n{\n\treturn (x - x/c - x/d + x/(c*d/__gcd(c,d)));\n}\n\nvoid solve(void)\n{\n\tcin >> a >> b >> c >> d;\n\tcout << f(b) - f(a-1) << endl;\n}\n\nint main()\n{\n\tsolve();\n\t//cout << \"yui(*-v・)yui\" << endl;\n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 285, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s452868023", "group_id": "codeNet:p02997", "input_text": "#include \n#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define int long long\n#define pb insert\n#define sz(i) (int)(i.size())\n#define F first\n#define S second\n#define L long double\n#define P pair\nconst int inf = 0x3f3f3f3f3f3f3f3LL;\nconst int mod = (int)1e9 + 7;\nusing namespace std;\n#if LOCAL\n#include \"../../tr.h\"\n#else\n#define tr(...)\n#define endl '\\n'\n#endif\ntemplate void smin(T& a, T val) {if (a > val) a = val;}template void smax(T& a, T val) {if (a < val) a = val;}\nconst int N = 5*(int)1e5 + 10;\n\nint n, k;\nset

v;\n\nint32_t main(){_\n\n cin>>n>>k;\n\n int ma = (n-2) * (n-1) / 2;\n \n if (k <= 0){\n cout<<-1;\n exit(0);\n }\n\n if (k > ma){\n cout<<-1;\n exit(0);\n }\n\n int vals = 0;\n for (int adj = 1; adj <= n; ++adj)\n {\n int tot = adj - 1;\n tot = tot * (tot+1);\n tot >>= 1;\n if(tot <= k){\n vals = adj;\n }\n else{\n break;\n }\n }\n\n int adj = vals;\n\n for (int i = 1; i <= adj; ++i)\n {\n v.pb({1, i+1});\n }\n\n k -= ((adj * (adj - 1)) / 2);\n\n adj+=2;\n int lst = adj;\n tr(adj, k, v);\n for (int i = adj; i <= n; ++i)\n {\n int poss = adj-2;\n if(k > 0 and k - poss < 0){\n v.pb({i, 1});\n int rem = k;\n k = 0;\n for (int j = 2; j <= adj-rem-1; ++j)\n {\n v.pb({i, j}); \n }\n lst = adj+1;\n break;\n }\n }\n\n tr(lst, k);\n\n for (int i = lst; i <= n; ++i)\n {\n for (int j = 1; j <= i-1; ++j)\n {\n v.pb({i, j});\n }\n }\n\n if(k > 0){\n assert(0);\n cout<<-1;\n exit(0);\n }\n\n cout<\n#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define int long long\n#define pb insert\n#define sz(i) (int)(i.size())\n#define F first\n#define S second\n#define L long double\n#define P pair\nconst int inf = 0x3f3f3f3f3f3f3f3LL;\nconst int mod = (int)1e9 + 7;\nusing namespace std;\n#if LOCAL\n#include \"../../tr.h\"\n#else\n#define tr(...)\n#define endl '\\n'\n#endif\ntemplate void smin(T& a, T val) {if (a > val) a = val;}template void smax(T& a, T val) {if (a < val) a = val;}\nconst int N = 5*(int)1e5 + 10;\n\nint n, k;\nset

v;\n\nint32_t main(){_\n\n cin>>n>>k;\n\n int ma = (n-2) * (n-1) / 2;\n \n if (k <= 0){\n cout<<-1;\n exit(0);\n }\n\n if (k > ma){\n cout<<-1;\n exit(0);\n }\n\n int vals = 0;\n for (int adj = 1; adj <= n; ++adj)\n {\n int tot = adj - 1;\n tot = tot * (tot+1);\n tot >>= 1;\n if(tot <= k){\n vals = adj;\n }\n else{\n break;\n }\n }\n\n int adj = vals;\n\n for (int i = 1; i <= adj; ++i)\n {\n v.pb({1, i+1});\n }\n\n k -= ((adj * (adj - 1)) / 2);\n\n adj+=2;\n int lst = adj;\n tr(adj, k, v);\n for (int i = adj; i <= n; ++i)\n {\n int poss = adj-2;\n if(k > 0 and k - poss < 0){\n v.pb({i, 1});\n int rem = k;\n k = 0;\n for (int j = 2; j <= adj-rem-1; ++j)\n {\n v.pb({i, j}); \n }\n lst = adj+1;\n break;\n }\n }\n\n tr(lst, k);\n\n for (int i = lst; i <= n; ++i)\n {\n for (int j = 1; j <= i-1; ++j)\n {\n v.pb({i, j});\n }\n }\n\n if(k > 0){\n assert(0);\n cout<<-1;\n exit(0);\n }\n\n cout<> X >> A;\n\tif (X < A) cout << 0;\n\telse cout << 10;\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1561996841, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/C++/s905157501.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s905157501", "user_id": "u074003648"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n \nusing namespace std;\n \nint X, A;\n \nint main() {\n\tcin >> X >> A;\n\tif (X < A) cout << 0;\n\telse cout << 10;\n\treturn 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s829193727", "group_id": "codeNet:p02999", "input_text": "#include \nusing namespace std;\n \nint main() {\n int X, A;\n cin >> X >> A;\n cout << (X < A ? 0 : 10);\n}", "language": "C++", "metadata": {"date": 1560725240, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p02999/input.txt", "sample_output_relpath": "derived/input_output/data/p02999/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02999/C++/s829193727.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829193727", "user_id": "u261514692"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include \nusing namespace std;\n \nint main() {\n int X, A;\n cin >> X >> A;\n cout << (X < A ? 0 : 10);\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02999", "source_text": "Score : 100 points\n\nProblem Statement\n\nX and A are integers between 0 and 9 (inclusive).\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nConstraints\n\n0 \\leq X, A \\leq 9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A\n\nOutput\n\nIf X is less than A, print 0; if X is not less than A, print 10.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\n3 is less than 5, so we should print 0.\n\nSample Input 2\n\n7 5\n\nSample Output 2\n\n10\n\n7 is not less than 5, so we should print 10.\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n10\n\n6 is not less than 6, so we should print 10.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 119, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s275098334", "group_id": "codeNet:p03000", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N, X;\n cin >> N >> X;\n int L[N];\n int D[N]={0};\n for(int i=0; i> L[i];\n }\n \n for(int j=1; j X){\n cout << j;\n return 0;\n }\n }\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1570805690, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/C++/s275098334.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s275098334", "user_id": "u115102935"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int N, X;\n cin >> N >> X;\n int L[N];\n int D[N]={0};\n for(int i=0; i> L[i];\n }\n \n for(int j=1; j X){\n cout << j;\n return 0;\n }\n }\n \n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s715545945", "group_id": "codeNet:p03001", "input_text": "using namespace std;\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;\n \n \nint main(void){\n\tlong long int W,H,x,y;\n \n\tcin >>W>>H>>x>>y;\n \n \tlong long int xmin = min(W - x, x), ymin = min(H - y, y);\n\t\n\tcout << (long double)W * (long double)H / (long double)2.0 << \" \" << ((xmin * H == ymin * W) ? 1 : 0) << endl;\n \n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1560717393, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/C++/s715545945.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s715545945", "user_id": "u766779796"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "using namespace std;\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;\n \n \nint main(void){\n\tlong long int W,H,x,y;\n \n\tcin >>W>>H>>x>>y;\n \n \tlong long int xmin = min(W - x, x), ymin = min(H - y, y);\n\t\n\tcout << (long double)W * (long double)H / (long double)2.0 << \" \" << ((xmin * H == ymin * W) ? 1 : 0) << endl;\n \n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 522, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s083278905", "group_id": "codeNet:p03001", "input_text": "#include \nusing namespace std;\nusing ll = long long;\n#define rep(i, m, n) for (int i = m; i < n; ++i)\n#define rem(i, m, n) for (int i = m; i > n; --i)\nconst int MOD = 1000000007;\n\nint main() {\n double W, H, x, y;\n cin >> W >> H >> x >> y;\n printf(\"%.15lf \", W * H / 2);\n double mx = W / 2, my = H / 2;\n if(x == mx && y == my) cout << 1 << endl;\n else cout << 0 << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1560712462, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/C++/s083278905.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s083278905", "user_id": "u756388720"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\n#define rep(i, m, n) for (int i = m; i < n; ++i)\n#define rem(i, m, n) for (int i = m; i > n; --i)\nconst int MOD = 1000000007;\n\nint main() {\n double W, H, x, y;\n cin >> W >> H >> x >> y;\n printf(\"%.15lf \", W * H / 2);\n double mx = W / 2, my = H / 2;\n if(x == mx && y == my) cout << 1 << endl;\n else cout << 0 << endl;\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 405, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s044478620", "group_id": "codeNet:p03003", "input_text": "#include \nusing namespace std;\n\nint main() {\n int64_t MOD = 1000000000 + 7;\n int N, M;\n cin >> N >> M;\n vector S(N);\n vector T(M);\n for(int i = 0; i < N; i++) {\n cin >> S.at(i);\n }\n for(int i = 0; i < M; i++) {\n cin >> T.at(i);\n }\n vector> data(N + 1, vector (M + 1, 0));\n for(int i = 0; i <= N; i++) {\n data.at(i).at(0) = 1;\n }\n for(int i = 0; i <= M; i++) {\n data.at(0).at(i) = 1;\n }\n for(int i = 1; i <= N; i++) {\n for(int j = 1; j <= M; j++) {\n if(S.at(i - 1) == T.at(j - 1)) {\n data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j);\n data.at(i).at(j) %= MOD;\n }\n else {\n data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j) - data.at(i - 1).at(j - 1);\n data.at(i).at(j) %= MOD;\n }\n }\n }\n cout << data.at(N).at(M) << endl;\n}", "language": "C++", "metadata": {"date": 1597149146, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03003.html", "problem_id": "p03003", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03003/input.txt", "sample_output_relpath": "derived/input_output/data/p03003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03003/C++/s044478620.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s044478620", "user_id": "u602140789"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int64_t MOD = 1000000000 + 7;\n int N, M;\n cin >> N >> M;\n vector S(N);\n vector T(M);\n for(int i = 0; i < N; i++) {\n cin >> S.at(i);\n }\n for(int i = 0; i < M; i++) {\n cin >> T.at(i);\n }\n vector> data(N + 1, vector (M + 1, 0));\n for(int i = 0; i <= N; i++) {\n data.at(i).at(0) = 1;\n }\n for(int i = 0; i <= M; i++) {\n data.at(0).at(i) = 1;\n }\n for(int i = 1; i <= N; i++) {\n for(int j = 1; j <= M; j++) {\n if(S.at(i - 1) == T.at(j - 1)) {\n data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j);\n data.at(i).at(j) %= MOD;\n }\n else {\n data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j) - data.at(i - 1).at(j - 1);\n data.at(i).at(j) %= MOD;\n }\n }\n }\n cout << data.at(N).at(M) << endl;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "sample_input": "2 2\n1 3\n3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03003", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 888, "cpu_time_ms": 57, "memory_kb": 34564}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s012650920", "group_id": "codeNet:p03003", "input_text": "#define _CRT_SECURE_NO_WARNINGS\n#pragma comment(linker, \"/stack:256000000\")\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//4Head\n#define all(x) x.begin(), x.end()\n#define mp make_pair\n#define X first\n#define Y second\n\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\nmt19937_64 gen(time(NULL));\n\n// belik's shit\nll const mod = 1e9 + 7;\nnamespace {\n\tll mult(ll a, ll b) {\n\t\tll val = a * b - (ll)((ld)a * b / mod) * mod;\n\t\tif (val < 0) {\n\t\t\tval += mod;\n\t\t}\n\t\tif (val >= mod) {\n\t\t\tval -= mod;\n\t\t}\n\t\treturn val;\n\t}\n\tll poww(ll a, ll b)\n\t{\n\t\tll val = 1;\n\t\ta %= mod;\n\t\twhile (b > 0){\n\t\t\tif (b % 2) val = mult(a, val);\n\t\t\ta = mult(a, a);\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn val % mod;\n\t}\n\tll inv(ll a) {\n\t\treturn poww(a, mod - 2);\n\t}\n}\n\nll const maxn = 2e3 + 5;\n\n\nll dp[maxn][maxn];\n\nsigned main() {\n\tios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tll n, m; cin >> n >> m;\n\tvectora(n + 1), b(m + 1);\n\ta[0] = -1; b[0] = -2;\n\tfor (ll i = 1; i <= n; i++) cin >> a[i];\n\tfor (ll i = 1; i <= m; i++) cin >> b[i];\n\tdp[0][0] = 1;\n\tfor (ll i = 0; i <= n; i++) {\n\t\tfor (ll j = 0; j <= m; j++) {\n\t\t\t(dp[i][j] += (i ? dp[i - 1][j] : 0)) %= mod;\n\t\t\t(dp[i][j] += (j ? dp[i][j - 1] : 0)) %= mod;\n\t\t\t(dp[i][j] -= (i && j ? dp[i - 1][j - 1] : 0)) %= mod;\n\t\t\tif (dp[i][j] < 0) dp[i][j] += mod;\n\t\t\tif (a[i] == b[j]) {\n\t\t\t\t(dp[i][j] += (i && j ? dp[i - 1][j - 1] : 0)) %= mod;\n\t\t\t}\n\t\t\tll tt = 0;\n\t\t}\n\t}\n\tcout << (dp[n][m])%mod << endl;\n\treturn 0;\n\n}\n/*\n\n*/", "language": "C++", "metadata": {"date": 1564920676, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03003.html", "problem_id": "p03003", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03003/input.txt", "sample_output_relpath": "derived/input_output/data/p03003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03003/C++/s012650920.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012650920", "user_id": "u258032299"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#define _CRT_SECURE_NO_WARNINGS\n#pragma comment(linker, \"/stack:256000000\")\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//4Head\n#define all(x) x.begin(), x.end()\n#define mp make_pair\n#define X first\n#define Y second\n\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\nmt19937_64 gen(time(NULL));\n\n// belik's shit\nll const mod = 1e9 + 7;\nnamespace {\n\tll mult(ll a, ll b) {\n\t\tll val = a * b - (ll)((ld)a * b / mod) * mod;\n\t\tif (val < 0) {\n\t\t\tval += mod;\n\t\t}\n\t\tif (val >= mod) {\n\t\t\tval -= mod;\n\t\t}\n\t\treturn val;\n\t}\n\tll poww(ll a, ll b)\n\t{\n\t\tll val = 1;\n\t\ta %= mod;\n\t\twhile (b > 0){\n\t\t\tif (b % 2) val = mult(a, val);\n\t\t\ta = mult(a, a);\n\t\t\tb >>= 1;\n\t\t}\n\t\treturn val % mod;\n\t}\n\tll inv(ll a) {\n\t\treturn poww(a, mod - 2);\n\t}\n}\n\nll const maxn = 2e3 + 5;\n\n\nll dp[maxn][maxn];\n\nsigned main() {\n\tios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tll n, m; cin >> n >> m;\n\tvectora(n + 1), b(m + 1);\n\ta[0] = -1; b[0] = -2;\n\tfor (ll i = 1; i <= n; i++) cin >> a[i];\n\tfor (ll i = 1; i <= m; i++) cin >> b[i];\n\tdp[0][0] = 1;\n\tfor (ll i = 0; i <= n; i++) {\n\t\tfor (ll j = 0; j <= m; j++) {\n\t\t\t(dp[i][j] += (i ? dp[i - 1][j] : 0)) %= mod;\n\t\t\t(dp[i][j] += (j ? dp[i][j - 1] : 0)) %= mod;\n\t\t\t(dp[i][j] -= (i && j ? dp[i - 1][j - 1] : 0)) %= mod;\n\t\t\tif (dp[i][j] < 0) dp[i][j] += mod;\n\t\t\tif (a[i] == b[j]) {\n\t\t\t\t(dp[i][j] += (i && j ? dp[i - 1][j - 1] : 0)) %= mod;\n\t\t\t}\n\t\t\tll tt = 0;\n\t\t}\n\t}\n\tcout << (dp[n][m])%mod << endl;\n\treturn 0;\n\n}\n/*\n\n*/", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "sample_input": "2 2\n1 3\n3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03003", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1811, "cpu_time_ms": 84, "memory_kb": 31616}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s718710589", "group_id": "codeNet:p03004", "input_text": "#include \n#define int long long\n#define double long double\n#pragma GCC optimize(\"O3,Ofast,no-stack-protector,unroll-loops,fast-math\")\n#pragma GCC target(\"avx,avx2,sse\")\nusing namespace std;\n\nint n;\nvector x(n);\nvector y(n);\nvector c(n);\n\ndouble calc(double steps) {\n double ax = 1e15;\n double bx = -1e15;\n double ay = 1e15;\n double by = -1e15;\n for (int i = 0; i < n; i++) {\n double X = x[i];\n double Y = y[i];\n if (c[i] == 'L') X -= steps;\n if (c[i] == 'R') X += steps;\n if (c[i] == 'D') Y -= steps;\n if (c[i] == 'U') Y += steps;\n ax = min(ax, X);\n bx = max(bx, X);\n ay = min(ay, Y);\n by = max(by, Y);\n }\n return (by - ay) * (bx - ax);\n}\n\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n cin >> n;\n x.resize(n);\n y.resize(n);\n c.resize(n);\n for (int i = 0; i < n; i++) {\n cin >> x[i] >> y[i] >> c[i];\n }\n double s = 0;\n double e = 1e9;\n while (e - s > 0.000000000001) {\n double a = (s * 2 + e) / 3.0;\n double b = (s + e * 2) / 3.0;\n double fa = calc(a);\n double fb = calc(b);\n if (fa <= fb) {\n e = b;\n } else {\n s = a;\n }\n }\n cout << fixed << ' ' << setprecision(11) << calc(s) << endl;\n\n fflush(stdout);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592869146, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03004.html", "problem_id": "p03004", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03004/input.txt", "sample_output_relpath": "derived/input_output/data/p03004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03004/C++/s718710589.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s718710589", "user_id": "u460297807"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "#include \n#define int long long\n#define double long double\n#pragma GCC optimize(\"O3,Ofast,no-stack-protector,unroll-loops,fast-math\")\n#pragma GCC target(\"avx,avx2,sse\")\nusing namespace std;\n\nint n;\nvector x(n);\nvector y(n);\nvector c(n);\n\ndouble calc(double steps) {\n double ax = 1e15;\n double bx = -1e15;\n double ay = 1e15;\n double by = -1e15;\n for (int i = 0; i < n; i++) {\n double X = x[i];\n double Y = y[i];\n if (c[i] == 'L') X -= steps;\n if (c[i] == 'R') X += steps;\n if (c[i] == 'D') Y -= steps;\n if (c[i] == 'U') Y += steps;\n ax = min(ax, X);\n bx = max(bx, X);\n ay = min(ay, Y);\n by = max(by, Y);\n }\n return (by - ay) * (bx - ax);\n}\n\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n cin >> n;\n x.resize(n);\n y.resize(n);\n c.resize(n);\n for (int i = 0; i < n; i++) {\n cin >> x[i] >> y[i] >> c[i];\n }\n double s = 0;\n double e = 1e9;\n while (e - s > 0.000000000001) {\n double a = (s * 2 + e) / 3.0;\n double b = (s + e * 2) / 3.0;\n double fa = calc(a);\n double fb = calc(b);\n if (fa <= fb) {\n e = b;\n } else {\n s = a;\n }\n }\n cout << fixed << ' ' << setprecision(11) << calc(s) << endl;\n\n fflush(stdout);\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "sample_input": "2\n0 3 D\n3 0 L\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03004", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1398, "cpu_time_ms": 5513, "memory_kb": 5236}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s945988342", "group_id": "codeNet:p03007", "input_text": "#include \nusing namespace std;\nusing ll = long long;\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)\n#define all(v) v.begin(), v.end()\n#define sz(v) v.size()\n#define INF 100000000000000 //10^14\ntemplate \nbool chmax(T &a, const T& b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nbool chmin(T &a, const T& b) {\n if (a > b) {\n a = b;\n return true;\n }\n return false;\n}\n\nint main()\n{\n ll N;\n cin >> N;\n vector A(N);\n rep(i, N) cin >> A.at(i);\n sort(all(A));\n ll p = N;\n rep(i, N){\n if(A.at(i) > 0){\n p = i;\n break;\n }\n }\n ll M = 0;\n M += A.at(N-1);\n M -= A.at(0);\n rep(i, N-2){\n if(i+1 >= p){\n M += A.at(i+1);\n }\n else{\n M -= A.at(i+1);\n }\n }\n cout << M << endl;\n ll x = A.at(0);\n if(p == 0){\n p++;\n }\n rep2(j, p, N-1){\n cout << x << \" \" << A.at(j) << endl;\n x -= A.at(j);\n }\n ll y = A.at(N-1);\n rep2(i, 1, p){\n cout << y << \" \" << A.at(i) << endl;\n y -= A.at(i);\n }\n cout << y << \" \" << x << endl;\n}", "language": "C++", "metadata": {"date": 1598748303, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03007.html", "problem_id": "p03007", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03007/input.txt", "sample_output_relpath": "derived/input_output/data/p03007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03007/C++/s945988342.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s945988342", "user_id": "u208059640"}, "prompt_components": {"gold_output": "4\n-1 1\n2 -2\n", "input_to_evaluate": "#include \nusing namespace std;\nusing ll = long long;\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)\n#define all(v) v.begin(), v.end()\n#define sz(v) v.size()\n#define INF 100000000000000 //10^14\ntemplate \nbool chmax(T &a, const T& b) {\n if (a < b) {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \nbool chmin(T &a, const T& b) {\n if (a > b) {\n a = b;\n return true;\n }\n return false;\n}\n\nint main()\n{\n ll N;\n cin >> N;\n vector A(N);\n rep(i, N) cin >> A.at(i);\n sort(all(A));\n ll p = N;\n rep(i, N){\n if(A.at(i) > 0){\n p = i;\n break;\n }\n }\n ll M = 0;\n M += A.at(N-1);\n M -= A.at(0);\n rep(i, N-2){\n if(i+1 >= p){\n M += A.at(i+1);\n }\n else{\n M -= A.at(i+1);\n }\n }\n cout << M << endl;\n ll x = A.at(0);\n if(p == 0){\n p++;\n }\n rep2(j, p, N-1){\n cout << x << \" \" << A.at(j) << endl;\n x -= A.at(j);\n }\n ll y = A.at(N-1);\n rep2(i, 1, p){\n cout << y << \" \" << A.at(i) << endl;\n y -= A.at(i);\n }\n cout << y << \" \" << x << endl;\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "sample_input": "3\n1 -1 2\n"}, "reference_outputs": ["4\n-1 1\n2 -2\n"], "source_document_id": "p03007", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1191, "cpu_time_ms": 185, "memory_kb": 4052}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s761030962", "group_id": "codeNet:p03008", "input_text": "#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 rep(index,num) for(int index=0;index>argument\n#define prin(argument) cout< pll;\ntypedef pair pint;\ntypedef vector vint;\ntypedef vector vll;\ntypedef vector vpint;\ntypedef vector vpll;\nll INFl=1e+18+1;\nint INF=1e+9+1;\nint main(){\n\tll N,g[2][3];\n\tscan(N);\n\trep(i,2) rep(j,3) scan(g[i][j]);\n\tvpll AB,BA;\n\trep(j,3){\n\t\tif(g[0][j]g[1][j]) BA.push_back({g[1][j],g[0][j]});\n\t}\n\tll maxD=N;\n\tif(AB.size()==3){\n\t\tfor(ll a=0;a*AB[0].first<=N;a++){\n\t\t\tfor(ll b=0;a*AB[0].first+b*AB[1].first<=N;b++){\n\t\t\t\tll c=(N-a*AB[0].first-b*AB[1].first)/AB[2].first;\n\t\t\t\tll nokorid=N-a*AB[0].first-b*AB[1].first-c*AB[2].first;\n\t\t\t\tll D=nokorid+a*AB[0].second+b*AB[1].second+c*AB[2].second;\n\t\t\t\tmaxD=max(maxD,D);\n\t\t\t\t//printf(\"a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,c,nokorid,D,maxD);\n\t\t\t}\n\t\t}\n\t}\n\telse if(AB.size()==2){\n\t\tfor(ll a=0;a*AB[0].first<=N;a++){\n\t\t\tll b=(N-a*AB[0].first)/AB[1].first;\n\t\t\tll nokorid=N-a*AB[0].first-b*AB[1].first;\n\t\t\tll D=nokorid+a*AB[0].second+b*AB[1].second;\n\t\t\tmaxD=max(maxD,D);\n\t\t\t//printf(\"a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,nokorid,D,maxD);\n\n\t\t}\n\t}\n\telse if(AB.size()==1){\n\t\tmaxD=(N-N/AB[0].first*AB[0].first+N/AB[0].first*AB[0].second);\n\t}\n\t//printf(\"maxD:%lld\\n\",maxD);\n\tN=maxD;\n\tif(BA.size()==3){\n\t\tfor(ll a=0;a*BA[0].first<=N;a++){\n\t\t\tfor(ll b=0;a*BA[0].first+b*BA[1].first<=N;b++){\n\t\t\t\tll c=(N-a*BA[0].first-b*BA[1].first)/BA[2].first;\n\t\t\t\tll nokorid=N-a*BA[0].first-b*BA[1].first-c*BA[2].first;\n\t\t\t\tll D=nokorid+a*BA[0].second+b*BA[1].second+c*BA[2].second;\n\t\t\t\tmaxD=max(maxD,D);\n\t\t\t\t//printf(\"a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,c,nokorid,D,maxD);\n\n\t\t\t}\n\t\t}\n\t}\n\telse if(BA.size()==2){\n\t\tfor(ll a=0;a*BA[0].first<=N;a++){\n\t\t\tll b=(N-a*BA[0].first)/BA[1].first;\n\t\t\tll nokorid=N-a*BA[0].first-b*BA[1].first;\n\t\t\tll D=nokorid+a*BA[0].second+b*BA[1].second;\n\t\t\tmaxD=max(maxD,D);\n\t\t//\tprintf(\"a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,nokorid,D,maxD);\n\n\t\t}\n\t}\n\telse if(BA.size()==1){\n\t\tmaxD=(N-N/BA[0].first*BA[0].first+N/BA[0].first*BA[0].second);\n\t}\n\tprin(maxD);\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1560650913, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03008.html", "problem_id": "p03008", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03008/input.txt", "sample_output_relpath": "derived/input_output/data/p03008/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03008/C++/s761030962.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s761030962", "user_id": "u222030240"}, "prompt_components": {"gold_output": "46\n", "input_to_evaluate": "#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 rep(index,num) for(int index=0;index>argument\n#define prin(argument) cout< pll;\ntypedef pair pint;\ntypedef vector vint;\ntypedef vector vll;\ntypedef vector vpint;\ntypedef vector vpll;\nll INFl=1e+18+1;\nint INF=1e+9+1;\nint main(){\n\tll N,g[2][3];\n\tscan(N);\n\trep(i,2) rep(j,3) scan(g[i][j]);\n\tvpll AB,BA;\n\trep(j,3){\n\t\tif(g[0][j]g[1][j]) BA.push_back({g[1][j],g[0][j]});\n\t}\n\tll maxD=N;\n\tif(AB.size()==3){\n\t\tfor(ll a=0;a*AB[0].first<=N;a++){\n\t\t\tfor(ll b=0;a*AB[0].first+b*AB[1].first<=N;b++){\n\t\t\t\tll c=(N-a*AB[0].first-b*AB[1].first)/AB[2].first;\n\t\t\t\tll nokorid=N-a*AB[0].first-b*AB[1].first-c*AB[2].first;\n\t\t\t\tll D=nokorid+a*AB[0].second+b*AB[1].second+c*AB[2].second;\n\t\t\t\tmaxD=max(maxD,D);\n\t\t\t\t//printf(\"a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,c,nokorid,D,maxD);\n\t\t\t}\n\t\t}\n\t}\n\telse if(AB.size()==2){\n\t\tfor(ll a=0;a*AB[0].first<=N;a++){\n\t\t\tll b=(N-a*AB[0].first)/AB[1].first;\n\t\t\tll nokorid=N-a*AB[0].first-b*AB[1].first;\n\t\t\tll D=nokorid+a*AB[0].second+b*AB[1].second;\n\t\t\tmaxD=max(maxD,D);\n\t\t\t//printf(\"a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,nokorid,D,maxD);\n\n\t\t}\n\t}\n\telse if(AB.size()==1){\n\t\tmaxD=(N-N/AB[0].first*AB[0].first+N/AB[0].first*AB[0].second);\n\t}\n\t//printf(\"maxD:%lld\\n\",maxD);\n\tN=maxD;\n\tif(BA.size()==3){\n\t\tfor(ll a=0;a*BA[0].first<=N;a++){\n\t\t\tfor(ll b=0;a*BA[0].first+b*BA[1].first<=N;b++){\n\t\t\t\tll c=(N-a*BA[0].first-b*BA[1].first)/BA[2].first;\n\t\t\t\tll nokorid=N-a*BA[0].first-b*BA[1].first-c*BA[2].first;\n\t\t\t\tll D=nokorid+a*BA[0].second+b*BA[1].second+c*BA[2].second;\n\t\t\t\tmaxD=max(maxD,D);\n\t\t\t\t//printf(\"a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,c,nokorid,D,maxD);\n\n\t\t\t}\n\t\t}\n\t}\n\telse if(BA.size()==2){\n\t\tfor(ll a=0;a*BA[0].first<=N;a++){\n\t\t\tll b=(N-a*BA[0].first)/BA[1].first;\n\t\t\tll nokorid=N-a*BA[0].first-b*BA[1].first;\n\t\t\tll D=nokorid+a*BA[0].second+b*BA[1].second;\n\t\t\tmaxD=max(maxD,D);\n\t\t//\tprintf(\"a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\\n\",a,b,nokorid,D,maxD);\n\n\t\t}\n\t}\n\telse if(BA.size()==1){\n\t\tmaxD=(N-N/BA[0].first*BA[0].first+N/BA[0].first*BA[0].second);\n\t}\n\tprin(maxD);\n\treturn 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThe squirrel Chokudai has N acorns.\nOne day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\nGet out of the nest with N acorns in his hands.\n\nGo to Exchange A and do some trades.\n\nGo to Exchange B and do some trades.\n\nGo to Exchange A and do some trades.\n\nGo back to the nest.\n\nIn Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:\n\nLose g_{X} acorns and gain 1 gram of gold.\n\nGain g_{X} acorns and lose 1 gram of gold.\n\nLose s_{X} acorns and gain 1 gram of silver.\n\nGain s_{X} acorns and lose 1 gram of silver.\n\nLose b_{X} acorns and gain 1 gram of bronze.\n\nGain b_{X} acorns and lose 1 gram of bronze.\n\nNaturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.\n\nWhat is the maximum number of acorns that he can bring to the nest?\nNote that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq g_{X} \\leq 5000\n\n1 \\leq s_{X} \\leq 5000\n\n1 \\leq b_{X} \\leq 5000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ng_A s_A b_A\ng_B s_B b_B\n\nOutput\n\nPrint the maximum number of acorns that Chokudai can bring to the nest.\n\nSample Input 1\n\n23\n1 1 1\n2 1 1\n\nSample Output 1\n\n46\n\nHe can bring 46 acorns to the nest, as follows:\n\nIn Exchange A, trade 23 acorns for 23 grams of gold. {acorns, gold, silver, bronze}={ 0,23,0,0 }\n\nIn Exchange B, trade 23 grams of gold for 46 acorns. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nIn Exchange A, trade nothing. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nHe cannot have 47 or more acorns, so the answer is 46.", "sample_input": "23\n1 1 1\n2 1 1\n"}, "reference_outputs": ["46\n"], "source_document_id": "p03008", "source_text": "Score : 600 points\n\nProblem Statement\n\nThe squirrel Chokudai has N acorns.\nOne day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\nGet out of the nest with N acorns in his hands.\n\nGo to Exchange A and do some trades.\n\nGo to Exchange B and do some trades.\n\nGo to Exchange A and do some trades.\n\nGo back to the nest.\n\nIn Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:\n\nLose g_{X} acorns and gain 1 gram of gold.\n\nGain g_{X} acorns and lose 1 gram of gold.\n\nLose s_{X} acorns and gain 1 gram of silver.\n\nGain s_{X} acorns and lose 1 gram of silver.\n\nLose b_{X} acorns and gain 1 gram of bronze.\n\nGain b_{X} acorns and lose 1 gram of bronze.\n\nNaturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.\n\nWhat is the maximum number of acorns that he can bring to the nest?\nNote that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n1 \\leq g_{X} \\leq 5000\n\n1 \\leq s_{X} \\leq 5000\n\n1 \\leq b_{X} \\leq 5000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ng_A s_A b_A\ng_B s_B b_B\n\nOutput\n\nPrint the maximum number of acorns that Chokudai can bring to the nest.\n\nSample Input 1\n\n23\n1 1 1\n2 1 1\n\nSample Output 1\n\n46\n\nHe can bring 46 acorns to the nest, as follows:\n\nIn Exchange A, trade 23 acorns for 23 grams of gold. {acorns, gold, silver, bronze}={ 0,23,0,0 }\n\nIn Exchange B, trade 23 grams of gold for 46 acorns. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nIn Exchange A, trade nothing. {acorns, gold, silver, bronze}={ 46,0,0,0 }\n\nHe cannot have 47 or more acorns, so the answer is 46.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2631, "cpu_time_ms": 141, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s925079974", "group_id": "codeNet:p03013", "input_text": "#include \nusing namespace std;\nconst int mod =1e9+7;\nint main(void){\n int n,m;cin>>n>>m;\n vector d(m);\n for(int i=0;i>d[i];\n vector dp(n+1,0);\n dp[0]=dp[1]=1;\n int tmp=0;\n if(d[0]==1){\n tmp++;\n dp[1]=0;\n }\n for(int i=2;i<=n;i++){\n if(tmp\nusing namespace std;\nconst int mod =1e9+7;\nint main(void){\n int n,m;cin>>n>>m;\n vector d(m);\n for(int i=0;i>d[i];\n vector dp(n+1,0);\n dp[0]=dp[1]=1;\n int tmp=0;\n if(d[0]==1){\n tmp++;\n dp[1]=0;\n }\n for(int i=2;i<=n;i++){\n if(tmp\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<(int)(n);i++)\n#define RREP(i,n) for(int i=n-1;i>=0;i--)\n#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)\n#define all(i,n) (i),(i+n)\n\nint dx4[4]={1,0,-1,0};\nint dy4[4]={0,-1,0,1};\nint dx8[8]={1,0,-1,1,-1,1,0,-1};\nint dy8[8]={1,1,1,0,0,-1,-1,-1};\n\ntypedef pair P;\ntypedef pair SP;\ntypedef long long ll;\n\nconst int INF = 1e9;\nconst ll LLINF = 1e18;\nconst int MAX_V = 1e6+1;\nconst ll mod = 1000000007;\n\n// --------------------------------------\nint n, m;\nvector v;\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n cin >> n >> m;\n vector v(n + 1, true);\n REP(i, m) {\n int a;\n cin >> a;\n v[a] = false;\n }\n\n vector memo(n + 1, 0);\n memo[0] = 1;\n FOR(i, 1, n + 1) {\n if(v[i]) {\n if(i == 1) memo[i] = memo[i - 1] % mod;\n else memo[i] = (memo[i - 1] + memo[i - 2]) % mod;\n } else {\n memo[i] = 0;\n }\n }\n\n cout << memo[n] << endl;\n}\n", "language": "C++", "metadata": {"date": 1578633046, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/C++/s100925528.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s100925528", "user_id": "u502772848"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#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<(int)(n);i++)\n#define RREP(i,n) for(int i=n-1;i>=0;i--)\n#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)\n#define all(i,n) (i),(i+n)\n\nint dx4[4]={1,0,-1,0};\nint dy4[4]={0,-1,0,1};\nint dx8[8]={1,0,-1,1,-1,1,0,-1};\nint dy8[8]={1,1,1,0,0,-1,-1,-1};\n\ntypedef pair P;\ntypedef pair SP;\ntypedef long long ll;\n\nconst int INF = 1e9;\nconst ll LLINF = 1e18;\nconst int MAX_V = 1e6+1;\nconst ll mod = 1000000007;\n\n// --------------------------------------\nint n, m;\nvector v;\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n cin >> n >> m;\n vector v(n + 1, true);\n REP(i, m) {\n int a;\n cin >> a;\n v[a] = false;\n }\n\n vector memo(n + 1, 0);\n memo[0] = 1;\n FOR(i, 1, n + 1) {\n if(v[i]) {\n if(i == 1) memo[i] = memo[i - 1] % mod;\n else memo[i] = (memo[i - 1] + memo[i - 2]) % mod;\n } else {\n memo[i] = 0;\n }\n }\n\n cout << memo[n] << endl;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1181, "cpu_time_ms": 9, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s992802621", "group_id": "codeNet:p03013", "input_text": "#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 MOD 1000000007;\n\nint main(){\n\tint n, m;\n\tcin >> n >> m;\n\tvector a(m);\n\tfor(int i=0; i> a[i];\n\tvector dp(n+1);\n\tdp[n]=1;\n\tdp[n-1]=1;\n\tint key=m-1;\n\tfor(int i=n-2; i>=0; i--){\n\t\tdp[i] = (dp[i+1]+dp[i+2])%MOD;\n\t\tif(key>=0 && i==a[key]){\n\t\t\tdp[i] = 0;\n\t\t\tkey--;\n\t\t}\n\t}\n\tcout << dp[0] << endl;\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1560265149, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/C++/s992802621.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s992802621", "user_id": "u608258653"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#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 MOD 1000000007;\n\nint main(){\n\tint n, m;\n\tcin >> n >> m;\n\tvector a(m);\n\tfor(int i=0; i> a[i];\n\tvector dp(n+1);\n\tdp[n]=1;\n\tdp[n-1]=1;\n\tint key=m-1;\n\tfor(int i=n-2; i>=0; i--){\n\t\tdp[i] = (dp[i+1]+dp[i+2])%MOD;\n\t\tif(key>=0 && i==a[key]){\n\t\t\tdp[i] = 0;\n\t\t\tkey--;\n\t\t}\n\t}\n\tcout << dp[0] << endl;\n\treturn 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 550, "cpu_time_ms": 29, "memory_kb": 1408}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s896875251", "group_id": "codeNet:p03013", "input_text": "#include \"bits/stdc++.h\"\n\nusing namespace std;\nusing ll = long long;\nconst double pi = acos(-1);\n#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)\n#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)\n#define REP(i,n) FOR(i,0,n)\n#define RREP(i,n) RFOR(i,0,n)\n#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME\n#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)\n#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)\ntemplate ostream& operator<<(ostream& os, const vector& v) {\n\tREP(i, v.size()) { if (i)os << \" \"; os << v[i]; }return os;\n}\ntemplate ostream& operator<<(ostream& os, const vector>& v) {\n\tREP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;\n}\n\nconst ll INF = 1LL << 60;\nll MOD = 1000000007;\nll _MOD = 1000000009;\ndouble EPS = 1e-10;\n\n#define int long long\n\ninline void my_io() {\n\n\tstd::ios::sync_with_stdio(false);\n\n\tstd::cin.tie(0);\n\n\tcout << fixed << setprecision(16);\n\n\t//cout << setprecision(10) << scientific << ans << endl;\n\n}\n\nsigned main() {\n\tll n, m;\n\tll ans = INF;\n\n\tcin >> n >> m;\n\n\tvector v(m, 0);\n\n\tREP(i, m) {\n\t\tcin >> v[i];\n\t}\n\n\tvector dp(n + 1, 0);\n\n\tREP(i, m) {\n\t\tdp[v[i]] = -1;\n\t}\n\n\tdp[0] = 1;\n\n\tFOR(i, 1, n + 1) {\n\t\tif (dp[i] == -1) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (dp[i - 1] != -1) {\n\t\t\tdp[i] += dp[i - 1];\n\t\t\tdp[i] %= MOD;\n\t\t}\n\t\tif (i > 1 && dp[i - 2] != -1) {\n\t\t\tdp[i] += dp[i - 2];\n\t\t\tdp[i] %= MOD;\n\t\t}\n\t}\n\n\tcout << dp[n] % MOD << endl;\n}", "language": "C++", "metadata": {"date": 1560129202, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/C++/s896875251.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s896875251", "user_id": "u800551451"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\n\nusing namespace std;\nusing ll = long long;\nconst double pi = acos(-1);\n#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)\n#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)\n#define REP(i,n) FOR(i,0,n)\n#define RREP(i,n) RFOR(i,0,n)\n#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME\n#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)\n#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)\ntemplate ostream& operator<<(ostream& os, const vector& v) {\n\tREP(i, v.size()) { if (i)os << \" \"; os << v[i]; }return os;\n}\ntemplate ostream& operator<<(ostream& os, const vector>& v) {\n\tREP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;\n}\n\nconst ll INF = 1LL << 60;\nll MOD = 1000000007;\nll _MOD = 1000000009;\ndouble EPS = 1e-10;\n\n#define int long long\n\ninline void my_io() {\n\n\tstd::ios::sync_with_stdio(false);\n\n\tstd::cin.tie(0);\n\n\tcout << fixed << setprecision(16);\n\n\t//cout << setprecision(10) << scientific << ans << endl;\n\n}\n\nsigned main() {\n\tll n, m;\n\tll ans = INF;\n\n\tcin >> n >> m;\n\n\tvector v(m, 0);\n\n\tREP(i, m) {\n\t\tcin >> v[i];\n\t}\n\n\tvector dp(n + 1, 0);\n\n\tREP(i, m) {\n\t\tdp[v[i]] = -1;\n\t}\n\n\tdp[0] = 1;\n\n\tFOR(i, 1, n + 1) {\n\t\tif (dp[i] == -1) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (dp[i - 1] != -1) {\n\t\t\tdp[i] += dp[i - 1];\n\t\t\tdp[i] %= MOD;\n\t\t}\n\t\tif (i > 1 && dp[i - 2] != -1) {\n\t\t\tdp[i] += dp[i - 2];\n\t\t\tdp[i] %= MOD;\n\t\t}\n\t}\n\n\tcout << dp[n] % MOD << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1481, "cpu_time_ms": 29, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s003406685", "group_id": "codeNet:p03017", "input_text": "#include \nusing namespace std;\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n int n, a, b, c, d;\n cin >> n >> a >> b >> c >> d;\n --a, --b, --c, --d;\n string t;\n cin >> t;\n auto reachable = [&](int s, int f) {\n if (t[s] == '#' || t[f] == '#') return false;\n for (int i = s + 1; i <= f; ++i) {\n if (t[i] == t[i - 1] && t[i] == '#') {\n return false;\n }\n }\n return true;\n };\n auto hasg3 = [&](int s, int f) {\n for (int i = s; i <= f - 2; ++i) {\n if (t[i] == t[i + 1] && t[i] == t[i + 2] && t[i] == '.') {\n return true;\n }\n }\n return false;\n };\n bool can = true;\n if (!reachable(a, c) || !reachable(b, d)) {\n can = false;\n }\n if (c > d) {\n if (!hasg3(b - 1, d + 1)) {\n can = false;\n }\n }\n cout << (can ? \"Yes\" : \"No\") << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1570195663, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/C++/s003406685.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003406685", "user_id": "u499656581"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n int n, a, b, c, d;\n cin >> n >> a >> b >> c >> d;\n --a, --b, --c, --d;\n string t;\n cin >> t;\n auto reachable = [&](int s, int f) {\n if (t[s] == '#' || t[f] == '#') return false;\n for (int i = s + 1; i <= f; ++i) {\n if (t[i] == t[i - 1] && t[i] == '#') {\n return false;\n }\n }\n return true;\n };\n auto hasg3 = [&](int s, int f) {\n for (int i = s; i <= f - 2; ++i) {\n if (t[i] == t[i + 1] && t[i] == t[i + 2] && t[i] == '.') {\n return true;\n }\n }\n return false;\n };\n bool can = true;\n if (!reachable(a, c) || !reachable(b, d)) {\n can = false;\n }\n if (c > d) {\n if (!hasg3(b - 1, d + 1)) {\n can = false;\n }\n }\n cout << (can ? \"Yes\" : \"No\") << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 859, "cpu_time_ms": 3, "memory_kb": 592}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s772625282", "group_id": "codeNet:p03017", "input_text": "#include \nusing namespace std;\n\nint main(){\n int N, A, B, C, D;\n string S;\n \n cin >> N >> A >> B >> C >> D;\n cin >> S;\n \n vector rock;\n vector jump;\n \n for(int i=0; i A && rock.at(i) < C){\n flag = true; break;\n }\n if(rock.at(i) > B && rock.at(i) < D){\n flag = true; break;\n }\n \n }\n \n if(C > D){\n //入れ替えが必要\n flag = true;\n for(int i=0; i B && jump.at(i) <= D){\n flag = false; break;\n }\n \n }\n \n }\n\n \n if(flag)\n cout << \"No\" << endl;\n else\n cout << \"Yes\" << endl;\n\n}", "language": "C++", "metadata": {"date": 1563081710, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03017/input.txt", "sample_output_relpath": "derived/input_output/data/p03017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03017/C++/s772625282.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s772625282", "user_id": "u879434320"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int N, A, B, C, D;\n string S;\n \n cin >> N >> A >> B >> C >> D;\n cin >> S;\n \n vector rock;\n vector jump;\n \n for(int i=0; i A && rock.at(i) < C){\n flag = true; break;\n }\n if(rock.at(i) > B && rock.at(i) < D){\n flag = true; break;\n }\n \n }\n \n if(C > D){\n //入れ替えが必要\n flag = true;\n for(int i=0; i B && jump.at(i) <= D){\n flag = false; break;\n }\n \n }\n \n }\n\n \n if(flag)\n cout << \"No\" << endl;\n else\n cout << \"Yes\" << endl;\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "sample_input": "7 1 3 6 7\n.#..#..\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03017", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares arranged in a row, numbered 1, 2, ..., N from left to right.\nYou are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.\n\nIn the beginning, Snuke stands on Square A, and Fnuke stands on Square B.\n\nYou can repeat the following operation any number of times:\n\nChoose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.\n\nYou want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.\n\nDetermine whether this is possible.\n\nConstraints\n\n4 \\leq N \\leq 200\\ 000\n\nS is a string of length N consisting of . and #.\n\n1 \\leq A, B, C, D \\leq N\n\nSquare A, B, C and D do not contain a rock.\n\nA, B, C and D are all different.\n\nA < B\n\nA < C\n\nB < D\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\nS\n\nOutput\n\nPrint Yes if the objective is achievable, and No if it is not.\n\nSample Input 1\n\n7 1 3 6 7\n.#..#..\n\nSample Output 1\n\nYes\n\nThe objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)\n\nA#B.#..\n\nA#.B#..\n\n.#AB#..\n\n.#A.#B.\n\n.#.A#B.\n\n.#.A#.B\n\n.#..#AB\n\nSample Input 2\n\n7 1 3 7 6\n.#..#..\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n15 1 3 15 13\n...#.#...#.#...\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 917, "cpu_time_ms": 9, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s300542037", "group_id": "codeNet:p03019", "input_text": "#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\ntypedef long long ll;\ntypedef pair P;\n\nlong long int INF = 3e18;\ndouble Pi = 3.1415926535897932384626;\n\nvector G[500005];\n//vector

tree[500010];\npriority_queue pql;\npriority_queue

pqp;\n//big priority queue\npriority_queue ,greater > pqls;\npriority_queue ,greater

> pqps;\n//small priority queue\n//top pop\n\nint dx[8]={1,0,-1,0,1,1,-1,-1};\nint dy[8]={0,1,0,-1,1,-1,-1,1};\nchar dir[] = \"DRUL\";\n//ll bit[500005];\n//↓,→,↑,←\n\n\n#define p(x) cout< number2){\n swap(number1,number2);\n }\n if(number1 == 0 || number1 == number2){\n return number2;\n }else{\n return gcd(number2 % number1,number1);\n }\n}\nvoid YES(bool condition){\n\n if(condition){\n p(\"YES\");\n }else{\n p(\"NO\");\n }\n return;\n}\nvoid Yes(bool condition){\n\n if(condition){\n p(\"Yes\");\n }else{\n p(\"No\");\n }\n return;\n}\n\n/*\nvoid c3_init(){\n fact[0] = rfact[0] = 1;\n for(ll i=1; i<=800000; i++){\n fact[i] = (fact[i-1]*i) % mod;\n }\n\trfact[800000] = rui(fact[800000],mod - 2);\n\tfor(ll i=800000; i>=1; i--){\n\t rfact[i-1] = rfact[i] * i;\n\t rfact[i-1] %= mod;\n\t}\n\treturn;}\nll c3(ll n,ll r){\n return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}\n*/\n\nll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;\nll x[500005],y[500005],z[500005];\nchar s[500005],t[500005];\n//bool used[500005];\nbool flag,dame;\nP table[500005];\n\n\nint main(){\n\tcin >> n >> k;\n for(i=0;i> x[i] >> y[i] >> z[i];\n }\n for(i=0;i= 0){\n p(ans);\n return 0;\n }\n if(sum + table[i].first < 0){\n ans += k;\n sum += table[i].first;\n }else{\n num = k;\n for(j=0;j i)break;\n ll idx = table[j].second;\n if(sum + y[idx] * x[idx] + (k-x[idx]) * z[idx] < 0){\n continue;\n }else if(sum + y[idx] * x[idx] >= 0){\n sum *= -1;\n num = min(num,(sum + y[idx] - 1) / y[idx]);\n sum *= -1;\n }else{\n sum += y[idx] * x[idx];\n a = x[idx];\n sum *= -1;\n num = min(num,a + ((sum + z[idx] - 1) / z[idx]));\n sum *= -1;\n sum -= y[idx] * x[idx];\n }\n }\n ans += num;\n p(ans);\n return 0;\n } \n }\n\n\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1559530760, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03019.html", "problem_id": "p03019", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03019/input.txt", "sample_output_relpath": "derived/input_output/data/p03019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03019/C++/s300542037.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s300542037", "user_id": "u399527088"}, "prompt_components": {"gold_output": "115\n", "input_to_evaluate": "#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\ntypedef long long ll;\ntypedef pair P;\n\nlong long int INF = 3e18;\ndouble Pi = 3.1415926535897932384626;\n\nvector G[500005];\n//vector

tree[500010];\npriority_queue pql;\npriority_queue

pqp;\n//big priority queue\npriority_queue ,greater > pqls;\npriority_queue ,greater

> pqps;\n//small priority queue\n//top pop\n\nint dx[8]={1,0,-1,0,1,1,-1,-1};\nint dy[8]={0,1,0,-1,1,-1,-1,1};\nchar dir[] = \"DRUL\";\n//ll bit[500005];\n//↓,→,↑,←\n\n\n#define p(x) cout< number2){\n swap(number1,number2);\n }\n if(number1 == 0 || number1 == number2){\n return number2;\n }else{\n return gcd(number2 % number1,number1);\n }\n}\nvoid YES(bool condition){\n\n if(condition){\n p(\"YES\");\n }else{\n p(\"NO\");\n }\n return;\n}\nvoid Yes(bool condition){\n\n if(condition){\n p(\"Yes\");\n }else{\n p(\"No\");\n }\n return;\n}\n\n/*\nvoid c3_init(){\n fact[0] = rfact[0] = 1;\n for(ll i=1; i<=800000; i++){\n fact[i] = (fact[i-1]*i) % mod;\n }\n\trfact[800000] = rui(fact[800000],mod - 2);\n\tfor(ll i=800000; i>=1; i--){\n\t rfact[i-1] = rfact[i] * i;\n\t rfact[i-1] %= mod;\n\t}\n\treturn;}\nll c3(ll n,ll r){\n return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}\n*/\n\nll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;\nll x[500005],y[500005],z[500005];\nchar s[500005],t[500005];\n//bool used[500005];\nbool flag,dame;\nP table[500005];\n\n\nint main(){\n\tcin >> n >> k;\n for(i=0;i> x[i] >> y[i] >> z[i];\n }\n for(i=0;i= 0){\n p(ans);\n return 0;\n }\n if(sum + table[i].first < 0){\n ans += k;\n sum += table[i].first;\n }else{\n num = k;\n for(j=0;j i)break;\n ll idx = table[j].second;\n if(sum + y[idx] * x[idx] + (k-x[idx]) * z[idx] < 0){\n continue;\n }else if(sum + y[idx] * x[idx] >= 0){\n sum *= -1;\n num = min(num,(sum + y[idx] - 1) / y[idx]);\n sum *= -1;\n }else{\n sum += y[idx] * x[idx];\n a = x[idx];\n sum *= -1;\n num = min(num,a + ((sum + z[idx] - 1) / z[idx]));\n sum *= -1;\n sum -= y[idx] * x[idx];\n }\n }\n ans += num;\n p(ans);\n return 0;\n } \n }\n\n\n\treturn 0;\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will take N exams numbered 1 to N.\nThey have decided to compete in these exams.\nThe winner will be determined as follows:\n\nFor each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).\n\nLet A be \\sum_{i=1}^{N} c_i \\times (Takahashi's score on Exam i), and B be \\sum_{i=1}^{N} c_i \\times (Aoki's score on Exam i). Takahashi wins if A \\geq B, and Aoki wins if A < B.\n\nTakahashi knows that Aoki will score b_i on Exam i, with his supernatural power.\n\nTakahashi himself, on the other hand, will score 0 on all the exams without studying more. For each hour of study, he can increase his score on some exam by 1. (He can only study for an integer number of hours.)\nHowever, he cannot score more than X on an exam, since the perfect score for all the exams is X.\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq X \\leq 10^5\n\n0 \\leq b_i \\leq X (1 \\leq i \\leq N)\n\n1 \\leq l_i \\leq u_i \\leq 10^5 (1 \\leq i \\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nb_1 l_1 u_1\nb_2 l_2 u_2\n:\nb_N l_N u_N\n\nOutput\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nSample Input 1\n\n2 100\n85 2 3\n60 1 1\n\nSample Output 1\n\n115\n\nOne optimal strategy is as follows:\n\nChoose c_1 = 3, c_2 = 1.\n\nStudy to score 100 on Exam 1 and 15 on Exam 2.\n\nThen, A = 3 \\times 100 + 1 \\times 15 = 315, B = 3 \\times 85 + 1 \\times 60 = 315 and Takahashi will win.\n\nSample Input 2\n\n2 100\n85 2 3\n60 10 10\n\nSample Output 2\n\n77\n\nSample Input 3\n\n1 100000\n31415 2718 2818\n\nSample Output 3\n\n31415\n\nSample Input 4\n\n10 1000\n451 4593 6263\n324 310 6991\n378 1431 7068\n71 1757 9218\n204 3676 4328\n840 6221 9080\n684 1545 8511\n709 5467 8674\n862 6504 9835\n283 4965 9980\n\nSample Output 4\n\n2540", "sample_input": "2 100\n85 2 3\n60 1 1\n"}, "reference_outputs": ["115\n"], "source_document_id": "p03019", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will take N exams numbered 1 to N.\nThey have decided to compete in these exams.\nThe winner will be determined as follows:\n\nFor each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).\n\nLet A be \\sum_{i=1}^{N} c_i \\times (Takahashi's score on Exam i), and B be \\sum_{i=1}^{N} c_i \\times (Aoki's score on Exam i). Takahashi wins if A \\geq B, and Aoki wins if A < B.\n\nTakahashi knows that Aoki will score b_i on Exam i, with his supernatural power.\n\nTakahashi himself, on the other hand, will score 0 on all the exams without studying more. For each hour of study, he can increase his score on some exam by 1. (He can only study for an integer number of hours.)\nHowever, he cannot score more than X on an exam, since the perfect score for all the exams is X.\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq X \\leq 10^5\n\n0 \\leq b_i \\leq X (1 \\leq i \\leq N)\n\n1 \\leq l_i \\leq u_i \\leq 10^5 (1 \\leq i \\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nb_1 l_1 u_1\nb_2 l_2 u_2\n:\nb_N l_N u_N\n\nOutput\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nSample Input 1\n\n2 100\n85 2 3\n60 1 1\n\nSample Output 1\n\n115\n\nOne optimal strategy is as follows:\n\nChoose c_1 = 3, c_2 = 1.\n\nStudy to score 100 on Exam 1 and 15 on Exam 2.\n\nThen, A = 3 \\times 100 + 1 \\times 15 = 315, B = 3 \\times 85 + 1 \\times 60 = 315 and Takahashi will win.\n\nSample Input 2\n\n2 100\n85 2 3\n60 10 10\n\nSample Output 2\n\n77\n\nSample Input 3\n\n1 100000\n31415 2718 2818\n\nSample Output 3\n\n31415\n\nSample Input 4\n\n10 1000\n451 4593 6263\n324 310 6991\n378 1431 7068\n71 1757 9218\n204 3676 4328\n840 6221 9080\n684 1545 8511\n709 5467 8674\n862 6504 9835\n283 4965 9980\n\nSample Output 4\n\n2540", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3789, "cpu_time_ms": 99, "memory_kb": 19712}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s187190107", "group_id": "codeNet:p03031", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n\nusing namespace std;\n\nvoid next(int array[], int size){\n for(int i = 1; i <= size; i++){\n if(array[i] == 0){\n array[i] = 1;\n break;\n }else{\n array[i] = 0;\n }\n }\n}\n\nint main(){\n\n int n,m;\n cin >> n >> m;\n vector> s;\n vector p;\n\n for(int i = 0; i < m; i++){\n int k;\n cin >> k;\n vector tmpv;\n for(int j = 0; j < k; j++){\n int tmps;\n cin >> tmps;\n tmpv.push_back(tmps);\n\n }\n s.push_back(tmpv);\n }\n\n for(int i = 0; i < m; i++){\n int tmp;\n cin >> tmp;\n p.push_back(tmp);\n }\n\n int count = 1;\n\n for(int i = 0; i < n; i++) count = count * 2;\n\n int ans = 0;\n int onoff[11] = {};\n\n for(int i = 0; i < count; i++){\n bool b = true;\n\n \n for(int j = 1; j <= m; j++){\n //jは電球の番号\n int tmpc = 0;\n vector tmpv = s[j - 1];\n\n //つながっているスイッチのonの数を数える\n for(int k = 0; k < tmpv.size(); k++){\n if(onoff[tmpv[k]] == 1) tmpc++;\n }\n\n if(tmpc % 2 != p[j - 1]){\n b = false;\n break;\n }\n }\n\n if(b) ans++;\n\n next(onoff, n);\n }\n\n cout << ans << endl;\n\n return 0;\n\n}", "language": "C++", "metadata": {"date": 1558922048, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03031/input.txt", "sample_output_relpath": "derived/input_output/data/p03031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03031/C++/s187190107.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187190107", "user_id": "u145078501"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n\nusing namespace std;\n\nvoid next(int array[], int size){\n for(int i = 1; i <= size; i++){\n if(array[i] == 0){\n array[i] = 1;\n break;\n }else{\n array[i] = 0;\n }\n }\n}\n\nint main(){\n\n int n,m;\n cin >> n >> m;\n vector> s;\n vector p;\n\n for(int i = 0; i < m; i++){\n int k;\n cin >> k;\n vector tmpv;\n for(int j = 0; j < k; j++){\n int tmps;\n cin >> tmps;\n tmpv.push_back(tmps);\n\n }\n s.push_back(tmpv);\n }\n\n for(int i = 0; i < m; i++){\n int tmp;\n cin >> tmp;\n p.push_back(tmp);\n }\n\n int count = 1;\n\n for(int i = 0; i < n; i++) count = count * 2;\n\n int ans = 0;\n int onoff[11] = {};\n\n for(int i = 0; i < count; i++){\n bool b = true;\n\n \n for(int j = 1; j <= m; j++){\n //jは電球の番号\n int tmpc = 0;\n vector tmpv = s[j - 1];\n\n //つながっているスイッチのonの数を数える\n for(int k = 0; k < tmpv.size(); k++){\n if(onoff[tmpv[k]] == 1) tmpc++;\n }\n\n if(tmpc % 2 != p[j - 1]){\n b = false;\n break;\n }\n }\n\n if(b) ans++;\n\n next(onoff, n);\n }\n\n cout << ans << endl;\n\n return 0;\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1516, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s382409153", "group_id": "codeNet:p03036", "input_text": "#include \n#define rep(i,n) for (int i = 0; i < (n); i++)\nusing namespace std;\nusing ll = long long;\n\nint main(){\n int r,D,x;\n cin >>r >>D >>x;\n rep(i,10){\n x = r*x - D;\n cout << x << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1585947238, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03036/input.txt", "sample_output_relpath": "derived/input_output/data/p03036/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03036/C++/s382409153.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382409153", "user_id": "u321168841"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "#include \n#define rep(i,n) for (int i = 0; i < (n); i++)\nusing namespace std;\nusing ll = long long;\n\nint main(){\n int r,D,x;\n cin >>r >>D >>x;\n rep(i,10){\n x = r*x - D;\n cout << x << endl;\n }\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "sample_input": "2 10 20\n"}, "reference_outputs": ["30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n"], "source_document_id": "p03036", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe development of algae in a pond is as follows.\n\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n\nx_{i+1} = rx_i - D\n\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\nConstraints\n\n2 ≤ r ≤ 5\n\n1 ≤ D ≤ 100\n\nD < x_{2000} ≤ 200\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr D x_{2000}\n\nOutput\n\nPrint 10 lines. The i-th line (1 ≤ i ≤ 10) should contain x_{2000+i} as an integer.\n\nSample Input 1\n\n2 10 20\n\nSample Output 1\n\n30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n\nFor example, x_{2001} = rx_{2000} - D = 2 \\times 20 - 10 = 30 and x_{2002} = rx_{2001} - D = 2 \\times 30 - 10 = 50.\n\nSample Input 2\n\n4 40 60\n\nSample Output 2\n\n200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s852097363", "group_id": "codeNet:p03037", "input_text": "#include \nusing namespace std;\n\nint main() {\n int n, m;\n cin >> n >> m;\n vector l(m), r(m);\n for(int i=0; i> l.at(i) >> r.at(i);\n }\n \n int L = l.at(0);\n int R = r.at(0);\n \n for(int i=0; i= L) {\n cout << R - L + 1 << endl;\n }\n else {\n cout << 0 << endl;\n }\n}", "language": "C++", "metadata": {"date": 1578803886, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03037/input.txt", "sample_output_relpath": "derived/input_output/data/p03037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03037/C++/s852097363.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s852097363", "user_id": "u438313904"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() {\n int n, m;\n cin >> n >> m;\n vector l(m), r(m);\n for(int i=0; i> l.at(i) >> r.at(i);\n }\n \n int L = l.at(0);\n int R = r.at(0);\n \n for(int i=0; i= L) {\n cout << R - L + 1 << endl;\n }\n else {\n cout << 0 << endl;\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 56, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s590265946", "group_id": "codeNet:p03037", "input_text": "#include \n\nusing namespace std;\n\nint main() {\n int n,m;\n int t[100002] = {};\n cin >> n >> m;\n for(int i=0;i> l >> r;\n t[l-1]++;\n t[r]--;\n }\n int ans = 0;\n for(int i=0;i\n\nusing namespace std;\n\nint main() {\n int n,m;\n int t[100002] = {};\n cin >> n >> m;\n for(int i=0;i> l >> r;\n t[l-1]++;\n t[r]--;\n }\n int ans = 0;\n for(int i=0;i\nusing namespace std;\n\nint main(){\n int N,M;\n cin>>N>>M;\n int mir=N,mal=0;\n vector L(M),R(M);\n for(int i=0;i>L.at(i)>>R.at(i);\n mir=min(mir,R.at(i));\n mal=max(mal,L.at(i));\n }\n cout<\nusing namespace std;\n\nint main(){\n int N,M;\n cin>>N>>M;\n int mir=N,mal=0;\n vector L(M),R(M);\n for(int i=0;i>L.at(i)>>R.at(i);\n mir=min(mir,R.at(i));\n mal=max(mal,L.at(i));\n }\n cout<\n#define rep(i,n)for(int i=0;i<(n);i++)\n#define INF 0x3f3f3f3f\n#define INFL 0x3f3f3f3f3f3f3f3f\n#define MOD 1000000007\nusing namespace std;\ntypedef long long ll;\ntypedef pairP;\n\nstruct Med{\n\tmultisetf,b;\n\tll s1=0,s2=0;\n\tvoid balance(){\n\t\twhile(f.size()>=b.size()+2){\n\t\t\tint t=*f.rbegin();\n\t\t\tf.erase(--f.end());\n\t\t\ts1-=t;\n\t\t\ts2+=t;\n\t\t\tb.insert(t);\n\t\t}\n\t\twhile(f.size()>q;\n\tll t=0;\n\trep(i,q){\n\t\tint ty;scanf(\"%d\",&ty);\n\t\tif(ty==1){\n\t\t\tint a,b;scanf(\"%d%d\",&a,&b);\n\t\t\tt+=b;\n\t\t\tmed.insert(a);\n\t\t}\n\t\telse{\n\t\t\tint x=*med.f.rbegin();\n\t\t\tprintf(\"%d %lld\\n\",x,t+x*(ll)med.f.size()-med.s1+med.s2-x*(ll)med.b.size());\n\t\t}\n\t}\n}", "language": "C++", "metadata": {"date": 1558839471, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03040/input.txt", "sample_output_relpath": "derived/input_output/data/p03040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03040/C++/s724360802.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724360802", "user_id": "u781091740"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "#include \n#define rep(i,n)for(int i=0;i<(n);i++)\n#define INF 0x3f3f3f3f\n#define INFL 0x3f3f3f3f3f3f3f3f\n#define MOD 1000000007\nusing namespace std;\ntypedef long long ll;\ntypedef pairP;\n\nstruct Med{\n\tmultisetf,b;\n\tll s1=0,s2=0;\n\tvoid balance(){\n\t\twhile(f.size()>=b.size()+2){\n\t\t\tint t=*f.rbegin();\n\t\t\tf.erase(--f.end());\n\t\t\ts1-=t;\n\t\t\ts2+=t;\n\t\t\tb.insert(t);\n\t\t}\n\t\twhile(f.size()>q;\n\tll t=0;\n\trep(i,q){\n\t\tint ty;scanf(\"%d\",&ty);\n\t\tif(ty==1){\n\t\t\tint a,b;scanf(\"%d%d\",&a,&b);\n\t\t\tt+=b;\n\t\t\tmed.insert(a);\n\t\t}\n\t\telse{\n\t\t\tint x=*med.f.rbegin();\n\t\t\tprintf(\"%d %lld\\n\",x,t+x*(ll)med.f.size()-med.s1+med.s2-x*(ll)med.b.size());\n\t\t}\n\t}\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 908, "cpu_time_ms": 149, "memory_kb": 9600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s518736725", "group_id": "codeNet:p03041", "input_text": "#include \nusing namespace std;\n\nint main(){\n int s,f=0,l=0;\n cin >> s;\n \n f = s/100;\n l = s%100;\n \n if(1<=f<=12 && 1<=l<=12){\n cout << \"AMBIGUOUS\" << endl;\n } else if(1<=f<=12){\n cout << \"MMYY\" << endl;\n } else if(1<=l<=12){\n cout << \"YYMM\" << endl;\n } else{\n cout << \"NA\" << endl;\n }\n}\n", "language": "C++", "metadata": {"date": 1567040361, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/C++/s518736725.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s518736725", "user_id": "u959353968"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int s,f=0,l=0;\n cin >> s;\n \n f = s/100;\n l = s%100;\n \n if(1<=f<=12 && 1<=l<=12){\n cout << \"AMBIGUOUS\" << endl;\n } else if(1<=f<=12){\n cout << \"MMYY\" << endl;\n } else if(1<=l<=12){\n cout << \"YYMM\" << endl;\n } else{\n cout << \"NA\" << endl;\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 326, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s887364210", "group_id": "codeNet:p03041", "input_text": "#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 \nint main() {\n int n,b;\n cin >> n >> b;\n std::string s;\n cin >> s;\n \n char cary[n]; \n s.copy(cary, n);\n \n for (int i=0;i\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 \nint main() {\n int n,b;\n cin >> n >> b;\n std::string s;\n cin >> s;\n \n char cary[n]; \n s.copy(cary, n);\n \n for (int i=0;i\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\nint main()\n{\n\tint N, K;\n\tstd::string S;\n\t\n\tstd::cin >> N >> K;\n\tstd::cin >> S;\n\n\tS[K-1] = S[K-1] + ('a' - 'A');\n\n\tstd::cout << S << \"\\n\";\n}\n", "language": "C++", "metadata": {"date": 1558314169, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03041/input.txt", "sample_output_relpath": "derived/input_output/data/p03041/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03041/C++/s371162646.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371162646", "user_id": "u504322356"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "#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\nint main()\n{\n\tint N, K;\n\tstd::string S;\n\t\n\tstd::cin >> N >> K;\n\tstd::cin >> S;\n\n\tS[K-1] = S[K-1] + ('a' - 'A');\n\n\tstd::cout << S << \"\\n\";\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 441, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s355847206", "group_id": "codeNet:p03042", "input_text": "#include \n\nusing namespace std;\n\nint main(){\n char n[4];\n cin >> n;\n int period[4] = {n[0] - '0', n[1] - '0', n[2] - '0', n[3] - '0'};\n int front = (10 * period[0]) + period[1];\n int back = (10 * period[2]) + period[3];\n if(front > 12 && back > 12){\n cout << \"NA\" << endl;\n }else if(front == 0 && back >12){\n cout << \"NA\" << endl;\n }else if(front > 12 && back ==0){\n cout << \"NA\" << endl;\n }else if(front ==0 && back ==0){\n cout << \"NA\" << endl;\n }else if(front <=12 && back > 12){\n cout << \"MMYY\";\n }else if(front > 12 && back <= 12){\n cout << \"YYMM\";\n }else{\n cout << \"AMBIGUOUS\";\n }\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1558319379, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/C++/s355847206.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s355847206", "user_id": "u283567612"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main(){\n char n[4];\n cin >> n;\n int period[4] = {n[0] - '0', n[1] - '0', n[2] - '0', n[3] - '0'};\n int front = (10 * period[0]) + period[1];\n int back = (10 * period[2]) + period[3];\n if(front > 12 && back > 12){\n cout << \"NA\" << endl;\n }else if(front == 0 && back >12){\n cout << \"NA\" << endl;\n }else if(front > 12 && back ==0){\n cout << \"NA\" << endl;\n }else if(front ==0 && back ==0){\n cout << \"NA\" << endl;\n }else if(front <=12 && back > 12){\n cout << \"MMYY\";\n }else if(front > 12 && back <= 12){\n cout << \"YYMM\";\n }else{\n cout << \"AMBIGUOUS\";\n }\n\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 705, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s819258719", "group_id": "codeNet:p03042", "input_text": "#include \n#include \nusing namespace std;\n\nint main()\n{\n string s;\n cin>>s;\n bool b1,b2;\n b1=false;\n b2=false;\n if((s[0]=='1' && ((int)s[1]>=48 && (int)s[1]<=50))|| (s[0]=='0' &&(int)s[1]>=49 &&(int)s[1]<=57)){\n b1=true;\n }\n if((s[2]=='1' && ((int)s[3]>=48 && (int)s[3]<=50))|| (s[2]=='0' &&(int)s[3]>=49 &&(int)s[3]<=57)){\n \tb2=true;\n } \n if(b1&&b2){\n \tcout << \"AMBIGUOUS\" << endl;\n return 0;\n }else if(b1){\n \tcout << \"MMYY\" << endl;\n return 0;\n }else if(b2){\n \tcout << \"YYMM\" << endl;\n return 0;\n }else{\n \tcout << \"NA\" << endl;\n return 0;\n }\n\n}", "language": "C++", "metadata": {"date": 1558316858, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/C++/s819258719.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819258719", "user_id": "u442039299"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n\nint main()\n{\n string s;\n cin>>s;\n bool b1,b2;\n b1=false;\n b2=false;\n if((s[0]=='1' && ((int)s[1]>=48 && (int)s[1]<=50))|| (s[0]=='0' &&(int)s[1]>=49 &&(int)s[1]<=57)){\n b1=true;\n }\n if((s[2]=='1' && ((int)s[3]>=48 && (int)s[3]<=50))|| (s[2]=='0' &&(int)s[3]>=49 &&(int)s[3]<=57)){\n \tb2=true;\n } \n if(b1&&b2){\n \tcout << \"AMBIGUOUS\" << endl;\n return 0;\n }else if(b1){\n \tcout << \"MMYY\" << endl;\n return 0;\n }else if(b2){\n \tcout << \"YYMM\" << endl;\n return 0;\n }else{\n \tcout << \"NA\" << endl;\n return 0;\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 655, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s332203810", "group_id": "codeNet:p03042", "input_text": "#include \nusing namespace std;\n#define endl '\\n'\n#define ll long long\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tstring s;\n\tcin >> s;\n\tint a=0,vv=0;\n\t\n\tif((s[0]=='1' && s[1]<='2') || (s[0]=='0' && s[1]!='0'))\n\t{\n\t\ta=1;\n\t}\n\tif((s[2]=='1' && s[3]<='2') || (s[2]=='0' && s[3]!='0'))\n\t{\n\t\tvv=1;\n\t}\n\tif(a==1 && vv!=1)\n\t{\n\t\tcout << \"MMYY\";\n\t}\n\telse if(a==1)\n\t{\n\t\tcout << \"AMBIGUOUS\";\n\t}\n\telse if(vv==1)\n\t{\n\t\tcout << \"YYMM\";\n\t}\n\telse\n\t{\n\t\tcout << \"NA\";\n\t}\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1558316826, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03042/input.txt", "sample_output_relpath": "derived/input_output/data/p03042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03042/C++/s332203810.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s332203810", "user_id": "u037006720"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "#include \nusing namespace std;\n#define endl '\\n'\n#define ll long long\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tstring s;\n\tcin >> s;\n\tint a=0,vv=0;\n\t\n\tif((s[0]=='1' && s[1]<='2') || (s[0]=='0' && s[1]!='0'))\n\t{\n\t\ta=1;\n\t}\n\tif((s[2]=='1' && s[3]<='2') || (s[2]=='0' && s[3]!='0'))\n\t{\n\t\tvv=1;\n\t}\n\tif(a==1 && vv!=1)\n\t{\n\t\tcout << \"MMYY\";\n\t}\n\telse if(a==1)\n\t{\n\t\tcout << \"AMBIGUOUS\";\n\t}\n\telse if(vv==1)\n\t{\n\t\tcout << \"YYMM\";\n\t}\n\telse\n\t{\n\t\tcout << \"NA\";\n\t}\n\treturn 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 495, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s100762482", "group_id": "codeNet:p03043", "input_text": "#include\n#define inf 0x3f3f3f3f\n#define pb push_back\n#define AA first\n#define BB second\n#define ONES(x) __builtin_popcount(x)\n#define _ <<\" \"<<\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\nint dx[4]={0,0,1,-1};\nint dy[4]={1,-1,0,0};\nconst double eps=1e-6;\nconst int mod=1e9+7;\nconst double PI=acos(-1.0);\ninline int read(){ int num; scanf(\"%2d\",&num); return num;}\nconst int maxn=1e5+7;\n//numerator分子 denominator分母\nclass Rational {\n\tpublic:\n Rational(int n=0,int d=1):num(n),den(d) {} //有参构造函数\n friend Rational operator+(const Rational &r1,const Rational &r2);//相加\n friend Rational operator-(const Rational &r1,const Rational &r2);//相减\n friend Rational operator/(const Rational &r1,const Rational &r2);//相除\n friend Rational operator*(const Rational &r1,const Rational &r2);//相乘\n void simplify();//对有理数进行化简\n void display(); //显示结果\n double num;\n double den;\n\n};\nRational operator+(const Rational &r1,const Rational &r2) {\n Rational r;\n r.num = r1.den*r2.num+r1.num*r2.den;//相加的分子等于r1分母和r2分子相乘,r1分子和r2分母相乘之和\n r.den = r1.den*r2.den;//分母等于两个有理数分母的相乘\n r.simplify();//调用simplify对结果进行化简\n return r;//将结果返回\n}\nRational operator-(const Rational &r1,const Rational &r2) {\n Rational r;\n r.num = r1.num*r2.den-r1.den*r2.num;//相加的分子等于r1分母和r2分子相乘,r1分子和r2分母相乘之差\n r.den = r1.den*r2.den;//分母等于两个有理数分母的相乘\n r.simplify();\n return r;\n}\nRational operator/(const Rational &r1,const Rational &r2) {\n Rational r;\n if(r1.den==0||r2.den==0||r2.num==0) {\n cout<<\"分母或者除数不能为0\"<\n#define inf 0x3f3f3f3f\n#define pb push_back\n#define AA first\n#define BB second\n#define ONES(x) __builtin_popcount(x)\n#define _ <<\" \"<<\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\nint dx[4]={0,0,1,-1};\nint dy[4]={1,-1,0,0};\nconst double eps=1e-6;\nconst int mod=1e9+7;\nconst double PI=acos(-1.0);\ninline int read(){ int num; scanf(\"%2d\",&num); return num;}\nconst int maxn=1e5+7;\n//numerator分子 denominator分母\nclass Rational {\n\tpublic:\n Rational(int n=0,int d=1):num(n),den(d) {} //有参构造函数\n friend Rational operator+(const Rational &r1,const Rational &r2);//相加\n friend Rational operator-(const Rational &r1,const Rational &r2);//相减\n friend Rational operator/(const Rational &r1,const Rational &r2);//相除\n friend Rational operator*(const Rational &r1,const Rational &r2);//相乘\n void simplify();//对有理数进行化简\n void display(); //显示结果\n double num;\n double den;\n\n};\nRational operator+(const Rational &r1,const Rational &r2) {\n Rational r;\n r.num = r1.den*r2.num+r1.num*r2.den;//相加的分子等于r1分母和r2分子相乘,r1分子和r2分母相乘之和\n r.den = r1.den*r2.den;//分母等于两个有理数分母的相乘\n r.simplify();//调用simplify对结果进行化简\n return r;//将结果返回\n}\nRational operator-(const Rational &r1,const Rational &r2) {\n Rational r;\n r.num = r1.num*r2.den-r1.den*r2.num;//相加的分子等于r1分母和r2分子相乘,r1分子和r2分母相乘之差\n r.den = r1.den*r2.den;//分母等于两个有理数分母的相乘\n r.simplify();\n return r;\n}\nRational operator/(const Rational &r1,const Rational &r2) {\n Rational r;\n if(r1.den==0||r2.den==0||r2.num==0) {\n cout<<\"分母或者除数不能为0\"<\nusing namespace std;\nusing Graph = vector>;\n\n// DFS\n\nvoid dfs(Graph &G, map, int> &MAP, vector &color, int x) {\n \n for (int nx : G[x]) {\n \n if (color[nx] != -1) continue;\n \n if (MAP[{x, nx}] % 2 == 0) {\n color[nx] = color[x];\n dfs(G, MAP, color, nx);\n }\n \n else {\n color[nx] = 1 - color[x];\n dfs(G, MAP, color, nx);\n }\n \n }\n \n return;\n \n}\n\nint main () {\n \n // 入力\n \n int N;\n cin >> N;\n \n Graph G(N);\n map, int> MAP;\n \n for(int i = 0; i < N - 1; i++) {\n \n int a, b, w;\n cin >> a >> b >> w;\n a--;\n b--;\n \n G[a].push_back(b);\n G[b].push_back(a);\n MAP[{a, b}] = w;\n MAP[{b, a}] = w;\n \n }\n \n // DFS\n \n vector color(N, -1);\n color[0] = 0;\n dfs(G, MAP, color, 0);\n \n // 出力\n \n for (int i = 0; i < N; i++) {\n cout << color[i] << endl;\n }\n \n \n}", "language": "C++", "metadata": {"date": 1570477123, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03044/input.txt", "sample_output_relpath": "derived/input_output/data/p03044/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03044/C++/s133319438.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133319438", "user_id": "u688422725"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "#include \nusing namespace std;\nusing Graph = vector>;\n\n// DFS\n\nvoid dfs(Graph &G, map, int> &MAP, vector &color, int x) {\n \n for (int nx : G[x]) {\n \n if (color[nx] != -1) continue;\n \n if (MAP[{x, nx}] % 2 == 0) {\n color[nx] = color[x];\n dfs(G, MAP, color, nx);\n }\n \n else {\n color[nx] = 1 - color[x];\n dfs(G, MAP, color, nx);\n }\n \n }\n \n return;\n \n}\n\nint main () {\n \n // 入力\n \n int N;\n cin >> N;\n \n Graph G(N);\n map, int> MAP;\n \n for(int i = 0; i < N - 1; i++) {\n \n int a, b, w;\n cin >> a >> b >> w;\n a--;\n b--;\n \n G[a].push_back(b);\n G[b].push_back(a);\n MAP[{a, b}] = w;\n MAP[{b, a}] = w;\n \n }\n \n // DFS\n \n vector color(N, -1);\n color[0] = 0;\n dfs(G, MAP, color, 0);\n \n // 出力\n \n for (int i = 0; i < N; i++) {\n cout << color[i] << endl;\n }\n \n \n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 933, "cpu_time_ms": 390, "memory_kb": 24448}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s186443737", "group_id": "codeNet:p03045", "input_text": "#include \n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\n\ntemplate \nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate \nusing ordered_set_rev = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate \nusing dijkstra = priority_queue, greater>;\n\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define fbo find_by_order //k th index\n#define ook order_of_key // strictly smaller than k\n#define PI acos(-1.0)\n#define inf 0x3f3f3f3f\n#define max_ull 18446744073709551615\n#define max_ll 9223372036854775807\n#define min3(a, b, c) min(a, min(b, c))\n#define max3(a, b, c) max(a, max(b, c))\n#define min4(a, b, c, d) min(min(a, b), min(c, d))\n#define max4(a, b, c, d) max(max(a, b), max(c, d))\n#define max5(a, b, c, d, e) max(max3(a, b, c), max(d, e))\n#define min5(a, b, c, d, e) min(min3(a, b, c), min(d, e))\n#define lead_zero(x) __builtin_clzll(x)\n#define trail_zero(x) __builtin_ctzll(x)\n#define total_1s(x) __builtin_popcountll(x)\n#define first_1(x) __builtin_ffsll(x)\n#define log2_(x) __builtin_clz(1) - __builtin_clz(x)\n#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))\n#define QUERY int test;scanf(\"%d\", &test);for (int _T = 1; _T <= test; _T++)\n#define FAST ios_base::sync_with_stdio(0), cin.tie(0)\n#define all(v) v.begin(), v.end()\n#define reunique(v) v.resize(std::unique(all(v)) - v.begin())\n#define pii pair\n#define pll pair\n#define ff first\n#define ss second\n#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))\n#define MP make_pair\n#define EB emplace_back\n#define read freopen(\"input.txt\", \"r\", stdin)\n#define write freopen(\"output.txt\", \"w\", stdout)\n#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)\n#define LCM(a,b) (a/__gcd(a,b))*b;\nll rdn(int y, int m, int d) {\n /* Rata Die day one is 0001-01-01 */\n if (m < 3)\n y--, m += 12;\n return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;\n}\n/* Direction arrays */\n/* int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; */ // 4 Direction\n/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction\n/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction\n/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction\n/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction\n/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */\nconst int N=1e5+9;\nint par[N];\nint hight[N];\nint find_(int x)\n{\n while(x!=par[x])\n {\n par[x]=par[par[x]];\n x=par[x];\n }\n return x;\n}\nvoid UNION(int x,int y)\n{\n x=find_(x);\n y=find_(y);\n if(x!=y)\n {\n if(hight[x]v[3];\nint main() {\n int n,m;\n scanf(\"%d %d\",&n,&m);\n int a,b,c;\n for(int i=0;i\n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\n\ntemplate \nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate \nusing ordered_set_rev = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate \nusing dijkstra = priority_queue, greater>;\n\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define fbo find_by_order //k th index\n#define ook order_of_key // strictly smaller than k\n#define PI acos(-1.0)\n#define inf 0x3f3f3f3f\n#define max_ull 18446744073709551615\n#define max_ll 9223372036854775807\n#define min3(a, b, c) min(a, min(b, c))\n#define max3(a, b, c) max(a, max(b, c))\n#define min4(a, b, c, d) min(min(a, b), min(c, d))\n#define max4(a, b, c, d) max(max(a, b), max(c, d))\n#define max5(a, b, c, d, e) max(max3(a, b, c), max(d, e))\n#define min5(a, b, c, d, e) min(min3(a, b, c), min(d, e))\n#define lead_zero(x) __builtin_clzll(x)\n#define trail_zero(x) __builtin_ctzll(x)\n#define total_1s(x) __builtin_popcountll(x)\n#define first_1(x) __builtin_ffsll(x)\n#define log2_(x) __builtin_clz(1) - __builtin_clz(x)\n#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))\n#define QUERY int test;scanf(\"%d\", &test);for (int _T = 1; _T <= test; _T++)\n#define FAST ios_base::sync_with_stdio(0), cin.tie(0)\n#define all(v) v.begin(), v.end()\n#define reunique(v) v.resize(std::unique(all(v)) - v.begin())\n#define pii pair\n#define pll pair\n#define ff first\n#define ss second\n#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))\n#define MP make_pair\n#define EB emplace_back\n#define read freopen(\"input.txt\", \"r\", stdin)\n#define write freopen(\"output.txt\", \"w\", stdout)\n#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)\n#define LCM(a,b) (a/__gcd(a,b))*b;\nll rdn(int y, int m, int d) {\n /* Rata Die day one is 0001-01-01 */\n if (m < 3)\n y--, m += 12;\n return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;\n}\n/* Direction arrays */\n/* int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; */ // 4 Direction\n/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction\n/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction\n/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction\n/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction\n/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */\nconst int N=1e5+9;\nint par[N];\nint hight[N];\nint find_(int x)\n{\n while(x!=par[x])\n {\n par[x]=par[par[x]];\n x=par[x];\n }\n return x;\n}\nvoid UNION(int x,int y)\n{\n x=find_(x);\n y=find_(y);\n if(x!=y)\n {\n if(hight[x]v[3];\nint main() {\n int n,m;\n scanf(\"%d %d\",&n,&m);\n int a,b,c;\n for(int i=0;i\nusing namespace std;\n\nconst int N = 1100000;\n\nint main() {\n#ifdef Hwang_Baek_I\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tfreopen(\"out.txt\", \"w\", stdout);\n#endif\n\tios::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tlong long n; cin >> n;\n\tset S;\n\tfor (int i = 1; (long long)i * i <= n; i++) {\n\t\tif (n % i) continue;\n\t\tlong long m, k;\n\t\tm = i - 1, k = n / i;\n\t\tif (m > k) S.insert(m);\n\t\tm = n / i - 1, k = i;\n\t\tif (m > k) S.insert(m);\n\t}\n\tlong long ans = 0;\n\tfor (long long t : S) ans += t;\n\tcout << ans << endl;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1574121877, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03050.html", "problem_id": "p03050", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03050/input.txt", "sample_output_relpath": "derived/input_output/data/p03050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03050/C++/s332433986.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s332433986", "user_id": "u089230684"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include \nusing namespace std;\n\nconst int N = 1100000;\n\nint main() {\n#ifdef Hwang_Baek_I\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tfreopen(\"out.txt\", \"w\", stdout);\n#endif\n\tios::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tlong long n; cin >> n;\n\tset S;\n\tfor (int i = 1; (long long)i * i <= n; i++) {\n\t\tif (n % i) continue;\n\t\tlong long m, k;\n\t\tm = i - 1, k = n / i;\n\t\tif (m > k) S.insert(m);\n\t\tm = n / i - 1, k = i;\n\t\tif (m > k) S.insert(m);\n\t}\n\tlong long ans = 0;\n\tfor (long long t : S) ans += t;\n\tcout << ans << endl;\n\treturn 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "sample_input": "8\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03050", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 551, "cpu_time_ms": 12, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s427261396", "group_id": "codeNet:p03050", "input_text": "#include \nusing namespace std;\nint main(){\n int64_t N,ans;\n cin >>N;\n for (int i = 1; i <= (int)(sqrt(N+1)-1); i++)if((N-i) % i == 0)ans+=(N-i)/i;\n cout<\nusing namespace std;\nint main(){\n int64_t N,ans;\n cin >>N;\n for (int i = 1; i <= (int)(sqrt(N+1)-1); i++)if((N-i) % i == 0)ans+=(N-i)/i;\n cout<\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n#define rep1(i,n) for(int i=1;i<=(int)(n);i++)\n#define all(c) c.begin(),c.end()\n#define pb push_back\n#define fs first\n#define sc second\n#define chmin(x,y) x=min(x,y)\n#define chmax(x,y) x=max(x,y)\nusing namespace std;\ntemplate ostream& operator<<(ostream& o,const pair &p){\n\treturn o<<\"(\"< ostream& operator<<(ostream& o,const vector &vc){\n\to<<\"{\";\n\tfor(const T& v:vc) o< using V = vector;\ntemplate using VV = vector>;\nconstexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }\n\n#ifdef LOCAL\n#define show(x) cerr << \"LINE\" << __LINE__ << \" : \" << #x << \" = \" << (x) << endl\n#else\n#define show(x) true\n#endif\n\nint H,W;\nV s;\nconst int X = 187;\nint lrd2u[2][X][X][X];\nint dul2r[2][X][X][X];\n\nint A[X][X];\nbool allEqual(int d,int u,int l,int r){\n\tint c = A[u][r] - A[u][l] - A[d][r] + A[d][l];\n\treturn c == 0 || c == (u-d)*(r-l);\n}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\t\t//DON'T USE scanf/printf/puts !!\n\tcout << fixed << setprecision(20);\n\t\n\tcin >> H >> W;\n\ts.resize(H);\n\trep(i,H) cin >> s[i];\n\trep(i,H) rep(j,W){\n\t\tif(s[i][j] == '#') A[i+1][j+1] = 1;\n\t}\n\trep(i,H+1) rep(j,W) A[i][j+1] += A[i][j];\n\trep(i,H) rep(j,W+1) A[i+1][j] += A[i][j];\n\n\n\n\trep(l,W) for(int r=l+1;r<=W;r++){\n\t\tlrd2u[0][l][r][H] = H;\n\t\tfor(int d=H-1;d>=0;d--){\n\t\t\tlrd2u[0][l][r][d] = d;\n\t\t\tif(allEqual(d,d+1,l,r)){\n\t\t\t\tlrd2u[0][l][r][d] = d + 1;\n\t\t\t\tif(d != H-1 && s[d][l] == s[d+1][l]) lrd2u[0][l][r][d] = lrd2u[0][l][r][d+1];\n\t\t\t}\n\t\t}\n\t}\n\trep(d,H) for(int u=d+1;u<=H;u++){\n\t\tdul2r[0][d][u][W] = W;\n\t\tfor(int l=W-1;l>=0;l--){\n\t\t\tdul2r[0][d][u][l] = l;\n\t\t\tif(allEqual(d,u,l,l+1)){\n\t\t\t\tdul2r[0][d][u][l] = l+1;\n\t\t\t\tif(l != W-1 && s[d][l] == s[d][l+1]) dul2r[0][d][u][l] = dul2r[0][d][u][l+1];\n\t\t\t}\n\t\t}\n\t}\n\trep(t,100){\n\n\t\t// cerr << \" -----------turn = \" << t << endl;\n\t\t// rep(l,W) for(int r=l+1;r<=W;r++) rep(d,H){\n\t\t// \tcerr << \"lrd2u[\"<0;len--){\n\t\t\trep(l,W){\n\t\t\t\tint r = l + len;\n\t\t\t\tif(r > W) break;\n\t\t\t\trep(d,H+1){\n\t\t\t\t\tchmax(lrd2u[1-(t&1)][l+1][r][d],lrd2u[1-(t&1)][l][r][d]);\n\t\t\t\t\tchmax(lrd2u[1-(t&1)][l][r-1][d],lrd2u[1-(t&1)][l][r][d]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int len=H;len>0;len--){\n\t\t\trep(d,H){\n\t\t\t\tint u = d + len;\n\t\t\t\tif(u > H) break;\n\t\t\t\trep(l,W+1){\n\t\t\t\t\tchmax(dul2r[1-(t&1)][d+1][u][l],dul2r[1-(t&1)][d][u][l]);\n\t\t\t\t\tchmax(dul2r[1-(t&1)][d][u-1][l],dul2r[1-(t&1)][d][u][l]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n", "language": "C++", "metadata": {"date": 1560219948, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03056.html", "problem_id": "p03056", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03056/input.txt", "sample_output_relpath": "derived/input_output/data/p03056/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03056/C++/s777741165.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777741165", "user_id": "u309470177"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n#define rep1(i,n) for(int i=1;i<=(int)(n);i++)\n#define all(c) c.begin(),c.end()\n#define pb push_back\n#define fs first\n#define sc second\n#define chmin(x,y) x=min(x,y)\n#define chmax(x,y) x=max(x,y)\nusing namespace std;\ntemplate ostream& operator<<(ostream& o,const pair &p){\n\treturn o<<\"(\"< ostream& operator<<(ostream& o,const vector &vc){\n\to<<\"{\";\n\tfor(const T& v:vc) o< using V = vector;\ntemplate using VV = vector>;\nconstexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }\n\n#ifdef LOCAL\n#define show(x) cerr << \"LINE\" << __LINE__ << \" : \" << #x << \" = \" << (x) << endl\n#else\n#define show(x) true\n#endif\n\nint H,W;\nV s;\nconst int X = 187;\nint lrd2u[2][X][X][X];\nint dul2r[2][X][X][X];\n\nint A[X][X];\nbool allEqual(int d,int u,int l,int r){\n\tint c = A[u][r] - A[u][l] - A[d][r] + A[d][l];\n\treturn c == 0 || c == (u-d)*(r-l);\n}\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\t\t//DON'T USE scanf/printf/puts !!\n\tcout << fixed << setprecision(20);\n\t\n\tcin >> H >> W;\n\ts.resize(H);\n\trep(i,H) cin >> s[i];\n\trep(i,H) rep(j,W){\n\t\tif(s[i][j] == '#') A[i+1][j+1] = 1;\n\t}\n\trep(i,H+1) rep(j,W) A[i][j+1] += A[i][j];\n\trep(i,H) rep(j,W+1) A[i+1][j] += A[i][j];\n\n\n\n\trep(l,W) for(int r=l+1;r<=W;r++){\n\t\tlrd2u[0][l][r][H] = H;\n\t\tfor(int d=H-1;d>=0;d--){\n\t\t\tlrd2u[0][l][r][d] = d;\n\t\t\tif(allEqual(d,d+1,l,r)){\n\t\t\t\tlrd2u[0][l][r][d] = d + 1;\n\t\t\t\tif(d != H-1 && s[d][l] == s[d+1][l]) lrd2u[0][l][r][d] = lrd2u[0][l][r][d+1];\n\t\t\t}\n\t\t}\n\t}\n\trep(d,H) for(int u=d+1;u<=H;u++){\n\t\tdul2r[0][d][u][W] = W;\n\t\tfor(int l=W-1;l>=0;l--){\n\t\t\tdul2r[0][d][u][l] = l;\n\t\t\tif(allEqual(d,u,l,l+1)){\n\t\t\t\tdul2r[0][d][u][l] = l+1;\n\t\t\t\tif(l != W-1 && s[d][l] == s[d][l+1]) dul2r[0][d][u][l] = dul2r[0][d][u][l+1];\n\t\t\t}\n\t\t}\n\t}\n\trep(t,100){\n\n\t\t// cerr << \" -----------turn = \" << t << endl;\n\t\t// rep(l,W) for(int r=l+1;r<=W;r++) rep(d,H){\n\t\t// \tcerr << \"lrd2u[\"<0;len--){\n\t\t\trep(l,W){\n\t\t\t\tint r = l + len;\n\t\t\t\tif(r > W) break;\n\t\t\t\trep(d,H+1){\n\t\t\t\t\tchmax(lrd2u[1-(t&1)][l+1][r][d],lrd2u[1-(t&1)][l][r][d]);\n\t\t\t\t\tchmax(lrd2u[1-(t&1)][l][r-1][d],lrd2u[1-(t&1)][l][r][d]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int len=H;len>0;len--){\n\t\t\trep(d,H){\n\t\t\t\tint u = d + len;\n\t\t\t\tif(u > H) break;\n\t\t\t\trep(l,W+1){\n\t\t\t\t\tchmax(dul2r[1-(t&1)][d+1][u][l],dul2r[1-(t&1)][d][u][l]);\n\t\t\t\t\tchmax(dul2r[1-(t&1)][d][u-1][l],dul2r[1-(t&1)][d][u][l]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nNote the unusual memory limit.\n\nFor a rectangular grid where each square is painted white or black, we define its complexity as follows:\n\nIf all the squares are black or all the squares are white, the complexity is 0.\n\nOtherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \\max(c_1, c_2) in those divisions. The complexity of the grid is m+1.\n\nYou are given a grid with H horizontal rows and W vertical columns where each square is painted white or black.\nHW characters from A_{11} to A_{HW} represent the colors of the squares.\nA_{ij} is # if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is . if that square is white.\n\nFind the complexity of the given grid.\n\nConstraints\n\n1 \\leq H,W \\leq 185\n\nA_{ij} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11}A_{12}...A_{1W}\n:\nA_{H1}A_{H2}...A_{HW}\n\nOutput\n\nPrint the complexity of the given grid.\n\nSample Input 1\n\n3 3\n...\n.##\n.##\n\nSample Output 1\n\n2\n\nLet us divide the grid by the boundary line between the first and second columns.\nThe subgrid consisting of the first column has the complexity of 0, and the subgrid consisting of the second and third columns has the complexity of 1, so the whole grid has the complexity of at most 2.\n\nSample Input 2\n\n6 7\n.####.#\n#....#.\n#....#.\n#....#.\n.####.#\n#....##\n\nSample Output 2\n\n4", "sample_input": "3 3\n...\n.##\n.##\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03056", "source_text": "Score : 1000 points\n\nProblem Statement\n\nNote the unusual memory limit.\n\nFor a rectangular grid where each square is painted white or black, we define its complexity as follows:\n\nIf all the squares are black or all the squares are white, the complexity is 0.\n\nOtherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \\max(c_1, c_2) in those divisions. The complexity of the grid is m+1.\n\nYou are given a grid with H horizontal rows and W vertical columns where each square is painted white or black.\nHW characters from A_{11} to A_{HW} represent the colors of the squares.\nA_{ij} is # if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is . if that square is white.\n\nFind the complexity of the given grid.\n\nConstraints\n\n1 \\leq H,W \\leq 185\n\nA_{ij} is # or ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11}A_{12}...A_{1W}\n:\nA_{H1}A_{H2}...A_{HW}\n\nOutput\n\nPrint the complexity of the given grid.\n\nSample Input 1\n\n3 3\n...\n.##\n.##\n\nSample Output 1\n\n2\n\nLet us divide the grid by the boundary line between the first and second columns.\nThe subgrid consisting of the first column has the complexity of 0, and the subgrid consisting of the second and third columns has the complexity of 1, so the whole grid has the complexity of at most 2.\n\nSample Input 2\n\n6 7\n.####.#\n#....#.\n#....#.\n#....#.\n.####.#\n#....##\n\nSample Output 2\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3366, "cpu_time_ms": 616, "memory_kb": 100736}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s301492597", "group_id": "codeNet:p03059", "input_text": "#include\n\nusing namespace std;\n\nint main()\n{\tint a,b,t;\n\tcin >> a >> b >> t;\n\tcout << (t/a) * b;\n}", "language": "C++", "metadata": {"date": 1556413423, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/C++/s301492597.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301492597", "user_id": "u337741100"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "#include\n\nusing namespace std;\n\nint main()\n{\tint a,b,t;\n\tcin >> a >> b >> t;\n\tcout << (t/a) * b;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 108, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s370515236", "group_id": "codeNet:p03060", "input_text": "#include\nusing namespace std;\n#define FOR(i,l,r) for(long long i=(l);i<(r);++i)\n#define REP(i,n) FOR(i,0,n)\n#define int long long\n\nsigned main(){\n int N;\n cin>>N;\n int ans=0;\n int V[N],C[N];\n REP(i,N){\n cin>>V[i];\n }\n REP(i,N){\n cin>>C[i];\n }\n REP(i,N){\n if(V[i]-C[i]>0) ans+=V[i]-C[i];\n }\n cout<\nusing namespace std;\n#define FOR(i,l,r) for(long long i=(l);i<(r);++i)\n#define REP(i,n) FOR(i,0,n)\n#define int long long\n\nsigned main(){\n int N;\n cin>>N;\n int ans=0;\n int V[N],C[N];\n REP(i,N){\n cin>>V[i];\n }\n REP(i,N){\n cin>>C[i];\n }\n REP(i,N){\n if(V[i]-C[i]>0) ans+=V[i]-C[i];\n }\n cout<\n\n#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define rep(i,l,r) for (int i=l;i<=r;i++)\n#define fi first\n#define se second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define ll long long\n#define mod 1000000007\n#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nusing namespace std;\n\nint main(){\n int n,v[30],b[30];\n cin>>n;\n int ans=0;\n for (int i=1;i<=n;i++)cin>>v[i];\n for (int i=1;i<=n;i++){\n cin>>b[i];\n ans+=max(0,v[i]-b[i]);\n }\n cout<\n\n#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define rep(i,l,r) for (int i=l;i<=r;i++)\n#define fi first\n#define se second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define ll long long\n#define mod 1000000007\n#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nusing namespace std;\n\nint main(){\n int n,v[30],b[30];\n cin>>n;\n int ans=0;\n for (int i=1;i<=n;i++)cin>>v[i];\n for (int i=1;i<=n;i++){\n cin>>b[i];\n ans+=max(0,v[i]-b[i]);\n }\n cout<\nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n int a[n];\n int minus = 0;\n for(int i = 0; i < n; i++) {\n cin >> a[i];\n if(a[i] < 0) minus++;\n }\n int ans = 0;\n for(int i = 0; i < n; i++) {\n ans += abs(a[i]);\n }\n bool f = 1;\n for(int i = 0; i < n; i++) {\n if(a[i] == 0) f = 0;\n }\n int AT[n];\n for(int i = 0; i < n; i++) {\n AT[i] = abs(a[i]);\n }\n if(f) {\n if(minus % 2 == 1) {\n sort(AT, AT + n);\n ans -= AT[0];\n }\n }\n cout << ans << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1558059351, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03062/input.txt", "sample_output_relpath": "derived/input_output/data/p03062/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03062/C++/s632603412.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632603412", "user_id": "u681869152"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n int a[n];\n int minus = 0;\n for(int i = 0; i < n; i++) {\n cin >> a[i];\n if(a[i] < 0) minus++;\n }\n int ans = 0;\n for(int i = 0; i < n; i++) {\n ans += abs(a[i]);\n }\n bool f = 1;\n for(int i = 0; i < n; i++) {\n if(a[i] == 0) f = 0;\n }\n int AT[n];\n for(int i = 0; i < n; i++) {\n AT[i] = abs(a[i]);\n }\n if(f) {\n if(minus % 2 == 1) {\n sort(AT, AT + n);\n ans -= AT[0];\n }\n }\n cout << ans << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 63, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s620936868", "group_id": "codeNet:p03064", "input_text": "#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\n#define fs first\n#define sc second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\nll mod = 998244353;\n\nbool pp[2][101000];\nint N;\nint a[300];\nvector> dp(2, vector(1010000, 0));\nunordered_map mp;\nvector e;\n\n\nint main(){\n cin >> N;\n int s = 0;\n for(int i = 0; i < N; i++){\n cin >> a[i];\n s += a[i];\n }\n\n pp[0][0] = true;\n for(int i = 0; i < N; i++){\n for(int j = 0; j < 101000; j++){\n pp[1][j] = pp[0][j];\n if(j - a[i] >= 0 && pp[0][j-a[i]]){\n pp[1][j] = true;\n }\n }\n for(int j = 0; j < 101000; j++){\n pp[0][j] = pp[1][j];\n }\n }\n\n for(int i = 0; i < 101000; i++){\n if(pp[0][i]){\n e.push_back(i);\n }\n }\n\n for(int i = 0; i < e.size(); i++){\n mp[e[i]] = i;\n }\n\n int n = e.size();\n dp[1][0] = 1;\n\n for(int i = 0; i < N; i++){\n int p = i % 2;\n int q = 1 - p;\n int x = a[i];\n for(int j = 0; j < n*n; j++){\n int red_w = e[j % n];\n int red_index = j % n;\n int blue_w = e[(j / n)];\n int blue_index = (j / n) * n;\n if(mp.find(x+red_w) != mp.end()){\n // 赤に加える\n int index = mp[red_w + x];\n ll add_red = (dp[p][blue_index + index] + dp[q][j]) % mod;\n dp[p][blue_index + index] = add_red;\n }\n\n if(mp.find(x+blue_w) != mp.end()){\n // 青に加える\n int index = mp[x + blue_w];\n ll add_blue = (dp[p][index * n + red_index] + dp[q][j]) % mod;\n dp[p][index * n + red_index] = add_blue;\n }\n // 緑に加える\n ll add_green = (dp[p][j] + dp[q][j]) % mod;\n dp[p][j] = add_green;\n }\n fill(dp[q].begin(), dp[q].end(), 0);\n }\n\n ll ret = 0;\n int p = (N-1) % 2;\n for(int i = 0; i < n*n; i++){\n int red = e[i % n];\n int blue = e[(i / n)];\n int green = s - red - blue;\n if(red + green > blue && red + blue > green && blue + green > red){\n ret = (ret + dp[p][i]) % mod;\n }\n }\n ret = (ret) % mod;\n\n cout << ret << endl;\n\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1555812778, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03064.html", "problem_id": "p03064", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03064/input.txt", "sample_output_relpath": "derived/input_output/data/p03064/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03064/C++/s620936868.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s620936868", "user_id": "u852158538"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "#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\n#define fs first\n#define sc second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair P;\nll mod = 998244353;\n\nbool pp[2][101000];\nint N;\nint a[300];\nvector> dp(2, vector(1010000, 0));\nunordered_map mp;\nvector e;\n\n\nint main(){\n cin >> N;\n int s = 0;\n for(int i = 0; i < N; i++){\n cin >> a[i];\n s += a[i];\n }\n\n pp[0][0] = true;\n for(int i = 0; i < N; i++){\n for(int j = 0; j < 101000; j++){\n pp[1][j] = pp[0][j];\n if(j - a[i] >= 0 && pp[0][j-a[i]]){\n pp[1][j] = true;\n }\n }\n for(int j = 0; j < 101000; j++){\n pp[0][j] = pp[1][j];\n }\n }\n\n for(int i = 0; i < 101000; i++){\n if(pp[0][i]){\n e.push_back(i);\n }\n }\n\n for(int i = 0; i < e.size(); i++){\n mp[e[i]] = i;\n }\n\n int n = e.size();\n dp[1][0] = 1;\n\n for(int i = 0; i < N; i++){\n int p = i % 2;\n int q = 1 - p;\n int x = a[i];\n for(int j = 0; j < n*n; j++){\n int red_w = e[j % n];\n int red_index = j % n;\n int blue_w = e[(j / n)];\n int blue_index = (j / n) * n;\n if(mp.find(x+red_w) != mp.end()){\n // 赤に加える\n int index = mp[red_w + x];\n ll add_red = (dp[p][blue_index + index] + dp[q][j]) % mod;\n dp[p][blue_index + index] = add_red;\n }\n\n if(mp.find(x+blue_w) != mp.end()){\n // 青に加える\n int index = mp[x + blue_w];\n ll add_blue = (dp[p][index * n + red_index] + dp[q][j]) % mod;\n dp[p][index * n + red_index] = add_blue;\n }\n // 緑に加える\n ll add_green = (dp[p][j] + dp[q][j]) % mod;\n dp[p][j] = add_green;\n }\n fill(dp[q].begin(), dp[q].end(), 0);\n }\n\n ll ret = 0;\n int p = (N-1) % 2;\n for(int i = 0; i < n*n; i++){\n int red = e[i % n];\n int blue = e[(i / n)];\n int green = s - red - blue;\n if(red + green > blue && red + blue > green && blue + green > red){\n ret = (ret + dp[p][i]) % mod;\n }\n }\n ret = (ret) % mod;\n\n cout << ret << endl;\n\n\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given N integers. The i-th integer is a_i.\nFind the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:\n\nLet R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.\n\nConstraints\n\n3 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 300(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\n:\na_N\n\nOutput\n\nPrint the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the condition is satisfied.\n\nSample Input 1\n\n4\n1\n1\n1\n2\n\nSample Output 1\n\n18\n\nWe can only paint the integers so that the lengths of the sides of the triangle will be 1, 2 and 2, and there are 18 such ways.\n\nSample Input 2\n\n6\n1\n3\n2\n3\n5\n2\n\nSample Output 2\n\n150\n\nSample Input 3\n\n20\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4\n\nSample Output 3\n\n563038556", "sample_input": "4\n1\n1\n1\n2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03064", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given N integers. The i-th integer is a_i.\nFind the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:\n\nLet R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.\n\nConstraints\n\n3 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 300(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\n:\na_N\n\nOutput\n\nPrint the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the condition is satisfied.\n\nSample Input 1\n\n4\n1\n1\n1\n2\n\nSample Output 1\n\n18\n\nWe can only paint the integers so that the lengths of the sides of the triangle will be 1, 2 and 2, and there are 18 such ways.\n\nSample Input 2\n\n6\n1\n3\n2\n3\n5\n2\n\nSample Output 2\n\n150\n\nSample Input 3\n\n20\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n3\n2\n3\n8\n4\n\nSample Output 3\n\n563038556", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2619, "cpu_time_ms": 3156, "memory_kb": 23936}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s849213338", "group_id": "codeNet:p03069", "input_text": "#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 LLI = long long int;\nLLI N;\n\n//arraydir_x = { 0,0,1,1,1,-1,-1,-1 };\n//arraydir_y = { 1,-1,1,0,-1,1,0,-1 };\n//arraydir_x2 = { 0,0,1,-1 };\n//arraydir_y2 = { 1,-1,0,0 };\n//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };\n\n//class UnionFind {\n//public:\n//\tvectordata;\n//\tUnionFind(int size) :data(size, -1) {};\n//\tbool unionset(int x, int y) {\n//\t\tx = root(x), y = root(y);\n//\t\tif (x != y) {\n//\t\t\tif (data[y] < data[x]) {\n//\t\t\t\tswap(x, y);\n//\t\t\t}\n//\t\t\tdata[x] += data[y];\n//\t\t\tdata[y] = x;\n//\t\t}\n//\t\treturn x != y;\n//\t}\n//\tbool findset(int x, int y) {\n//\t\treturn root(x) == root(y);\n//\t}\n//\tint root(int x) {\n//\t\treturn data[x] < 0 ? x : data[x] = root(data[x]);\n//\t}\n//\tint size(int x) {\n//\t\treturn -data[root(x)];\n//\t}\n//};\n\n//LLI gcd(LLI x, LLI y) {\n//\tLLI r;\n//\tif (x < y) {\n//\t\tswap(x,y);\n//\t}\n//\tr = x % y;\n//\twhile (r != 0) {\n//\t\tx = y;\n//\t\ty = r;\n//\t\tr = x % y;\n//\t}\n//\treturn y;\n//}\n//LLI lcm(LLI x,LLI y) {\n//\treturn x / gcd(x,y) * y;\n//}\n\n//long nCr(int n,int r) {\n//\tlong ans = 1;\n//\tfor (int i = n; i > n - r;i--) {\n//\t\tans = ans * i;\n//\t}\n//\tfor (int i = 1; i < r + 1;i++) {\n//\t\tans = ans / i;\n//\t}\n//\treturn ans;\n//}\n\n//const int n_max = 8;\n//array, n_max>graph;\n//int dfs(int v,int N,arrayvisited) {\n//\tint ret = 0;\n//\tbool all_visited = true;\n//\tfor (int i = 0; i < N;i++) {\n//\t\tif (visited[i] == false) {\n//\t\t\tall_visited = false;\n//\t\t}\n//\t}\t\n//\tif (all_visited) {\n//\t\treturn 1;\n//\t}\n//\tfor (int i = 0; i < N;i++) {\n//\t\tif (graph[v][i] == false) {\n//\t\t\tcontinue;\n//\t\t}\n//\t\tif (visited[i] == true) {\n//\t\t\tcontinue;\n//\t\t}\n//\t\tvisited[i] = true;\n//\t\tret += dfs(i,N,visited);\n//\t\tvisited[i] = false;\n//\t}\n//\treturn ret;\n//}\n\n//vector>sub;\n//int dfs(int id) {\n//\tif (sub[id].size() == 0) {\n//\t\treturn 1;\n//\t}\n//\tint minP = (int)1e9;\n//\tint maxP = 0;\n//\tfor (int i : sub[id]) {\n//\t\tint P = dfs(i);\n//\t\tminP = min(minP, P);\n//\t\tmaxP = max(maxP, P);\n//\t}\n//\treturn minP + maxP + 1;\n//}\n\n#define debug(x) cerr << #x << \" : \" << x << endl\n#define debugv(x) cerr << #x << \" : \"; for(auto i:x) cerr << i << \", \"; cerr<> N >> S;\n\tLLI last = N,first = 0;\n\tfor (int i = 0; i < N;i++) {\n\t\tif (S[i] == '.') {\n\t\t\tfirst++;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (int i = N - 1; i >= first;i--) {\n\t\tif (S[i] == '#') {\n\t\t\tif (d == true) {\n\t\t\t\tlast--;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tw++;\n\t\t\td = false;\n\t\t}\n\t}\n\tfor (int i = 0; i < last;i++) {\n\t\tif (S[i] == '#') {\n\t\t\tb++;\n\t\t}\n\t}\n\tLLI res = min(b,w);\n\tcout << res << endl;\n}", "language": "C++", "metadata": {"date": 1555811991, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/C++/s849213338.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s849213338", "user_id": "u457033460"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#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 LLI = long long int;\nLLI N;\n\n//arraydir_x = { 0,0,1,1,1,-1,-1,-1 };\n//arraydir_y = { 1,-1,1,0,-1,1,0,-1 };\n//arraydir_x2 = { 0,0,1,-1 };\n//arraydir_y2 = { 1,-1,0,0 };\n//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };\n\n//class UnionFind {\n//public:\n//\tvectordata;\n//\tUnionFind(int size) :data(size, -1) {};\n//\tbool unionset(int x, int y) {\n//\t\tx = root(x), y = root(y);\n//\t\tif (x != y) {\n//\t\t\tif (data[y] < data[x]) {\n//\t\t\t\tswap(x, y);\n//\t\t\t}\n//\t\t\tdata[x] += data[y];\n//\t\t\tdata[y] = x;\n//\t\t}\n//\t\treturn x != y;\n//\t}\n//\tbool findset(int x, int y) {\n//\t\treturn root(x) == root(y);\n//\t}\n//\tint root(int x) {\n//\t\treturn data[x] < 0 ? x : data[x] = root(data[x]);\n//\t}\n//\tint size(int x) {\n//\t\treturn -data[root(x)];\n//\t}\n//};\n\n//LLI gcd(LLI x, LLI y) {\n//\tLLI r;\n//\tif (x < y) {\n//\t\tswap(x,y);\n//\t}\n//\tr = x % y;\n//\twhile (r != 0) {\n//\t\tx = y;\n//\t\ty = r;\n//\t\tr = x % y;\n//\t}\n//\treturn y;\n//}\n//LLI lcm(LLI x,LLI y) {\n//\treturn x / gcd(x,y) * y;\n//}\n\n//long nCr(int n,int r) {\n//\tlong ans = 1;\n//\tfor (int i = n; i > n - r;i--) {\n//\t\tans = ans * i;\n//\t}\n//\tfor (int i = 1; i < r + 1;i++) {\n//\t\tans = ans / i;\n//\t}\n//\treturn ans;\n//}\n\n//const int n_max = 8;\n//array, n_max>graph;\n//int dfs(int v,int N,arrayvisited) {\n//\tint ret = 0;\n//\tbool all_visited = true;\n//\tfor (int i = 0; i < N;i++) {\n//\t\tif (visited[i] == false) {\n//\t\t\tall_visited = false;\n//\t\t}\n//\t}\t\n//\tif (all_visited) {\n//\t\treturn 1;\n//\t}\n//\tfor (int i = 0; i < N;i++) {\n//\t\tif (graph[v][i] == false) {\n//\t\t\tcontinue;\n//\t\t}\n//\t\tif (visited[i] == true) {\n//\t\t\tcontinue;\n//\t\t}\n//\t\tvisited[i] = true;\n//\t\tret += dfs(i,N,visited);\n//\t\tvisited[i] = false;\n//\t}\n//\treturn ret;\n//}\n\n//vector>sub;\n//int dfs(int id) {\n//\tif (sub[id].size() == 0) {\n//\t\treturn 1;\n//\t}\n//\tint minP = (int)1e9;\n//\tint maxP = 0;\n//\tfor (int i : sub[id]) {\n//\t\tint P = dfs(i);\n//\t\tminP = min(minP, P);\n//\t\tmaxP = max(maxP, P);\n//\t}\n//\treturn minP + maxP + 1;\n//}\n\n#define debug(x) cerr << #x << \" : \" << x << endl\n#define debugv(x) cerr << #x << \" : \"; for(auto i:x) cerr << i << \", \"; cerr<> N >> S;\n\tLLI last = N,first = 0;\n\tfor (int i = 0; i < N;i++) {\n\t\tif (S[i] == '.') {\n\t\t\tfirst++;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (int i = N - 1; i >= first;i--) {\n\t\tif (S[i] == '#') {\n\t\t\tif (d == true) {\n\t\t\t\tlast--;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tw++;\n\t\t\td = false;\n\t\t}\n\t}\n\tfor (int i = 0; i < last;i++) {\n\t\tif (S[i] == '#') {\n\t\t\tb++;\n\t\t}\n\t}\n\tLLI res = min(b,w);\n\tcout << res << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2857, "cpu_time_ms": 9, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s826134168", "group_id": "codeNet:p03069", "input_text": "#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\n\nint main() {\n int N; cin >> N;\n string S; cin >> S;\n \n bool b = false;\n int cntw = 0;\n for(int i=0; i=0; i--){\n if(S[i]=='.') w = true;\n if(w && S[i]=='#') cntb++;\n }\n \n cout << min(cntb, cntw) << endl;\n \n \n \n return 0;\n}\n", "language": "C++", "metadata": {"date": 1555810366, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/C++/s826134168.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s826134168", "user_id": "u290693410"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#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\n\nint main() {\n int N; cin >> N;\n string S; cin >> S;\n \n bool b = false;\n int cntw = 0;\n for(int i=0; i=0; i--){\n if(S[i]=='.') w = true;\n if(w && S[i]=='#') cntb++;\n }\n \n cout << min(cntb, cntw) << endl;\n \n \n \n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 839, "cpu_time_ms": 10, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s799382108", "group_id": "codeNet:p03071", "input_text": "#include \nusing namespace std;\n\nint main() {\n int a,b;\n cin>>a>>b;\n cout<<(a==b?a+b:max(a,b)*2-1)<\nusing namespace std;\n\nint main() {\n int a,b;\n cin>>a>>b;\n cout<<(a==b?a+b:max(a,b)*2-1)<\nusing namespace std;\n\nint main() { \n int A,B;\n cin >> A;\n cin >> B;\n \n if (A+B >= A+A-1 && A+B >= B+B-1){\n cout << A+B <= A+B && A+A-1 >= B+B-1){\n cout << A+A-1 <= A+B && B+B-1 >= A+A-1 ){\n cout << B+B-1 << endl;}\n}", "language": "C++", "metadata": {"date": 1557420485, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03071/input.txt", "sample_output_relpath": "derived/input_output/data/p03071/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03071/C++/s441152363.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s441152363", "user_id": "u553128965"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint main() { \n int A,B;\n cin >> A;\n cin >> B;\n \n if (A+B >= A+A-1 && A+B >= B+B-1){\n cout << A+B <= A+B && A+A-1 >= B+B-1){\n cout << A+A-1 <= A+B && B+B-1 >= A+A-1 ){\n cout << B+B-1 << endl;}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s509101619", "group_id": "codeNet:p03071", "input_text": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int a, b;\n int ans = 0;\n cin >> a >> b;\n\n for (int i = 0; i < 2; i++) {\n if (a < b) {\n ans += b;\n b--;\n }\n else {\n ans += a;\n a--;\n }\n }\n\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1555182081, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03071/input.txt", "sample_output_relpath": "derived/input_output/data/p03071/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03071/C++/s509101619.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509101619", "user_id": "u846686917"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int a, b;\n int ans = 0;\n cin >> a >> b;\n\n for (int i = 0; i < 2; i++) {\n if (a < b) {\n ans += b;\n b--;\n }\n else {\n ans += a;\n a--;\n }\n }\n\n cout << ans << endl;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s463827889", "group_id": "codeNet:p03072", "input_text": "#include \n#include\nusing namespace std;\n\nint main() {\n int n,cnt = 1;\n cin >> n;\n vectorheight(n);\n for (int i = 0; i < n; i++) {\n cin >> height.at(i);\n }\n for (int i = 1; i < n; i++) {\n bool check = 1;\n for (int j = 0; j < i; j++) {\n if (height.at(i) < height.at(j)) {\n check = 0;\n }\n }\n if (check == 1) cnt ++;\n }\n cout << cnt;\n}", "language": "C++", "metadata": {"date": 1586192437, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/C++/s463827889.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s463827889", "user_id": "u331498629"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include\nusing namespace std;\n\nint main() {\n int n,cnt = 1;\n cin >> n;\n vectorheight(n);\n for (int i = 0; i < n; i++) {\n cin >> height.at(i);\n }\n for (int i = 1; i < n; i++) {\n bool check = 1;\n for (int j = 0; j < i; j++) {\n if (height.at(i) < height.at(j)) {\n check = 0;\n }\n }\n if (check == 1) cnt ++;\n }\n cout << cnt;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s412801047", "group_id": "codeNet:p03072", "input_text": "#include \n#include \n#include \nusing namespace std;\n#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)\n#define ROF(i,a,b) for(int i =(b) ; i >= (a); i--)\n#define REP(i,n) FOR( i, 0, (n) - 1 )\n#define PER(i,n) ROF( i, 0, (n) - 1 )\n\nint main(){\n int N,H[21],max=0,ans=0;\n cin >> N;\n REP(i,N){\n cin >> H[i];\n if(max <= H[i]){\n ans++;\n max = H[i];\n }\n }\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1555962318, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/C++/s412801047.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s412801047", "user_id": "u168578024"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\n#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)\n#define ROF(i,a,b) for(int i =(b) ; i >= (a); i--)\n#define REP(i,n) FOR( i, 0, (n) - 1 )\n#define PER(i,n) ROF( i, 0, (n) - 1 )\n\nint main(){\n int N,H[21],max=0,ans=0;\n cin >> N;\n REP(i,N){\n cin >> H[i];\n if(max <= H[i]){\n ans++;\n max = H[i];\n }\n }\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s932572030", "group_id": "codeNet:p03072", "input_text": "#include \nusing namespace std;\nint main(){\n\tint N;\n cin >> N;\n int height[N];\n for(int i = 0;i> height[i]; }\n int max=0;\n int counter=0;\n for(int k=0;k\nusing namespace std;\nint main(){\n\tint N;\n cin >> N;\n int height[N];\n for(int i = 0;i> height[i]; }\n int max=0;\n int counter=0;\n for(int k=0;k\n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed << setprecision(15);\n\n string s;\n cin >> s;\n int si = s.size();\n\n int cnt1 = 0, cnt2 = 0;\n for (int i = 0; i < si; ++i) {\n if (i % 2 == 0) {\n if (s[i] == '0') {\n ++cnt1;\n } else {\n ++cnt2;\n }\n } else {\n if (s[i] == '1') {\n ++cnt1;\n } else {\n ++cnt2;\n }\n }\n }\n\n cout << min(cnt1, cnt2) << '\\n';\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592945748, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/C++/s444037826.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444037826", "user_id": "u422813672"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed << setprecision(15);\n\n string s;\n cin >> s;\n int si = s.size();\n\n int cnt1 = 0, cnt2 = 0;\n for (int i = 0; i < si; ++i) {\n if (i % 2 == 0) {\n if (s[i] == '0') {\n ++cnt1;\n } else {\n ++cnt2;\n }\n } else {\n if (s[i] == '1') {\n ++cnt1;\n } else {\n ++cnt2;\n }\n }\n }\n\n cout << min(cnt1, cnt2) << '\\n';\n\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 511, "cpu_time_ms": 9, "memory_kb": 3680}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s129485248", "group_id": "codeNet:p03074", "input_text": "#include \n#include \n#include \n#define rep(i, x, n) for (int i = x; i < n; i++)\nusing namespace std;\nint main()\n{\n int N, K;\n cin >> N >> K;\n string S;\n cin >> S;\n int H[100000];\n rep(i, 0, N) { H[i] = 0; }\n int tmp = S[0] - '0';\n H[0] = 1;\n int tmpIdx = 0;\n int ind = 1;\n while (ind < N)\n {\n int si = S[ind] - '0';\n if (tmp == si)\n {\n H[tmpIdx]++;\n }\n else\n {\n H[tmpIdx + 1]++;\n tmpIdx++;\n tmp = si;\n }\n ind++;\n }\n int kukansu = tmpIdx + 1;\n int ruisekiwa[kukansu];\n rep(i, 0, kukansu)\n {\n if (i == 0)\n {\n ruisekiwa[i] = H[i];\n }\n else\n {\n ruisekiwa[i] = ruisekiwa[i - 1] + H[i];\n }\n // cout << ruisekiwa[i] << endl;\n }\n int kukanlong = 2 * K + 1;\n int max = 0;\n rep(i, 0, kukansu)\n {\n int sum;\n if (i + kukanlong > N)\n {\n kukanlong = N - i;\n }\n if (i == 0)\n {\n if (S[0] == '0' && i + kukanlong < N)\n {\n sum = ruisekiwa[kukanlong -2];\n }\n else\n {\n sum = ruisekiwa[kukanlong-1];\n }\n }else{\n sum=ruisekiwa[i+kukanlong-1]-ruisekiwa[i-1];\n }\n if(max\n#include \n#include \n#define rep(i, x, n) for (int i = x; i < n; i++)\nusing namespace std;\nint main()\n{\n int N, K;\n cin >> N >> K;\n string S;\n cin >> S;\n int H[100000];\n rep(i, 0, N) { H[i] = 0; }\n int tmp = S[0] - '0';\n H[0] = 1;\n int tmpIdx = 0;\n int ind = 1;\n while (ind < N)\n {\n int si = S[ind] - '0';\n if (tmp == si)\n {\n H[tmpIdx]++;\n }\n else\n {\n H[tmpIdx + 1]++;\n tmpIdx++;\n tmp = si;\n }\n ind++;\n }\n int kukansu = tmpIdx + 1;\n int ruisekiwa[kukansu];\n rep(i, 0, kukansu)\n {\n if (i == 0)\n {\n ruisekiwa[i] = H[i];\n }\n else\n {\n ruisekiwa[i] = ruisekiwa[i - 1] + H[i];\n }\n // cout << ruisekiwa[i] << endl;\n }\n int kukanlong = 2 * K + 1;\n int max = 0;\n rep(i, 0, kukansu)\n {\n int sum;\n if (i + kukanlong > N)\n {\n kukanlong = N - i;\n }\n if (i == 0)\n {\n if (S[0] == '0' && i + kukanlong < N)\n {\n sum = ruisekiwa[kukanlong -2];\n }\n else\n {\n sum = ruisekiwa[kukanlong-1];\n }\n }else{\n sum=ruisekiwa[i+kukanlong-1]-ruisekiwa[i-1];\n }\n if(max\n#include\n#include\n#define int long long int\n\nusing namespace std;\n\nsigned main(){\n\n int a[5], i;\n int tmp = 1000000;\n int pp;\n\n for(i = 0; i < 5; i++){\n cin >> a[i];\n \n if(a[i] % 10 == 0){\n continue;\n }\n\n if(tmp > a[i] % 10){\n tmp = a[i] % 10;\n pp = i;\n }\n }\n\n int ans = 0;\n for(i = 0; i < 5; i++){\n if(i == pp){\n ans = ans + a[pp];\n }else{\n if(a[i] % 10 != 0){\n ans = ans + a[i] + (10 - a[i] % 10);\n }else{\n ans = ans + a[i];\n }\n }\n }\n\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1554580748, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03076/input.txt", "sample_output_relpath": "derived/input_output/data/p03076/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03076/C++/s166908476.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166908476", "user_id": "u372231379"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "#include\n#include\n#include\n#define int long long int\n\nusing namespace std;\n\nsigned main(){\n\n int a[5], i;\n int tmp = 1000000;\n int pp;\n\n for(i = 0; i < 5; i++){\n cin >> a[i];\n \n if(a[i] % 10 == 0){\n continue;\n }\n\n if(tmp > a[i] % 10){\n tmp = a[i] % 10;\n pp = i;\n }\n }\n\n int ans = 0;\n for(i = 0; i < 5; i++){\n if(i == pp){\n ans = ans + a[pp];\n }else{\n if(a[i] % 10 != 0){\n ans = ans + a[i] + (10 - a[i] % 10);\n }else{\n ans = ans + a[i];\n }\n }\n }\n\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 703, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s831521259", "group_id": "codeNet:p03077", "input_text": "#define _LIBCPP_DEBUG 0\n#include \nusing namespace std;\n#define rep(i,a,b) for(int i=int(a);i vi;\ntypedef long long ll;\n\n\n\nint main(){\n \n ll N,a[5];\n cin>>N;\n rep(i,0,5)cin>>a[i];\n sort(a,a+5);\n if(N<=a[0])cout<<5<\nusing namespace std;\n#define rep(i,a,b) for(int i=int(a);i vi;\ntypedef long long ll;\n\n\n\nint main(){\n \n ll N,a[5];\n cin>>N;\n rep(i,0,5)cin>>a[i];\n sort(a,a+5);\n if(N<=a[0])cout<<5<\n#include\n#include\n#include\nusing namespace std;\n\nint main(){\n long N;\n cin >> N;\n long tmp;\n long trans[5];\n \n for(int i = 0; i < 5; i++){\n cin >> tmp;\n trans[i] = tmp; \n }\n\n long mini = trans[0];\n\n for(int i = 1; i < 5; i++){\n if(mini > trans[i]) mini = trans[i];\n }\n\n if(mini >= N) cout << 5 << '\\n';\n else cout << 5 + N/mini << '\\n';\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1558368176, "filename_ext": "cpp", "original_language": "C++14 (Clang 3.8.0)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/C++/s765917149.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s765917149", "user_id": "u115306811"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include\n#include\n#include\n#include\nusing namespace std;\n\nint main(){\n long N;\n cin >> N;\n long tmp;\n long trans[5];\n \n for(int i = 0; i < 5; i++){\n cin >> tmp;\n trans[i] = tmp; \n }\n\n long mini = trans[0];\n\n for(int i = 1; i < 5; i++){\n if(mini > trans[i]) mini = trans[i];\n }\n\n if(mini >= N) cout << 5 << '\\n';\n else cout << 5 + N/mini << '\\n';\n\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 463, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s240183128", "group_id": "codeNet:p03077", "input_text": "#include \n#include \n#include \n\ntypedef long long ll;\n\nint main (void){\n ll N; std::cin >> N;\n std::array t;\n for(int i=0; i<5; i++){\n std::cin >> t[i];\n }\n\n ll m = *std::min_element(t.begin(), t.end());\n ll s = N%m == 0 ? N/m : N/m+1;\n std::cout << 4 + s << std::endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1554584574, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/C++/s240183128.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240183128", "user_id": "u967843578"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "#include \n#include \n#include \n\ntypedef long long ll;\n\nint main (void){\n ll N; std::cin >> N;\n std::array t;\n for(int i=0; i<5; i++){\n std::cin >> t[i];\n }\n\n ll m = *std::min_element(t.begin(), t.end());\n ll s = N%m == 0 ? N/m : N/m+1;\n std::cout << 4 + s << std::endl;\n return 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s027937737", "group_id": "codeNet:p03078", "input_text": "#include \n#define all(x) begin(x), end(x)\n#define dbg(x) cerr << #x << \" = \" << x << endl\n#define _ << ' ' <<\nusing namespace std;\nusing ll = long long;\nusing vi = vector;\n\nll a[1001], b[1001], c[1001], d[1000001];\nint x, y, z, k;\nint p, q;\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cin >> x >> y >> z >> k;\n for (int i = 0; i < x; ++i)\n cin >> a[i];\n for (int i = 0; i < y; ++i)\n cin >> b[i];\n for (int i = 0; i < z; ++i)\n cin >> c[i];\n\n for (int i = 0; i < x; ++i)\n for (int j = 0; j < y; ++j)\n d[i * y + j] = a[i] + b[j];\n\n sort(c, c + z, greater());\n sort(d, d + (x * y), greater());\n\n vector sol;\n for (int i = 0; i < min(k, x * y); ++i)\n for (int j = 0; j < z; ++j)\n sol.push_back(c[i] + d[j]);\n\n sort(all(sol), greater());\n for (int i = 0; i < k; ++i)\n cout << sol[i] << '\\n';\n}\n", "language": "C++", "metadata": {"date": 1558756153, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03078/input.txt", "sample_output_relpath": "derived/input_output/data/p03078/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03078/C++/s027937737.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s027937737", "user_id": "u562319622"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "#include \n#define all(x) begin(x), end(x)\n#define dbg(x) cerr << #x << \" = \" << x << endl\n#define _ << ' ' <<\nusing namespace std;\nusing ll = long long;\nusing vi = vector;\n\nll a[1001], b[1001], c[1001], d[1000001];\nint x, y, z, k;\nint p, q;\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cin >> x >> y >> z >> k;\n for (int i = 0; i < x; ++i)\n cin >> a[i];\n for (int i = 0; i < y; ++i)\n cin >> b[i];\n for (int i = 0; i < z; ++i)\n cin >> c[i];\n\n for (int i = 0; i < x; ++i)\n for (int j = 0; j < y; ++j)\n d[i * y + j] = a[i] + b[j];\n\n sort(c, c + z, greater());\n sort(d, d + (x * y), greater());\n\n vector sol;\n for (int i = 0; i < min(k, x * y); ++i)\n for (int j = 0; j < z; ++j)\n sol.push_back(c[i] + d[j]);\n\n sort(all(sol), greater());\n for (int i = 0; i < k; ++i)\n cout << sol[i] << '\\n';\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "2 2 2 8\n4 6\n1 5\n3 8\n"}, "reference_outputs": ["19\n17\n15\n14\n13\n12\n10\n8\n"], "source_document_id": "p03078", "source_text": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 941, "cpu_time_ms": 252, "memory_kb": 42980}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s708949378", "group_id": "codeNet:p03086", "input_text": "#define rep(i,x) for (int i = 0; i < x; i++)\n#define mod 1000000007\n#define MOD 998244353\n#define INF (1<<31)-1\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#include \n#include \nusing namespace std;\ntypedef long long int ll;\ntypedef pair p;\ntypedef complex com;\n\n\nint main() {\n\tstring a;\n\tcin >> a;\n\tint ans = 0;\n\tstring s = \"ATGC\";\n\tint cnt = 0;\n\trep(i, a.size()) {\n\t\tint cnt2 = 0;\n\t\trep(j, 4) {\n\t\t\tif (s[j] == a[i]) {\n\t\t\t\tcnt2++;\n\t\t\t}\n\t\t}\n\t\tif (cnt2 > 0) {\n\t\t\tcnt++;\n\t\t\tans = max(ans, cnt);\n\t\t}\n\t\telse {\n\t\t\tcnt = 0;\n\t\t}\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1553458009, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/C++/s708949378.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s708949378", "user_id": "u407614884"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#define rep(i,x) for (int i = 0; i < x; i++)\n#define mod 1000000007\n#define MOD 998244353\n#define INF (1<<31)-1\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#include \n#include \nusing namespace std;\ntypedef long long int ll;\ntypedef pair p;\ntypedef complex com;\n\n\nint main() {\n\tstring a;\n\tcin >> a;\n\tint ans = 0;\n\tstring s = \"ATGC\";\n\tint cnt = 0;\n\trep(i, a.size()) {\n\t\tint cnt2 = 0;\n\t\trep(j, 4) {\n\t\t\tif (s[j] == a[i]) {\n\t\t\t\tcnt2++;\n\t\t\t}\n\t\t}\n\t\tif (cnt2 > 0) {\n\t\t\tcnt++;\n\t\t\tans = max(ans, cnt);\n\t\t}\n\t\telse {\n\t\t\tcnt = 0;\n\t\t}\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 811, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s135550489", "group_id": "codeNet:p03087", "input_text": "// スタックサイズ: 100MB\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 \nusing namespace std;\n\ntypedef int64_t ll;\ntypedef vector vll;\ntypedef pair pll;\nconst ll INF = 1000000000000000000;\n#define fori(i, a, b) for (ll i = (a); i < (b); ++i)\n#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)\n#define rep(i, n) fori(i, 0, n)\n#define all(v) (v).begin(), (v).end()\nll pw(ll x, ll y) { ll r = 1; rep(i, y) { r *= x; }; return r; }\n\n\nint main() {\n\n\tll N, Q;\n\tcin >> N >> Q;\n\tstring s;\n\tcin >> s;\n\tvll acc(N, 0);\n\tfori(i, 1, N) {\n\t\tif (s[i - 1] == 'A' && s[i] == 'C') acc[i] = acc[i - 1] + 1;\n\t\telse acc[i] = acc[i - 1];\n\t}\n\n\n\trep(i, Q) {\n\t\tll l, r;\n\t\tcin >> l >> r;\n\t\tl -= 1, r -= 1;\n\t\tcout << acc[r] - acc[l] << endl;\n\t}\n}", "language": "C++", "metadata": {"date": 1553510724, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03087/input.txt", "sample_output_relpath": "derived/input_output/data/p03087/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03087/C++/s135550489.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s135550489", "user_id": "u511401499"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "// スタックサイズ: 100MB\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 \nusing namespace std;\n\ntypedef int64_t ll;\ntypedef vector vll;\ntypedef pair pll;\nconst ll INF = 1000000000000000000;\n#define fori(i, a, b) for (ll i = (a); i < (b); ++i)\n#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)\n#define rep(i, n) fori(i, 0, n)\n#define all(v) (v).begin(), (v).end()\nll pw(ll x, ll y) { ll r = 1; rep(i, y) { r *= x; }; return r; }\n\n\nint main() {\n\n\tll N, Q;\n\tcin >> N >> Q;\n\tstring s;\n\tcin >> s;\n\tvll acc(N, 0);\n\tfori(i, 1, N) {\n\t\tif (s[i - 1] == 'A' && s[i] == 'C') acc[i] = acc[i - 1] + 1;\n\t\telse acc[i] = acc[i - 1];\n\t}\n\n\n\trep(i, Q) {\n\t\tll l, r;\n\t\tcin >> l >> r;\n\t\tl -= 1, r -= 1;\n\t\tcout << acc[r] - acc[l] << endl;\n\t}\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "sample_input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n"}, "reference_outputs": ["2\n0\n3\n"], "source_document_id": "p03087", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n\nQuery i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\nS is a string of length N.\n\nEach character in S is A, C, G or T.\n\n1 \\leq l_i < r_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nS\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the answer to the i-th query.\n\nSample Input 1\n\n8 3\nACACTACG\n3 7\n2 3\n1 8\n\nSample Output 1\n\n2\n0\n3\n\nQuery 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.\n\nQuery 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.\n\nQuery 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 978, "cpu_time_ms": 223, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s090581682", "group_id": "codeNet:p03089", "input_text": "#include \"bits/stdc++.h\"\nusing namespace std;\n\n/* macro */\n#define rep(i,a,b) for(int i=a;i b; i--)\n#define int long long\n#define exist(s,e) ((s).find(e)!=(s).end())\n#define all(v) (v).begin(), (v).end()\n#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)\n#define sum(v) accumulate(all(v), (0LL))\n#define isin(a, b, c) (b <= a && a <= c)\n#define println cout << \"\\n\";\n#define sz(v) (int)v.size()\n#define bin(x) static_cast >(x)\n\n\n\n/* alias */\ntemplate using vec = vector;\ntypedef vector vi;\ntypedef pair pi;\ntypedef tuple ti;\ntypedef map mi;\ntypedef set si;\n\n\n/* constant */\nconst int inf = 1LL << 62;\nconst int mod = 1e9 + 7;\nconst int dx[8]={1,0,-1,0,-1,1,-1,1};\nconst int dy[8]={0,1,0,-1,-1,-1,1,1};\nconst string alphabet = \"abcdefghijklmnopqrstuvwxyz\";\n\n/* io_method */\nint input(){int tmp;cin >> tmp;return tmp;}\nstring raw_input(){string tmp;cin >> tmp;return tmp;}\ntemplate void printx(T n){cout << n;}\ntemplate void printx(pair p){cout << \"(\" << p.first << \",\" << p.second << \")\";}\ntemplate void printx(tuple t){cout << \"{\" << get<0>(t) << \",\" << get<1>(t) <<\",\" << get<2>(t) << \"}\" << endl;}\ntemplate void printx(vector v){cout << \"{\";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(\",\");}cout << \"}\";}\ntemplate void print(T n){printx(n);cout << endl;}\ntemplate void print(set s){cout << \"{\";each(s, e){if(e != s.begin()) printx(\",\");printx(*e);}cout << \"}\" << endl;}\ntemplate void print(map mp){cout << \"{\";each(mp, e){cout << \"(\" << e -> first << \",\" << e -> second << \")\";}cout << \"}\" << endl;}\ntemplate void printans(vec v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? \"\" : \" \");}cout << endl;}\n\n\n/* general_method */\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bT cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}\n\n/* main */\n\nint n;\nvi arr;\nvoid in(){\n cin >> n;\n rep(i,0,n) arr.push_back(input());\n}\n\nvoid solve(){\n \n vi ans;\n rep(i,0,n){\n revrep(j,n - 1 - i, -1){\n if(arr[j] - 1 == j){\n ans.push_back(arr[j]);\n vi tmp = cut(arr, 0, j);\n vi b = cut(arr, j + 1, sz(arr));\n for(int e : b) tmp.push_back(e);\n arr = tmp;\n break;\n }\n }\n }\n\n if(sz(arr) > 0){\n print(-1);\n return ;\n }\n\n reverse(all(ans));\n printans(ans);\n\n\n}\n\nsigned main(){\n\n cin.tie(0);\n ios::sync_with_stdio(false);\n in();\n solve();\n \n}", "language": "C++", "metadata": {"date": 1553580014, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03089/input.txt", "sample_output_relpath": "derived/input_output/data/p03089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03089/C++/s090581682.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s090581682", "user_id": "u828847847"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "#include \"bits/stdc++.h\"\nusing namespace std;\n\n/* macro */\n#define rep(i,a,b) for(int i=a;i b; i--)\n#define int long long\n#define exist(s,e) ((s).find(e)!=(s).end())\n#define all(v) (v).begin(), (v).end()\n#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)\n#define sum(v) accumulate(all(v), (0LL))\n#define isin(a, b, c) (b <= a && a <= c)\n#define println cout << \"\\n\";\n#define sz(v) (int)v.size()\n#define bin(x) static_cast >(x)\n\n\n\n/* alias */\ntemplate using vec = vector;\ntypedef vector vi;\ntypedef pair pi;\ntypedef tuple ti;\ntypedef map mi;\ntypedef set si;\n\n\n/* constant */\nconst int inf = 1LL << 62;\nconst int mod = 1e9 + 7;\nconst int dx[8]={1,0,-1,0,-1,1,-1,1};\nconst int dy[8]={0,1,0,-1,-1,-1,1,1};\nconst string alphabet = \"abcdefghijklmnopqrstuvwxyz\";\n\n/* io_method */\nint input(){int tmp;cin >> tmp;return tmp;}\nstring raw_input(){string tmp;cin >> tmp;return tmp;}\ntemplate void printx(T n){cout << n;}\ntemplate void printx(pair p){cout << \"(\" << p.first << \",\" << p.second << \")\";}\ntemplate void printx(tuple t){cout << \"{\" << get<0>(t) << \",\" << get<1>(t) <<\",\" << get<2>(t) << \"}\" << endl;}\ntemplate void printx(vector v){cout << \"{\";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(\",\");}cout << \"}\";}\ntemplate void print(T n){printx(n);cout << endl;}\ntemplate void print(set s){cout << \"{\";each(s, e){if(e != s.begin()) printx(\",\");printx(*e);}cout << \"}\" << endl;}\ntemplate void print(map mp){cout << \"{\";each(mp, e){cout << \"(\" << e -> first << \",\" << e -> second << \")\";}cout << \"}\" << endl;}\ntemplate void printans(vec v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? \"\" : \" \");}cout << endl;}\n\n\n/* general_method */\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bT cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}\n\n/* main */\n\nint n;\nvi arr;\nvoid in(){\n cin >> n;\n rep(i,0,n) arr.push_back(input());\n}\n\nvoid solve(){\n \n vi ans;\n rep(i,0,n){\n revrep(j,n - 1 - i, -1){\n if(arr[j] - 1 == j){\n ans.push_back(arr[j]);\n vi tmp = cut(arr, 0, j);\n vi b = cut(arr, j + 1, sz(arr));\n for(int e : b) tmp.push_back(e);\n arr = tmp;\n break;\n }\n }\n }\n\n if(sz(arr) > 0){\n print(-1);\n return ;\n }\n\n reverse(all(ans));\n printans(ans);\n\n\n}\n\nsigned main(){\n\n cin.tie(0);\n ios::sync_with_stdio(false);\n in();\n solve();\n \n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2849, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s598658302", "group_id": "codeNet:p03092", "input_text": "#include \n#include \n#include \nusing namespace std;\nint main() {\n int n, a, b; cin >> n >> a >> b;\n int P[n]; for (int i = 0; i < n; i++) cin >> P[i];\n\n int lis[n] = {};\n fill(lis, lis+n, 1<<30);\n for (int i = 0; i < n; i++)\n *lower_bound(lis, lis+n, P[i]) = P[i];\n vector s;\n int m = lower_bound(lis, lis+n, 1<<30) - lis - 1;\n // for (int i = 0; i <= m; i++) cerr << lis[i] << ' '; cerr << endl;\n int prevv = 1<<30;\n for (int i = n-1; i >= 0; i--) {\n if (lis[m] <= P[i] && P[i] < prevv) {\n s.push_back(i);\n prevv = P[i];\n m--;\n }\n }\n // for (int x : s) cerr << x << ' '; cerr << endl;\n reverse(s.begin(), s.end());\n bool in_lis[n] = {};\n for (int i : s) in_lis[i] = true;\n int acc_min[n], acc_max[n];\n int temp = 1<<30;\n for (int i = n-1; i >= 0; i--) {\n if (in_lis[i]) temp = min(temp, P[i]);\n acc_min[i] = temp;\n }\n temp = 0;\n for (int i = 0; i < n; i++) {\n if (in_lis[i]) temp = max(temp, P[i]);\n acc_max[i] = temp;\n }\n long long ans = 0;\n for (int i = 0; i < n; i++) {\n if (in_lis[i]) continue;\n auto it = lower_bound(s.begin(), s.end(), i);\n if (it != s.end() && P[i] > P[*it]) ans += a;\n else if (it != s.begin() && P[i] < P[*prev(it)]) ans += b;\n }\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1553378586, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03092.html", "problem_id": "p03092", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03092/input.txt", "sample_output_relpath": "derived/input_output/data/p03092/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03092/C++/s598658302.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s598658302", "user_id": "u374416262"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\nint main() {\n int n, a, b; cin >> n >> a >> b;\n int P[n]; for (int i = 0; i < n; i++) cin >> P[i];\n\n int lis[n] = {};\n fill(lis, lis+n, 1<<30);\n for (int i = 0; i < n; i++)\n *lower_bound(lis, lis+n, P[i]) = P[i];\n vector s;\n int m = lower_bound(lis, lis+n, 1<<30) - lis - 1;\n // for (int i = 0; i <= m; i++) cerr << lis[i] << ' '; cerr << endl;\n int prevv = 1<<30;\n for (int i = n-1; i >= 0; i--) {\n if (lis[m] <= P[i] && P[i] < prevv) {\n s.push_back(i);\n prevv = P[i];\n m--;\n }\n }\n // for (int x : s) cerr << x << ' '; cerr << endl;\n reverse(s.begin(), s.end());\n bool in_lis[n] = {};\n for (int i : s) in_lis[i] = true;\n int acc_min[n], acc_max[n];\n int temp = 1<<30;\n for (int i = n-1; i >= 0; i--) {\n if (in_lis[i]) temp = min(temp, P[i]);\n acc_min[i] = temp;\n }\n temp = 0;\n for (int i = 0; i < n; i++) {\n if (in_lis[i]) temp = max(temp, P[i]);\n acc_max[i] = temp;\n }\n long long ans = 0;\n for (int i = 0; i < n; i++) {\n if (in_lis[i]) continue;\n auto it = lower_bound(s.begin(), s.end(), i);\n if (it != s.end() && P[i] > P[*it]) ans += a;\n else if (it != s.begin() && P[i] < P[*prev(it)]) ans += b;\n }\n cout << ans << endl;\n}\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nYou are given a permutation p = (p_1, \\ldots, p_N) of \\{ 1, \\ldots, N \\}.\nYou can perform the following two kinds of operations repeatedly in any order:\n\nPay a cost A. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the left by one. That is, replace p_l, p_{l + 1}, \\ldots, p_{r - 1}, p_r with p_{l + 1}, p_{l + 2}, \\ldots, p_r, p_l, respectively.\n\nPay a cost B. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the right by one. That is, replace p_l, p_{l + 1}, \\ldots, p_{r - 1}, p_r with p_r, p_l, \\ldots, p_{r - 2}, p_{r - 1}, respectively.\n\nFind the minimum total cost required to sort p in ascending order.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 5000\n\n1 \\leq A, B \\leq 10^9\n\n(p_1 \\ldots, p_N) is a permutation of \\{ 1, \\ldots, N \\}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\np_1 \\cdots p_N\n\nOutput\n\nPrint the minimum total cost required to sort p in ascending order.\n\nSample Input 1\n\n3 20 30\n3 1 2\n\nSample Output 1\n\n20\n\nShifting (p_1, p_2, p_3) to the left by one results in p = (1, 2, 3).\n\nSample Input 2\n\n4 20 30\n4 2 3 1\n\nSample Output 2\n\n50\n\nOne possible sequence of operations is as follows:\n\nShift (p_1, p_2, p_3, p_4) to the left by one. Now we have p = (2, 3, 1, 4).\n\nShift (p_1, p_2, p_3) to the right by one. Now we have p = (1, 2, 3, 4).\n\nHere, the total cost is 20 + 30 = 50.\n\nSample Input 3\n\n1 10 10\n1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n4 1000000000 1000000000\n4 3 2 1\n\nSample Output 4\n\n3000000000\n\nSample Input 5\n\n9 40 50\n5 3 4 7 6 1 2 9 8\n\nSample Output 5\n\n220", "sample_input": "3 20 30\n3 1 2\n"}, "reference_outputs": ["20\n"], "source_document_id": "p03092", "source_text": "Score : 1000 points\n\nProblem Statement\n\nYou are given a permutation p = (p_1, \\ldots, p_N) of \\{ 1, \\ldots, N \\}.\nYou can perform the following two kinds of operations repeatedly in any order:\n\nPay a cost A. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the left by one. That is, replace p_l, p_{l + 1}, \\ldots, p_{r - 1}, p_r with p_{l + 1}, p_{l + 2}, \\ldots, p_r, p_l, respectively.\n\nPay a cost B. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the right by one. That is, replace p_l, p_{l + 1}, \\ldots, p_{r - 1}, p_r with p_r, p_l, \\ldots, p_{r - 2}, p_{r - 1}, respectively.\n\nFind the minimum total cost required to sort p in ascending order.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 5000\n\n1 \\leq A, B \\leq 10^9\n\n(p_1 \\ldots, p_N) is a permutation of \\{ 1, \\ldots, N \\}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\np_1 \\cdots p_N\n\nOutput\n\nPrint the minimum total cost required to sort p in ascending order.\n\nSample Input 1\n\n3 20 30\n3 1 2\n\nSample Output 1\n\n20\n\nShifting (p_1, p_2, p_3) to the left by one results in p = (1, 2, 3).\n\nSample Input 2\n\n4 20 30\n4 2 3 1\n\nSample Output 2\n\n50\n\nOne possible sequence of operations is as follows:\n\nShift (p_1, p_2, p_3, p_4) to the left by one. Now we have p = (2, 3, 1, 4).\n\nShift (p_1, p_2, p_3) to the right by one. Now we have p = (1, 2, 3, 4).\n\nHere, the total cost is 20 + 30 = 50.\n\nSample Input 3\n\n1 10 10\n1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n4 1000000000 1000000000\n4 3 2 1\n\nSample Output 4\n\n3000000000\n\nSample Input 5\n\n9 40 50\n5 3 4 7 6 1 2 9 8\n\nSample Output 5\n\n220", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1402, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s829478275", "group_id": "codeNet:p03096", "input_text": "#include \nusing namespace std;\n\n#define rep(i,n) for(int i=0; i<(n); ++i)\n#define rrep(i,n) for(int i=1; i<=(n); ++i)\n#define drep(i,n) for(int i=(n)-1; i>=0; --i)\n#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)\n#define pb push_back\n#define sz(x) (int)(x).size()\n#define fi first\n#define se second\n\ntypedef unsigned int uint;\ntypedef long long int ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef set si;\n\n//MOD//\nconst ll MOD = 1000000007;\nstruct big;\nbig ex(big a, ll tms);\ntypedef struct big{\n ll val;\n big():val(0){}\n big(ll val):val((val%MOD+MOD)%MOD){}\n big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}\n big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}\n big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}\n big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}\n big operator + (const big& obj)const{ return big(*this) += obj;}\n big operator - (const big& obj)const{ return big(*this) -= obj;}\n big operator * (const big& obj)const{ return big(*this) *= obj;}\n big operator / (const big& obj)const{ return big(*this) /= obj;}\n bool operator < (const big& obj)const{ return val < obj.val;}\n bool operator == (const big& obj)const{ return val == obj.val;}\n} big;\nistream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}\nostream& operator << (ostream& o, const big& obj){ o<\nvoid convert(const F &f, T &t){\n stringstream ss;\n ss << f;\n ss >> t;\n}\n\nint N,M;\nint c[200001];\n\n//big jst[200000];\nbig cnt[200001];\n\nbig s[200001];\n\nint main(){\n\n scanf(\"%d\",&N);\n int bef = -1;\n int cc;\n rep (i,N) {\n scanf(\"%d\", &cc);\n if (cc != bef) {\n c[M] = cc;\n bef = cc;\n ++M;\n }\n }\n\n rep (i,M) {\n big cntbef = i==0 ? 1 : cnt[i-1];\n cnt[i] = cntbef + s[c[i]];\n s[c[i]] += cntbef;\n }\n\n cout << cnt[M-1] << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1552941214, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03096.html", "problem_id": "p03096", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03096/input.txt", "sample_output_relpath": "derived/input_output/data/p03096/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03096/C++/s829478275.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829478275", "user_id": "u807190097"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\n#define rep(i,n) for(int i=0; i<(n); ++i)\n#define rrep(i,n) for(int i=1; i<=(n); ++i)\n#define drep(i,n) for(int i=(n)-1; i>=0; --i)\n#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)\n#define pb push_back\n#define sz(x) (int)(x).size()\n#define fi first\n#define se second\n\ntypedef unsigned int uint;\ntypedef long long int ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef set si;\n\n//MOD//\nconst ll MOD = 1000000007;\nstruct big;\nbig ex(big a, ll tms);\ntypedef struct big{\n ll val;\n big():val(0){}\n big(ll val):val((val%MOD+MOD)%MOD){}\n big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}\n big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}\n big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}\n big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}\n big operator + (const big& obj)const{ return big(*this) += obj;}\n big operator - (const big& obj)const{ return big(*this) -= obj;}\n big operator * (const big& obj)const{ return big(*this) *= obj;}\n big operator / (const big& obj)const{ return big(*this) /= obj;}\n bool operator < (const big& obj)const{ return val < obj.val;}\n bool operator == (const big& obj)const{ return val == obj.val;}\n} big;\nistream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}\nostream& operator << (ostream& o, const big& obj){ o<\nvoid convert(const F &f, T &t){\n stringstream ss;\n ss << f;\n ss >> t;\n}\n\nint N,M;\nint c[200001];\n\n//big jst[200000];\nbig cnt[200001];\n\nbig s[200001];\n\nint main(){\n\n scanf(\"%d\",&N);\n int bef = -1;\n int cc;\n rep (i,N) {\n scanf(\"%d\", &cc);\n if (cc != bef) {\n c[M] = cc;\n bef = cc;\n ++M;\n }\n }\n\n rep (i,M) {\n big cntbef = i==0 ? 1 : cnt[i-1];\n cnt[i] = cntbef + s[c[i]];\n s[c[i]] += cntbef;\n }\n\n cout << cnt[M-1] << endl;\n\n return 0;\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "sample_input": "5\n1\n2\n1\n2\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03096", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2254, "cpu_time_ms": 26, "memory_kb": 4096}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s725517835", "group_id": "codeNet:p03103", "input_text": "#include \n#define rep(i,n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst int MOD = 1000000007;\nconst int INF = 999999999;\n\nint main(){\n int N, M;\n cin >> N >> M;\n vector

A(N);\n rep(i, N){\n cin >> A[i].first >> A[i].second;\n }\n sort(A.begin(), A.end());\n /*rep(i, N){\n cout << A[i].first << endl;\n }*/\n int ans = 0;\n rep(i, N){\n if(M > 0){\n if(A[i].second >= M){\n ans += A[i].first * M;\n M = 0;\n }else{\n ans += A[i].first * A[i].second;\n M -= A[i].second;\n }\n }else{\n break;\n }\n }\n cout << ans << endl;\nreturn 0;}", "language": "C++", "metadata": {"date": 1587831323, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/C++/s725517835.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s725517835", "user_id": "u767481489"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \n#define rep(i,n) for (int i = 0; i < (n); ++i)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nconst int MOD = 1000000007;\nconst int INF = 999999999;\n\nint main(){\n int N, M;\n cin >> N >> M;\n vector

A(N);\n rep(i, N){\n cin >> A[i].first >> A[i].second;\n }\n sort(A.begin(), A.end());\n /*rep(i, N){\n cout << A[i].first << endl;\n }*/\n int ans = 0;\n rep(i, N){\n if(M > 0){\n if(A[i].second >= M){\n ans += A[i].first * M;\n M = 0;\n }else{\n ans += A[i].first * A[i].second;\n M -= A[i].second;\n }\n }else{\n break;\n }\n }\n cout << ans << endl;\nreturn 0;}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 714, "cpu_time_ms": 76, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s427771857", "group_id": "codeNet:p03103", "input_text": "#include \n#define rep(i,n) for(int i = 0; i < (int)(n); i++)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing vi = vector;\nusing vc = vector;\nusing vs = vector;\nusing vll = vector;\nusing vvi = vector>;\nusing vvc = vector>;\nusing vvll = vector>;\ntemplate inline bool chmax(T &a, T b) { if (a inline bool chmin(T &a, T b) { if (b> n >> m;\n vector

ab(n);\n rep(i, n) {\n int a, b;\n cin >> a >> b;\n ab[i] = P(a, b);\n }\n sort(ab.begin(), ab.end());\n ll ans = 0;\n for (auto p : ab) {\n if (m <= 0) break;\n ans += (ll)p.first * min((ll)m, (ll)p.second);\n m -= min(m, p.second);\n }\n cout << ans << endl;\n\n}", "language": "C++", "metadata": {"date": 1586713236, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/C++/s427771857.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427771857", "user_id": "u009414205"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \n#define rep(i,n) for(int i = 0; i < (int)(n); i++)\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing vi = vector;\nusing vc = vector;\nusing vs = vector;\nusing vll = vector;\nusing vvi = vector>;\nusing vvc = vector>;\nusing vvll = vector>;\ntemplate inline bool chmax(T &a, T b) { if (a inline bool chmin(T &a, T b) { if (b> n >> m;\n vector

ab(n);\n rep(i, n) {\n int a, b;\n cin >> a >> b;\n ab[i] = P(a, b);\n }\n sort(ab.begin(), ab.end());\n ll ans = 0;\n for (auto p : ab) {\n if (m <= 0) break;\n ans += (ll)p.first * min((ll)m, (ll)p.second);\n m -= min(m, p.second);\n }\n cout << ans << endl;\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 26, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s460654755", "group_id": "codeNet:p03103", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstatic const long MAX = 1e5 + 3;\nint n, m, B[MAX];\nlong A[MAX], C[MAX][2], c, ans;\n\nlong h(long key, long i) {\n long r = (key % MAX + i * (1 + key % (MAX - 1))) % MAX;\n return r;\n}\n\nvoid insert(long key, long value) {\n long i = 0;\n\n while ( true ) {\n if ( C[h(key, i)][0] == key ) {\n break;\n } else if ( C[h(key, i)][0] ) {\n i++;\n } else {\n C[h(key, i)][0] = key;\n C[h(key, i)][1] = value;\n break;\n }\n }\n}\n\nlong find(long key) {\n long i = 0;\n\n while ( true ) {\n if ( C[h(key, i)][0] == key ) {\n return C[h(key, i)][1];\n break;\n } else if ( C[h(key, i)][0] ) {\n i++;\n } else {\n return 0;\n break;\n }\n }\n}\n\nint main() {\n scanf(\"%d %d\", &n, &m);\n \n for ( int i = 0; i < n; i++ ) {\n scanf(\"%ld %d\", &A[i], &B[i]);\n }\n\n for ( int i = 0; i < n; i++ ) {\n scanf(\"%ld %d\", &A[i], &B[i]);\n insert(A[i], B[i]);\n }\n\n c = 0;\n ans = 0;\n\n while ( m > 0 ) {\n m -= find(c);\n ans += c * find(c);\n c++;\n }\n\n ans += (c - 1) * m;\n printf(\"%ld\\n\", ans);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1556883613, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/C++/s460654755.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s460654755", "user_id": "u177182853"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstatic const long MAX = 1e5 + 3;\nint n, m, B[MAX];\nlong A[MAX], C[MAX][2], c, ans;\n\nlong h(long key, long i) {\n long r = (key % MAX + i * (1 + key % (MAX - 1))) % MAX;\n return r;\n}\n\nvoid insert(long key, long value) {\n long i = 0;\n\n while ( true ) {\n if ( C[h(key, i)][0] == key ) {\n break;\n } else if ( C[h(key, i)][0] ) {\n i++;\n } else {\n C[h(key, i)][0] = key;\n C[h(key, i)][1] = value;\n break;\n }\n }\n}\n\nlong find(long key) {\n long i = 0;\n\n while ( true ) {\n if ( C[h(key, i)][0] == key ) {\n return C[h(key, i)][1];\n break;\n } else if ( C[h(key, i)][0] ) {\n i++;\n } else {\n return 0;\n break;\n }\n }\n}\n\nint main() {\n scanf(\"%d %d\", &n, &m);\n \n for ( int i = 0; i < n; i++ ) {\n scanf(\"%ld %d\", &A[i], &B[i]);\n }\n\n for ( int i = 0; i < n; i++ ) {\n scanf(\"%ld %d\", &A[i], &B[i]);\n insert(A[i], B[i]);\n }\n\n c = 0;\n ans = 0;\n\n while ( m > 0 ) {\n m -= find(c);\n ans += c * find(c);\n c++;\n }\n\n ans += (c - 1) * m;\n printf(\"%ld\\n\", ans);\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1350, "cpu_time_ms": 2103, "memory_kb": 2944}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s178594487", "group_id": "codeNet:p03103", "input_text": "#include \nusing namespace std;\n\ntypedef pair P;\nint n, m;\npriority_queue, greater

> que;\nint main()\n{\n cin >> n >> m;\n for (int i = 0; i < n; i++)\n {\n long long int x;\n int y;\n cin >> x >> y;\n que.push(P(x, y));\n }\n long long int ans = 0;\n while (m)\n {\n P p = que.top();\n que.pop();\n if (p.second > m)\n {\n ans += p.first * m;\n m = 0;\n }\n else\n {\n ans += p.first * p.second;\n m -= p.second;\n }\n cout << ans << endl;\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1552162537, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/C++/s178594487.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s178594487", "user_id": "u693953100"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "#include \nusing namespace std;\n\ntypedef pair P;\nint n, m;\npriority_queue, greater

> que;\nint main()\n{\n cin >> n >> m;\n for (int i = 0; i < n; i++)\n {\n long long int x;\n int y;\n cin >> x >> y;\n que.push(P(x, y));\n }\n long long int ans = 0;\n while (m)\n {\n P p = que.top();\n que.pop();\n if (p.second > m)\n {\n ans += p.first * m;\n m = 0;\n }\n else\n {\n ans += p.first * p.second;\n m -= p.second;\n }\n cout << ans << endl;\n }\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 642, "cpu_time_ms": 231, "memory_kb": 3440}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s617291516", "group_id": "codeNet:p03107", "input_text": "#include \nusing namespace std;\nint main(){\n string S;\n cin >> S;\n int n = S.size();\n int t=0;\n int ans=0;\n while(t==0){\n t = 1;\n for(int i=0;i\nusing namespace std;\nint main(){\n string S;\n cin >> S;\n int n = S.size();\n int t=0;\n int ans=0;\n while(t==0){\n t = 1;\n for(int i=0;i\nusing namespace std;\n\nint main(){\n\n string s;\n cin >> s;\n\n int ans = 0;\n for (int i=0; i\nusing namespace std;\n\nint main(){\n\n string s;\n cin >> s;\n\n int ans = 0;\n for (int i=0; i\n\ntypedef long long ll;\nusing namespace std;\n\nint main() {\n string S;\n cin >> S;\n int a[2];\n int len = S.length();\n for (int i = 0; i < len; i++) {\n a[S[i] - '0']++;\n }\n cout << min(a[0], a[1]) * 2 << endl;\n}", "language": "C++", "metadata": {"date": 1558042597, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03107.html", "problem_id": "p03107", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03107/input.txt", "sample_output_relpath": "derived/input_output/data/p03107/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03107/C++/s904606937.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s904606937", "user_id": "u761362252"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \n\ntypedef long long ll;\nusing namespace std;\n\nint main() {\n string S;\n cin >> S;\n int a[2];\n int len = S.length();\n for (int i = 0; i < len; i++) {\n a[S[i] - '0']++;\n }\n cout << min(a[0], a[1]) * 2 << endl;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 5, "memory_kb": 512}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s826204630", "group_id": "codeNet:p03108", "input_text": "#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/*\nusing PAIR = pair;\nsort(sp.begin(), sp.end(), [](PAIR l, PAIR r){\n return l.first r.second);\n });\n*/\n\ntypedef long long ll;\n\n#define fi first\n#define se second\n#define rep(i, n) for (ll i = 0; i < n; i++)\n#define debugA() cerr << \"AAAAA\" << endl\n#define debug_() cerr << \"-------------\" << endl\n#define debug(x) cerr << #x << \": \" << x << endl\n#define debug_vec(v) \\\n for (int i = 0; i < v.size(); i++) \\\n { \\\n cout << v[i] << \" \"; \\\n } \\\n cout << endl;\n#define debug_vec2(v) \\\n for (int i = 0; i < v.size(); i++) \\\n { \\\n for (int j = 0; j < v[i].size(); j++) \\\n { \\\n cout << v[i][j] << \" \"; \\\n } \\\n cout << endl; \\\n }\n\nusing Graph = vector>;\nusing P = pair;\nusing P1 = pair>; // クラスカル法とかで、{cost, {from, to}}的に使う。\nconst int INF = 1001001001;\nconst double pi = acos(-1);\n\nclass UnionFind\n{\npublic:\n // 親の番号を格納する。親だった場合は -(その集合のサイズ)とする。\n vector Parent;\n\n // 作るときはParentの値を全て-1にする。\n UnionFind(int N)\n {\n Parent = vector(N, -1);\n }\n\n // Aがどのグループに所属しているか調べる。\n int root(int A)\n {\n if (Parent[A] < 0)\n return A;\n return Parent[A] = root(Parent[A]);\n }\n\n // 自分のいる頂点の数をイラべる。\n int size(int A)\n {\n return -Parent[root(A)]; // 親を取ってきたい。\n }\n\n // AとBをくっつける。\n bool unite(int A, int B)\n {\n // root(A)をroot(B)にくっつける。\n A = root(A);\n B = root(B);\n if (A == B)\n {\n return false;\n }\n // 大きい方(A)に小さい方(B)をくっつけたい。\n // 大小が逆ならひっくり返す。\n if (size(A) < size(B))\n {\n swap(A, B);\n }\n\n // Aのサイズを更新する。\n Parent[A] += Parent[B];\n // Bの親をAに変更する。\n Parent[B] = A;\n return true;\n }\n};\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n vector> b(m);\n for (int i = 0; i < m; i++)\n {\n int x, y;\n cin >> x >> y;\n x--;\n y--;\n b[i] = {x, y};\n }\n vector ans(m, 0);\n UnionFind tree(n);\n ans[m - 1] = n * (n - 1) / 2;\n for (int i = 0; i < m - 1; i++)\n {\n int x = b[m - 1 - i].fi;\n int y = b[m - 1 - i].se;\n if (tree.root(x) == tree.root(y))\n {\n ans[m - 2 - i] = ans[m - 1 - i];\n }\n else\n {\n ans[m - 2 - i] = ans[m - 1 - i] - tree.size(x) * tree.size(y);\n tree.unite(x, y);\n }\n }\n for (int i = 0; i < m; i++)\n {\n cout << ans[i] << endl;\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1592100080, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03108/input.txt", "sample_output_relpath": "derived/input_output/data/p03108/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03108/C++/s826204630.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s826204630", "user_id": "u275934251"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "#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/*\nusing PAIR = pair;\nsort(sp.begin(), sp.end(), [](PAIR l, PAIR r){\n return l.first r.second);\n });\n*/\n\ntypedef long long ll;\n\n#define fi first\n#define se second\n#define rep(i, n) for (ll i = 0; i < n; i++)\n#define debugA() cerr << \"AAAAA\" << endl\n#define debug_() cerr << \"-------------\" << endl\n#define debug(x) cerr << #x << \": \" << x << endl\n#define debug_vec(v) \\\n for (int i = 0; i < v.size(); i++) \\\n { \\\n cout << v[i] << \" \"; \\\n } \\\n cout << endl;\n#define debug_vec2(v) \\\n for (int i = 0; i < v.size(); i++) \\\n { \\\n for (int j = 0; j < v[i].size(); j++) \\\n { \\\n cout << v[i][j] << \" \"; \\\n } \\\n cout << endl; \\\n }\n\nusing Graph = vector>;\nusing P = pair;\nusing P1 = pair>; // クラスカル法とかで、{cost, {from, to}}的に使う。\nconst int INF = 1001001001;\nconst double pi = acos(-1);\n\nclass UnionFind\n{\npublic:\n // 親の番号を格納する。親だった場合は -(その集合のサイズ)とする。\n vector Parent;\n\n // 作るときはParentの値を全て-1にする。\n UnionFind(int N)\n {\n Parent = vector(N, -1);\n }\n\n // Aがどのグループに所属しているか調べる。\n int root(int A)\n {\n if (Parent[A] < 0)\n return A;\n return Parent[A] = root(Parent[A]);\n }\n\n // 自分のいる頂点の数をイラべる。\n int size(int A)\n {\n return -Parent[root(A)]; // 親を取ってきたい。\n }\n\n // AとBをくっつける。\n bool unite(int A, int B)\n {\n // root(A)をroot(B)にくっつける。\n A = root(A);\n B = root(B);\n if (A == B)\n {\n return false;\n }\n // 大きい方(A)に小さい方(B)をくっつけたい。\n // 大小が逆ならひっくり返す。\n if (size(A) < size(B))\n {\n swap(A, B);\n }\n\n // Aのサイズを更新する。\n Parent[A] += Parent[B];\n // Bの親をAに変更する。\n Parent[B] = A;\n return true;\n }\n};\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n vector> b(m);\n for (int i = 0; i < m; i++)\n {\n int x, y;\n cin >> x >> y;\n x--;\n y--;\n b[i] = {x, y};\n }\n vector ans(m, 0);\n UnionFind tree(n);\n ans[m - 1] = n * (n - 1) / 2;\n for (int i = 0; i < m - 1; i++)\n {\n int x = b[m - 1 - i].fi;\n int y = b[m - 1 - i].se;\n if (tree.root(x) == tree.root(y))\n {\n ans[m - 2 - i] = ans[m - 1 - i];\n }\n else\n {\n ans[m - 2 - i] = ans[m - 1 - i] - tree.size(x) * tree.size(y);\n tree.unite(x, y);\n }\n }\n for (int i = 0; i < m; i++)\n {\n cout << ans[i] << endl;\n }\n\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3562, "cpu_time_ms": 214, "memory_kb": 3328}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s610142348", "group_id": "codeNet:p03111", "input_text": "/*\nURL_HERE\n*/\n/*\n\n*/\n#ifdef _WIN32\n#pragma warning(disable:4996)\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \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= b ? a : b; }\nint _max(ll a, ll b) { return a >= b ? a : b; }\nvoid zero(int* data, int n) { memset(data, 0, sizeof(int) * n); }\nvoid zero(ll* data, int n) { memset(data, 0, sizeof(ll) * n); }\nvoid zero(char* data, int n) { memset(data, 0, sizeof(char) * n); }\nchar readc() { char var; fscanf(_fin, \"%c\", &var); return var; }\nint readi() { int var; fscanf(_fin, \"%d\", &var); return var; }\ndouble readlf() { double var; fscanf(_fin, \"%lf\", &var); return var; }\nll readll() { ll var; fscanf(_fin, \"%lld\", &var); return var; }\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{\n\tfor (;;) { if (fgets(str, maxsize, _fin) == NULL) break; if (str[0] != '\\n' && str[0] != '\\r') break; }\n\tint slen = strlen(str); if (slen == 0) return 0;\n\tif (str[slen - 1] == '\\n' || str[slen - 1] == '\\r') str[--slen] = 0;\n\treturn 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 RUN_LOCAL(testfilename) {_fin = fopen(testfilename, \"r\"); if(_fin==NULL) _fin=stdin;}\n#define swap(type,a, b) {type t=a;a=b;b=t;}\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) //what the hell is this...\nll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }\nll lcm(ll a, ll b) { ll g = gcd(a, b); return (a / g) * b; }\nvoid reverse(char* data, int n) { int k = n >> 1; repi(k) { char tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\nvoid reverse(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\n\n#define _Vec(type, name) \\\nstruct name { type* data; int size; int n; };\\\nvoid init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\\\nvoid resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\\\nvoid add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\\\nvoid free(name* t) { free(t->data);}\n_Vec(int, Veci)\n_Vec(long long, Vecll)\n_Vec(char*, Vecs)\n\n#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}\n_ispal(int, ispali)\n_ispal(char, ispalc)\n\n#define _Pair(type, name) struct name{type x, y;}; \\\nint cmp_##name(const void* _a, const void* _b)\\\n{\\\n\tname* a = (name*)_a;name* b = (name*)_b;\\\n\tif (a->x < b->x) return -1;\\\n\telse\\\n\t{\\\n\t\tif (a->x == b->x)\\\n\t\t{\\\n\t\t\tif (a->y == b->y) return 0;\\\n\t\t\tif (a->y < b->y) return -1;\\\n\t\t\telse return 1;\\\n\t\t}\\\n\t\telse\\\n\t\t{\\\n\t\t\treturn 1;\\\n\t\t}\\\n\t}\\\n}\\\nvoid sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}\n\t_Pair(int, Pairi)\n\n\tint cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }\nvoid sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }\n\nll expmod(ll x, ll n, ll m) {\n\tll ans = 1;\n\tfor (; n;) {\n\t\tif (n & 1) ans = (ans * x) % m;\n\t\tx = (x * x) % m;\n\t\tn >>= 1;\n\t}\n\treturn ans;\n}\n\nll combmod(ll n, ll k, ll m) {\n\tll ret = 1;\n\tll div = 1;\n\tfor (ll i = 0; i < k; ++i) {\n\t\tret = (ret * (n - i) % m) % m;\n\t\tdiv = (div * (i + 1)) % m;\n\t}\n\tdiv = expmod(div, m - 2, m) % m;\n\treturn (ret * div) % m;\n}\n\nint next_perm(int* data, int n)\n{\n\t//find first i,i+1 where d[i]= 0; --i)\n\t{\n\t\tif (data[i] < data[i + 1])\n\t\t{\n\t\t\trootidx = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (rootidx == -1) return 0;\n\n\tint ceilingidx = rootidx + 1;\n\t//find smallest d[x] after d[rooti] where d[x]>d[rooti]\n\tfor (int i = rootidx + 2; i < n; ++i)\n\t{\n\t\tif (data[i] > data[rootidx] && data[i] < data[ceilingidx])\n\t\t{\n\t\t\tceilingidx = i;\n\t\t}\n\t}\n\n\tswap(int, data[rootidx], data[ceilingidx]);\n\tsort(&data[rootidx + 1], n - rootidx - 1);\n\treturn 1;\n}\nint count_digits(ll a)\n{\n\tint k = 0;\n\tfor (;;)\n\t{\n\t\tif (a == 0)break;\n\t\tk++;\n\t\ta /= 10;\n\t}\n\treturn k;\n}\n\n/*\nuse only when val EXISTS in data\n*/\nint bs_exists(int* data, int n, int val)\n{\n\tint left = 0;\n\tint right = n - 1;\n\tfor (; left < right;)\n\t{\n\t\tint mid = (left + right + 1) >> 1;\n\t\tif (data[mid] <= val) left = mid;\n\t\telse right = mid - 1;\n\t}\n\treturn right;\n}\n//------------------------------------------\n\n//------------\n\nvoid dfs(int* bestmana, int currentmana, int* l, int nl, int maxnl, int a, int b, int c,int tA,int tB,int tC)\n{\n\tif (nl == maxnl)\n\t{\n\t\t//gotta make sure at least 1 stick was added\n\t\tif (a == 0 || b == 0 || c == 0)return;\n\t\tint totalmanacost = abs(a - tA) + abs(b - tB) + abs(c - tC);//this makes it so that lengths match\n\t\ttotalmanacost += currentmana;\n\t\tif (totalmanacost < *bestmana)\n\t\t{\n\t\t\t*bestmana = totalmanacost;\n\t\t}\n\t\treturn;\n\t}\n\t\n\tdfs(bestmana, currentmana, l, nl + 1, maxnl, a , b, c, tA, tB, tC);//dont use stick\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a + l[nl], b, c, tA, tB, tC);//add stick to a\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a, b + l[nl], c, tA, tB, tC);//add stick to b\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a, b, c + l[nl], tA, tB, tC);//add stick to c\n}\n\nint main()\n{\n\t\n\tRUN_LOCAL(\"xxtop2_0.txt\");\n\tint n = readi();\n\tint a = readi();\n\tint b = readi();\n\tint c = readi();\n\tstatic int l[10];\n\trepread(l, n);\n\n\tint bestmana = 1e9;\n\tdfs(&bestmana, 0, l, 0, n, 0, 0, 0, a, b, c);\n\twriteiln(bestmana);//initial placement of sticks are not considered joining\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1597790174, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03111.html", "problem_id": "p03111", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03111/input.txt", "sample_output_relpath": "derived/input_output/data/p03111/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03111/C++/s610142348.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s610142348", "user_id": "u950002813"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "/*\nURL_HERE\n*/\n/*\n\n*/\n#ifdef _WIN32\n#pragma warning(disable:4996)\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \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= b ? a : b; }\nint _max(ll a, ll b) { return a >= b ? a : b; }\nvoid zero(int* data, int n) { memset(data, 0, sizeof(int) * n); }\nvoid zero(ll* data, int n) { memset(data, 0, sizeof(ll) * n); }\nvoid zero(char* data, int n) { memset(data, 0, sizeof(char) * n); }\nchar readc() { char var; fscanf(_fin, \"%c\", &var); return var; }\nint readi() { int var; fscanf(_fin, \"%d\", &var); return var; }\ndouble readlf() { double var; fscanf(_fin, \"%lf\", &var); return var; }\nll readll() { ll var; fscanf(_fin, \"%lld\", &var); return var; }\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{\n\tfor (;;) { if (fgets(str, maxsize, _fin) == NULL) break; if (str[0] != '\\n' && str[0] != '\\r') break; }\n\tint slen = strlen(str); if (slen == 0) return 0;\n\tif (str[slen - 1] == '\\n' || str[slen - 1] == '\\r') str[--slen] = 0;\n\treturn 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 RUN_LOCAL(testfilename) {_fin = fopen(testfilename, \"r\"); if(_fin==NULL) _fin=stdin;}\n#define swap(type,a, b) {type t=a;a=b;b=t;}\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) //what the hell is this...\nll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }\nll lcm(ll a, ll b) { ll g = gcd(a, b); return (a / g) * b; }\nvoid reverse(char* data, int n) { int k = n >> 1; repi(k) { char tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\nvoid reverse(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }\n\n#define _Vec(type, name) \\\nstruct name { type* data; int size; int n; };\\\nvoid init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\\\nvoid resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\\\nvoid add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\\\nvoid free(name* t) { free(t->data);}\n_Vec(int, Veci)\n_Vec(long long, Vecll)\n_Vec(char*, Vecs)\n\n#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}\n_ispal(int, ispali)\n_ispal(char, ispalc)\n\n#define _Pair(type, name) struct name{type x, y;}; \\\nint cmp_##name(const void* _a, const void* _b)\\\n{\\\n\tname* a = (name*)_a;name* b = (name*)_b;\\\n\tif (a->x < b->x) return -1;\\\n\telse\\\n\t{\\\n\t\tif (a->x == b->x)\\\n\t\t{\\\n\t\t\tif (a->y == b->y) return 0;\\\n\t\t\tif (a->y < b->y) return -1;\\\n\t\t\telse return 1;\\\n\t\t}\\\n\t\telse\\\n\t\t{\\\n\t\t\treturn 1;\\\n\t\t}\\\n\t}\\\n}\\\nvoid sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}\n\t_Pair(int, Pairi)\n\n\tint cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }\nvoid sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }\n\nll expmod(ll x, ll n, ll m) {\n\tll ans = 1;\n\tfor (; n;) {\n\t\tif (n & 1) ans = (ans * x) % m;\n\t\tx = (x * x) % m;\n\t\tn >>= 1;\n\t}\n\treturn ans;\n}\n\nll combmod(ll n, ll k, ll m) {\n\tll ret = 1;\n\tll div = 1;\n\tfor (ll i = 0; i < k; ++i) {\n\t\tret = (ret * (n - i) % m) % m;\n\t\tdiv = (div * (i + 1)) % m;\n\t}\n\tdiv = expmod(div, m - 2, m) % m;\n\treturn (ret * div) % m;\n}\n\nint next_perm(int* data, int n)\n{\n\t//find first i,i+1 where d[i]= 0; --i)\n\t{\n\t\tif (data[i] < data[i + 1])\n\t\t{\n\t\t\trootidx = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (rootidx == -1) return 0;\n\n\tint ceilingidx = rootidx + 1;\n\t//find smallest d[x] after d[rooti] where d[x]>d[rooti]\n\tfor (int i = rootidx + 2; i < n; ++i)\n\t{\n\t\tif (data[i] > data[rootidx] && data[i] < data[ceilingidx])\n\t\t{\n\t\t\tceilingidx = i;\n\t\t}\n\t}\n\n\tswap(int, data[rootidx], data[ceilingidx]);\n\tsort(&data[rootidx + 1], n - rootidx - 1);\n\treturn 1;\n}\nint count_digits(ll a)\n{\n\tint k = 0;\n\tfor (;;)\n\t{\n\t\tif (a == 0)break;\n\t\tk++;\n\t\ta /= 10;\n\t}\n\treturn k;\n}\n\n/*\nuse only when val EXISTS in data\n*/\nint bs_exists(int* data, int n, int val)\n{\n\tint left = 0;\n\tint right = n - 1;\n\tfor (; left < right;)\n\t{\n\t\tint mid = (left + right + 1) >> 1;\n\t\tif (data[mid] <= val) left = mid;\n\t\telse right = mid - 1;\n\t}\n\treturn right;\n}\n//------------------------------------------\n\n//------------\n\nvoid dfs(int* bestmana, int currentmana, int* l, int nl, int maxnl, int a, int b, int c,int tA,int tB,int tC)\n{\n\tif (nl == maxnl)\n\t{\n\t\t//gotta make sure at least 1 stick was added\n\t\tif (a == 0 || b == 0 || c == 0)return;\n\t\tint totalmanacost = abs(a - tA) + abs(b - tB) + abs(c - tC);//this makes it so that lengths match\n\t\ttotalmanacost += currentmana;\n\t\tif (totalmanacost < *bestmana)\n\t\t{\n\t\t\t*bestmana = totalmanacost;\n\t\t}\n\t\treturn;\n\t}\n\t\n\tdfs(bestmana, currentmana, l, nl + 1, maxnl, a , b, c, tA, tB, tC);//dont use stick\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a + l[nl], b, c, tA, tB, tC);//add stick to a\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a, b + l[nl], c, tA, tB, tC);//add stick to b\n\tdfs(bestmana, currentmana + 10, l, nl + 1, maxnl, a, b, c + l[nl], tA, tB, tC);//add stick to c\n}\n\nint main()\n{\n\t\n\tRUN_LOCAL(\"xxtop2_0.txt\");\n\tint n = readi();\n\tint a = readi();\n\tint b = readi();\n\tint c = readi();\n\tstatic int l[10];\n\trepread(l, n);\n\n\tint bestmana = 1e9;\n\tdfs(&bestmana, 0, l, 0, n, 0, 0, 0, a, b, c);\n\twriteiln(bestmana);//initial placement of sticks are not considered joining\n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "sample_input": "5 100 90 80\n98\n40\n30\n21\n80\n"}, "reference_outputs": ["23\n"], "source_document_id": "p03111", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6754, "cpu_time_ms": 6, "memory_kb": 1740}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s087940496", "group_id": "codeNet:p03113", "input_text": "#include \n\nusing namespace std;\n\nint main() {\n\tint n, k, a[55], p = 99;\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n\tstringstream s;\n\tfor (int i = 0; i < k + 1; i++) {\n\t\tint m = 111, x;\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif (j != p && a[j] < m) m = a[x = j];\n\t\tif (!m) {\n\t\t\tcout << -1 << endl;\n\t\t\treturn 0;\n\t\t}\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif (j != p && j != x)\n\t\t\t\ts << j + 1 << ' ', a[j]--;\n\t\ts << x + 1 << ' ', a[x]--;\n\t\tp = x;\n\t}\n\tcout << n + (n - 1)*k << '\\n' << s.str() << endl;\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1550994573, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03113.html", "problem_id": "p03113", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03113/input.txt", "sample_output_relpath": "derived/input_output/data/p03113/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03113/C++/s087940496.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087940496", "user_id": "u337381518"}, "prompt_components": {"gold_output": "7\n1 1 2 1 2 2 1\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main() {\n\tint n, k, a[55], p = 99;\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n\tstringstream s;\n\tfor (int i = 0; i < k + 1; i++) {\n\t\tint m = 111, x;\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif (j != p && a[j] < m) m = a[x = j];\n\t\tif (!m) {\n\t\t\tcout << -1 << endl;\n\t\t\treturn 0;\n\t\t}\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif (j != p && j != x)\n\t\t\t\ts << j + 1 << ' ', a[j]--;\n\t\ts << x + 1 << ' ', a[x]--;\n\t\tp = x;\n\t}\n\tcout << n + (n - 1)*k << '\\n' << s.str() << endl;\n\treturn 0;\n}\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nSnuke participated in a magic show.\n\nA magician prepared N identical-looking boxes.\nHe put a treasure in one of the boxes, closed the boxes, shuffled them, and numbered them 1 through N.\n\nSince the boxes are shuffled, now Snuke has no idea which box contains the treasure.\nSnuke wins the game if he opens a box containing the treasure.\nYou may think that if Snuke opens all boxes at once, he can always win the game.\nHowever, there are some tricks:\n\nSnuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.\n\nHe is only allowed to open Box i at most a_i times.\n\nThe magician may secretly move the treasure from a closed box to another closed box, using some magic trick.\nFor simplicity, assume that the magician never moves the treasure while Snuke is opening some box.\nHowever, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).\n\nThe magician can perform the magic trick at most K times.\n\nCan Snuke always win the game, regardless of the initial position of the treasure and the movements of the magician?\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq K \\leq 50\n\n1 \\leq a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\cdots a_N\n\nOutput\n\nIf the answer is no, print a single -1.\n\nOtherwise, print one possible move of Snuke in the following format:\n\nQ\nx_1 x_2 \\cdots x_Q\n\nIt means that he opens boxes x_1, x_2, \\cdots, x_Q in this order.\n\nIn case there are multiple possible solutions, you can output any.\n\nSample Input 1\n\n2 1\n5 5\n\nSample Output 1\n\n7\n1 1 2 1 2 2 1\n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2 \\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find the treasure regardless of its initial position and the movements of the magician.\n\nSample Input 2\n\n3 50\n5 10 15\n\nSample Output 2\n\n-1", "sample_input": "2 1\n5 5\n"}, "reference_outputs": ["7\n1 1 2 1 2 2 1\n"], "source_document_id": "p03113", "source_text": "Score : 1000 points\n\nProblem Statement\n\nSnuke participated in a magic show.\n\nA magician prepared N identical-looking boxes.\nHe put a treasure in one of the boxes, closed the boxes, shuffled them, and numbered them 1 through N.\n\nSince the boxes are shuffled, now Snuke has no idea which box contains the treasure.\nSnuke wins the game if he opens a box containing the treasure.\nYou may think that if Snuke opens all boxes at once, he can always win the game.\nHowever, there are some tricks:\n\nSnuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.\n\nHe is only allowed to open Box i at most a_i times.\n\nThe magician may secretly move the treasure from a closed box to another closed box, using some magic trick.\nFor simplicity, assume that the magician never moves the treasure while Snuke is opening some box.\nHowever, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).\n\nThe magician can perform the magic trick at most K times.\n\nCan Snuke always win the game, regardless of the initial position of the treasure and the movements of the magician?\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq K \\leq 50\n\n1 \\leq a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\cdots a_N\n\nOutput\n\nIf the answer is no, print a single -1.\n\nOtherwise, print one possible move of Snuke in the following format:\n\nQ\nx_1 x_2 \\cdots x_Q\n\nIt means that he opens boxes x_1, x_2, \\cdots, x_Q in this order.\n\nIn case there are multiple possible solutions, you can output any.\n\nSample Input 1\n\n2 1\n5 5\n\nSample Output 1\n\n7\n1 1 2 1 2 2 1\n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2 \\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find the treasure regardless of its initial position and the movements of the magician.\n\nSample Input 2\n\n3 50\n5 10 15\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 531, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s658459847", "group_id": "codeNet:p03125", "input_text": "#include\nusing namespace std;\nint main()\n{\n // 整数の入力\n int a,b;\n cin >> a >> b;\n int c;\n if (b % a == 0){\n c = a + b;\n } else\n {\n c = b - a;\n }\n cout << c << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1550371733, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03125/input.txt", "sample_output_relpath": "derived/input_output/data/p03125/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03125/C++/s658459847.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658459847", "user_id": "u934405210"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "#include\nusing namespace std;\nint main()\n{\n // 整数の入力\n int a,b;\n cin >> a >> b;\n int c;\n if (b % a == 0){\n c = a + b;\n } else\n {\n c = b - a;\n }\n cout << c << endl;\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 239, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s273368545", "group_id": "codeNet:p03126", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define MOD 1000000007\n#define PI 3.141592653589793\nconst int INF = 100000000;\nint dx[] = {0,1,-1,0,1,-1,1,-1};\nint dy[] = {1,0,0,-1,1,-1,-1,1};\n\n\nint main(){\n int n, m;\n cin >> n >> m;\n vector v(m+1, 0);\n for(int i = 0; i < n; i++){\n int k;\n cin >> k;\n while(k--){\n int a;\n cin >> a;\n v[a]++;\n }\n }\n int ans = 0;\n for(auto i: v)\n if(i == n)\n ans++;\n cout << ans << endl;\n}\n", "language": "C++", "metadata": {"date": 1566618806, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/C++/s273368545.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273368545", "user_id": "u874723578"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define MOD 1000000007\n#define PI 3.141592653589793\nconst int INF = 100000000;\nint dx[] = {0,1,-1,0,1,-1,1,-1};\nint dy[] = {1,0,0,-1,1,-1,-1,1};\n\n\nint main(){\n int n, m;\n cin >> n >> m;\n vector v(m+1, 0);\n for(int i = 0; i < n; i++){\n int k;\n cin >> k;\n while(k--){\n int a;\n cin >> a;\n v[a]++;\n }\n }\n int ans = 0;\n for(auto i: v)\n if(i == n)\n ans++;\n cout << ans << endl;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s277630044", "group_id": "codeNet:p03126", "input_text": "#include \n#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n\nint main() {\n int a,b;\n cin>>a>>b;\n vector vec(b,0);\n rep(i,a){\n int c;\n cin>>c;\n for(int j=0;j>d;\n d--;\n vec.at(d)++;\n }\n }\n\n int count =0;\n rep(i,b){\n if(vec.at(i)==a){\n count++;\n }\n }\n cout<\n#include \nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n\nint main() {\n int a,b;\n cin>>a>>b;\n vector vec(b,0);\n rep(i,a){\n int c;\n cin>>c;\n for(int j=0;j>d;\n d--;\n vec.at(d)++;\n }\n }\n\n int count =0;\n rep(i,b){\n if(vec.at(i)==a){\n count++;\n }\n }\n cout<\nusing namespace std;\n\nint main() {\n\tint N, M;\n\tint K[30];\n\tint A[30][30];\n\tint like[30];\n\tint ans = 0;\n\n\tfor (int i = 0; i < 30; i++) {\n\t\tlike[i] =0;\n\t\tfor (int j = 0; j < 30; j++) {\n\t\t\t//A[i][j] = false;\n\t\t}\n\t}\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >>K[i];\n\t\tfor (int j = 0; j < K[i]; j++) {\n\t\t\tcin >> A[i][j];\n\t\t}\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tfor (int j = 0; j < K[i]; j++) {\n\t\t\tlike[A[i][j]]++;\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < M; i++) {\n\t\tif (like[i] == N) {\n\t\t\tans++;\n\t\t}\n\t}\n\n\tprintf(\"%d\", ans);\n}", "language": "C++", "metadata": {"date": 1550369796, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/C++/s425002537.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s425002537", "user_id": "u576167201"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\n#include\nusing namespace std;\n\nint main() {\n\tint N, M;\n\tint K[30];\n\tint A[30][30];\n\tint like[30];\n\tint ans = 0;\n\n\tfor (int i = 0; i < 30; i++) {\n\t\tlike[i] =0;\n\t\tfor (int j = 0; j < 30; j++) {\n\t\t\t//A[i][j] = false;\n\t\t}\n\t}\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >>K[i];\n\t\tfor (int j = 0; j < K[i]; j++) {\n\t\t\tcin >> A[i][j];\n\t\t}\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tfor (int j = 0; j < K[i]; j++) {\n\t\t\tlike[A[i][j]]++;\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < M; i++) {\n\t\tif (like[i] == N) {\n\t\t\tans++;\n\t\t}\n\t}\n\n\tprintf(\"%d\", ans);\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 541, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s014777282", "group_id": "codeNet:p03127", "input_text": "#include\nusing ll = long long;\nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n vector A(N,0);\n\n for(int i = 0; i < N; i++)\n {\n cin >> A[i];\n }\n \n sort(A.begin(),A.end());\n\n int Temp = 1000000001;\n for(int i = 1; i < N; i++)\n {\n for(int j = 0; j < i; j++)\n {\n if (A[i] % A[j] == 1)\n {\n cout << 1 << endl;\n return 0;\n }\n else if(A[i] % A[j] < Temp && A[i] % A[j] > 1)\n {\n Temp = A[i] % A[j];\n A[i] = Temp;\n sort(A.begin(),A.end());\n i = 1;\n }\n \n }\n }\n if(Temp<1000000001) cout << Temp << endl;\n else cout << A[0] << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1554141171, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/C++/s014777282.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s014777282", "user_id": "u808593466"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\nusing ll = long long;\nusing namespace std;\n\nint main(){\n int N;\n cin >> N;\n vector A(N,0);\n\n for(int i = 0; i < N; i++)\n {\n cin >> A[i];\n }\n \n sort(A.begin(),A.end());\n\n int Temp = 1000000001;\n for(int i = 1; i < N; i++)\n {\n for(int j = 0; j < i; j++)\n {\n if (A[i] % A[j] == 1)\n {\n cout << 1 << endl;\n return 0;\n }\n else if(A[i] % A[j] < Temp && A[i] % A[j] > 1)\n {\n Temp = A[i] % A[j];\n A[i] = Temp;\n sort(A.begin(),A.end());\n i = 1;\n }\n \n }\n }\n if(Temp<1000000001) cout << Temp << endl;\n else cout << A[0] << endl;\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 799, "cpu_time_ms": 2103, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s432144503", "group_id": "codeNet:p03128", "input_text": "#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#define ALL(a) (a).begin(),(a).end()\nconst long long MOD = 1000000007;\n\n//いろんなstlの使い方 https://qiita.com/tukejonny/items/f4013547df761a0b3523\n//http://y-mazun.hatenablog.com/entry/20111202/1322840281\n\n\n\nusing namespace std;\nstruct point{\n int x;\n int y;\n\n};\n//https://ei1333.github.io/luzhiled/snippets/structure/union-find.html\ntemplate< typename T >\nstruct WeightedUnionFind {\n vector< int > data;\n vector< T > ws;\n\n WeightedUnionFind() {}\n\n WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}\n\n int find(int k) {\n if(data[k] < 0) return k;\n auto par = find(data[k]);\n ws[k] += ws[data[k]];\n return data[k] = par;\n }\n\n T weight(int t) {\n find(t);\n return ws[t];\n }\n\n bool unite(int x, int y, T w) {\n w += weight(x);\n w -= weight(y);\n x = find(x), y = find(y);\n if(x == y) return false;\n if(data[x] > data[y]) {\n swap(x, y);\n w *= -1;\n }\n data[x] += data[y];\n data[y] = x;\n ws[y] = w;\n return true;\n }\n\n T diff(int x, int y) {\n return weight(y) - weight(x);\n }\n};\n\n\n\nlong long gcd(long long a, long long b)\n{\n if(a>b){\n return gcd(b,a);\n }\n return a == 0 ? b : gcd(b % a, a);\n}\nlong long lcm( long long m, long long n )\n{\n // 引数に0がある場合は0を返す\n if ( ( 0 == m ) || ( 0 == n ) )\n return 0;\n\n return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)\n}//lcm\nint input(){\n int x;\n cin>>x;\n return x;\n}\n\nint moji(char in)\n{\n int ans = (int)in-(int)'a';\n if((ans < 0) || (ans > 25)){\n ans = 26;\n }\n return ans;\n}\nconst int VV=1;//場合に応じてVVの値のみ変更する必要あり\n//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能\nint cost[VV][VV];\nint d[VV];\nbool used[VV];\nvoid dijkstra(int s){\n\n fill(d,d+VV,100000);\n fill(used,used+VV,false);\n d[s]=0;\n while(true){\n cout<<\"Hello\"<=1){\n int i=(l+r)/2;\n if(k[i]==x)return i;\n else if(k[i]0;i--){\n sum*=i;\n if(sum>l){\n sum%=l;\n }\n }\n return sum;\n}\n\n\ntemplatevoid chmin(T &a,T b){\n if(a>b){\n a=b;\n }\n}\n\n//formerは前方のindex(自分自身を含んで良い)\ntemplateint former(const vector&v,T x){\n return upper_bound(v.begin(),v.end(),x)-v.begin()-1;\n}\n//latterは後方のindex(自分自身を含んで良い)\ntemplateint latter(const vector&v,T x){\n return lower_bound(v.begin(),v.end(),x)-v.begin();\n}\n\nstruct UnionFind{\n //par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである\n vectorpar;\n //sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる\n vectorsizes;\n\n UnionFind(int n):par(n),sizes(n,1){\n //最初は全てのデータiがグループiに存在するものとして初期化\n for(int i=0;ies;//辺集合\n //クラスカル法で無向最小全域木のコストの和を計算する\n //グラフが非連結の時は最小全域森のコストの和になる\n //使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/\n int kruskal(){\n //コストが小さい順にソーと\n sort(es.begin(),es.end());\n UnionFind uf(n);\n int min_cost=0;\n for(int ei=0;ei>g.n>>m;\n for(int i=0;i>e.a>>e.b>>e.cost;\n g.es.push_back(e);\n }\n return g;\n}*/\nlong long labs(long long x){\n if(x<0){\n return -x;\n }\n return x;\n}\n// a^n mod を計算する\nlong long modpow(long long a, long long n, long long mod) {\n long long 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//indexを用いてvectorから要素削除\ntemplate\nvoid remove(std::vector& vector, unsigned int index)\n{\n vector.erase(vector.begin() + index);\n}\n\nvoid modadd(long long &a,long long b){\n a+=b;\n if(a>=MOD){\n a%=MOD;\n\n }\n}\n\nconst int MAX = 2;\nlong long fac[MAX], finv[MAX], inv[MAX];\n\n// テーブルを作る前処理\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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// 二項係数計算\nlong long COM(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}\nusing Graph = vector >;\nint main(){\n mapjoken;\n joken[1]=2;\n joken[2]=5;\n joken[3]=5;\n joken[4]=4;\n joken[5]=5;\n joken[6]=6;\n joken[7]=3;\n joken[8]=7;\n joken[9]=6;\n int N,M;\n cin>>N>>M;\n mapriyo;\n for(int i=0;i>a;\n riyo[joken[a]]=to_string(a);\n }\n string dp[N+1];\n string shoki=\"-\";\n for(int i=0;ifirst>=0){\n if(dp[i]==\"-\"){\n if(dp[i-iter->first]==\"-\"){\n continue;\n }else{\n dp[i]=dp[i-iter->first]+iter->second;\n }\n \n }else{\n if(dp[i-iter->first]==\"-\"){\n continue;\n }else{\n if(dp[i].size()==(dp[i-iter->first]+iter->second).size()){\n dp[i]=max(dp[i],dp[i-iter->first]+iter->second);\n }else if(dp[i].size()<(dp[i-iter->first]+iter->second).size()){\n dp[i]=dp[i-iter->first]+iter->second;\n\n }\n }\n\n }\n }\n }\n }\n cout<\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#define ALL(a) (a).begin(),(a).end()\nconst long long MOD = 1000000007;\n\n//いろんなstlの使い方 https://qiita.com/tukejonny/items/f4013547df761a0b3523\n//http://y-mazun.hatenablog.com/entry/20111202/1322840281\n\n\n\nusing namespace std;\nstruct point{\n int x;\n int y;\n\n};\n//https://ei1333.github.io/luzhiled/snippets/structure/union-find.html\ntemplate< typename T >\nstruct WeightedUnionFind {\n vector< int > data;\n vector< T > ws;\n\n WeightedUnionFind() {}\n\n WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}\n\n int find(int k) {\n if(data[k] < 0) return k;\n auto par = find(data[k]);\n ws[k] += ws[data[k]];\n return data[k] = par;\n }\n\n T weight(int t) {\n find(t);\n return ws[t];\n }\n\n bool unite(int x, int y, T w) {\n w += weight(x);\n w -= weight(y);\n x = find(x), y = find(y);\n if(x == y) return false;\n if(data[x] > data[y]) {\n swap(x, y);\n w *= -1;\n }\n data[x] += data[y];\n data[y] = x;\n ws[y] = w;\n return true;\n }\n\n T diff(int x, int y) {\n return weight(y) - weight(x);\n }\n};\n\n\n\nlong long gcd(long long a, long long b)\n{\n if(a>b){\n return gcd(b,a);\n }\n return a == 0 ? b : gcd(b % a, a);\n}\nlong long lcm( long long m, long long n )\n{\n // 引数に0がある場合は0を返す\n if ( ( 0 == m ) || ( 0 == n ) )\n return 0;\n\n return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)\n}//lcm\nint input(){\n int x;\n cin>>x;\n return x;\n}\n\nint moji(char in)\n{\n int ans = (int)in-(int)'a';\n if((ans < 0) || (ans > 25)){\n ans = 26;\n }\n return ans;\n}\nconst int VV=1;//場合に応じてVVの値のみ変更する必要あり\n//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能\nint cost[VV][VV];\nint d[VV];\nbool used[VV];\nvoid dijkstra(int s){\n\n fill(d,d+VV,100000);\n fill(used,used+VV,false);\n d[s]=0;\n while(true){\n cout<<\"Hello\"<=1){\n int i=(l+r)/2;\n if(k[i]==x)return i;\n else if(k[i]0;i--){\n sum*=i;\n if(sum>l){\n sum%=l;\n }\n }\n return sum;\n}\n\n\ntemplatevoid chmin(T &a,T b){\n if(a>b){\n a=b;\n }\n}\n\n//formerは前方のindex(自分自身を含んで良い)\ntemplateint former(const vector&v,T x){\n return upper_bound(v.begin(),v.end(),x)-v.begin()-1;\n}\n//latterは後方のindex(自分自身を含んで良い)\ntemplateint latter(const vector&v,T x){\n return lower_bound(v.begin(),v.end(),x)-v.begin();\n}\n\nstruct UnionFind{\n //par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである\n vectorpar;\n //sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる\n vectorsizes;\n\n UnionFind(int n):par(n),sizes(n,1){\n //最初は全てのデータiがグループiに存在するものとして初期化\n for(int i=0;ies;//辺集合\n //クラスカル法で無向最小全域木のコストの和を計算する\n //グラフが非連結の時は最小全域森のコストの和になる\n //使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/\n int kruskal(){\n //コストが小さい順にソーと\n sort(es.begin(),es.end());\n UnionFind uf(n);\n int min_cost=0;\n for(int ei=0;ei>g.n>>m;\n for(int i=0;i>e.a>>e.b>>e.cost;\n g.es.push_back(e);\n }\n return g;\n}*/\nlong long labs(long long x){\n if(x<0){\n return -x;\n }\n return x;\n}\n// a^n mod を計算する\nlong long modpow(long long a, long long n, long long mod) {\n long long 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//indexを用いてvectorから要素削除\ntemplate\nvoid remove(std::vector& vector, unsigned int index)\n{\n vector.erase(vector.begin() + index);\n}\n\nvoid modadd(long long &a,long long b){\n a+=b;\n if(a>=MOD){\n a%=MOD;\n\n }\n}\n\nconst int MAX = 2;\nlong long fac[MAX], finv[MAX], inv[MAX];\n\n// テーブルを作る前処理\nvoid COMinit() {\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < MAX; 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// 二項係数計算\nlong long COM(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}\nusing Graph = vector >;\nint main(){\n mapjoken;\n joken[1]=2;\n joken[2]=5;\n joken[3]=5;\n joken[4]=4;\n joken[5]=5;\n joken[6]=6;\n joken[7]=3;\n joken[8]=7;\n joken[9]=6;\n int N,M;\n cin>>N>>M;\n mapriyo;\n for(int i=0;i>a;\n riyo[joken[a]]=to_string(a);\n }\n string dp[N+1];\n string shoki=\"-\";\n for(int i=0;ifirst>=0){\n if(dp[i]==\"-\"){\n if(dp[i-iter->first]==\"-\"){\n continue;\n }else{\n dp[i]=dp[i-iter->first]+iter->second;\n }\n \n }else{\n if(dp[i-iter->first]==\"-\"){\n continue;\n }else{\n if(dp[i].size()==(dp[i-iter->first]+iter->second).size()){\n dp[i]=max(dp[i],dp[i-iter->first]+iter->second);\n }else if(dp[i].size()<(dp[i-iter->first]+iter->second).size()){\n dp[i]=dp[i-iter->first]+iter->second;\n\n }\n }\n\n }\n }\n }\n }\n cout<\n#include \nusing namespace std;\nint n,k;\nint abs(int x)\n{\n\treturn x>0?x:-x;\n} \nint main ()\n{\n\tscanf(\"%d%d\",&n,&k);\n\tif(abs(n)>=(k*2-1)) printf(\"YES\");\n\telse printf(\"NO\");\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1549764432, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03129.html", "problem_id": "p03129", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03129/input.txt", "sample_output_relpath": "derived/input_output/data/p03129/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03129/C++/s200140967.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200140967", "user_id": "u041194459"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\nint n,k;\nint abs(int x)\n{\n\treturn x>0?x:-x;\n} \nint main ()\n{\n\tscanf(\"%d%d\",&n,&k);\n\tif(abs(n)>=(k*2-1)) printf(\"YES\");\n\telse printf(\"NO\");\n\treturn 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "sample_input": "3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03129", "source_text": "Score : 100 points\n\nProblem Statement\n\nDetermine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n1\\leq N,K\\leq 100\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf we can choose K integers as above, print YES; otherwise, print NO.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\nYES\n\nWe can choose 1 and 3.\n\nSample Input 2\n\n5 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n31 10\n\nSample Output 3\n\nYES\n\nSample Input 4\n\n10 90\n\nSample Output 4\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 211, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s911506588", "group_id": "codeNet:p03130", "input_text": "#include\n#define loop(i,a,b) for(int i=a;i>a>>b;\n\t\tvertex[a-1]++;\n\t\tvertex[b-1]++;\n\t}\n\tint even,odd;\n\teven=odd=0;\n\tbool check=true;\n\trep(i,4){\n\t\tif(vertex[i]%2)odd++;\n\t\telse even++;\n\t}\n\tif(even==2&&odd==2)cout<<\"YES\"<\n#define loop(i,a,b) for(int i=a;i>a>>b;\n\t\tvertex[a-1]++;\n\t\tvertex[b-1]++;\n\t}\n\tint even,odd;\n\teven=odd=0;\n\tbool check=true;\n\trep(i,4){\n\t\tif(vertex[i]%2)odd++;\n\t\telse even++;\n\t}\n\tif(even==2&&odd==2)cout<<\"YES\"<\nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ll N, M;\n cin >> N >> M;\n vector X(M);\n for (int i = 0; i < M; i++) {\n cin >> X[i];\n }\n\n if (N >= M) cout << 0 << endl;\n else {\n sort(X.begin(), X.end());\n\n vector dist(M-1);\n for (int i = 0; i < M-1; i++) {\n dist[i] = X[i+1]-X[i];\n }\n\n sort(dist.begin(), dist.end());\n\n ll sum = 0;\n for (int i = 0; i < M-N; i++) {\n sum += dist[i];\n }\n\n cout << sum << endl;\n }\n \n return 0;\n}", "language": "C++", "metadata": {"date": 1583271685, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/C++/s230415971.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230415971", "user_id": "u241312295"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\ntypedef long long ll;\n\nint main() {\n ll N, M;\n cin >> N >> M;\n vector X(M);\n for (int i = 0; i < M; i++) {\n cin >> X[i];\n }\n\n if (N >= M) cout << 0 << endl;\n else {\n sort(X.begin(), X.end());\n\n vector dist(M-1);\n for (int i = 0; i < M-1; i++) {\n dist[i] = X[i+1]-X[i];\n }\n\n sort(dist.begin(), dist.end());\n\n ll sum = 0;\n for (int i = 0; i < M-N; i++) {\n sum += dist[i];\n }\n\n cout << sum << endl;\n }\n \n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 589, "cpu_time_ms": 40, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s569663146", "group_id": "codeNet:p03137", "input_text": "#include \n#include \ntypedef long long ll;\n#define rep(i,a,b) for(int i=a;i=b;--i)\nusing namespace std;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int N, M; cin >> N >> M;\n if (N >= M) {\n cout << 0 << \"\\n\";\n return 0;\n }\n\n vector X(M);\n rep(i, 0, M) cin >> X[i];\n sort(X.begin(), X.end());\n\n vector intervals(M-1);\n rep(i, 0, M-1) intervals[i] = X[i+1] - X[i];\n sort(intervals.begin(), intervals.end(), greater());\n\n int res = X.back() - X.front();\n rep(i, 0, N-1) res -= intervals[i];\n\n cout << res << \"\\n\";\n}", "language": "C++", "metadata": {"date": 1557902848, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/C++/s569663146.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s569663146", "user_id": "u980078875"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \n#include \ntypedef long long ll;\n#define rep(i,a,b) for(int i=a;i=b;--i)\nusing namespace std;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int N, M; cin >> N >> M;\n if (N >= M) {\n cout << 0 << \"\\n\";\n return 0;\n }\n\n vector X(M);\n rep(i, 0, M) cin >> X[i];\n sort(X.begin(), X.end());\n\n vector intervals(M-1);\n rep(i, 0, M-1) intervals[i] = X[i+1] - X[i];\n sort(intervals.begin(), intervals.end(), greater());\n\n int res = X.back() - X.front();\n rep(i, 0, N-1) res -= intervals[i];\n\n cout << res << \"\\n\";\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 662, "cpu_time_ms": 18, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s874905238", "group_id": "codeNet:p03142", "input_text": "#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\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef vector vpli;\n\ninline ll read(){\n ll Hashimoto=0;\n\tbool Kanna=1;\n char I_Love=getchar();\n while(I_Love<'0'||I_Love>'9'){\n if(I_Love=='-')Kanna=0;\n I_Love=getchar();\n }\n while(I_Love>='0'&&I_Love<='9'){\n Hashimoto=Hashimoto*10+I_Love-'0';\n I_Love=getchar();\n }\n return (Kanna?Hashimoto:-Hashimoto);\n}\ntemplate inline void Umax(T1 &a,T2 b){\n\tif(a inline void Umin(T1 &a,T2 b){\n\tif(a>b)a=b;\n}\n\n#define I_Love_Hashimoto_Kanna main\n#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define filein(s) freopen(s,\"r\",stdin);\n#define fileout(s) freopen(s,\"w\",stdout);\n#define file freopen(\"I_Love_Hashimoto_Kanna.out\",\"w\",stdout);\n#define RE cout<<\"I_Love_Hashimoto_Kanna\"<q;\nbool v[111111];\nint ans[111111];\n\nint I_Love_Hashimoto_Kanna() {\n\t//完全想清楚了再开始写。\n\t//写不顺、不知道怎么写、很乱的时候,停下来好好想想。\n\t//做得慢总比做不出好。\n\tfastio;\n\tn=read();m=read();\n\tFOR(i,1,n+m){\n\t\tint a=read()-1,b=read()-1;\n\t\tg[a].push_back(b);\n\t\tindegree[b]++;\n\t}\n\tint root=-1;\n\tFOR(i,0,n){\n\t\tif(indegree[i]==0)root=i;\n\t}\n\tassert(root!=-1);\n\tans[root]=-1;\n\tv[root]=1;\n\tq.push(root);\n\twhile(!q.empty()){\n\t\tint x=q.front();\n\t\tq.pop();\n\t\tFOR(i,0,g[x].size()){\n\t\t\tint to=g[x][i];\n\t\t\tans[to]=x;\n\t\t\tif(v[to])continue;\n\t\t\tq.push(to);\n\t\t\tv[to]=1;\n\t\t}\n\t}\n\tFOR(i,0,n){\n\t\tprintf(\"%d\\n\",ans[i]+1);\n\t}\n\t\n\t\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1548642625, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03142/input.txt", "sample_output_relpath": "derived/input_output/data/p03142/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03142/C++/s874905238.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s874905238", "user_id": "u754862537"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "#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\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef vector vpli;\n\ninline ll read(){\n ll Hashimoto=0;\n\tbool Kanna=1;\n char I_Love=getchar();\n while(I_Love<'0'||I_Love>'9'){\n if(I_Love=='-')Kanna=0;\n I_Love=getchar();\n }\n while(I_Love>='0'&&I_Love<='9'){\n Hashimoto=Hashimoto*10+I_Love-'0';\n I_Love=getchar();\n }\n return (Kanna?Hashimoto:-Hashimoto);\n}\ntemplate inline void Umax(T1 &a,T2 b){\n\tif(a inline void Umin(T1 &a,T2 b){\n\tif(a>b)a=b;\n}\n\n#define I_Love_Hashimoto_Kanna main\n#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define filein(s) freopen(s,\"r\",stdin);\n#define fileout(s) freopen(s,\"w\",stdout);\n#define file freopen(\"I_Love_Hashimoto_Kanna.out\",\"w\",stdout);\n#define RE cout<<\"I_Love_Hashimoto_Kanna\"<q;\nbool v[111111];\nint ans[111111];\n\nint I_Love_Hashimoto_Kanna() {\n\t//完全想清楚了再开始写。\n\t//写不顺、不知道怎么写、很乱的时候,停下来好好想想。\n\t//做得慢总比做不出好。\n\tfastio;\n\tn=read();m=read();\n\tFOR(i,1,n+m){\n\t\tint a=read()-1,b=read()-1;\n\t\tg[a].push_back(b);\n\t\tindegree[b]++;\n\t}\n\tint root=-1;\n\tFOR(i,0,n){\n\t\tif(indegree[i]==0)root=i;\n\t}\n\tassert(root!=-1);\n\tans[root]=-1;\n\tv[root]=1;\n\tq.push(root);\n\twhile(!q.empty()){\n\t\tint x=q.front();\n\t\tq.pop();\n\t\tFOR(i,0,g[x].size()){\n\t\t\tint to=g[x][i];\n\t\t\tans[to]=x;\n\t\t\tif(v[to])continue;\n\t\t\tq.push(to);\n\t\t\tv[to]=1;\n\t\t}\n\t}\n\tFOR(i,0,n){\n\t\tprintf(\"%d\\n\",ans[i]+1);\n\t}\n\t\n\t\n\treturn 0;\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "sample_input": "3 1\n1 2\n1 3\n2 3\n"}, "reference_outputs": ["0\n1\n2\n"], "source_document_id": "p03142", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2656, "cpu_time_ms": 33, "memory_kb": 7424}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s504400346", "group_id": "codeNet:p03143", "input_text": "///////////////////////// _LeMur_\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 N = 100005;\nconst int inf = 1000 * 1000 * 1000;\nconst int mod = 1000 * 1000 * 1000 + 7;\n\nint n , m;\nint cnt[N];\n\nint a[N] , b[N] , c[N];\n\npair p[N];\nvector g[N];\nbool used[N];\n\nint parent[N] , sz[N] , edge[N];\nlong long sum[N];\n\nbool mark[N];\n\nint findher(int a){\n if(a == parent[a])return a;\n return parent[a] = findher(parent[a]);\n}\n\nvoid tmerge(int a,int b){\n a = findher(a);\n b = findher(b);\n if(sz[a] < sz[b])\n swap(a , b);\n parent[b] = a;\n sum[a] += sum[b];\n sz[a] += sz[b];\n edge[a] += edge[b];\n for(int j=0;j<(int)g[b].size();j++){\n g[a].push_back(g[b][j]);\n }\n g[b].clear();\n}\n\nint main(){\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++){\n scanf(\"%d\",&cnt[i]);\n ///\n parent[i] = i;\n sum[i] = cnt[i];\n sz[i] = 1;\n }\n for(int i=1;i<=m;i++){\n scanf(\"%d%d%d\",&a[i],&b[i],&c[i]);\n p[i] = make_pair(c[i] , i);\n }\n sort(p + 1 , p + m + 1);\n int ind = -1;\n for(int i=1;i<=m;i++){\n int x = p[i].first;\n int id = p[i].second;\n int aa = a[id] , bb = b[id];\n if(findher(aa) != findher(bb)){\n tmerge(aa , bb);\n }\n int P = findher(aa);\n ++edge[P];\n if(sum[P] >= 1ll * x){\n mark[i] = true;\n ind = i;\n }\n }\n if(ind == -1){\n cout<=1;i--){\n int v = a[ p[i].second ];\n if(mark[i] && used[v] == false){\n v = findher(v);\n answ += edge[v];\n for(int j=0;j<(int)g[v].size();j++){\n int to = g[v][j];\n used[to] = true;\n }\n }\n }\n cout<\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 N = 100005;\nconst int inf = 1000 * 1000 * 1000;\nconst int mod = 1000 * 1000 * 1000 + 7;\n\nint n , m;\nint cnt[N];\n\nint a[N] , b[N] , c[N];\n\npair p[N];\nvector g[N];\nbool used[N];\n\nint parent[N] , sz[N] , edge[N];\nlong long sum[N];\n\nbool mark[N];\n\nint findher(int a){\n if(a == parent[a])return a;\n return parent[a] = findher(parent[a]);\n}\n\nvoid tmerge(int a,int b){\n a = findher(a);\n b = findher(b);\n if(sz[a] < sz[b])\n swap(a , b);\n parent[b] = a;\n sum[a] += sum[b];\n sz[a] += sz[b];\n edge[a] += edge[b];\n for(int j=0;j<(int)g[b].size();j++){\n g[a].push_back(g[b][j]);\n }\n g[b].clear();\n}\n\nint main(){\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++){\n scanf(\"%d\",&cnt[i]);\n ///\n parent[i] = i;\n sum[i] = cnt[i];\n sz[i] = 1;\n }\n for(int i=1;i<=m;i++){\n scanf(\"%d%d%d\",&a[i],&b[i],&c[i]);\n p[i] = make_pair(c[i] , i);\n }\n sort(p + 1 , p + m + 1);\n int ind = -1;\n for(int i=1;i<=m;i++){\n int x = p[i].first;\n int id = p[i].second;\n int aa = a[id] , bb = b[id];\n if(findher(aa) != findher(bb)){\n tmerge(aa , bb);\n }\n int P = findher(aa);\n ++edge[P];\n if(sum[P] >= 1ll * x){\n mark[i] = true;\n ind = i;\n }\n }\n if(ind == -1){\n cout<=1;i--){\n int v = a[ p[i].second ];\n if(mark[i] && used[v] == false){\n v = findher(v);\n answ += edge[v];\n for(int j=0;j<(int)g[v].size();j++){\n int to = g[v][j];\n used[to] = true;\n }\n }\n }\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\nint main(void){\n\tint c,a,b; cin>>c>>a>>b;\n\tcout<<(a*c)/2<\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\nint main(void){\n\tint c,a,b; cin>>c>>a>>b;\n\tcout<<(a*c)/2<\nusing namespace std;\n\n// typedef\n// -----------------------------------------------------------------------------\ntypedef long long ll;\ntypedef long double ld;\n\n// container util\n// -----------------------------------------------------------------------------\n#define ALL(c) (c).begin(),(c).end()\n#define SZ(c) ((ll)(c).size())\n#define MAX(c) *max_element(ALL(c))\n#define MIN(c) *min_element(ALL(c))\n#define SORT(c) sort((c).begin(),(c).end())\n\n// repetition\n// -----------------------------------------------------------------------------\n#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n\n// constant\n// -----------------------------------------------------------------------------\nconst ll INF = 1e9;\nconst ll MOD = 1e9 + 7;\nconst double EPS = 1e-9;\nconst double PI = acos(-1.0);\n\n// debug\n// -----------------------------------------------------------------------------\n#define DUMP(x) cerr << #x << \" = \" << (x) << endl\n\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed << setprecision(15);\n int s; cin >> s;\n bool A[1000000];\n int ans = 1;\n while(!A[s]) {\n ans++;\n A[s] = true;\n if(s % 2 == 0) {\n s /= 2;\n } else {\n s = 3 * s + 1;\n }\n }\n cout << ans << \"\\n\";\n}", "language": "C++", "metadata": {"date": 1595125705, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/C++/s616510794.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616510794", "user_id": "u811321379"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "#include \nusing namespace std;\n\n// typedef\n// -----------------------------------------------------------------------------\ntypedef long long ll;\ntypedef long double ld;\n\n// container util\n// -----------------------------------------------------------------------------\n#define ALL(c) (c).begin(),(c).end()\n#define SZ(c) ((ll)(c).size())\n#define MAX(c) *max_element(ALL(c))\n#define MIN(c) *min_element(ALL(c))\n#define SORT(c) sort((c).begin(),(c).end())\n\n// repetition\n// -----------------------------------------------------------------------------\n#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n\n// constant\n// -----------------------------------------------------------------------------\nconst ll INF = 1e9;\nconst ll MOD = 1e9 + 7;\nconst double EPS = 1e-9;\nconst double PI = acos(-1.0);\n\n// debug\n// -----------------------------------------------------------------------------\n#define DUMP(x) cerr << #x << \" = \" << (x) << endl\n\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed << setprecision(15);\n int s; cin >> s;\n bool A[1000000];\n int ans = 1;\n while(!A[s]) {\n ans++;\n A[s] = true;\n if(s % 2 == 0) {\n s /= 2;\n } else {\n s = 3 * s + 1;\n }\n }\n cout << ans << \"\\n\";\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1341, "cpu_time_ms": 3, "memory_kb": 3652}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s675756301", "group_id": "codeNet:p03146", "input_text": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing ll = long long int;\nusing ul = unsigned long long int;\nconst ll LL_MAX (1LL<<60);\nconst ll MOD (1000000007);\n\n#define rep(i,s,e) for(ll i=(s); i<(e); i++) \n\nusing namespace std;\n\nll f(ll n)\n{\n if (n%2==0) n/=2;\n else n=3*n+1;\n\n return n;\n}\n\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n ll s;\n cin >> s;\n unordered_set ss;\n\n ll cnt(0);\n while (true)\n {\n s = f(s);\n\n cnt++;\n\n if (ss.find(s)==ss.end())\n ss.insert(s);\n else\n break;\n }\n\n cout << cnt+1 << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1580873380, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03146/input.txt", "sample_output_relpath": "derived/input_output/data/p03146/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03146/C++/s675756301.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s675756301", "user_id": "u778668639"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing ll = long long int;\nusing ul = unsigned long long int;\nconst ll LL_MAX (1LL<<60);\nconst ll MOD (1000000007);\n\n#define rep(i,s,e) for(ll i=(s); i<(e); i++) \n\nusing namespace std;\n\nll f(ll n)\n{\n if (n%2==0) n/=2;\n else n=3*n+1;\n\n return n;\n}\n\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n ll s;\n cin >> s;\n unordered_set ss;\n\n ll cnt(0);\n while (true)\n {\n s = f(s);\n\n cnt++;\n\n if (ss.find(s)==ss.end())\n ss.insert(s);\n else\n break;\n }\n\n cout << cnt+1 << endl;\n\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "sample_input": "8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03146", "source_text": "Score : 200 points\n\nProblem Statement\n\nA sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n\nThe first term s is given as input.\n\nLet f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n\na_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\n\nFind the minimum integer m that satisfies the following condition:\n\nThere exists an integer n such that a_m = a_n (m > n).\n\nConstraints\n\n1 \\leq s \\leq 100\n\nAll values in input are integers.\n\nIt is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum integer m that satisfies the condition.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n5\n\na=\\{8,4,2,1,4,2,1,4,2,1,......\\}. As a_5=a_2, the answer is 5.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n18\n\na=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}.\n\nSample Input 3\n\n54\n\nSample Output 3\n\n114", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 798, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s471594817", "group_id": "codeNet:p03147", "input_text": "#include \n#include \n#include \n#include \n#include \n\nint main()\n{\n int N;\n std::cin >> N;\n std::vector H(N), X(N);\n for (int i = 0; i < N; i++)\n {\n X[i] = 0;\n std::cin >> H[i];\n }\n\n int cnt = 0;\n while (true)\n {\n bool e = false;\n bool s = false;\n int a = 0;\n for (int i = 0; i < N; i++)\n {\n int x = X[i];\n if (x < H[i])\n {\n s = true;\n }\n else if (x == H[i])\n {\n a++;\n if (s) cnt++;\n s = false;\n }\n if (s)\n {\n X[i]++;\n }\n }\n if (s)cnt++;\n if (a == N)break;\n }\n\n std::cout << cnt << std::endl;\n\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1556558445, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/C++/s471594817.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471594817", "user_id": "u303039933"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n\nint main()\n{\n int N;\n std::cin >> N;\n std::vector H(N), X(N);\n for (int i = 0; i < N; i++)\n {\n X[i] = 0;\n std::cin >> H[i];\n }\n\n int cnt = 0;\n while (true)\n {\n bool e = false;\n bool s = false;\n int a = 0;\n for (int i = 0; i < N; i++)\n {\n int x = X[i];\n if (x < H[i])\n {\n s = true;\n }\n else if (x == H[i])\n {\n a++;\n if (s) cnt++;\n s = false;\n }\n if (s)\n {\n X[i]++;\n }\n }\n if (s)cnt++;\n if (a == N)break;\n }\n\n std::cout << cnt << std::endl;\n\n\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s434848401", "group_id": "codeNet:p03147", "input_text": "#include\nusing namespace std;\nint main() {\n int n; cin >> n;\n int h[100] = {0};\n int Min = 100;\n for (int i = 0; i < n; ++i) {\n cin >> h[i];\n if (Min > h[i]) {\n Min = h[i];\n }\n }\n for (int i = 0; i < n; ++i) {\n h[i] -= Min;\n }\n int Delete = 0;\n int Sum = Min;\n for (int i = 0; i < n; ++i) {\n if (Delete < h[i]) {\n Delete = h[i];\n }\n if (h[i] != 0 && h[i + 1] == 0) {\n Sum += Delete;\n Delete = 0;\n }\n }\n cout << Sum << endl;\n return 0;\n}\n\n\n", "language": "C++", "metadata": {"date": 1548016527, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03147/input.txt", "sample_output_relpath": "derived/input_output/data/p03147/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03147/C++/s434848401.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s434848401", "user_id": "u277556971"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\nusing namespace std;\nint main() {\n int n; cin >> n;\n int h[100] = {0};\n int Min = 100;\n for (int i = 0; i < n; ++i) {\n cin >> h[i];\n if (Min > h[i]) {\n Min = h[i];\n }\n }\n for (int i = 0; i < n; ++i) {\n h[i] -= Min;\n }\n int Delete = 0;\n int Sum = Min;\n for (int i = 0; i < n; ++i) {\n if (Delete < h[i]) {\n Delete = h[i];\n }\n if (h[i] != 0 && h[i + 1] == 0) {\n Sum += Delete;\n Delete = 0;\n }\n }\n cout << Sum << endl;\n return 0;\n}\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 588, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s733903541", "group_id": "codeNet:p03155", "input_text": "#include \n#include\nusing namespace std;\ntypedef long long ll;\nvector f;\nvector c;\nvector c1;\nvector c2;\nint main()\n{\n int n;\n cin>>n;\n int a,b;\n cin>>a>>b;\n for(int i=0;i>x;\n f.push_back(x);\n }\n\n for(int i=0;i=a+1 && f[i]<=b)\n {\n\n c1.push_back(f[i]);\n }\n if(f[i]>=b+1)\n {\n\n c2.push_back(f[i]);\n }\n }\n cout<\n#include\nusing namespace std;\ntypedef long long ll;\nvector f;\nvector c;\nvector c1;\nvector c2;\nint main()\n{\n int n;\n cin>>n;\n int a,b;\n cin>>a>>b;\n for(int i=0;i>x;\n f.push_back(x);\n }\n\n for(int i=0;i=a+1 && f[i]<=b)\n {\n\n c1.push_back(f[i]);\n }\n if(f[i]>=b+1)\n {\n\n c2.push_back(f[i]);\n }\n }\n cout<\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n/*\ntime:\nwa:\n反省:\n考察:\n*/\nint main() {\n int N;\n cin >> N;\n int a, b;\n cin >> a >> b;\n int p[110];\n int ans;\n int q1 = 0;\n int q2 = 0;\n int q3 = 0;\n for(int i = 0; i < N; i++) {\n cin >> p[i];\n }\n for(int i = 0; i < N; i++){\n if(p[i] <= a) q1++;\n else if(a+1 <= p[i] && p[i] <= b) q2++;\n else q3++;\n }\n ans = min(min(q1, q2),q3);\n cout << ans << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1600349273, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03156.html", "problem_id": "p03156", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03156/input.txt", "sample_output_relpath": "derived/input_output/data/p03156/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03156/C++/s946577909.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946577909", "user_id": "u706342712"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n/*\ntime:\nwa:\n反省:\n考察:\n*/\nint main() {\n int N;\n cin >> N;\n int a, b;\n cin >> a >> b;\n int p[110];\n int ans;\n int q1 = 0;\n int q2 = 0;\n int q3 = 0;\n for(int i = 0; i < N; i++) {\n cin >> p[i];\n }\n for(int i = 0; i < N; i++){\n if(p[i] <= a) q1++;\n else if(a+1 <= p[i] && p[i] <= b) q2++;\n else q3++;\n }\n ans = min(min(q1, q2),q3);\n cout << ans << endl;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "sample_input": "7\n5 15\n1 10 16 2 7 20 12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03156", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 568, "cpu_time_ms": 9, "memory_kb": 3596}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s919204546", "group_id": "codeNet:p03162", "input_text": "#include\nusing namespace std;\n#define gc getchar_unlocked\n#define pb push_back\n#define fo(i,n) for(int i=0;in;k>x; while(x--)\n//=======================\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vvi;\n//=======================\nconst int MOD = 1000000007;\nconst int N = 300005, M = N;\n//=======================\nvi g[N],adj[N];\nint n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;\n\n\nvoid abhinay()\n{\n \n #ifndef ONLINE_JUDGE \n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout); \n #endif \n \n}\n\nint main(){\n abhinay();\n cin>>n>>k;\n int dp[100005][3];\n vi A(n+1),B(n+1),C(n+1); \n fo(i,n) cin>>A[i]>>B[i]>>C[i];\n dp[0][0]=A[0],dp[0][1]=B[0],dp[0][2]=C[0];\n for (int i = 1; i < n; i++)\n for (int j =0;j<3;j++)\n for(int k=0;k<3;k++)\n if (j==k) continue;\n else{\n if (j==0) dp[i][j]= max(dp[i][j],dp[i-1][k]+A[i]);\n if (j==1) dp[i][j]= max(dp[i][j],dp[i-1][k]+B[i]);\n if (j==2) dp[i][j]= max(dp[i][j],dp[i-1][k]+C[i]);\n }\n int ret = 0;\n ret = max(ret,dp[n-1][0]);\n ret = max(ret,dp[n-1][1]);\n ret = max(ret,dp[n-1][2]);\n\n cout << ret;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1598565921, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/C++/s919204546.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s919204546", "user_id": "u876474655"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "#include\nusing namespace std;\n#define gc getchar_unlocked\n#define pb push_back\n#define fo(i,n) for(int i=0;in;k>x; while(x--)\n//=======================\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vvi;\n//=======================\nconst int MOD = 1000000007;\nconst int N = 300005, M = N;\n//=======================\nvi g[N],adj[N];\nint n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;\n\n\nvoid abhinay()\n{\n \n #ifndef ONLINE_JUDGE \n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout); \n #endif \n \n}\n\nint main(){\n abhinay();\n cin>>n>>k;\n int dp[100005][3];\n vi A(n+1),B(n+1),C(n+1); \n fo(i,n) cin>>A[i]>>B[i]>>C[i];\n dp[0][0]=A[0],dp[0][1]=B[0],dp[0][2]=C[0];\n for (int i = 1; i < n; i++)\n for (int j =0;j<3;j++)\n for(int k=0;k<3;k++)\n if (j==k) continue;\n else{\n if (j==0) dp[i][j]= max(dp[i][j],dp[i-1][k]+A[i]);\n if (j==1) dp[i][j]= max(dp[i][j],dp[i-1][k]+B[i]);\n if (j==2) dp[i][j]= max(dp[i][j],dp[i-1][k]+C[i]);\n }\n int ret = 0;\n ret = max(ret,dp[n-1][0]);\n ret = max(ret,dp[n-1][1]);\n ret = max(ret,dp[n-1][2]);\n\n cout << ret;\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2001, "cpu_time_ms": 81, "memory_kb": 19676}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s256274452", "group_id": "codeNet:p03162", "input_text": "#include\nusing namespace std;\n\nvoid input(vector > &arr,int n,int m)\n{\n\tfor(int i=0;i temp;\n\t\tfor(int j=0;j>x;\n\t\t\ttemp.push_back(x);\n\t\t}\n\t\tarr.push_back(temp);\n\t\ttemp.clear();\n\t}\n}\nint main()\n{\n\tint n;\n\tcin>>n;\n\tvector >arr;\n\tinput(arr,n,3);\n\tvectordp(n,0);\n\tint k=0;\n\tif(arr[0][0]>=arr[0][1] && arr[0][0]>=arr[0][2])\n\t dp[0]=arr[0][0];\n\telse if(arr[0][1]>=arr[0][0] && arr[0][1]>=arr[0][2]){\n\t\tdp[0]=arr[0][1];\n\t\tk=1;\n\t}\n\telse{\n\t dp[0]=arr[0][2];\n\t k=2;\n}\n\tfor(int i=1;i\nusing namespace std;\n\nvoid input(vector > &arr,int n,int m)\n{\n\tfor(int i=0;i temp;\n\t\tfor(int j=0;j>x;\n\t\t\ttemp.push_back(x);\n\t\t}\n\t\tarr.push_back(temp);\n\t\ttemp.clear();\n\t}\n}\nint main()\n{\n\tint n;\n\tcin>>n;\n\tvector >arr;\n\tinput(arr,n,3);\n\tvectordp(n,0);\n\tint k=0;\n\tif(arr[0][0]>=arr[0][1] && arr[0][0]>=arr[0][2])\n\t dp[0]=arr[0][0];\n\telse if(arr[0][1]>=arr[0][0] && arr[0][1]>=arr[0][2]){\n\t\tdp[0]=arr[0][1];\n\t\tk=1;\n\t}\n\telse{\n\t dp[0]=arr[0][2];\n\t k=2;\n}\n\tfor(int i=1;i\n#include \n#include \n\n#define ll long long\n#define pb push_back\n#define ppb pop_back\n#define endl '\\n'\n#define mii map\n#define pii pair\n#define vi vector\n#define vs vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll)x.size()\n#define hell 1000000007\n#define inf (ll)1e18 + 5\n#define PI 3.14159265358979323844\n#define rep(i,a,b) for (ll i=a;i=b;i--)\n#define lbnd lower_bound\n#define ubnd upper_bound\n#define mp make_pair\n#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\n#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\n\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n std::cerr << name << \" : \" << arg1 << endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << \" : \" << arg1<<\" | \";__f(comma+1, args...);\n}\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\n/*----------------------Graph Moves----------------*/\n//const int fx[]={+1,-1,+0,+0};\n//const int fy[]={+0,+0,+1,-1};\n//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move\n//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move\n//const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move\n//const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move\n/*------------------------------------------------*/\n\n//primes for hashing 937,991,1013,1409,1741\n\nll n;\nvi a,b,c;\nll dp[100005][3];\n\nll find(ll n,ll i){\n\tif (n<=0)return 0;\n\tif (dp[n][i]!=-1)return dp[n][i];\n\tif (i==0){\n\t\tdp[n][i]=a[n-1];\n\t\tll meow=max(find(n-1,1),find(n-1,2));\n\t\tdp[n][i]+=max(meow,find(n-2,0));\n\t}\n\telse if (i==1){\n\t\tdp[n][i]=b[n-1];\n\t\tll meow=max(find(n-1,0),find(n-1,2));\n\t\tdp[n][i]+=max(meow,find(n-2,1));\n\t}\n\telse {\n\t\tdp[n][i]=c[n-1];\n\t\tll meow=max(find(n-1,1),find(n-1,0));\n\t\tdp[n][i]+=max(meow,find(n-2,2));\n\t}\n\treturn dp[n][i];\n}\n\nvoid solve() {\n cin>>n;\n memset(dp,-1,sizeof dp);\n rep(i,0,n){\n \tll x,y,z;\n \tcin>>x>>y>>z;\n \ta.pb(x),b.pb(y),c.pb(z);\n }\n find(n,0);\n find(n,1);\n find(n,2);\n cout<>test;\n while (test--) solve();\n return 0;\n}", "language": "C++", "metadata": {"date": 1585452456, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/C++/s144866565.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144866565", "user_id": "u314355819"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "#include \n#include \n#include \n\n#define ll long long\n#define pb push_back\n#define ppb pop_back\n#define endl '\\n'\n#define mii map\n#define pii pair\n#define vi vector\n#define vs vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll)x.size()\n#define hell 1000000007\n#define inf (ll)1e18 + 5\n#define PI 3.14159265358979323844\n#define rep(i,a,b) for (ll i=a;i=b;i--)\n#define lbnd lower_bound\n#define ubnd upper_bound\n#define mp make_pair\n#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\n#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\n\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n std::cerr << name << \" : \" << arg1 << endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << \" : \" << arg1<<\" | \";__f(comma+1, args...);\n}\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\n/*----------------------Graph Moves----------------*/\n//const int fx[]={+1,-1,+0,+0};\n//const int fy[]={+0,+0,+1,-1};\n//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move\n//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move\n//const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move\n//const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move\n/*------------------------------------------------*/\n\n//primes for hashing 937,991,1013,1409,1741\n\nll n;\nvi a,b,c;\nll dp[100005][3];\n\nll find(ll n,ll i){\n\tif (n<=0)return 0;\n\tif (dp[n][i]!=-1)return dp[n][i];\n\tif (i==0){\n\t\tdp[n][i]=a[n-1];\n\t\tll meow=max(find(n-1,1),find(n-1,2));\n\t\tdp[n][i]+=max(meow,find(n-2,0));\n\t}\n\telse if (i==1){\n\t\tdp[n][i]=b[n-1];\n\t\tll meow=max(find(n-1,0),find(n-1,2));\n\t\tdp[n][i]+=max(meow,find(n-2,1));\n\t}\n\telse {\n\t\tdp[n][i]=c[n-1];\n\t\tll meow=max(find(n-1,1),find(n-1,0));\n\t\tdp[n][i]+=max(meow,find(n-2,2));\n\t}\n\treturn dp[n][i];\n}\n\nvoid solve() {\n cin>>n;\n memset(dp,-1,sizeof dp);\n rep(i,0,n){\n \tll x,y,z;\n \tcin>>x>>y>>z;\n \ta.pb(x),b.pb(y),c.pb(z);\n }\n find(n,0);\n find(n,1);\n find(n,2);\n cout<>test;\n while (test--) solve();\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2755, "cpu_time_ms": 32, "memory_kb": 9952}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s230861190", "group_id": "codeNet:p03162", "input_text": "//template by I_Love_Totoro, inspired by chamow\n//Doing VC Everyday #SpecialistByMarch\n//refer cook_book and AC of/Ubuntu folder _FunWithCP_ dated:16/03/2020- for POC and more insights respectively\n//interactive comments ahead! : for the love of CP <3\n//note to self:for the love of everything good, uncomment fastread whenever applicable :) \n\n/* footnotes/ obs\n*\n*/\n\n/*main idea:\n*\n*/\n\n/*similar to:\n*\n*/\n\n/*re-learnt/ got better clarity\n*\n*/\n\n/*corollary\n*\n*/\n\n#include \n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\n#define rep(i,a,n) for(i=a;i=a;i--)\n#define all(x) (x).begin(),(x).end()\n#define PI (atan(1)*4)\n#define INF (int)1e9\n\n#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n//typedef vec vector\ntypedef long long ll;\ntypedef long double ld;\ntypedef long int li;\n\nusing namespace std;\n\nll lcm(ll val1,ll val2)\n{\n\tif(val1==0||val2==0)\n\t\treturn 0;\n\telse\n\t\treturn (val1*val2)/__gcd(val1,val2);\n}\n\nll pw(ll base,ll p)\n{\n\tif(base==1||p==0)\t\t\t\t\n\t\treturn 1;\n\tif(p%2==0){\n\t\tll interm=pw(base,p/2);\n\t\treturn interm*interm;\n\n\t}\n\telse\n\t\treturn base*pw(base,p-1);\n\n}\n\nint main()\n{\n\n\t//fastread;\n\t/*\n\tfreopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n */\n\t\n\tll n, a, b, c, ansa = 0, ansb = 0, ansc = 0;\n\tcin>>n;\n\n\tvector>dp(n,vector(3,0));\n\n\tfor (ll i = 0; i < n; i ++) {\n\t\tcin>>a>>b>>c;\n\n\t\tif (i == 0)\n\t\t\tansa += a,ansb += b,ansc += c;//dp[i][0] = a, dp[i][1] = b, dp[i][2] = c;\n\t\telse {\n\t\t\t/*dp[i][0]*/ansa += max(b,c);\n\t\t\tansb += max(a,c);\n\t\t\tansc += max(a,b);\n\t\t}\n\t}\n\tcout<\n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\n#define rep(i,a,n) for(i=a;i=a;i--)\n#define all(x) (x).begin(),(x).end()\n#define PI (atan(1)*4)\n#define INF (int)1e9\n\n#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n//typedef vec vector\ntypedef long long ll;\ntypedef long double ld;\ntypedef long int li;\n\nusing namespace std;\n\nll lcm(ll val1,ll val2)\n{\n\tif(val1==0||val2==0)\n\t\treturn 0;\n\telse\n\t\treturn (val1*val2)/__gcd(val1,val2);\n}\n\nll pw(ll base,ll p)\n{\n\tif(base==1||p==0)\t\t\t\t\n\t\treturn 1;\n\tif(p%2==0){\n\t\tll interm=pw(base,p/2);\n\t\treturn interm*interm;\n\n\t}\n\telse\n\t\treturn base*pw(base,p-1);\n\n}\n\nint main()\n{\n\n\t//fastread;\n\t/*\n\tfreopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n */\n\t\n\tll n, a, b, c, ansa = 0, ansb = 0, ansc = 0;\n\tcin>>n;\n\n\tvector>dp(n,vector(3,0));\n\n\tfor (ll i = 0; i < n; i ++) {\n\t\tcin>>a>>b>>c;\n\n\t\tif (i == 0)\n\t\t\tansa += a,ansb += b,ansc += c;//dp[i][0] = a, dp[i][1] = b, dp[i][2] = c;\n\t\telse {\n\t\t\t/*dp[i][0]*/ansa += max(b,c);\n\t\t\tansb += max(a,c);\n\t\t\tansc += max(a,b);\n\t\t}\n\t}\n\tcout<\n\nusing namespace std;\n\ntypedef long long ll;\nconst double eps=1e-6,pi=acos(-1);\nconst int N=1e3+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;\nint t,n,W;\nint p[N],w[N];\nmap,int>mp;\n\nint solve(int i,int remW){\n if(i==n) return 0;\n if(mp.find({i,remW})!=mp.end()) return mp[{i,remW}];\n return mp[{i,remW}]=max(solve(i+1,remW),remW-w[i]>=0?solve(i+1,remW-w[i])+p[i]:(int)-1e9);\n}\n\nint main(){\n //freopen(\"myfile.txt\",\"w\",stdout);\n scanf(\"%d%d\",&n,&W);\n for(int i=0;i\n\nusing namespace std;\n\ntypedef long long ll;\nconst double eps=1e-6,pi=acos(-1);\nconst int N=1e3+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;\nint t,n,W;\nint p[N],w[N];\nmap,int>mp;\n\nint solve(int i,int remW){\n if(i==n) return 0;\n if(mp.find({i,remW})!=mp.end()) return mp[{i,remW}];\n return mp[{i,remW}]=max(solve(i+1,remW),remW-w[i]>=0?solve(i+1,remW-w[i])+p[i]:(int)-1e9);\n}\n\nint main(){\n //freopen(\"myfile.txt\",\"w\",stdout);\n scanf(\"%d%d\",&n,&W);\n for(int i=0;i\n\nusing namespace std;\nusing ll = long long;\nconst ll inf = 1e18 + 5;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n int n, W, V = 0;\n cin >> n >> W;\n vector w(n), v(n); \n for(int i = 0; i < n; i++) cin >> w[i] >> v[i];\n for(int i = 0; i < n; i++) V += v[i];\n vector> dp(n + 1, vector (V + 1, inf));\n for(int i = 0; i <= n; i++) dp[i][0] = 0LL;\n for(int i = 1; i <= n; i++) {\n for(int j = 1; j <= V; j++) {\n if(j >= v[i - 1] && dp[i - 1][j - v[i - 1]] < inf) {\n dp[i][j] = min(dp[i - 1][j], (ll)w[i - 1] + dp[i - 1][j - v[i - 1]]);\n } else {\n dp[i][j] = dp[i - 1][j];\n }\n }\n }\n ll ans = 0;\n for(int j = 1; j <= V; j++) {\n if(dp[n][j] <= W) ans = j;\n }\n cout << ans << '\\n';\n return 0;\n}\n \n", "language": "C++", "metadata": {"date": 1594484969, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/C++/s084373911.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084373911", "user_id": "u731566764"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "#include \n\nusing namespace std;\nusing ll = long long;\nconst ll inf = 1e18 + 5;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n int n, W, V = 0;\n cin >> n >> W;\n vector w(n), v(n); \n for(int i = 0; i < n; i++) cin >> w[i] >> v[i];\n for(int i = 0; i < n; i++) V += v[i];\n vector> dp(n + 1, vector (V + 1, inf));\n for(int i = 0; i <= n; i++) dp[i][0] = 0LL;\n for(int i = 1; i <= n; i++) {\n for(int j = 1; j <= V; j++) {\n if(j >= v[i - 1] && dp[i - 1][j - v[i - 1]] < inf) {\n dp[i][j] = min(dp[i - 1][j], (ll)w[i - 1] + dp[i - 1][j - v[i - 1]]);\n } else {\n dp[i][j] = dp[i - 1][j];\n }\n }\n }\n ll ans = 0;\n for(int j = 1; j <= V; j++) {\n if(dp[n][j] <= W) ans = j;\n }\n cout << ans << '\\n';\n return 0;\n}\n \n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 804, "cpu_time_ms": 76, "memory_kb": 83188}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s023902168", "group_id": "codeNet:p03164", "input_text": "#include\nusing namespace std;\ntypedef long long ll;\nconst ll inf=1e18;\nint main()\n{\n\tint n,W;\n\tcin>>n>>W;\n\tint w[n],v[n];\n\tfor(int i=0;i>w[i]>>v[i];\n\tll dp[1010*n];\n\tfor(int i=0;i< 1010*n;i++)dp[i]=inf;\n\tfor(int i=0;i=0;x--)\n\t\t{\n\t\t\tdp[x]=min(dp[x-v[i]]+w[i], dp[x]);\n\t\t}\n\t}\n\tll a=-1;\n\tfor(int i=(1000*n);i>=0;i--)\n\t{\n\t\tif(dp[i]<=W){cout<\nusing namespace std;\ntypedef long long ll;\nconst ll inf=1e18;\nint main()\n{\n\tint n,W;\n\tcin>>n>>W;\n\tint w[n],v[n];\n\tfor(int i=0;i>w[i]>>v[i];\n\tll dp[1010*n];\n\tfor(int i=0;i< 1010*n;i++)dp[i]=inf;\n\tfor(int i=0;i=0;x--)\n\t\t{\n\t\t\tdp[x]=min(dp[x-v[i]]+w[i], dp[x]);\n\t\t}\n\t}\n\tll a=-1;\n\tfor(int i=(1000*n);i>=0;i--)\n\t{\n\t\tif(dp[i]<=W){cout<\n#include \n#include \n\nusing namespace std;\n\nvector c(101), g(101);\n\nint main()\n{\n int n, w;\n long long sumMax = 0;\n cin >> n >> w;\n\n for (int i = 1; i <= n; i++)\n {\n cin >> g[i] >> c[i];\n sumMax += c[i];\n }\n\n vector> dp(105, vector(100005, sumMax + 1));\n\n dp[0][0] = 0;\n int ans = 0;\n\n for (int i = 1; i <= n; i++)\n for (int j = 0; j <= sumMax; j++)\n {\n long long localBest = dp[i - 1][j];\n\n if (j >= c[i] && dp[i - 1][j - c[i]] != sumMax + 1)\n {\n localBest = dp[i - 1][j - c[i]] + g[i];\n localBest = min(localBest, dp[i - 1][j]);\n }\n dp[i][j] = localBest;\n\n if(dp[i][j] <= w)\n ans = max(ans, j);\n }\n\n cout << ans;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1575048066, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/C++/s025439788.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s025439788", "user_id": "u189233751"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "#include \n#include \n#include \n\nusing namespace std;\n\nvector c(101), g(101);\n\nint main()\n{\n int n, w;\n long long sumMax = 0;\n cin >> n >> w;\n\n for (int i = 1; i <= n; i++)\n {\n cin >> g[i] >> c[i];\n sumMax += c[i];\n }\n\n vector> dp(105, vector(100005, sumMax + 1));\n\n dp[0][0] = 0;\n int ans = 0;\n\n for (int i = 1; i <= n; i++)\n for (int j = 0; j <= sumMax; j++)\n {\n long long localBest = dp[i - 1][j];\n\n if (j >= c[i] && dp[i - 1][j - c[i]] != sumMax + 1)\n {\n localBest = dp[i - 1][j - c[i]] + g[i];\n localBest = min(localBest, dp[i - 1][j]);\n }\n dp[i][j] = localBest;\n\n if(dp[i][j] <= w)\n ans = max(ans, j);\n }\n\n cout << ans;\n\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 881, "cpu_time_ms": 57, "memory_kb": 83328}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s301454503", "group_id": "codeNet:p03164", "input_text": "#include \n#define debug(a) cout << #a << \" = \" << a << endl;\nusing ll = long long;\nusing namespace std;\n\nconst ll inf = 100000000000000;\nconst int N = 100;\nint w[N],v[N];\nll dp[200000];\n\n// here dp[i] = minimum weight to make value exactly i \n\nint main(int argc, char const *argv[])\n{\n int cap = 0,n;\n for(int i =0 ;i < 200000;i++)dp[i] = inf;\n // here dp[i] = minimum weight to make value exactly i \n scanf(\"%d%d\",&n,&cap);\n dp[0] = 0;\n for(int i = 0; i < n;i++){\n scanf(\"%d %d\",&w[i],&v[i]);\n for(int x = 100000;x>=0;x--){\n if(x-v[i]>=0){\n dp[x] = min(dp[x],dp[x-v[i]]+w[i]);\n }\n }\n }\n ll ans = 0;\n //for(int i = 0; i <= 200;i++){\n // printf(\"%d = %lld\\n\",i,dp[i]);\n //}\n for(int i = 100004 ; i >=0 ; i--){\n if(dp[i] <= cap){ans = i;break;}\n } \n printf(\"%lld\\n\",ans);\n return 0;\n}", "language": "C++", "metadata": {"date": 1561280465, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03164.html", "problem_id": "p03164", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03164/input.txt", "sample_output_relpath": "derived/input_output/data/p03164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03164/C++/s301454503.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301454503", "user_id": "u075800845"}, "prompt_components": {"gold_output": "90\n", "input_to_evaluate": "#include \n#define debug(a) cout << #a << \" = \" << a << endl;\nusing ll = long long;\nusing namespace std;\n\nconst ll inf = 100000000000000;\nconst int N = 100;\nint w[N],v[N];\nll dp[200000];\n\n// here dp[i] = minimum weight to make value exactly i \n\nint main(int argc, char const *argv[])\n{\n int cap = 0,n;\n for(int i =0 ;i < 200000;i++)dp[i] = inf;\n // here dp[i] = minimum weight to make value exactly i \n scanf(\"%d%d\",&n,&cap);\n dp[0] = 0;\n for(int i = 0; i < n;i++){\n scanf(\"%d %d\",&w[i],&v[i]);\n for(int x = 100000;x>=0;x--){\n if(x-v[i]>=0){\n dp[x] = min(dp[x],dp[x-v[i]]+w[i]);\n }\n }\n }\n ll ans = 0;\n //for(int i = 0; i <= 200;i++){\n // printf(\"%d = %lld\\n\",i,dp[i]);\n //}\n for(int i = 100004 ; i >=0 ; i--){\n if(dp[i] <= cap){ans = i;break;}\n } \n printf(\"%lld\\n\",ans);\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "sample_input": "3 8\n3 30\n4 50\n5 60\n"}, "reference_outputs": ["90\n"], "source_document_id": "p03164", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N items, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), Item i has a weight of w_i and a value of v_i.\n\nTaro has decided to choose some of the N items and carry them home in a knapsack.\nThe capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.\n\nFind the maximum possible sum of the values of items that Taro takes home.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq W \\leq 10^9\n\n1 \\leq w_i \\leq W\n\n1 \\leq v_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible sum of the values of items that Taro takes home.\n\nSample Input 1\n\n3 8\n3 30\n4 50\n5 60\n\nSample Output 1\n\n90\n\nItems 1 and 3 should be taken.\nThen, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.\n\nSample Input 2\n\n1 1000000000\n1000000000 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n6 15\n6 5\n5 6\n6 4\n6 6\n3 5\n7 2\n\nSample Output 3\n\n17\n\nItems 2, 4 and 5 should be taken.\nThen, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 913, "cpu_time_ms": 15, "memory_kb": 1792}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s998793848", "group_id": "codeNet:p03166", "input_text": "#include\n#define forn(i,a,b) for(long long i=a;i<=b;i++)\n#define fork(i,a,b,k) for(long long i=a;i<=b;i+=k)\nusing namespace std;\ntypedef long long ll;\nvectorchild[100005],parent[100005];\nqueueq;\nint used[100005],dist[100005];\nint n,m,x[100005],y[100005],mx;\nvoid bfs(int s){\n\tdist[s]=0;\n\tq.push(s);\n\tused[s]=1;\n\twhile(!q.empty()){\n\t\tint v=q.front();\n\t\tq.pop();\n\t\tfor(int u : parent[v]){\n\t\t\tdist[u]=dist[v]+1;\n\t\t\tmx=max(mx,dist[u]);\n\t\t\tq.push(u);\n\t\t}\n\t}\n}\nint main(){\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\tcin>>n>>m;\n\tfor(ll i=1;i<=m;i++){\n\t\tcin>>x[i]>>y[i];\n\t\tparent[y[i]].push_back(x[i]);\n\t\tchild[x[i]].push_back(y[i]);\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\tif(child[y[i]].empty()){\n\t\t\tbfs(y[i]);\n\t\t}\n\t}\n\tcout<\n#define forn(i,a,b) for(long long i=a;i<=b;i++)\n#define fork(i,a,b,k) for(long long i=a;i<=b;i+=k)\nusing namespace std;\ntypedef long long ll;\nvectorchild[100005],parent[100005];\nqueueq;\nint used[100005],dist[100005];\nint n,m,x[100005],y[100005],mx;\nvoid bfs(int s){\n\tdist[s]=0;\n\tq.push(s);\n\tused[s]=1;\n\twhile(!q.empty()){\n\t\tint v=q.front();\n\t\tq.pop();\n\t\tfor(int u : parent[v]){\n\t\t\tdist[u]=dist[v]+1;\n\t\t\tmx=max(mx,dist[u]);\n\t\t\tq.push(u);\n\t\t}\n\t}\n}\nint main(){\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\tcin>>n>>m;\n\tfor(ll i=1;i<=m;i++){\n\t\tcin>>x[i]>>y[i];\n\t\tparent[y[i]].push_back(x[i]);\n\t\tchild[x[i]].push_back(y[i]);\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\tif(child[y[i]].empty()){\n\t\t\tbfs(y[i]);\n\t\t}\n\t}\n\tcout<\n#define ll long long\n#define pb push_back\n#define endl '\\n'\n#define pii pair\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll int)x.size()\n#define hell 1000000001\n#define r(i,a,b) for(i=a;i\nusing namespace std;\n \n#define N 1000000\n#define M 100000000\n\nstruct unit {\n ll int a[N]; \n};\n\nll fact (ll int x)\n{if(x==1 || x==0)return 1;\nelse return x*fact(x-1);}\n\nll power(ll int x,ll int n)\n{if(n==0)return 1;\nelse if(n%2 == 0)return power(x*x,n/2);\nelse return x*power(x*x,(n-1)/2);}\n\nbool cmp (const pii&a,const pii&b)\n{ return((a.F-a.S) > (b.F-b.S));\n/*if(a.S<=b.S){if(a.S==b.S)return a.F>n>>m;\n vector v;\n r(i,0,m)\n {\n cin>>k>>l;\n v.pb(mp(k,l));\n }\n ll dp[n+1];\n memset(dp,0,sizeof(dp));\n r(j,0,m)\n dp[v[j].S]=1;\n r(j,0,m)\n dp[v[j].S]=max(dp[v[j].S],dp[v[j].F]+1);\n cout<<*max_element(dp,dp+n+1);\n}", "language": "C++", "metadata": {"date": 1589468801, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/C++/s662930292.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s662930292", "user_id": "u890898725"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\n#define ll long long\n#define pb push_back\n#define endl '\\n'\n#define pii pair\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll int)x.size()\n#define hell 1000000001\n#define r(i,a,b) for(i=a;i\nusing namespace std;\n \n#define N 1000000\n#define M 100000000\n\nstruct unit {\n ll int a[N]; \n};\n\nll fact (ll int x)\n{if(x==1 || x==0)return 1;\nelse return x*fact(x-1);}\n\nll power(ll int x,ll int n)\n{if(n==0)return 1;\nelse if(n%2 == 0)return power(x*x,n/2);\nelse return x*power(x*x,(n-1)/2);}\n\nbool cmp (const pii&a,const pii&b)\n{ return((a.F-a.S) > (b.F-b.S));\n/*if(a.S<=b.S){if(a.S==b.S)return a.F>n>>m;\n vector v;\n r(i,0,m)\n {\n cin>>k>>l;\n v.pb(mp(k,l));\n }\n ll dp[n+1];\n memset(dp,0,sizeof(dp));\n r(j,0,m)\n dp[v[j].S]=1;\n r(j,0,m)\n dp[v[j].S]=max(dp[v[j].S],dp[v[j].F]+1);\n cout<<*max_element(dp,dp+n+1);\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1423, "cpu_time_ms": 18, "memory_kb": 2672}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s993710494", "group_id": "codeNet:p03166", "input_text": "#include \n\nusing namespace std;\n\nusing ll = long long;\n\nconst int INF = 1e9 + 5;\n\ntemplate\nvoid min_self(T& a, T b)\n{\n a = min(a,b);\n}\n\ntemplate\nvoid max_self(T& a, T b)\n{\n a = max(a,b);\n}\n\nconst int Nax=1e5 + 5;\n\nvector edges[Nax];\nbool visited[Nax];\nint dist[Nax];\nint in[Nax];\n\nvoid dfs(int a)\n{\n //visited[a] = true;\n \n for(int b: edges[a])\n {\n dist[b] = max(dist[b],1+dist[a]);\n \n if(--in[b] == 0)\n {\n dfs(b);\n }\n }\n}\n\nint main() {\n \n ios::sync_with_stdio(0);\n cin.tie(0);\n\n int N, M;\n cin >> N >> M;\n \n int a, b;\n\n while(M--)\n {\n cin >> a >> b;\n edges[a].push_back(b);\n \n ++in[b];\n }\n \n for(int i=1; i<=N; ++i)\n {\n if(/*!visited[i] && */in[i] == 0)\n {\n dfs(i);\n }\n }\n \n cout << *max_element(dist+1,dist+N+1);\n \n}\n", "language": "C++", "metadata": {"date": 1584610238, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/C++/s993710494.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s993710494", "user_id": "u308143294"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nusing ll = long long;\n\nconst int INF = 1e9 + 5;\n\ntemplate\nvoid min_self(T& a, T b)\n{\n a = min(a,b);\n}\n\ntemplate\nvoid max_self(T& a, T b)\n{\n a = max(a,b);\n}\n\nconst int Nax=1e5 + 5;\n\nvector edges[Nax];\nbool visited[Nax];\nint dist[Nax];\nint in[Nax];\n\nvoid dfs(int a)\n{\n //visited[a] = true;\n \n for(int b: edges[a])\n {\n dist[b] = max(dist[b],1+dist[a]);\n \n if(--in[b] == 0)\n {\n dfs(b);\n }\n }\n}\n\nint main() {\n \n ios::sync_with_stdio(0);\n cin.tie(0);\n\n int N, M;\n cin >> N >> M;\n \n int a, b;\n\n while(M--)\n {\n cin >> a >> b;\n edges[a].push_back(b);\n \n ++in[b];\n }\n \n for(int i=1; i<=N; ++i)\n {\n if(/*!visited[i] && */in[i] == 0)\n {\n dfs(i);\n }\n }\n \n cout << *max_element(dist+1,dist+N+1);\n \n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 941, "cpu_time_ms": 33, "memory_kb": 9600}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s828004392", "group_id": "codeNet:p03167", "input_text": "#include \nusing namespace std;\n\nint h, w;\nstring m[1005];\nint dp[1005][1005];\n\nint main (){\n\t\n\tcin >> h >> w;\n\tfor (int i=0; i < h; i++)\n\t\tcin >>m[i];\n\t\t\n\tdp[0][0]=1;\n\t\t\n\tfor (int i=0; i < h; i++)\n\t\tfor (int j=0; j < w; j++)\n\t\t{\n\t\t\tif (i==0 && j==0) continue;\n\t\t\tif (m[i][j]!='#')\n\t\t\t{\n\t\t\t\tif (i>0) dp[i][j]+=dp[i-1][j];\n\t\t\t\tif (j>0) dp[i][j]+=dp[i][j-1];\n\t\t\t}\n\t\t}\n\t\t\n\t\n\tcout << dp[h-1][w-1];\n\t\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1548287429, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03167.html", "problem_id": "p03167", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03167/input.txt", "sample_output_relpath": "derived/input_output/data/p03167/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03167/C++/s828004392.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s828004392", "user_id": "u440584387"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\nint h, w;\nstring m[1005];\nint dp[1005][1005];\n\nint main (){\n\t\n\tcin >> h >> w;\n\tfor (int i=0; i < h; i++)\n\t\tcin >>m[i];\n\t\t\n\tdp[0][0]=1;\n\t\t\n\tfor (int i=0; i < h; i++)\n\t\tfor (int j=0; j < w; j++)\n\t\t{\n\t\t\tif (i==0 && j==0) continue;\n\t\t\tif (m[i][j]!='#')\n\t\t\t{\n\t\t\t\tif (i>0) dp[i][j]+=dp[i-1][j];\n\t\t\t\tif (j>0) dp[i][j]+=dp[i][j-1];\n\t\t\t}\n\t\t}\n\t\t\n\t\n\tcout << dp[h-1][w-1];\n\t\n\treturn 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "3 4\n...#\n.#..\n....\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03167", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 422, "cpu_time_ms": 41, "memory_kb": 5248}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s235438369", "group_id": "codeNet:p03168", "input_text": "#include \n#define lli long long int\n#define ld long double\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define reps(i,a,n) for(int i = a; i < n; i++)\n#define s(n) cin >> n\n#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)\n#define rsz(x,n) x.clear(); x.resize(n)\n#define rrsz(x,a,n) x.clear(); x.resize(n,a)\n#define wt while(true)\n#define all(x) x.begin(),x.end()\n#define pb push_back\n#define ls(x) ((2*(x)) + 1)\n#define rs(x) ((ls(x)) + 1)\n#define md(a,b) (((a) + (b))/2)\n#define INF (1e9 + 7)\n\nusing namespace std;\n\nint main()\n{\n lli n;s(n);\n vectora(n+1);\n rep(i,n)\n {\n ld b;s(b);\n a[i+1]=b;\n }\n vector>vec(n+1,vector(n+1,0));\n vec[0][0]=1;\n reps(i,1,n+1)\n vec[i][0]=vec[i-1][0]*(1-a[i]);\n vec[1][1]=a[1];\n reps(i,2,n+1)\n {\n reps(j,1,i+1)\n {\n vec[i][j]+=((vec[i-1][j-1])*(a[i])+(vec[i-1][j])*(1-a[i]));\n }\n }\n /*reps(i,1,n+1)\n cout<\n#define lli long long int\n#define ld long double\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define reps(i,a,n) for(int i = a; i < n; i++)\n#define s(n) cin >> n\n#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)\n#define rsz(x,n) x.clear(); x.resize(n)\n#define rrsz(x,a,n) x.clear(); x.resize(n,a)\n#define wt while(true)\n#define all(x) x.begin(),x.end()\n#define pb push_back\n#define ls(x) ((2*(x)) + 1)\n#define rs(x) ((ls(x)) + 1)\n#define md(a,b) (((a) + (b))/2)\n#define INF (1e9 + 7)\n\nusing namespace std;\n\nint main()\n{\n lli n;s(n);\n vectora(n+1);\n rep(i,n)\n {\n ld b;s(b);\n a[i+1]=b;\n }\n vector>vec(n+1,vector(n+1,0));\n vec[0][0]=1;\n reps(i,1,n+1)\n vec[i][0]=vec[i-1][0]*(1-a[i]);\n vec[1][1]=a[1];\n reps(i,2,n+1)\n {\n reps(j,1,i+1)\n {\n vec[i][j]+=((vec[i-1][j-1])*(a[i])+(vec[i-1][j])*(1-a[i]));\n }\n }\n /*reps(i,1,n+1)\n cout<\n#define maxn 3000\nusing namespace std;\n\nint n;\ndouble p[maxn];\ndouble dp[maxn][maxn];\n\nint main() {\n\tscanf(\"%d\",&n);\n\tfor( int i = 1 ; i <= n ; i++ )\n\t\tscanf(\"%lf\",&p[i]);\n\tdp[0][0] = 1;\n\tfor( int i = 1 ; i <= n ; i++ )\n\t\tfor( int j = 0 ; j <= i ; j++ ) {\n\t\t\tif(j)\n\t\t\t\tdp[i][j] = dp[i-1][j-1] * p[i];\n\t\t\tdp[i][j] += dp[i-1][j] * (1-p[i]);\n\t\t}\n\tdouble ans = 0;\n\tfor( int i = n/2+1 ; i <= n ; i++ )\n\t\tans += dp[n][i];\n\tprintf(\"%.10lf\\n\",ans);\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1585262189, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03168.html", "problem_id": "p03168", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03168/input.txt", "sample_output_relpath": "derived/input_output/data/p03168/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03168/C++/s381296720.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s381296720", "user_id": "u229051304"}, "prompt_components": {"gold_output": "0.612\n", "input_to_evaluate": "#include \n#define maxn 3000\nusing namespace std;\n\nint n;\ndouble p[maxn];\ndouble dp[maxn][maxn];\n\nint main() {\n\tscanf(\"%d\",&n);\n\tfor( int i = 1 ; i <= n ; i++ )\n\t\tscanf(\"%lf\",&p[i]);\n\tdp[0][0] = 1;\n\tfor( int i = 1 ; i <= n ; i++ )\n\t\tfor( int j = 0 ; j <= i ; j++ ) {\n\t\t\tif(j)\n\t\t\t\tdp[i][j] = dp[i-1][j-1] * p[i];\n\t\t\tdp[i][j] += dp[i-1][j] * (1-p[i]);\n\t\t}\n\tdouble ans = 0;\n\tfor( int i = n/2+1 ; i <= n ; i++ )\n\t\tans += dp[n][i];\n\tprintf(\"%.10lf\\n\",ans);\n\treturn 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "sample_input": "3\n0.30 0.60 0.80\n"}, "reference_outputs": ["0.612\n"], "source_document_id": "p03168", "source_text": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 479, "cpu_time_ms": 27, "memory_kb": 68864}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s122412104", "group_id": "codeNet:p03168", "input_text": "// Author - Saikat_7\n#include \nusing namespace std;\n#define fl(i,a,b) for(int i=a;i>tc;\n while(tc-- > 0)\n {\n \t\tint n;\n \t\tcin>>n;\n \t\tdouble arr[n];\n \t\tint h=n/2+1;\n \t\tfor(int i=0;i<=n;i++)\n \t\t{\n \t\t\tfor (int j=0;j<=h;j++)\n \t\t\t\tdp[i][j]=-1;\n \t\t}\n \t\tfor(int i=0;i>arr[i];\n \t\t} \n \t\tdouble ans=coins(arr,n,(n/2)+1);\n \t\tcout< \nusing namespace std;\n#define fl(i,a,b) for(int i=a;i>tc;\n while(tc-- > 0)\n {\n \t\tint n;\n \t\tcin>>n;\n \t\tdouble arr[n];\n \t\tint h=n/2+1;\n \t\tfor(int i=0;i<=n;i++)\n \t\t{\n \t\t\tfor (int j=0;j<=h;j++)\n \t\t\t\tdp[i][j]=-1;\n \t\t}\n \t\tfor(int i=0;i>arr[i];\n \t\t} \n \t\tdouble ans=coins(arr,n,(n/2)+1);\n \t\tcout<\nusing namespace std;\n#define _USE_MATH_DEFINES\n\n#include \n#include \nusing namespace __gnu_pbds;\ntemplate \nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\n// DON'T USE THESE MACROS DURING ICPC PRACTICE\n#define For(i,n) for (int i=0; i=0; i--)\n#define DOWN(i,a,b) for (int i=b; i>=a; i--)\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef complex pt;\ntypedef vector pol;\ntypedef vector vi;\n\nconst char nl = '\\n';\nconst int INF = 0x3f3f3f3f;\nconst ll INFLL = 0x3f3f3f3f3f3f3f3f;\nconst ll MOD = 1e9+7;\nconst ld EPS = 1e-10;\nmt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());\n\n\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tcout << fixed << setprecision(17);\n\n\tint n;\n\tcin >> n;\n\n\tld p[n+1];\n\tFOR(i,1,n) {\n\t\tcin >> p[i];\n\t}\n\n\tld dp[n+1][n/2+1];\n\tfill(dp[0], dp[0]+n/2+1, 0);\n\tdp[0][0] = 1;\n\tFOR(i,1,n) {\n\t\tFor(j,n/2+1) {\n\t\t\tdp[i][j] = dp[i-1][j] * p[i];\n\t\t\tif (j>0) dp[i][j] += dp[i-1][j-1] * (1-p[i]);\n\t\t}\n\t}\n\n\tld ans = 0;\n\tFor(j,n/2+1) {\n\t\tans += dp[n][j];\n\t}\n\tcout << ans << nl;\n\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1564575382, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03168.html", "problem_id": "p03168", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03168/input.txt", "sample_output_relpath": "derived/input_output/data/p03168/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03168/C++/s389171947.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s389171947", "user_id": "u645327277"}, "prompt_components": {"gold_output": "0.612\n", "input_to_evaluate": "#include \nusing namespace std;\n#define _USE_MATH_DEFINES\n\n#include \n#include \nusing namespace __gnu_pbds;\ntemplate \nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\n// DON'T USE THESE MACROS DURING ICPC PRACTICE\n#define For(i,n) for (int i=0; i=0; i--)\n#define DOWN(i,a,b) for (int i=b; i>=a; i--)\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef complex pt;\ntypedef vector pol;\ntypedef vector vi;\n\nconst char nl = '\\n';\nconst int INF = 0x3f3f3f3f;\nconst ll INFLL = 0x3f3f3f3f3f3f3f3f;\nconst ll MOD = 1e9+7;\nconst ld EPS = 1e-10;\nmt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());\n\n\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\tcout << fixed << setprecision(17);\n\n\tint n;\n\tcin >> n;\n\n\tld p[n+1];\n\tFOR(i,1,n) {\n\t\tcin >> p[i];\n\t}\n\n\tld dp[n+1][n/2+1];\n\tfill(dp[0], dp[0]+n/2+1, 0);\n\tdp[0][0] = 1;\n\tFOR(i,1,n) {\n\t\tFor(j,n/2+1) {\n\t\t\tdp[i][j] = dp[i-1][j] * p[i];\n\t\t\tif (j>0) dp[i][j] += dp[i-1][j-1] * (1-p[i]);\n\t\t}\n\t}\n\n\tld ans = 0;\n\tFor(j,n/2+1) {\n\t\tans += dp[n][j];\n\t}\n\tcout << ans << nl;\n\n\treturn 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "sample_input": "3\n0.30 0.60 0.80\n"}, "reference_outputs": ["0.612\n"], "source_document_id": "p03168", "source_text": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1368, "cpu_time_ms": 39, "memory_kb": 70656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s840390478", "group_id": "codeNet:p03168", "input_text": "#include\nusing namespace std;\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define trace1(x) cerr<<#x<<\": \"< v;\nll dp[3000][3000];\nlong double f(int x,int y)\n{\n\tif(x==n)\n\t{\n\t\treturn y>n/2;\n\t\t\n\t}\n\tif(dp[x][y]>0)\n\t\treturn dp[x][y];\n\treturn dp[x][y]=(v[x]*f(x+1,y+1)+(1-v[x])*f(x+1,y));\n}\nint32_t main()\n{\n\tIOS;\n\tcin>>n;\n\tmemset(dp,-1,sizeof(dp));\n\tfor(int i=0;i>x;\n\t\tv.push_back(x);\n\t}\n\tcout<\nusing namespace std;\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define trace1(x) cerr<<#x<<\": \"< v;\nll dp[3000][3000];\nlong double f(int x,int y)\n{\n\tif(x==n)\n\t{\n\t\treturn y>n/2;\n\t\t\n\t}\n\tif(dp[x][y]>0)\n\t\treturn dp[x][y];\n\treturn dp[x][y]=(v[x]*f(x+1,y+1)+(1-v[x])*f(x+1,y));\n}\nint32_t main()\n{\n\tIOS;\n\tcin>>n;\n\tmemset(dp,-1,sizeof(dp));\n\tfor(int i=0;i>x;\n\t\tv.push_back(x);\n\t}\n\tcout<\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef pair pll;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\n#define endl \"\\n\"\n#define mt make_tuple\n#define mp make_pair\n\ntemplate \nbool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}\ntemplate \nbool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}\ntemplate \nT sqr(T a) {return a * a;}\n\nmt19937 rng(20010709);\nconst int mod = 1000000007;\nconst int INF = 1000000001;\n\nint n;\nld dp[3000][6005], p[3000];\nld result;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n\n cin >> n;\n\n for (int i = 1; i <= n; i++)\n cin >> p[i];\n\n dp[0][0 + n] = 1;\n\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n * 2; j++) {\n dp[i][j + 1] += dp[i - 1][j] * p[i];\n dp[i][j - 1] += dp[i - 1][j] * (1.0 - p[i]);\n }\n }\n\n for (int i = 1; i <= n; i++)\n result += dp[n][i + n];\n\n cout << fixed << setprecision(15) << result << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1546864624, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03168.html", "problem_id": "p03168", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03168/input.txt", "sample_output_relpath": "derived/input_output/data/p03168/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03168/C++/s454394751.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s454394751", "user_id": "u438783465"}, "prompt_components": {"gold_output": "0.612\n", "input_to_evaluate": "//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma GCC optimize(\"unroll-loops\")\n\n#define _CRT_SECURE_NO_WARNINGS\n#include \n\nusing namespace std;\n\ntypedef pair pii;\ntypedef pair pll;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\n#define endl \"\\n\"\n#define mt make_tuple\n#define mp make_pair\n\ntemplate \nbool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}\ntemplate \nbool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}\ntemplate \nT sqr(T a) {return a * a;}\n\nmt19937 rng(20010709);\nconst int mod = 1000000007;\nconst int INF = 1000000001;\n\nint n;\nld dp[3000][6005], p[3000];\nld result;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n\n cin >> n;\n\n for (int i = 1; i <= n; i++)\n cin >> p[i];\n\n dp[0][0 + n] = 1;\n\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n * 2; j++) {\n dp[i][j + 1] += dp[i - 1][j] * p[i];\n dp[i][j - 1] += dp[i - 1][j] * (1.0 - p[i]);\n }\n }\n\n for (int i = 1; i <= n; i++)\n result += dp[n][i + n];\n\n cout << fixed << setprecision(15) << result << endl;\n\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "sample_input": "3\n0.30 0.60 0.80\n"}, "reference_outputs": ["0.612\n"], "source_document_id": "p03168", "source_text": "Score : 100 points\n\nProblem Statement\n\nLet N be a positive odd number.\n\nThere are N coins, numbered 1, 2, \\ldots, N.\nFor each i (1 \\leq i \\leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.\n\nTaro has tossed all the N coins.\nFind the probability of having more heads than tails.\n\nConstraints\n\nN is an odd number.\n\n1 \\leq N \\leq 2999\n\np_i is a real number and has two decimal places.\n\n0 < p_i < 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint the probability of having more heads than tails.\nThe output is considered correct when the absolute error is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n0.30 0.60 0.80\n\nSample Output 1\n\n0.612\n\nThe probability of each case where we have more heads than tails is as follows:\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Head) is 0.3 × 0.6 × 0.8 = 0.144;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Tail, Head, Head) is 0.7 × 0.6 × 0.8 = 0.336;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Tail, Head) is 0.3 × 0.4 × 0.8 = 0.096;\n\nThe probability of having (Coin 1, Coin 2, Coin 3) = (Head, Head, Tail) is 0.3 × 0.6 × 0.2 = 0.036.\n\nThus, the probability of having more heads than tails is 0.144 + 0.336 + 0.096 + 0.036 = 0.612.\n\nSample Input 2\n\n1\n0.50\n\nSample Output 2\n\n0.5\n\nOutputs such as 0.500, 0.500000001 and 0.499999999 are also considered correct.\n\nSample Input 3\n\n5\n0.42 0.01 0.42 0.99 0.42\n\nSample Output 3\n\n0.3821815872", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1285, "cpu_time_ms": 190, "memory_kb": 281728}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s232109235", "group_id": "codeNet:p03175", "input_text": "#include\nusing namespace std;\n\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)\n#define INF 10000000000\n#define MOD 1000000007\nusing ll = long long;\nusing Graph = vector>;\n\nll dp[100100][2];//dp[v][color]\nGraph G;\n\nll rec(int v, int color, int parent){\n if(dp[v][color]!=-1) return dp[v][color];\n ll res = 1;\n for(auto nv : G[v]){\n ll tmp = 0;\n if(nv != parent){\n if(!color) (tmp += rec(nv,1,v)) %= MOD;\n (tmp += rec(nv,0,v)) %= MOD;\n tmp %= MOD;\n if(tmp!=0) (res *= tmp) %= MOD;\n }\n }\n res %= MOD;\n return dp[v][color] = res;\n}\n\nint main(){\n int N; cin>>N;\n G.resize(N);\n rep(i,N-1){\n int x,y; cin>>x>>y;\n x--;y--;\n G[x].push_back(y); G[y].push_back(x);\n }\n rep(i,100100)rep(j,2)dp[i][j] = -1;\n ll res = rec(0,0,-1);\n res += rec(0,1,-1);\n res %= MOD;\n cout<\nusing namespace std;\n\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)\n#define INF 10000000000\n#define MOD 1000000007\nusing ll = long long;\nusing Graph = vector>;\n\nll dp[100100][2];//dp[v][color]\nGraph G;\n\nll rec(int v, int color, int parent){\n if(dp[v][color]!=-1) return dp[v][color];\n ll res = 1;\n for(auto nv : G[v]){\n ll tmp = 0;\n if(nv != parent){\n if(!color) (tmp += rec(nv,1,v)) %= MOD;\n (tmp += rec(nv,0,v)) %= MOD;\n tmp %= MOD;\n if(tmp!=0) (res *= tmp) %= MOD;\n }\n }\n res %= MOD;\n return dp[v][color] = res;\n}\n\nint main(){\n int N; cin>>N;\n G.resize(N);\n rep(i,N-1){\n int x,y; cin>>x>>y;\n x--;y--;\n G[x].push_back(y); G[y].push_back(x);\n }\n rep(i,100100)rep(j,2)dp[i][j] = -1;\n ll res = rec(0,0,-1);\n res += rec(0,1,-1);\n res %= MOD;\n cout<\nusing namespace std;\n#define ll long long\n#define fr(i,j,k) for(int i=j;i> now.a[i][j];\n\t\t}\n\t}\n\tmat ans;\n\tans.n = n;\n\tf(n) {\n\t\tans.a[i][0] = 1;\n\t}\n\twhile (k) {\n\t\tif (k & 1) {\n\t\t\tans = now * ans;\n\t\t}\n\t\tnow = now * now;\n\t\tk >>= 1;\n\t}\n\tll sum = 0;\n\tf(n) {\n\t\tsum += ans.a[i][0];\n\t\tsum %= mod;\n\t}\n\treturn sum;\n}\nvoid go() {\n\tll n, m, k;\n\tcin >> n >> k;\n\tcout << solve(n, k) << '\\n';\n\n}\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n int c = 0;\n int t;\n if (!c) {\n t = 1;\n }\n else {\n cin >> t;\n }\n while (t--) {\n go();\n }\n \n}", "language": "C++", "metadata": {"date": 1597785989, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03177.html", "problem_id": "p03177", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03177/input.txt", "sample_output_relpath": "derived/input_output/data/p03177/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03177/C++/s840028821.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s840028821", "user_id": "u308590217"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include \nusing namespace std;\n#define ll long long\n#define fr(i,j,k) for(int i=j;i> now.a[i][j];\n\t\t}\n\t}\n\tmat ans;\n\tans.n = n;\n\tf(n) {\n\t\tans.a[i][0] = 1;\n\t}\n\twhile (k) {\n\t\tif (k & 1) {\n\t\t\tans = now * ans;\n\t\t}\n\t\tnow = now * now;\n\t\tk >>= 1;\n\t}\n\tll sum = 0;\n\tf(n) {\n\t\tsum += ans.a[i][0];\n\t\tsum %= mod;\n\t}\n\treturn sum;\n}\nvoid go() {\n\tll n, m, k;\n\tcin >> n >> k;\n\tcout << solve(n, k) << '\\n';\n\n}\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n int c = 0;\n int t;\n if (!c) {\n t = 1;\n }\n else {\n cin >> t;\n }\n while (t--) {\n go();\n }\n \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a simple directed graph G with N vertices, numbered 1, 2, \\ldots, N.\n\nFor each i and j (1 \\leq i, j \\leq N), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j.\nIf a_{i, j} = 1, there is a directed edge from Vertex i to j; if a_{i, j} = 0, there is not.\n\nFind the number of different directed paths of length K in G, modulo 10^9 + 7.\nWe will also count a path that traverses the same edge multiple times.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 10^{18}\n\na_{i, j} is 0 or 1.\n\na_{i, i} = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of different directed paths of length K in G, modulo 10^9 + 7.\n\nSample Input 1\n\n4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n\nSample Output 1\n\n6\n\nG is drawn in the figure below:\n\nThere are six directed paths of length 2:\n\n1 → 2 → 3\n\n1 → 2 → 4\n\n2 → 3 → 4\n\n2 → 4 → 1\n\n3 → 4 → 1\n\n4 → 1 → 2\n\nSample Input 2\n\n3 3\n0 1 0\n1 0 1\n0 0 0\n\nSample Output 2\n\n3\n\nG is drawn in the figure below:\n\nThere are three directed paths of length 3:\n\n1 → 2 → 1 → 2\n\n2 → 1 → 2 → 1\n\n2 → 1 → 2 → 3\n\nSample Input 3\n\n6 2\n0 0 0 0 0 0\n0 0 1 0 0 0\n0 0 0 0 0 0\n0 0 0 0 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n\nSample Output 3\n\n1\n\nG is drawn in the figure below:\n\nThere is one directed path of length 2:\n\n4 → 5 → 6\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n0\n\nSample Input 5\n\n10 1000000000000000000\n0 0 1 1 0 0 0 1 1 0\n0 0 0 0 0 1 1 1 0 0\n0 1 0 0 0 1 0 1 0 1\n1 1 1 0 1 1 0 1 1 0\n0 1 1 1 0 1 0 1 1 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 1 0 1\n1 0 0 0 1 0 1 0 0 0\n0 0 0 0 0 1 0 0 0 0\n1 0 1 1 1 0 1 1 1 0\n\nSample Output 5\n\n957538352\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03177", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a simple directed graph G with N vertices, numbered 1, 2, \\ldots, N.\n\nFor each i and j (1 \\leq i, j \\leq N), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j.\nIf a_{i, j} = 1, there is a directed edge from Vertex i to j; if a_{i, j} = 0, there is not.\n\nFind the number of different directed paths of length K in G, modulo 10^9 + 7.\nWe will also count a path that traverses the same edge multiple times.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 10^{18}\n\na_{i, j} is 0 or 1.\n\na_{i, i} = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_{1, 1} \\ldots a_{1, N}\n:\na_{N, 1} \\ldots a_{N, N}\n\nOutput\n\nPrint the number of different directed paths of length K in G, modulo 10^9 + 7.\n\nSample Input 1\n\n4 2\n0 1 0 0\n0 0 1 1\n0 0 0 1\n1 0 0 0\n\nSample Output 1\n\n6\n\nG is drawn in the figure below:\n\nThere are six directed paths of length 2:\n\n1 → 2 → 3\n\n1 → 2 → 4\n\n2 → 3 → 4\n\n2 → 4 → 1\n\n3 → 4 → 1\n\n4 → 1 → 2\n\nSample Input 2\n\n3 3\n0 1 0\n1 0 1\n0 0 0\n\nSample Output 2\n\n3\n\nG is drawn in the figure below:\n\nThere are three directed paths of length 3:\n\n1 → 2 → 1 → 2\n\n2 → 1 → 2 → 1\n\n2 → 1 → 2 → 3\n\nSample Input 3\n\n6 2\n0 0 0 0 0 0\n0 0 1 0 0 0\n0 0 0 0 0 0\n0 0 0 0 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n\nSample Output 3\n\n1\n\nG is drawn in the figure below:\n\nThere is one directed path of length 2:\n\n4 → 5 → 6\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n0\n\nSample Input 5\n\n10 1000000000000000000\n0 0 1 1 0 0 0 1 1 0\n0 0 0 0 0 1 1 1 0 0\n0 1 0 0 0 1 0 1 0 1\n1 1 1 0 1 1 0 1 1 0\n0 1 1 1 0 1 0 1 1 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 1 0 1\n1 0 0 0 1 0 1 0 0 0\n0 0 0 0 0 1 0 0 0 0\n1 0 1 1 1 0 1 1 1 0\n\nSample Output 5\n\n957538352\n\nBe sure to print the count modulo 10^9 + 7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1286, "cpu_time_ms": 57, "memory_kb": 3864}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s551338760", "group_id": "codeNet:p03178", "input_text": "#include \n#define int long long\n#define maxn 10005\n#define maxc 105\nusing namespace std;\n\nconst int mod = 1e9 + 7;\n\n// len sum last\nint dp[maxn][maxc][10] = {};\nstring s;\nint n, k;\n\nint32_t main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cin >> s >> k;\n reverse(begin(s), end(s));\n n = s.size(); s = \"@\" + s;\n for(int i = 0; i < 10; i++) {\n dp[1][i % k][i] = 1;\n }\n for(int len = 2; len <= n; len++) {\n for(int sum = 0; sum < k; sum++) {\n for(int last = 0; last < 10; last++) {\n int prev = (sum - last + k) % k;\n for(int i = 0; i < 10; i++)\n dp[len][sum][last] += dp[len - 1][prev][i];\n dp[len][sum][last] %= mod;\n }\n }\n }\n int ans = 0, cnt = 0;\n for(int i = n; i > 0; i--) {\n for(int j = 0; j < (s[i] - '0'); j++) {\n int prev = (k - cnt + k) % k;\n ans += dp[i][prev][j];\n }\n ans %= mod;\n cnt += s[i] - '0';\n }\n if(cnt % k == 0) ans++;\n ans = (ans - 1 + mod) % mod;\n cout << ans << '\\n';\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1598137053, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03178.html", "problem_id": "p03178", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03178/input.txt", "sample_output_relpath": "derived/input_output/data/p03178/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03178/C++/s551338760.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551338760", "user_id": "u635731706"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#include \n#define int long long\n#define maxn 10005\n#define maxc 105\nusing namespace std;\n\nconst int mod = 1e9 + 7;\n\n// len sum last\nint dp[maxn][maxc][10] = {};\nstring s;\nint n, k;\n\nint32_t main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cin >> s >> k;\n reverse(begin(s), end(s));\n n = s.size(); s = \"@\" + s;\n for(int i = 0; i < 10; i++) {\n dp[1][i % k][i] = 1;\n }\n for(int len = 2; len <= n; len++) {\n for(int sum = 0; sum < k; sum++) {\n for(int last = 0; last < 10; last++) {\n int prev = (sum - last + k) % k;\n for(int i = 0; i < 10; i++)\n dp[len][sum][last] += dp[len - 1][prev][i];\n dp[len][sum][last] %= mod;\n }\n }\n }\n int ans = 0, cnt = 0;\n for(int i = n; i > 0; i--) {\n for(int j = 0; j < (s[i] - '0'); j++) {\n int prev = (k - cnt + k) % k;\n ans += dp[i][prev][j];\n }\n ans %= mod;\n cnt += s[i] - '0';\n }\n if(cnt % k == 0) ans++;\n ans = (ans - 1 + mod) % mod;\n cout << ans << '\\n';\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "sample_input": "30\n4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03178", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1140, "cpu_time_ms": 212, "memory_kb": 85696}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s695061280", "group_id": "codeNet:p03178", "input_text": "#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 long double db;\ntypedef pair pii;\nconst int N=10000;\nconst db pi=acos(-1.0);\n#define lowbit(x) (x)&(-x)\n#define sqr(x) (x)*(x)\n#define rep(i,a,b) for (register int i=a;i<=b;i++)\n#define per(i,a,b) for (register int i=a;i>=b;i--)\n#define fir first\n#define sec second\n#define mp(a,b) make_pair(a,b)\n#define pb(a) push_back(a)\n#define maxd 1000000007\n#define eps 1e-8\nint n,d,a[100100],dp[10010][110][2];\nchar s[100100];\n\nint read()\n{\n int x=0,f=1;char ch=getchar();\n while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}\n while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}\n return x*f;\n}\n\nint dfs(int pos,int mod,int lim)\n{\n\tif (pos>n) dp[pos][mod][lim]=(mod==0);\n\tif (dp[pos][mod][lim]>-1) return dp[pos][mod][lim];\n\tint sum=0,up=9;\n\tif (lim) up=a[pos];\n\trep(i,0,up)\n\t{\n\t\tint tmp=dfs(pos+1,(mod+i)%d,lim&&(i==up));\n\t\tsum=(sum+tmp)%maxd;\n\t}\n\tdp[pos][mod][lim]=sum;\n\treturn sum;\n}\n\nint main()\n{\n\tscanf(\"%s\",s+1);d=read();n=strlen(s+1);\n\trep(i,1,n) a[i]=s[i]-'0';\n\tmemset(dp,-1,sizeof(dp));\n\tprintf(\"%d\",(dfs(1,0,1)+maxd-1)%maxd);\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1566018448, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03178.html", "problem_id": "p03178", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03178/input.txt", "sample_output_relpath": "derived/input_output/data/p03178/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03178/C++/s695061280.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695061280", "user_id": "u340402002"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "#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 long double db;\ntypedef pair pii;\nconst int N=10000;\nconst db pi=acos(-1.0);\n#define lowbit(x) (x)&(-x)\n#define sqr(x) (x)*(x)\n#define rep(i,a,b) for (register int i=a;i<=b;i++)\n#define per(i,a,b) for (register int i=a;i>=b;i--)\n#define fir first\n#define sec second\n#define mp(a,b) make_pair(a,b)\n#define pb(a) push_back(a)\n#define maxd 1000000007\n#define eps 1e-8\nint n,d,a[100100],dp[10010][110][2];\nchar s[100100];\n\nint read()\n{\n int x=0,f=1;char ch=getchar();\n while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}\n while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}\n return x*f;\n}\n\nint dfs(int pos,int mod,int lim)\n{\n\tif (pos>n) dp[pos][mod][lim]=(mod==0);\n\tif (dp[pos][mod][lim]>-1) return dp[pos][mod][lim];\n\tint sum=0,up=9;\n\tif (lim) up=a[pos];\n\trep(i,0,up)\n\t{\n\t\tint tmp=dfs(pos+1,(mod+i)%d,lim&&(i==up));\n\t\tsum=(sum+tmp)%maxd;\n\t}\n\tdp[pos][mod][lim]=sum;\n\treturn sum;\n}\n\nint main()\n{\n\tscanf(\"%s\",s+1);d=read();n=strlen(s+1);\n\trep(i,1,n) a[i]=s[i]-'0';\n\tmemset(dp,-1,sizeof(dp));\n\tprintf(\"%d\",(dfs(1,0,1)+maxd-1)%maxd);\n\treturn 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "sample_input": "30\n4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03178", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1304, "cpu_time_ms": 69, "memory_kb": 9728}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s401697873", "group_id": "codeNet:p03187", "input_text": "#include\nusing namespace std;\n\ntypedef long long lint;\ntypedef long double louble;\n\ntemplate inline T1 max(T1 a,T2 b){return a inline T1 min(T1 a,T2 b){return a>1,x=n-i-rx;\n\t\tans=max(ans,(sum(s,i,i+x-1)+sum(sr,n-rx+1,n))*2+(((n-i)&1)?rdis[n-rx]:dis[n-x]));\n\t}\n\treturn ans;\n}\n\nint main()\n{\n\tlen=ty(),n=ty();\n\tfor(int i=1;i<=n;i++)dis[i]=ty(),rdis[i]=len-dis[i],s[i]=s[i-1]+dis[i],sr[i]=sr[i-1]+rdis[i];\n\tlint ans=finder();\n\tfor(int i=1;i<=n;i++)dis[i]=len-dis[i];\n\treverse(dis+1,dis+n+1);\n\tfor(int i=1;i<=n;i++)rdis[i]=len-dis[i],s[i]=s[i-1]+dis[i],sr[i]=sr[i-1]+rdis[i];\n\tans=max(ans,finder());\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1576467353, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03187.html", "problem_id": "p03187", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03187/input.txt", "sample_output_relpath": "derived/input_output/data/p03187/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03187/C++/s401697873.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s401697873", "user_id": "u326034736"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "#include\nusing namespace std;\n\ntypedef long long lint;\ntypedef long double louble;\n\ntemplate inline T1 max(T1 a,T2 b){return a inline T1 min(T1 a,T2 b){return a>1,x=n-i-rx;\n\t\tans=max(ans,(sum(s,i,i+x-1)+sum(sr,n-rx+1,n))*2+(((n-i)&1)?rdis[n-rx]:dis[n-x]));\n\t}\n\treturn ans;\n}\n\nint main()\n{\n\tlen=ty(),n=ty();\n\tfor(int i=1;i<=n;i++)dis[i]=ty(),rdis[i]=len-dis[i],s[i]=s[i-1]+dis[i],sr[i]=sr[i-1]+rdis[i];\n\tlint ans=finder();\n\tfor(int i=1;i<=n;i++)dis[i]=len-dis[i];\n\treverse(dis+1,dis+n+1);\n\tfor(int i=1;i<=n;i++)rdis[i]=len-dis[i],s[i]=s[i-1]+dis[i],sr[i]=sr[i-1]+rdis[i];\n\tans=max(ans,finder());\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi.\nEach point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise.\n\nThere are N trees around the lake; the coordinate of the i-th tree is X_i. There is no tree at coordinate 0, the location of Takahashi's residence.\n\nStarting at his residence, Takahashi will repeat the following action:\n\nIf all trees are burnt, terminate the process.\n\nSpecify a direction: clockwise or counter-clockwise.\n\nWalk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time.\n\nWhen the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step.\n\nFind the longest possible total distance Takahashi walks during the process.\n\nPartial Score\n\nA partial score can be obtained in this problem:\n\n300 points will be awarded for passing the input satisfying N \\leq 2000.\n\nConstraints\n\n2 \\leq L \\leq 10^9\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_1 < ... < X_N \\leq L-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL N\nX_1\n:\nX_N\n\nOutput\n\nPrint the longest possible total distance Takahashi walks during the process.\n\nSample Input 1\n\n10 3\n2\n7\n9\n\nSample Output 1\n\n15\n\nTakahashi walks the distance of 15 if the process goes as follows:\n\nWalk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n\nWalk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n\nWalk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\nSample Input 2\n\n10 6\n1\n2\n3\n6\n7\n9\n\nSample Output 2\n\n27\n\nSample Input 3\n\n314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265\n\nSample Output 3\n\n1204124749", "sample_input": "10 3\n2\n7\n9\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03187", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi.\nEach point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise.\n\nThere are N trees around the lake; the coordinate of the i-th tree is X_i. There is no tree at coordinate 0, the location of Takahashi's residence.\n\nStarting at his residence, Takahashi will repeat the following action:\n\nIf all trees are burnt, terminate the process.\n\nSpecify a direction: clockwise or counter-clockwise.\n\nWalk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time.\n\nWhen the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step.\n\nFind the longest possible total distance Takahashi walks during the process.\n\nPartial Score\n\nA partial score can be obtained in this problem:\n\n300 points will be awarded for passing the input satisfying N \\leq 2000.\n\nConstraints\n\n2 \\leq L \\leq 10^9\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_1 < ... < X_N \\leq L-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL N\nX_1\n:\nX_N\n\nOutput\n\nPrint the longest possible total distance Takahashi walks during the process.\n\nSample Input 1\n\n10 3\n2\n7\n9\n\nSample Output 1\n\n15\n\nTakahashi walks the distance of 15 if the process goes as follows:\n\nWalk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n\nWalk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n\nWalk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\nSample Input 2\n\n10 6\n1\n2\n3\n6\n7\n9\n\nSample Output 2\n\n27\n\nSample Input 3\n\n314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265\n\nSample Output 3\n\n1204124749", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1288, "cpu_time_ms": 8, "memory_kb": 4992}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s346859959", "group_id": "codeNet:p03194", "input_text": "#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;\nconst int INF = 1<<30; \nconst int MOD = 1e9 + 7;\nconst int dy[] = {1, 0, -1, 0};\nconst int dx[] = {0, 1, 0, -1};\nmap mp;\nvoid prime_factor(ll n)\n{\n for(int i = 2; i * i <= n; i++)\n {\n while (n % i == 0)\n {\n mp[i]++;\n n /= i;\n }\n }\n if (n != 1) mp[n] = 1;\n}\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n ll n, p;\n cin >> n >> p;\n prime_factor(p);\n ll ans = 1LL;\n if(n == 1) cout << p << endl;\n else\n {\n for(auto x : mp)\n {\n if(x.second >= n)\n {\n ans *= x.first * (x.second / n);\n }\n }\n cout << ans << endl;\n }\n return 0;\n}\n\n", "language": "C++", "metadata": {"date": 1545534145, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03194.html", "problem_id": "p03194", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03194/input.txt", "sample_output_relpath": "derived/input_output/data/p03194/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03194/C++/s346859959.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s346859959", "user_id": "u952094438"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#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;\nconst int INF = 1<<30; \nconst int MOD = 1e9 + 7;\nconst int dy[] = {1, 0, -1, 0};\nconst int dx[] = {0, 1, 0, -1};\nmap mp;\nvoid prime_factor(ll n)\n{\n for(int i = 2; i * i <= n; i++)\n {\n while (n % i == 0)\n {\n mp[i]++;\n n /= i;\n }\n }\n if (n != 1) mp[n] = 1;\n}\nint main()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n ll n, p;\n cin >> n >> p;\n prime_factor(p);\n ll ans = 1LL;\n if(n == 1) cout << p << endl;\n else\n {\n for(auto x : mp)\n {\n if(x.second >= n)\n {\n ans *= x.first * (x.second / n);\n }\n }\n cout << ans << endl;\n }\n return 0;\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03194", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 973, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s334347386", "group_id": "codeNet:p03196", "input_text": "#include \n#define fr(i, n, m) for(int i = (n); i < (m); i ++)\n#define pb push_back\n#define pq priority_queue\n#define st first\n#define nd second\n\nusing namespace std;\ntypedef long long ll;\nll const inf = 1e9;\nll const mod = 998244353 ;\n\nint main()\n{\n ll n, p;\n cin >> n >> p;\n ll prime = 2;\n ll c = 0;\n ll gcd = 1;\n while(p > 1){\n if(p % prime == 0){\n c ++;\n p /= prime;\n }\n else{\n gcd = gcd * max(1LL, (c / n) * prime);\n c = 0;\n prime ++;\n }\n\n }\n if(c > 0) gcd = gcd * max(1LL, c / n * prime);\n cout << gcd << endl;\n\n return 0;\n\n}\n", "language": "C++", "metadata": {"date": 1546074946, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/C++/s334347386.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s334347386", "user_id": "u858402748"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#define fr(i, n, m) for(int i = (n); i < (m); i ++)\n#define pb push_back\n#define pq priority_queue\n#define st first\n#define nd second\n\nusing namespace std;\ntypedef long long ll;\nll const inf = 1e9;\nll const mod = 998244353 ;\n\nint main()\n{\n ll n, p;\n cin >> n >> p;\n ll prime = 2;\n ll c = 0;\n ll gcd = 1;\n while(p > 1){\n if(p % prime == 0){\n c ++;\n p /= prime;\n }\n else{\n gcd = gcd * max(1LL, (c / n) * prime);\n c = 0;\n prime ++;\n }\n\n }\n if(c > 0) gcd = gcd * max(1LL, c / n * prime);\n cout << gcd << endl;\n\n return 0;\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 660, "cpu_time_ms": 2103, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s151969817", "group_id": "codeNet:p03196", "input_text": "#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#define mp make_pair\n#define pb push_back\n#define re return\n#define fi first\n#define se second\ntypedef vector vi;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef vector vs;\ntypedef vector vvi;\nlong long n,p,sum=1;\nint mx=1;\nlong long cnt[1000100]; \nint main() {\n //freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n\tcin>>n>>p;\n\tif(n==1){\n\t\tcout<=n){\n\t\t\tint t=cnt[i]/n;\n\t\t\tfor(int j=0;j\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#define mp make_pair\n#define pb push_back\n#define re return\n#define fi first\n#define se second\ntypedef vector vi;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef vector vs;\ntypedef vector vvi;\nlong long n,p,sum=1;\nint mx=1;\nlong long cnt[1000100]; \nint main() {\n //freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n\tcin>>n>>p;\n\tif(n==1){\n\t\tcout<=n){\n\t\t\tint t=cnt[i]/n;\n\t\t\tfor(int j=0;j\n#include \n\nusing namespace std;\n\nint main() {\n long long n, m;\n scanf(\"%lld %lld\", &n, &m);\n map cnt;\n for (long long i = 2; i * i <= m; ++i) {\n while (m % i == 0) {\n ++cnt[i];\n m /= i;\n }\n }\n if (m > 1) {\n ++cnt[m];\n }\n long long ans = 1;\n for (auto &e : cnt) {\n for (int i = 0; i < e.second / n; ++i) {\n ans *= e.first;\n }\n }\n printf(\"%lld\\n\", ans);\n}\n", "language": "C++", "metadata": {"date": 1545530777, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03196/input.txt", "sample_output_relpath": "derived/input_output/data/p03196/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03196/C++/s975525024.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975525024", "user_id": "u127130661"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \n\nusing namespace std;\n\nint main() {\n long long n, m;\n scanf(\"%lld %lld\", &n, &m);\n map cnt;\n for (long long i = 2; i * i <= m; ++i) {\n while (m % i == 0) {\n ++cnt[i];\n m /= i;\n }\n }\n if (m > 1) {\n ++cnt[m];\n }\n long long ans = 1;\n for (auto &e : cnt) {\n for (int i = 0; i < e.second / n; ++i) {\n ans *= e.first;\n }\n }\n printf(\"%lld\\n\", ans);\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03196", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 434, "cpu_time_ms": 6, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s236450131", "group_id": "codeNet:p03197", "input_text": "#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;\ntypedef pair P;\n\nconst ll mod = 1e9 + 7;\n\nvector dx = {1, -1, 0, 0};\nvector dy = {0, 0, 1, -1};\n\nvector> g;\n\n\nint main() {\n \n \n cin.tie(0);\n ios_base::sync_with_stdio(0);\n \n ll n;\n cin >> n;\n bool f = 0;\n for (int i = 0; i < n; ++i)\n {\n ll tmp;\n cin >> tmp;\n tmp %= 2ll;\n if (tmp)\n {\n f = 1;\n }\n }\n if (f)\n {\n cout << \"first\" <\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;\ntypedef pair P;\n\nconst ll mod = 1e9 + 7;\n\nvector dx = {1, -1, 0, 0};\nvector dy = {0, 0, 1, -1};\n\nvector> g;\n\n\nint main() {\n \n \n cin.tie(0);\n ios_base::sync_with_stdio(0);\n \n ll n;\n cin >> n;\n bool f = 0;\n for (int i = 0; i < n; ++i)\n {\n ll tmp;\n cin >> tmp;\n tmp %= 2ll;\n if (tmp)\n {\n f = 1;\n }\n }\n if (f)\n {\n cout << \"first\" <\nusing namespace std;\n\nint main() {\n string S;\n cin>>S;\n long long w=0LL,sum=0LL;\n for(int i=0;i\nusing namespace std;\n\nint main() {\n string S;\n cin>>S;\n long long w=0LL,sum=0LL;\n for(int i=0;i\n#include \nusing namespace std;\n#define ll long long\n#define mod107 1000000007\n#define rep(i, n) for (int i = 0; i < n; ++i)\nusing Graph = vector>;\n#define grepq priority_queue, std::greater>\n#define all(v) v.begin(), v.end()\n#define PI acos(-1)\n \ntemplate \ninline bool chmin(T &a, T b)\n{\n if (a > b)\n {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \ninline bool chmax(T &a, T b)\n{\n if (a < b)\n {\n a = b;\n return true;\n }\n return false;\n}\nconst ll INF = 10010001010;\nconst int inf = 1000034000;\n \nconst int dx[4] = {1, 0, -1, 0};\nconst int dy[4] = {0, 1, 0, -1};\n \nint main() {\n string S;\n cin >> S;\n int N = S.size();\n int black = 0;\n int ans = 0;\n for(int i = 0;i < N;i++){\n if(S[i] == 'B'){\n black++;\n }\n else{\n ans += black;\n }\n }\n cout << ans << endl;\n \n}\n", "language": "C++", "metadata": {"date": 1592450722, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03200/input.txt", "sample_output_relpath": "derived/input_output/data/p03200/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03200/C++/s551348739.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551348739", "user_id": "u935370883"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n#define ll long long\n#define mod107 1000000007\n#define rep(i, n) for (int i = 0; i < n; ++i)\nusing Graph = vector>;\n#define grepq priority_queue, std::greater>\n#define all(v) v.begin(), v.end()\n#define PI acos(-1)\n \ntemplate \ninline bool chmin(T &a, T b)\n{\n if (a > b)\n {\n a = b;\n return true;\n }\n return false;\n}\ntemplate \ninline bool chmax(T &a, T b)\n{\n if (a < b)\n {\n a = b;\n return true;\n }\n return false;\n}\nconst ll INF = 10010001010;\nconst int inf = 1000034000;\n \nconst int dx[4] = {1, 0, -1, 0};\nconst int dy[4] = {0, 1, 0, -1};\n \nint main() {\n string S;\n cin >> S;\n int N = S.size();\n int black = 0;\n int ans = 0;\n for(int i = 0;i < N;i++){\n if(S[i] == 'B'){\n black++;\n }\n else{\n ans += black;\n }\n }\n cout << ans << endl;\n \n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 948, "cpu_time_ms": 9, "memory_kb": 640}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s868718917", "group_id": "codeNet:p03201", "input_text": "#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\nusing ll = long long;\nusing ull = unsigned long long;\n\n//vector\ntemplate \nusing vec = std::vector;\n\ntemplate \nusing vvec = vec>;\n\nconstexpr std::size_t operator\"\"_sz(ull n) { return std::size_t(n); }\n\nint main()\n{\n using namespace std;\n\n int n;\n cin >> n;\n vec v(n);\n vec used(n);\n set se;\n\n vec pow2(32);\n pow2[0] = 1;\n for (int i = 1; i < 32; ++i)\n {\n pow2[i] = pow2[i - 1] * 2;\n }\n\n for (auto &e : v)\n {\n cin >> e;\n se.emplace(e);\n }\n\n sort(v.begin(), v.end());\n\n int ans{};\n\n for (int i = n - 1; i >= 0; --i)\n {\n if (used[i])\n continue;\n\n auto target = *upper_bound(pow2.cbegin(), pow2.cend(), v[i]);\n\n auto find = se.find(target - v[i]);\n\n if (find != se.end() && target != v[i])\n {\n auto val = *find;\n se.erase(val);\n\n auto index = distance(v.begin(), upper_bound(v.begin(), v.end(), val));\n used[index] = true;\n used[i] = true;\n ++ans;\n }\n }\n\n cout << ans << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1544929937, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/C++/s868718917.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s868718917", "user_id": "u207917850"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#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\nusing ll = long long;\nusing ull = unsigned long long;\n\n//vector\ntemplate \nusing vec = std::vector;\n\ntemplate \nusing vvec = vec>;\n\nconstexpr std::size_t operator\"\"_sz(ull n) { return std::size_t(n); }\n\nint main()\n{\n using namespace std;\n\n int n;\n cin >> n;\n vec v(n);\n vec used(n);\n set se;\n\n vec pow2(32);\n pow2[0] = 1;\n for (int i = 1; i < 32; ++i)\n {\n pow2[i] = pow2[i - 1] * 2;\n }\n\n for (auto &e : v)\n {\n cin >> e;\n se.emplace(e);\n }\n\n sort(v.begin(), v.end());\n\n int ans{};\n\n for (int i = n - 1; i >= 0; --i)\n {\n if (used[i])\n continue;\n\n auto target = *upper_bound(pow2.cbegin(), pow2.cend(), v[i]);\n\n auto find = se.find(target - v[i]);\n\n if (find != se.end() && target != v[i])\n {\n auto val = *find;\n se.erase(val);\n\n auto index = distance(v.begin(), upper_bound(v.begin(), v.end(), val));\n used[index] = true;\n used[i] = true;\n ++ans;\n }\n }\n\n cout << ans << endl;\n\n return 0;\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1578, "cpu_time_ms": 187, "memory_kb": 10368}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s120203617", "group_id": "codeNet:p03203", "input_text": "#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\ntypedef unsigned uint;\ntypedef long long Int;\ntypedef unsigned long long UInt;\n\nconst int INF = 1001001001;\nconst Int INFLL = 1001001001001001001LL;\n\ntemplate void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << \" \"; cout << endl; }\ntemplate void chmin(T& a, T b) { if (a > b) a = b; }\ntemplate void chmax(T& a, T b) { if (a < b) a = b; }\nint in() { int x; scanf(\"%d\", &x); return x; }\ndouble fin() { double x; scanf(\"%lf\", &x); return x; }\nInt lin() { Int x; scanf(\"%lld\", &x); return x; }\n\nint main() {\n int H = in();\n int W = in();\n int N = in();\n set> X;\n for (int i = 0; i < N; ++i) {\n int r = in() - 1;\n int c = in() - 1;\n X.insert(make_pair(r, c));\n }\n\n vector top(W, INF);\n int ar = 0, ac = 0;\n while (true) {\n chmin(top[ac], ar);\n ++ar;\n if (ar >= H) {\n break;\n }\n if (X.count(make_pair(ar, ac + 1)) == 0) {\n ++ac;\n }\n }\n\n int res = H;\n for (const auto& p : X) {\n if (top[p.second] < p.first) {\n chmin(res, p.first);\n }\n }\n printf(\"%d\\n\", res);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1544928783, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03203.html", "problem_id": "p03203", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03203/input.txt", "sample_output_relpath": "derived/input_output/data/p03203/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03203/C++/s120203617.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s120203617", "user_id": "u965315642"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#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\ntypedef unsigned uint;\ntypedef long long Int;\ntypedef unsigned long long UInt;\n\nconst int INF = 1001001001;\nconst Int INFLL = 1001001001001001001LL;\n\ntemplate void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << \" \"; cout << endl; }\ntemplate void chmin(T& a, T b) { if (a > b) a = b; }\ntemplate void chmax(T& a, T b) { if (a < b) a = b; }\nint in() { int x; scanf(\"%d\", &x); return x; }\ndouble fin() { double x; scanf(\"%lf\", &x); return x; }\nInt lin() { Int x; scanf(\"%lld\", &x); return x; }\n\nint main() {\n int H = in();\n int W = in();\n int N = in();\n set> X;\n for (int i = 0; i < N; ++i) {\n int r = in() - 1;\n int c = in() - 1;\n X.insert(make_pair(r, c));\n }\n\n vector top(W, INF);\n int ar = 0, ac = 0;\n while (true) {\n chmin(top[ac], ar);\n ++ar;\n if (ar >= H) {\n break;\n }\n if (X.count(make_pair(ar, ac + 1)) == 0) {\n ++ac;\n }\n }\n\n int res = H;\n for (const auto& p : X) {\n if (top[p.second] < p.first) {\n chmin(res, p.first);\n }\n }\n printf(\"%d\\n\", res);\n return 0;\n}\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game using a grid with H rows and W columns of square cells.\nThere are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i).\nHere, we represent the cell at the i-th row and j-th column (1 \\leq i \\leq H, 1 \\leq j \\leq W) by (i,j).\nThere is no obstacle at (1,1), and there is a piece placed there at (1,1).\n\nStarting from Takahashi, he and Aoki alternately perform one of the following actions:\n\nMove the piece to an adjacent cell.\nHere, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1).\nIf the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken.\n\nDo not move the piece, and end his turn without affecting the grid.\n\nThe game ends when the piece does not move twice in a row.\n\nTakahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends.\nHow many actions will Takahashi end up performing?\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n0 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_i \\leq H\n\n1 \\leq Y_i \\leq W\n\nIf i \\neq j, (X_i,Y_i) \\neq (X_j,Y_j)\n\n(X_i,Y_i) \\neq (1,1)\n\nX_i and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\nX_1 Y_1\n:\nX_N Y_N\n\nOutput\n\nPrint the number of actions Takahashi will end up performing.\n\nSample Input 1\n\n3 3 1\n3 2\n\nSample Output 1\n\n2\n\nFor example, the game proceeds as follows:\n\nTakahashi moves the piece to (2,1).\n\nAoki does not move the piece.\n\nTakahashi moves the piece to (3,1).\n\nAoki does not move the piece.\n\nTakahashi does not move the piece.\n\nTakahashi performs three actions in this case, but if both players play optimally, Takahashi will perform only two actions before the game ends.\n\nSample Input 2\n\n10 10 14\n4 3\n2 2\n7 3\n9 10\n7 7\n8 1\n10 10\n5 4\n3 4\n2 8\n6 4\n4 4\n5 8\n9 2\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100000 100000 0\n\nSample Output 3\n\n100000", "sample_input": "3 3 1\n3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03203", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game using a grid with H rows and W columns of square cells.\nThere are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i).\nHere, we represent the cell at the i-th row and j-th column (1 \\leq i \\leq H, 1 \\leq j \\leq W) by (i,j).\nThere is no obstacle at (1,1), and there is a piece placed there at (1,1).\n\nStarting from Takahashi, he and Aoki alternately perform one of the following actions:\n\nMove the piece to an adjacent cell.\nHere, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1).\nIf the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken.\n\nDo not move the piece, and end his turn without affecting the grid.\n\nThe game ends when the piece does not move twice in a row.\n\nTakahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends.\nHow many actions will Takahashi end up performing?\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n0 \\leq N \\leq 2\\times 10^5\n\n1 \\leq X_i \\leq H\n\n1 \\leq Y_i \\leq W\n\nIf i \\neq j, (X_i,Y_i) \\neq (X_j,Y_j)\n\n(X_i,Y_i) \\neq (1,1)\n\nX_i and Y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W N\nX_1 Y_1\n:\nX_N Y_N\n\nOutput\n\nPrint the number of actions Takahashi will end up performing.\n\nSample Input 1\n\n3 3 1\n3 2\n\nSample Output 1\n\n2\n\nFor example, the game proceeds as follows:\n\nTakahashi moves the piece to (2,1).\n\nAoki does not move the piece.\n\nTakahashi moves the piece to (3,1).\n\nAoki does not move the piece.\n\nTakahashi does not move the piece.\n\nTakahashi performs three actions in this case, but if both players play optimally, Takahashi will perform only two actions before the game ends.\n\nSample Input 2\n\n10 10 14\n4 3\n2 2\n7 3\n9 10\n7 7\n8 1\n10 10\n5 4\n3 4\n2 8\n6 4\n4 4\n5 8\n9 2\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100000 100000 0\n\nSample Output 3\n\n100000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1479, "cpu_time_ms": 249, "memory_kb": 10368}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s476434068", "group_id": "codeNet:p03210", "input_text": "#include\nusing namespace std;\nint main(){\n int age;\n cin >> age;\n if(age == 3 || age==5 || age==7) cout << \"YES\" << endl;\n else cout << \"NO\" <\nusing namespace std;\nint main(){\n int age;\n cin >> age;\n if(age == 3 || age==5 || age==7) cout << \"YES\" << endl;\n else cout << \"NO\" <\n#include \n#include \nusing namespace std;\n\nint main(){\n string S;\n cin >> S;\n \n int n =S.size();\n int x = 999;\n for(int i=0;i\n#include \n#include \nusing namespace std;\n\nint main(){\n string S;\n cin >> S;\n \n int n =S.size();\n int x = 999;\n for(int i=0;i\nusing namespace std;\nint main(){\n\tstring s,x;\n\tint mi;\n\tcin>>s;\n\tmi=1000;\n\tfor(int i=0;i\nusing namespace std;\nint main(){\n\tstring s,x;\n\tint mi;\n\tcin>>s;\n\tmi=1000;\n\tfor(int i=0;i\n#include \n\nlong long dp[11][2][8];\n\nint main()\n{\n char s[12];\n scanf(\"%s\", s);\n dp[0][0][0] = 1;\n int i;\n for (i = 0; s[i]; ++i)\n {\n int D = s[i] - '0';\n for (int j = 0; j < 2; ++j)\n {\n for (int m = 0; m < (1 << 3); ++m)\n {\n for (int k = 0; k <= (j ? 9 : D); ++k)\n {\n if (k != 3 && k != 5 && k != 7) continue;\n dp[i + 1][j || k < D][m | (k == 3 ? 1 : k == 5 ? 2 : 4)] += dp[i][j][m];\n }\n }\n }\n }\n long long ans = 0;\n for (long long j = 3; j < (long long)i; ++j)\n {\n ans += (long long)std::pow(3, j) - 3 * (long long)std::pow(2, j) + 3;\n }\n printf(\"%lld\\n\", dp[i][0][7] + dp[i][1][7] + ans);\n return 0;\n}", "language": "C++", "metadata": {"date": 1570437766, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03212/input.txt", "sample_output_relpath": "derived/input_output/data/p03212/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03212/C++/s679635304.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679635304", "user_id": "u931819817"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#include \n#include \n\nlong long dp[11][2][8];\n\nint main()\n{\n char s[12];\n scanf(\"%s\", s);\n dp[0][0][0] = 1;\n int i;\n for (i = 0; s[i]; ++i)\n {\n int D = s[i] - '0';\n for (int j = 0; j < 2; ++j)\n {\n for (int m = 0; m < (1 << 3); ++m)\n {\n for (int k = 0; k <= (j ? 9 : D); ++k)\n {\n if (k != 3 && k != 5 && k != 7) continue;\n dp[i + 1][j || k < D][m | (k == 3 ? 1 : k == 5 ? 2 : 4)] += dp[i][j][m];\n }\n }\n }\n }\n long long ans = 0;\n for (long long j = 3; j < (long long)i; ++j)\n {\n ans += (long long)std::pow(3, j) - 3 * (long long)std::pow(2, j) + 3;\n }\n printf(\"%lld\\n\", dp[i][0][7] + dp[i][1][7] + ans);\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 710, "cpu_time_ms": 1, "memory_kb": 128}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s664475550", "group_id": "codeNet:p03219", "input_text": "//author:luckYrat(twitter:@luckYrat_)\n//#include \n\n//def\n#include \n\n#include \n#include \n#include \n\n//array\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\nusing namespace std;\n\nusing ll = long long;\nusing P = pair;\n\n#define anyfill(n,s) setw(n) << setfill(s)\n#define loop(s) for(int i = 0; s > i; i++)\n#define rep(i,q) for(int i = 0; (q) > i; i++)\n#define repp(i,n,q) for(int i = n; (q) > i; i++)\n#define dep(i,q) for(int i = (q); 0 < i; i--)\n\n\n#define MAX 1000000000\nconst int mod = 1000000007;\n#define EPS (1e-10)\n\n#define pb push_back\n#define fir first\n#define scn second\n#define ednl endl\n\n#define YesNo(a) (a?\"Yes\":\"No\")\n#define YESNO(a) (a?\"YES\":\"NO\")\n#define yesno(a) (a?\"yes\":\"no\")\n\n\nP ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};\nP ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};\n/*\n確認ポイント\ncout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる\nvector.unique()は隣接した同じ要素を削除するので先にソートをする\n\n計算量は変わらないが楽できるシリーズ\nC++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる\nmin(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる\ncount(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる\n\n*/\n__attribute__((constructor))\nvoid initial() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n}\n\n\n\nint main(){\n int a,b;cin>>a>>b;\n cout << a+b/2 << endl;\n}\n", "language": "C++", "metadata": {"date": 1583804408, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/C++/s664475550.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664475550", "user_id": "u466161487"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "//author:luckYrat(twitter:@luckYrat_)\n//#include \n\n//def\n#include \n\n#include \n#include \n#include \n\n//array\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\nusing namespace std;\n\nusing ll = long long;\nusing P = pair;\n\n#define anyfill(n,s) setw(n) << setfill(s)\n#define loop(s) for(int i = 0; s > i; i++)\n#define rep(i,q) for(int i = 0; (q) > i; i++)\n#define repp(i,n,q) for(int i = n; (q) > i; i++)\n#define dep(i,q) for(int i = (q); 0 < i; i--)\n\n\n#define MAX 1000000000\nconst int mod = 1000000007;\n#define EPS (1e-10)\n\n#define pb push_back\n#define fir first\n#define scn second\n#define ednl endl\n\n#define YesNo(a) (a?\"Yes\":\"No\")\n#define YESNO(a) (a?\"YES\":\"NO\")\n#define yesno(a) (a?\"yes\":\"no\")\n\n\nP ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};\nP ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};\n/*\n確認ポイント\ncout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる\nvector.unique()は隣接した同じ要素を削除するので先にソートをする\n\n計算量は変わらないが楽できるシリーズ\nC++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる\nmin(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる\ncount(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる\n\n*/\n__attribute__((constructor))\nvoid initial() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n}\n\n\n\nint main(){\n int a,b;cin>>a>>b;\n cout << a+b/2 << endl;\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1592, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s283060593", "group_id": "codeNet:p03219", "input_text": "#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define repr(i, n) for (int i = (n); i >= 0; --i)\n#define FOR(i, m, n) for (int i = (m); i < (n); ++i)\n#define FORR(i, m, n) for (int i = (m); i >= (n); --i)\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1000000007;\nconst ll mod2 = 998244353;\n\nint main() {\n int x, y;\n cin >> x >> y;\n cout << x+y/2 << endl;\n}", "language": "C++", "metadata": {"date": 1569344514, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/C++/s283060593.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s283060593", "user_id": "u759721333"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "#include \n#define rep(i, n) for (int i = 0; i < (n); ++i)\n#define repr(i, n) for (int i = (n); i >= 0; --i)\n#define FOR(i, m, n) for (int i = (m); i < (n); ++i)\n#define FORR(i, m, n) for (int i = (m); i >= (n); --i)\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1000000007;\nconst ll mod2 = 998244353;\n\nint main() {\n int x, y;\n cin >> x >> y;\n cout << x+y/2 << endl;\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 397, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s698428971", "group_id": "codeNet:p03219", "input_text": "#pragma GCC optimize \"-O3\"\n#pragma GCC target (\"avx\")\n#define _USE_MATH_DEFINES\n#include\n#define int long long\n#define rep(i,n) for(int i=0;i\n#define vvi vector\n#define pb push_back\n#define pi pair\n#define vp vector>\n#define mp make_pair\n#define all(v) (v).begin(),(v).end()\n#define fi first\n#define se second\n#define inf (1ll<<60)\n#define SORT(v) sort(all(v))\n#define RSORT(v) sort(all(v),greater())\nsigned gcd(int a, int b){return b?gcd(b,a%b):a;}\nsigned lcm(int a,int b){return a*b/gcd(a,b);}\n\nusing namespace std;\n\nconst int mod=1e9+7;\n\nvoid run();\n\nvoid init() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout<> x >> y;\n cout << x+y/2 << endl;\n}", "language": "C++", "metadata": {"date": 1563222798, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/C++/s698428971.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698428971", "user_id": "u775507068"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "#pragma GCC optimize \"-O3\"\n#pragma GCC target (\"avx\")\n#define _USE_MATH_DEFINES\n#include\n#define int long long\n#define rep(i,n) for(int i=0;i\n#define vvi vector\n#define pb push_back\n#define pi pair\n#define vp vector>\n#define mp make_pair\n#define all(v) (v).begin(),(v).end()\n#define fi first\n#define se second\n#define inf (1ll<<60)\n#define SORT(v) sort(all(v))\n#define RSORT(v) sort(all(v),greater())\nsigned gcd(int a, int b){return b?gcd(b,a%b):a;}\nsigned lcm(int a,int b){return a*b/gcd(a,b);}\n\nusing namespace std;\n\nconst int mod=1e9+7;\n\nvoid run();\n\nvoid init() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout<> x >> y;\n cout << x+y/2 << endl;\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 860, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s750022109", "group_id": "codeNet:p03219", "input_text": "#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\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vec;\n\n\nint main()\n{\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint x, y; cin >> x >> y;\n\tcout << x + y / 2;\n\n\n\treturn 0;\n\n}", "language": "C++", "metadata": {"date": 1541383271, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/C++/s750022109.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s750022109", "user_id": "u844155089"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "#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\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vec;\n\n\nint main()\n{\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint x, y; cin >> x >> y;\n\tcout << x + y / 2;\n\n\n\treturn 0;\n\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 6, "memory_kb": 768}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s482737238", "group_id": "codeNet:p03220", "input_text": "#include\n#define rep(i,n) for (int i = 0; i < n; ++i)\n#define rep2(i,s,n) for (int i = s; i < n; ++i)\n#define all(a) a.begin(),a.end()\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n int n,t,a;\n cin >> n >> t >> a;\n int ans;\n double now = 1001001001;\n rep(i,n) {\n int h;\n cin >> h;\n double nt = t-nt*0.006;\n double dif = abs(nt-a);\n if(dif < now) {\n now = dif;\n ans = i+1;\n }\n }\n cout << ans << endl;\n}", "language": "C++", "metadata": {"date": 1583970392, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/C++/s482737238.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s482737238", "user_id": "u853721692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\n#define rep(i,n) for (int i = 0; i < n; ++i)\n#define rep2(i,s,n) for (int i = s; i < n; ++i)\n#define all(a) a.begin(),a.end()\nusing namespace std;\nusing ll = long long;\nusing P = pair;\n\nint main() {\n int n,t,a;\n cin >> n >> t >> a;\n int ans;\n double now = 1001001001;\n rep(i,n) {\n int h;\n cin >> h;\n double nt = t-nt*0.006;\n double dif = abs(nt-a);\n if(dif < now) {\n now = dif;\n ans = i+1;\n }\n }\n cout << ans << endl;\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 537, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s945304034", "group_id": "codeNet:p03220", "input_text": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n// define list\n\n\nnamespace math{\n const double PI = 3.14;\n const int INF = 1000000007;\n int GCM(int a,int b); //最大公約数\n int LCM(int a,int b); //最小公倍数\n int Pemu(int n,int r); //順列\n int Comb(int n,int m); //組み合わせ\n int Digit(int N); //桁和\n \n int GCM(int a,int b){\n if(a=10)\n {\n r += (N%10);\n N /= 10;\n }\n r += N;\n return r;\n }\n}\n\nnamespace SubLib{\n #define int long long\n #define double long double\n #define incin(n) int (n); cin >> (n);\n #define incin2(a,b) int a,b; cin >> a >> b; \n #define rap(n,i) for(int (i) = 0;i<(n);(i)++)\n #define input(n,v) (v) = SubLib::Input((n),(v))\n #define all(v) (v).begin(),(v).end()\n using intv = vector;\n using strv = vector;\n using charv = vector;\n template \n using pvec = vector>;\n template vector Input(int n,vector v){\n for(int i=0;i> v.at(i);\n }\n return v;\n }\n}\n\nusing namespace math;\nusing namespace SubLib;\ndouble Kion(int X,int T){\n return T -X * 0.006;\n}\n\nsigned main(){\n incin(n);\n incin2(t,a);\n intv h(n);\n input(n,h);\n int log_dif = 1000000000;\n int point;\n rap(n,i){ \n if(abs(Kion(h[i],t)-a)\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n// define list\n\n\nnamespace math{\n const double PI = 3.14;\n const int INF = 1000000007;\n int GCM(int a,int b); //最大公約数\n int LCM(int a,int b); //最小公倍数\n int Pemu(int n,int r); //順列\n int Comb(int n,int m); //組み合わせ\n int Digit(int N); //桁和\n \n int GCM(int a,int b){\n if(a=10)\n {\n r += (N%10);\n N /= 10;\n }\n r += N;\n return r;\n }\n}\n\nnamespace SubLib{\n #define int long long\n #define double long double\n #define incin(n) int (n); cin >> (n);\n #define incin2(a,b) int a,b; cin >> a >> b; \n #define rap(n,i) for(int (i) = 0;i<(n);(i)++)\n #define input(n,v) (v) = SubLib::Input((n),(v))\n #define all(v) (v).begin(),(v).end()\n using intv = vector;\n using strv = vector;\n using charv = vector;\n template \n using pvec = vector>;\n template vector Input(int n,vector v){\n for(int i=0;i> v.at(i);\n }\n return v;\n }\n}\n\nusing namespace math;\nusing namespace SubLib;\ndouble Kion(int X,int T){\n return T -X * 0.006;\n}\n\nsigned main(){\n incin(n);\n incin2(t,a);\n intv h(n);\n input(n,h);\n int log_dif = 1000000000;\n int point;\n rap(n,i){ \n if(abs(Kion(h[i],t)-a)\nusing namespace std;\nusing ll = long long;\nusing product = pair;\nusing vvll = vector>;\nusing vll = vector;\n\nint main()\n{\n ll N,M;\n cin>>N>>M;\n vll P(M);\n vll Y(M);\n for(ll i=0;i>P[i]>>Y[i];\n --P[i];\n }\n vvll vals(N);\n for(ll i=0;i\nusing namespace std;\nusing ll = long long;\nusing product = pair;\nusing vvll = vector>;\nusing vll = vector;\n\nint main()\n{\n ll N,M;\n cin>>N>>M;\n vll P(M);\n vll Y(M);\n for(ll i=0;i>P[i]>>Y[i];\n --P[i];\n }\n vvll vals(N);\n for(ll i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nconst int mod = 1e9 + 7;\nconst int kmax = 510000;\nconst int last_days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n\nlong long fact[kmax], fact_inv[kmax], inv[kmax];\n\nvoid init_comb()\n{\n fact[0] = fact[1] = 1;\n fact_inv[0] = fact_inv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < kmax; i++) {\n fact[i] = fact[i - 1] * i % mod;\n inv[i] = mod - inv[mod % i] * (mod / i) % mod;\n fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;\n }\n}\n\nlong long comb(int n, int r)\n{\n if (n < r) {\n return 0;\n }\n\n if (n < 0 || r < 0) {\n return 0;\n }\n\n return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;\n}\n\ntemplate \nclass UnionFind {\n T parent_[N];\n T rank_[N];\n T size_[N];\n\npublic:\n UnionFind();\n T Root(T idx);\n bool IsSame(T x, T y);\n void Unite(T x, T y);\n T GetSize(T idx);\n};\n\ntemplate \nUnionFind::UnionFind()\n{\n for (T i = 0; i < N; i++) {\n parent_[i] = i;\n rank_[i] = 0;\n size_[i] = 1;\n }\n}\n\ntemplate \nT UnionFind::Root(T idx)\n{\n return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);\n}\n\ntemplate \nbool UnionFind::IsSame(T x, T y)\n{\n return Root(x) == Root(y);\n}\n\ntemplate \nvoid UnionFind::Unite(T x, T y)\n{\n x = Root(x);\n y = Root(y);\n if (x == y) {\n return;\n }\n\n if (rank_[x] < rank_[y]) {\n parent_[x] = y;\n size_[y] += size_[x];\n } else {\n parent_[y] = x;\n size_[x] += size_[y];\n if (rank_[x] == rank_[y]) {\n rank_[x]++;\n }\n }\n}\n\ntemplate \nT UnionFind::GetSize(T idx)\n{\n return size_[Root(idx)];\n}\n\nlong long pow_mod(long long n, long long p, long long m)\n{\n if (p == 0) {\n return 1;\n }\n\n if (p % 2 == 0) {\n long long t = pow_mod(n, p / 2, m);\n return t * t % m;\n }\n return n * pow_mod(n, p - 1, m) % mod;\n}\n\nlong long nCr_mod(long long n, long long r)\n{\n long long x = 1;\n for (long long i = n - r + 1; i <= n; i++) {\n x *= i;\n x %= mod;\n }\n\n long long a = 1;\n for (long long i = 1; i <= r; i++) {\n a *= i;\n a %= mod;\n }\n\n long long y = pow_mod(a, mod - 2, mod) % mod;\n\n return x * y % mod;\n}\n\nbool is_prime(long long n)\n{\n if (n == 1) {\n return false;\n }\n\n for (long long i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n\n return true;\n}\n\nbool is_leap(long long y)\n{\n return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;\n}\n\nvoid next_day(long long& y, long long& m, long long& d)\n{\n d++;\n\n if (d > last_days[m - 1] + (m == 2 && is_leap(y) ? 1 : 0)) {\n d = 1;\n m++;\n }\n\n if (m > 12) {\n y++;\n m = 1;\n }\n}\n\nlong long fib(long long n)\n{\n long long a = 0, b = 1;\n for (int i = 0; i < n; i++) {\n long long t = a;\n a = b;\n b = a + t;\n }\n\n return a;\n}\n\nstd::vector argsort(const std::vector& v)\n{\n std::vector indices(v.size());\n std::iota(indices.begin(), indices.end(), 0);\n\n std::sort(indices.begin(), indices.end(), [&v](size_t i, size_t j) { return v[i] < v[j]; });\n\n for (auto i = 0LU; i < indices.size(); i++) {\n indices[i]++;\n }\n\n return indices;\n}\n\nint main()\n{\n long long n, m;\n std::cin >> n >> m;\n\n std::vector p(m), y(m);\n\n for (int i = 0; i < m; i++) {\n std::cin >> p[i] >> y[i];\n p[i]--;\n }\n\n std::vector> nums(n);\n\n for (int i = 0; i < m; i++) {\n nums[p[i]].push_back(y[i]);\n }\n\n for (int i = 0; i < n; i++) {\n std::reverse(nums[i].begin(), nums[i].end());\n }\n\n std::vector> args(n);\n for (int i = 0; i < n; i++) {\n args[i] = argsort(nums[i]);\n std::reverse(args[i].begin(), args[i].end());\n }\n\n std::vector indexes(n, 0);\n for (int i = 0; i < m; i++) {\n printf(\"%06Ld%06ld\\n\", p[i] + 1, args[p[i]][indexes[p[i]]++]);\n }\n}\n", "language": "C++", "metadata": {"date": 1591541793, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/C++/s398962183.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s398962183", "user_id": "u083910207"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nconst int mod = 1e9 + 7;\nconst int kmax = 510000;\nconst int last_days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n\nlong long fact[kmax], fact_inv[kmax], inv[kmax];\n\nvoid init_comb()\n{\n fact[0] = fact[1] = 1;\n fact_inv[0] = fact_inv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < kmax; i++) {\n fact[i] = fact[i - 1] * i % mod;\n inv[i] = mod - inv[mod % i] * (mod / i) % mod;\n fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;\n }\n}\n\nlong long comb(int n, int r)\n{\n if (n < r) {\n return 0;\n }\n\n if (n < 0 || r < 0) {\n return 0;\n }\n\n return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;\n}\n\ntemplate \nclass UnionFind {\n T parent_[N];\n T rank_[N];\n T size_[N];\n\npublic:\n UnionFind();\n T Root(T idx);\n bool IsSame(T x, T y);\n void Unite(T x, T y);\n T GetSize(T idx);\n};\n\ntemplate \nUnionFind::UnionFind()\n{\n for (T i = 0; i < N; i++) {\n parent_[i] = i;\n rank_[i] = 0;\n size_[i] = 1;\n }\n}\n\ntemplate \nT UnionFind::Root(T idx)\n{\n return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);\n}\n\ntemplate \nbool UnionFind::IsSame(T x, T y)\n{\n return Root(x) == Root(y);\n}\n\ntemplate \nvoid UnionFind::Unite(T x, T y)\n{\n x = Root(x);\n y = Root(y);\n if (x == y) {\n return;\n }\n\n if (rank_[x] < rank_[y]) {\n parent_[x] = y;\n size_[y] += size_[x];\n } else {\n parent_[y] = x;\n size_[x] += size_[y];\n if (rank_[x] == rank_[y]) {\n rank_[x]++;\n }\n }\n}\n\ntemplate \nT UnionFind::GetSize(T idx)\n{\n return size_[Root(idx)];\n}\n\nlong long pow_mod(long long n, long long p, long long m)\n{\n if (p == 0) {\n return 1;\n }\n\n if (p % 2 == 0) {\n long long t = pow_mod(n, p / 2, m);\n return t * t % m;\n }\n return n * pow_mod(n, p - 1, m) % mod;\n}\n\nlong long nCr_mod(long long n, long long r)\n{\n long long x = 1;\n for (long long i = n - r + 1; i <= n; i++) {\n x *= i;\n x %= mod;\n }\n\n long long a = 1;\n for (long long i = 1; i <= r; i++) {\n a *= i;\n a %= mod;\n }\n\n long long y = pow_mod(a, mod - 2, mod) % mod;\n\n return x * y % mod;\n}\n\nbool is_prime(long long n)\n{\n if (n == 1) {\n return false;\n }\n\n for (long long i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n\n return true;\n}\n\nbool is_leap(long long y)\n{\n return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;\n}\n\nvoid next_day(long long& y, long long& m, long long& d)\n{\n d++;\n\n if (d > last_days[m - 1] + (m == 2 && is_leap(y) ? 1 : 0)) {\n d = 1;\n m++;\n }\n\n if (m > 12) {\n y++;\n m = 1;\n }\n}\n\nlong long fib(long long n)\n{\n long long a = 0, b = 1;\n for (int i = 0; i < n; i++) {\n long long t = a;\n a = b;\n b = a + t;\n }\n\n return a;\n}\n\nstd::vector argsort(const std::vector& v)\n{\n std::vector indices(v.size());\n std::iota(indices.begin(), indices.end(), 0);\n\n std::sort(indices.begin(), indices.end(), [&v](size_t i, size_t j) { return v[i] < v[j]; });\n\n for (auto i = 0LU; i < indices.size(); i++) {\n indices[i]++;\n }\n\n return indices;\n}\n\nint main()\n{\n long long n, m;\n std::cin >> n >> m;\n\n std::vector p(m), y(m);\n\n for (int i = 0; i < m; i++) {\n std::cin >> p[i] >> y[i];\n p[i]--;\n }\n\n std::vector> nums(n);\n\n for (int i = 0; i < m; i++) {\n nums[p[i]].push_back(y[i]);\n }\n\n for (int i = 0; i < n; i++) {\n std::reverse(nums[i].begin(), nums[i].end());\n }\n\n std::vector> args(n);\n for (int i = 0; i < n; i++) {\n args[i] = argsort(nums[i]);\n std::reverse(args[i].begin(), args[i].end());\n }\n\n std::vector indexes(n, 0);\n for (int i = 0; i < m; i++) {\n printf(\"%06Ld%06ld\\n\", p[i] + 1, args[p[i]][indexes[p[i]]++]);\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4341, "cpu_time_ms": 111, "memory_kb": 14720}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s465362390", "group_id": "codeNet:p03222", "input_text": "#include \n#define int long long\n#define mod (int)(1e9+7)\n#define inf (int)(3e18+7)\n#define rep(i,n) for(int i=0;i\n#define all(v) v.begin(),v.end()\n#define mkp make_pair\n#define mkt make_tuple\n#define prique(T) priority_queue,greater>\n#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())\nusing namespace std;\n\nbool prime(int x) {\n\tfor (int i = 2; i * i <= x; i++) {\n\t\tif (x % i == 0)return false;\n\t}\n\treturn x > 1;\n}\nint gcd(int x, int y) {\n\tif (y == 0)return x;\n\treturn gcd(y, x % y);\n}\nint lcm(int x, int y) {\n\treturn x * y / gcd(x, y);\n}\nint kai(int x) {\n\tif (x == 0)return 1;\n\treturn kai(x - 1) * x % mod;\n}\nint mod_pow(int x, int y, int mod_) {\n\tint res = 1;\n\twhile (y > 0) {\n\t\tif (y & 1) {\n\t\t\tres = res * x % mod_;\n\t\t}\n\t\tx = x * x % mod_;\n\t\ty >>= 1;\n\t}\n\treturn res;\n}\nint comb(int x, int y) {\n\treturn kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;\n}\n/*--------Library Zone!--------*/\n\nint h, w, k;\nint dp[114][19];\nsigned main() {\n\tcin >> h >> w >> k;\n\tdp[0][0] = 1;\n\trep(i, h) {\n\t\trep(j, w) {\n\t\t\tdp[i][j] %= mod;\n\t\t\trep(k, 1 << (w - 1)) {\n\t\t\t\trep(l, w - 2) {\n\t\t\t\t\tif ((k >> l) & 1 && (k >> (l + 1) & 1))goto ng;\n\t\t\t\t}\n\t\t\t\tif (j && (k >> (j - 1)) & 1)dp[i + 1][j - 1] += dp[i][j];\n\t\t\t\telse if ((k >> j) & 1)dp[i + 1][j + 1] += dp[i][j];\n\t\t\t\telse dp[i + 1][j] += dp[i][j];\n\t\t\tng:;\n\t\t\t}\n\t\t}\n\t}\n\tcout << dp[h][k - 1] % mod << endl;\n}", "language": "C++", "metadata": {"date": 1558219920, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03222.html", "problem_id": "p03222", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03222/input.txt", "sample_output_relpath": "derived/input_output/data/p03222/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03222/C++/s465362390.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465362390", "user_id": "u147049801"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#define int long long\n#define mod (int)(1e9+7)\n#define inf (int)(3e18+7)\n#define rep(i,n) for(int i=0;i\n#define all(v) v.begin(),v.end()\n#define mkp make_pair\n#define mkt make_tuple\n#define prique(T) priority_queue,greater>\n#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())\nusing namespace std;\n\nbool prime(int x) {\n\tfor (int i = 2; i * i <= x; i++) {\n\t\tif (x % i == 0)return false;\n\t}\n\treturn x > 1;\n}\nint gcd(int x, int y) {\n\tif (y == 0)return x;\n\treturn gcd(y, x % y);\n}\nint lcm(int x, int y) {\n\treturn x * y / gcd(x, y);\n}\nint kai(int x) {\n\tif (x == 0)return 1;\n\treturn kai(x - 1) * x % mod;\n}\nint mod_pow(int x, int y, int mod_) {\n\tint res = 1;\n\twhile (y > 0) {\n\t\tif (y & 1) {\n\t\t\tres = res * x % mod_;\n\t\t}\n\t\tx = x * x % mod_;\n\t\ty >>= 1;\n\t}\n\treturn res;\n}\nint comb(int x, int y) {\n\treturn kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;\n}\n/*--------Library Zone!--------*/\n\nint h, w, k;\nint dp[114][19];\nsigned main() {\n\tcin >> h >> w >> k;\n\tdp[0][0] = 1;\n\trep(i, h) {\n\t\trep(j, w) {\n\t\t\tdp[i][j] %= mod;\n\t\t\trep(k, 1 << (w - 1)) {\n\t\t\t\trep(l, w - 2) {\n\t\t\t\t\tif ((k >> l) & 1 && (k >> (l + 1) & 1))goto ng;\n\t\t\t\t}\n\t\t\t\tif (j && (k >> (j - 1)) & 1)dp[i + 1][j - 1] += dp[i][j];\n\t\t\t\telse if ((k >> j) & 1)dp[i + 1][j + 1] += dp[i][j];\n\t\t\t\telse dp[i + 1][j] += dp[i][j];\n\t\t\tng:;\n\t\t\t}\n\t\t}\n\t}\n\tcout << dp[h][k - 1] % mod << endl;\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAmidakuji is a traditional method of lottery in Japan.\n\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.\n\nA valid amidakuji is an amidakuji that satisfies the following conditions:\n\nNo two horizontal lines share an endpoint.\n\nThe two endpoints of each horizontal lines must be at the same height.\n\nA horizontal line must connect adjacent vertical lines.\n\nFind the number of the valid amidakuji that satisfy the following condition, modulo 1\\ 000\\ 000\\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.\n\nFor example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.\n\nConstraints\n\nH is an integer between 1 and 100 (inclusive).\n\nW is an integer between 1 and 8 (inclusive).\n\nK is an integer between 1 and W (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\n\nOutput\n\nPrint the number of the amidakuji that satisfy the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 2\n\n1 3 1\n\nSample Output 2\n\n2\n\nOnly the following two amidakuji satisfy the condition:\n\nSample Input 3\n\n2 3 3\n\nSample Output 3\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 4\n\n2 3 1\n\nSample Output 4\n\n5\n\nOnly the following five amidakuji satisfy the condition:\n\nSample Input 5\n\n7 1 1\n\nSample Output 5\n\n1\n\nAs there is only one vertical line, we cannot draw any horizontal lines. Thus, there is only one amidakuji that satisfies the condition: the amidakuji with no horizontal lines.\n\nSample Input 6\n\n15 8 5\n\nSample Output 6\n\n437760187\n\nBe sure to print the answer modulo 1\\ 000\\ 000\\ 007.", "sample_input": "1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03222", "source_text": "Score: 400 points\n\nProblem Statement\n\nAmidakuji is a traditional method of lottery in Japan.\n\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.\n\nA valid amidakuji is an amidakuji that satisfies the following conditions:\n\nNo two horizontal lines share an endpoint.\n\nThe two endpoints of each horizontal lines must be at the same height.\n\nA horizontal line must connect adjacent vertical lines.\n\nFind the number of the valid amidakuji that satisfy the following condition, modulo 1\\ 000\\ 000\\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.\n\nFor example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.\n\nConstraints\n\nH is an integer between 1 and 100 (inclusive).\n\nW is an integer between 1 and 8 (inclusive).\n\nK is an integer between 1 and W (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\n\nOutput\n\nPrint the number of the amidakuji that satisfy the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 2\n\n1 3 1\n\nSample Output 2\n\n2\n\nOnly the following two amidakuji satisfy the condition:\n\nSample Input 3\n\n2 3 3\n\nSample Output 3\n\n1\n\nOnly the following one amidakuji satisfies the condition:\n\nSample Input 4\n\n2 3 1\n\nSample Output 4\n\n5\n\nOnly the following five amidakuji satisfy the condition:\n\nSample Input 5\n\n7 1 1\n\nSample Output 5\n\n1\n\nAs there is only one vertical line, we cannot draw any horizontal lines. Thus, there is only one amidakuji that satisfies the condition: the amidakuji with no horizontal lines.\n\nSample Input 6\n\n15 8 5\n\nSample Output 6\n\n437760187\n\nBe sure to print the answer modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1571, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s860361405", "group_id": "codeNet:p03229", "input_text": "#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#define ll long long\n#define pii pair\n#define pll pair\n#define vii vector\n#define vll vector\n#define lb lower_bound\n#define pb push_back\n#define mp make_pair\n#define rep(i,n) for(ll i=0;i=0;i--)\n#define all(x) x.begin(),x.end()\n#define INF (1 << 30) - 1\n#define LLINF (1LL << 61) - 1\n// #define int ll\nusing namespace std;\nconst int MOD = 1000000007;\nconst int MAX = 510000;\n\n\nint main(){\n cin.tie(0);\n ios::sync_with_stdio(false);\n ll n,a[100010],ans=0;\n deque deq;\n cin>>n;\n rep(i,n){\n cin>>a[i];\n }\n sort(a,a+n);\n rep(i,n-1){\n if(i%4==0){\n deq.push_back(a[n-(i/2+1)]);\n }\n else if(i%4==1){\n deq.push_front(a[i/2]);\n }\n else if(i%4==2){\n deq.push_back(a[i/2]);\n }\n else{\n deq.push_front(a[n-(i/2+1)]);\n }\n }\n rep(i,n-2){\n ans+=abs(deq.at(i)-deq.at(i+1));\n }\n ans+=max(abs(deq.at(0)-a[n/2-(1-n%2)]),abs(deq.at(n-2)-a[n/2-(1-n%2)]));\n cout<\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#define ll long long\n#define pii pair\n#define pll pair\n#define vii vector\n#define vll vector\n#define lb lower_bound\n#define pb push_back\n#define mp make_pair\n#define rep(i,n) for(ll i=0;i=0;i--)\n#define all(x) x.begin(),x.end()\n#define INF (1 << 30) - 1\n#define LLINF (1LL << 61) - 1\n// #define int ll\nusing namespace std;\nconst int MOD = 1000000007;\nconst int MAX = 510000;\n\n\nint main(){\n cin.tie(0);\n ios::sync_with_stdio(false);\n ll n,a[100010],ans=0;\n deque deq;\n cin>>n;\n rep(i,n){\n cin>>a[i];\n }\n sort(a,a+n);\n rep(i,n-1){\n if(i%4==0){\n deq.push_back(a[n-(i/2+1)]);\n }\n else if(i%4==1){\n deq.push_front(a[i/2]);\n }\n else if(i%4==2){\n deq.push_back(a[i/2]);\n }\n else{\n deq.push_front(a[n-(i/2+1)]);\n }\n }\n rep(i,n-2){\n ans+=abs(deq.at(i)-deq.at(i+1));\n }\n ans+=max(abs(deq.at(0)-a[n/2-(1-n%2)]),abs(deq.at(n-2)-a[n/2-(1-n%2)]));\n cout<\n#define rep(i, a, b) for(int i = int(a); i < int(b); i++)\n#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)\n#define sz(v) (int)(v).size()\n#define pb push_back\n#define sc second\n#define fr first\n#define sor(v) sort(v.begin(),v.end())\n#define rev(s) reverse(s.begin(),s.end())\n#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)\n#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)\n#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())\nusing namespace std;\ntypedef long long int ll;\ntypedef pair P;\n\nconst ll MOD=1000000007;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll N;\n cin>>N;\n vector A;\n rep(i,0,N){\n ll a;\n cin>>a;\n A.pb(a);\n }\n sor(A);\n ll res1=0,res2=0;\n if(N%2){\n rep(i,N/2+1,N){\n res1+=2*A[i];\n }\n rep(i,0,N/2-1){\n res1-=2*A[i];\n }\n res1-=A[N/2-1]+A[N/2];\n rep(i,0,N/2){\n res2-=2*A[i];\n }\n rep(i,N/2,N){\n res2+=2*A[i];\n }\n res2-=A[N/2]+A[N/2+1];\n }\n else{\n rep(i,N/2,N){\n res1+=2*A[i];\n }\n rep(i,0,N/2){\n res1-=2*A[i];\n }\n res1+=-A[N/2]+A[N/2-1];\n }\n cout <\n#define rep(i, a, b) for(int i = int(a); i < int(b); i++)\n#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)\n#define sz(v) (int)(v).size()\n#define pb push_back\n#define sc second\n#define fr first\n#define sor(v) sort(v.begin(),v.end())\n#define rev(s) reverse(s.begin(),s.end())\n#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)\n#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)\n#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())\nusing namespace std;\ntypedef long long int ll;\ntypedef pair P;\n\nconst ll MOD=1000000007;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll N;\n cin>>N;\n vector A;\n rep(i,0,N){\n ll a;\n cin>>a;\n A.pb(a);\n }\n sor(A);\n ll res1=0,res2=0;\n if(N%2){\n rep(i,N/2+1,N){\n res1+=2*A[i];\n }\n rep(i,0,N/2-1){\n res1-=2*A[i];\n }\n res1-=A[N/2-1]+A[N/2];\n rep(i,0,N/2){\n res2-=2*A[i];\n }\n rep(i,N/2,N){\n res2+=2*A[i];\n }\n res2-=A[N/2]+A[N/2+1];\n }\n else{\n rep(i,N/2,N){\n res1+=2*A[i];\n }\n rep(i,0,N/2){\n res1-=2*A[i];\n }\n res1+=-A[N/2]+A[N/2-1];\n }\n cout <\nusing namespace std;\n\n\nstruct node\n{\n\t int c;\n\t int num;\n\t \n};\nstruct node a[100005],b[100005];\n\nbool cmp(node a,node b)\n{\n\t return a.c>b.c;\n}\nint main()\n{for(int i=0;i<100005;i++)\n{\n\ta[i].c=0;\n\ta[i].num=i;\n\tb[i].c=0;\n\tb[i].num=i;\n}\n\t int n;\n\t cin>>n;\n\t int jd=0,od=0,jx=1000000000,ox=1000000000;\n\t vectorj,o;\n\t int jmax=0,jmaxn=0,omax=0,omaxn=0;\n\t for(int i=1;i<=n;i++)\n\t {int t;\n\t cin>>t;\n\t \n\t \tif(i&1)\n\t \t{\n\t \t j.push_back(t);\n\t \t jd=max(jd,t);\n\t \t jx=min(jx,t);\n\t \t a[t].c++;\n\t \t \n\t \t if(a[t].c>jmax)\n\t \t {\n\t \t \tjmax=a[t].c;\n\t \t \tjmaxn=t;\n\t\t\t }\n\t\t }\n\t\t else\n\t\t { \n\t\t \to.push_back(t);\n\t\t \tod=max(od,t);\n\t\t \tox=min(ox,t);\n\t\t \tb[t].c++;\n\t\t \tif(b[t].c>omax)\n\t \t {\n\t \t \tomax=b[t].c;\n\t \t \tomaxn=t;\n\t\t\t }\n\t\t }\n\t \t\n\t }\n\t if(jd==od&&jx==ox&&jd==jx)\n\t {\n\t \tcout<\nusing namespace std;\n\n\nstruct node\n{\n\t int c;\n\t int num;\n\t \n};\nstruct node a[100005],b[100005];\n\nbool cmp(node a,node b)\n{\n\t return a.c>b.c;\n}\nint main()\n{for(int i=0;i<100005;i++)\n{\n\ta[i].c=0;\n\ta[i].num=i;\n\tb[i].c=0;\n\tb[i].num=i;\n}\n\t int n;\n\t cin>>n;\n\t int jd=0,od=0,jx=1000000000,ox=1000000000;\n\t vectorj,o;\n\t int jmax=0,jmaxn=0,omax=0,omaxn=0;\n\t for(int i=1;i<=n;i++)\n\t {int t;\n\t cin>>t;\n\t \n\t \tif(i&1)\n\t \t{\n\t \t j.push_back(t);\n\t \t jd=max(jd,t);\n\t \t jx=min(jx,t);\n\t \t a[t].c++;\n\t \t \n\t \t if(a[t].c>jmax)\n\t \t {\n\t \t \tjmax=a[t].c;\n\t \t \tjmaxn=t;\n\t\t\t }\n\t\t }\n\t\t else\n\t\t { \n\t\t \to.push_back(t);\n\t\t \tod=max(od,t);\n\t\t \tox=min(ox,t);\n\t\t \tb[t].c++;\n\t\t \tif(b[t].c>omax)\n\t \t {\n\t \t \tomax=b[t].c;\n\t \t \tomaxn=t;\n\t\t\t }\n\t\t }\n\t \t\n\t }\n\t if(jd==od&&jx==ox&&jd==jx)\n\t {\n\t \tcout<\n \nusing namespace std;\n \n#define fread(x) freopen(x,\"r\",stdin)\n#define fwrite(x) freopen (x,\"w\",stdout)\n \n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define min4(a,b,c,d) min(a,min(b,min(c,d)))\n#define max4(a,b,c,d) max(a,max(b,max(c,d)))\n#define SQR(a) ((a)*(a))\n#define MEMSET(a,x) memset(a,x,sizeof(a))\n#define ABS(x) ((x)<0?-(x):(x))\n \n#define white 1\n#define grey 2\n#define black 3\n \n#define ll long long\n#define pb push_back\n#define pf push_front\n#define INF 9e18\n#define PI acos(-1.0)\n#define pii pair\n#define pll pair\n \n#define all(v) v.begin(), v.end()\n \n#define fastread ios_base::sync_with_stdio(0);cin.tie(nullptr);\nint on(int N,int pos){return N=N | (1< 1){\n\t\tmid=(start+ed)>>1;\n\t\tif(arr[mid] > n){\n\t\t\ted = mid;\n\t\t}else if(arr[mid] < n){\n\t\t\tstart = mid;\n\t\t}else{\n\t\t\treturn arr[mid];\n\t\t}\n\t}\n\tif(arr[start]==n)return arr[start];\n\telse return arr[start+1];\n}\nint main(){\n\tfastread\n\tint n;\n\tcin>>n;\n\tcout<\n \nusing namespace std;\n \n#define fread(x) freopen(x,\"r\",stdin)\n#define fwrite(x) freopen (x,\"w\",stdout)\n \n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define min4(a,b,c,d) min(a,min(b,min(c,d)))\n#define max4(a,b,c,d) max(a,max(b,max(c,d)))\n#define SQR(a) ((a)*(a))\n#define MEMSET(a,x) memset(a,x,sizeof(a))\n#define ABS(x) ((x)<0?-(x):(x))\n \n#define white 1\n#define grey 2\n#define black 3\n \n#define ll long long\n#define pb push_back\n#define pf push_front\n#define INF 9e18\n#define PI acos(-1.0)\n#define pii pair\n#define pll pair\n \n#define all(v) v.begin(), v.end()\n \n#define fastread ios_base::sync_with_stdio(0);cin.tie(nullptr);\nint on(int N,int pos){return N=N | (1< 1){\n\t\tmid=(start+ed)>>1;\n\t\tif(arr[mid] > n){\n\t\t\ted = mid;\n\t\t}else if(arr[mid] < n){\n\t\t\tstart = mid;\n\t\t}else{\n\t\t\treturn arr[mid];\n\t\t}\n\t}\n\tif(arr[start]==n)return arr[start];\n\telse return arr[start+1];\n}\nint main(){\n\tfastread\n\tint n;\n\tcin>>n;\n\tcout<\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 PI 3.141592653\n#define rep(i,a,n) for(int i=a;i<(int)n;++i)\n#define SZ(x) ((int)(x).size())\t//size() unsigned -> int\n#define DescSort(a) sort(a.begin(),a.end(),std::greater())\n\nusing namespace std;\ntypedef long long ll;\nconst ll INF=1e9+7;\n\nint main(void) {\n\tint n;\n\tvector e(1e5 + 5, 0), o(1e5 + 5, 0);\n\tcin >> n;\n\trep(i, 0, n) {\n\t\tint input;\n\t\tcin >> input;\n\t\tif (i % 2) {\n\t\t\to[input]++;\n\t\t}\n\t\telse {\n\t\t\te[input]++;\n\t\t}\n\t}\n\tint o_max_idx, e_max_idx;\n\to_max_idx = distance(o.begin(), max_element(o.begin(), o.end()));\n\te_max_idx = distance(e.begin(), max_element(e.begin(), e.end()));\n\tint ans = n - o[o_max_idx] - e[e_max_idx];\n\tif (o_max_idx == e_max_idx){\n\t\tint o_max_tmp = o[o_max_idx];\n\t\tint e_max_tmp = e[e_max_idx];\n\t\to[o_max_idx] = 0;e[e_max_idx] = 0;\n\t\tint o_2_max_idx = distance(o.begin(), max_element(o.begin(), o.end()));\n\t\tint e_2_max_idx = distance(e.begin(), max_element(e.begin(), e.end()));\n\t\tans = n - max(e[e_2_max_idx]+o_max_tmp, e_2_max_idx+o[o_max_tmp]);\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1581660884, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/C++/s224729445.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s224729445", "user_id": "u817523595"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#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 PI 3.141592653\n#define rep(i,a,n) for(int i=a;i<(int)n;++i)\n#define SZ(x) ((int)(x).size())\t//size() unsigned -> int\n#define DescSort(a) sort(a.begin(),a.end(),std::greater())\n\nusing namespace std;\ntypedef long long ll;\nconst ll INF=1e9+7;\n\nint main(void) {\n\tint n;\n\tvector e(1e5 + 5, 0), o(1e5 + 5, 0);\n\tcin >> n;\n\trep(i, 0, n) {\n\t\tint input;\n\t\tcin >> input;\n\t\tif (i % 2) {\n\t\t\to[input]++;\n\t\t}\n\t\telse {\n\t\t\te[input]++;\n\t\t}\n\t}\n\tint o_max_idx, e_max_idx;\n\to_max_idx = distance(o.begin(), max_element(o.begin(), o.end()));\n\te_max_idx = distance(e.begin(), max_element(e.begin(), e.end()));\n\tint ans = n - o[o_max_idx] - e[e_max_idx];\n\tif (o_max_idx == e_max_idx){\n\t\tint o_max_tmp = o[o_max_idx];\n\t\tint e_max_tmp = e[e_max_idx];\n\t\to[o_max_idx] = 0;e[e_max_idx] = 0;\n\t\tint o_2_max_idx = distance(o.begin(), max_element(o.begin(), o.end()));\n\t\tint e_2_max_idx = distance(e.begin(), max_element(e.begin(), e.end()));\n\t\tans = n - max(e[e_2_max_idx]+o_max_tmp, e_2_max_idx+o[o_max_tmp]);\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1268, "cpu_time_ms": 32, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s481607441", "group_id": "codeNet:p03244", "input_text": "#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// ascending order\n#define vsort(v) sort(v.begin(), v.end())\n// descending order\n#define vsort_r(v) sort(v.begin(), v.end(), greater())\n#define vunique(v) unique(v.begin(), v.end())\n#define mp make_pair\n#define ts(x) to_string(x)\n#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)\n#define repm(i, a, b) for(ll i = (ll)a; i > (ll)b; i--)\n#define bit(a) bitset<8>(a)\n#define des_priority_queue priority_queue, greater >\n#define all(v) (v).begin(), (v).end()\ntypedef long long ll;\ntypedef pair P;\nconst ll INF = 1e18;\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\tll n;\n\tcin >> n;\n\tmap even;\n\tmap odd;\n\tvector tmp_v;\n\trep(i, 0, n) {\n\t\tll v;\n\t\tcin >> v;\n\t\tif(i % 2 == 0) even[v]++;\n\t\telse odd[v]++;\n\t\ttmp_v.push_back(v);\n\t}\n\n\tll e1 = -1;\n\tll e2 = -1;\n\tll max_e1 = -1;\n\tll max_e2 = -1;\n\tll o1 = -1;\n\tll o2 = -1;\n\tll max_o1 = -1;\n\tll max_o2 = -1;\n\n\tfor(map::iterator it = even.begin(); it != even.end(); it++) {\n\t\tif(max_e1 < it->second) {\n\t\t\tif(e2 != -1) {\n\t\t\t\tmax_e2 = max_e1;\n\t\t\t\te2 = e1;\n\t\t\t}\n\t\t\te1 = it->first;\n\t\t\tmax_e1 = it->second;\n\t\t\tcontinue;\n\t\t} \n\n\t\tif(e2 != it->first and max_e2 < it->second) {\n\t\t\te2 = it->first;\n\t\t\tmax_e2 = it->second;\n\t\t}\n\t}\n\n\tfor(map::iterator it = odd.begin(); it != odd.end(); it++) {\n\t\tif(max_o1 < it->second) {\n\t\t\tif(o2 != -1) {\n\t\t\t\tmax_o2 = max_o1;\n\t\t\t\to2 = o1;\n\t\t\t}\n\t\t\to1 = it->first;\n\t\t\tmax_o1 = it->second;\n\t\t\tcontinue;\n\t\t} \n\n\t\tif(o2 != it->first and max_o2 < it->second) {\n\t\t\to2 = it->first;\n\t\t\tmax_o2 = it->second;\n\t\t}\n\t}\n\t\n\tll rsl1 = 0;\n\tll rsl2 = 0;\n\tif(e1 != o1) {\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e1 != tmp_v[i]) rsl1++;\n\t\t\t} else {\n\t\t\t\tif(o1 != tmp_v[i]) rsl1++;\n\t\t\t}\n\t\t}\n\t\tcout << rsl1 << endl;\n\t} else {\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e1 != tmp_v[i]) rsl1++;\n\t\t\t} else {\n\t\t\t\tif(o2 != tmp_v[i]) rsl1++;\n\t\t\t}\n\t\t}\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e2 != tmp_v[i]) rsl2++;\n\t\t\t} else {\n\t\t\t\tif(o1 != tmp_v[i]) rsl2++;\n\t\t\t}\n\t\t}\n\t\tll rsl = min(rsl1, rsl2);\n\t\tcout << rsl << endl;\n\t}\n}\n", "language": "C++", "metadata": {"date": 1541302768, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/C++/s481607441.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s481607441", "user_id": "u355254193"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#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// ascending order\n#define vsort(v) sort(v.begin(), v.end())\n// descending order\n#define vsort_r(v) sort(v.begin(), v.end(), greater())\n#define vunique(v) unique(v.begin(), v.end())\n#define mp make_pair\n#define ts(x) to_string(x)\n#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)\n#define repm(i, a, b) for(ll i = (ll)a; i > (ll)b; i--)\n#define bit(a) bitset<8>(a)\n#define des_priority_queue priority_queue, greater >\n#define all(v) (v).begin(), (v).end()\ntypedef long long ll;\ntypedef pair P;\nconst ll INF = 1e18;\n\nint main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(false);\n\tll n;\n\tcin >> n;\n\tmap even;\n\tmap odd;\n\tvector tmp_v;\n\trep(i, 0, n) {\n\t\tll v;\n\t\tcin >> v;\n\t\tif(i % 2 == 0) even[v]++;\n\t\telse odd[v]++;\n\t\ttmp_v.push_back(v);\n\t}\n\n\tll e1 = -1;\n\tll e2 = -1;\n\tll max_e1 = -1;\n\tll max_e2 = -1;\n\tll o1 = -1;\n\tll o2 = -1;\n\tll max_o1 = -1;\n\tll max_o2 = -1;\n\n\tfor(map::iterator it = even.begin(); it != even.end(); it++) {\n\t\tif(max_e1 < it->second) {\n\t\t\tif(e2 != -1) {\n\t\t\t\tmax_e2 = max_e1;\n\t\t\t\te2 = e1;\n\t\t\t}\n\t\t\te1 = it->first;\n\t\t\tmax_e1 = it->second;\n\t\t\tcontinue;\n\t\t} \n\n\t\tif(e2 != it->first and max_e2 < it->second) {\n\t\t\te2 = it->first;\n\t\t\tmax_e2 = it->second;\n\t\t}\n\t}\n\n\tfor(map::iterator it = odd.begin(); it != odd.end(); it++) {\n\t\tif(max_o1 < it->second) {\n\t\t\tif(o2 != -1) {\n\t\t\t\tmax_o2 = max_o1;\n\t\t\t\to2 = o1;\n\t\t\t}\n\t\t\to1 = it->first;\n\t\t\tmax_o1 = it->second;\n\t\t\tcontinue;\n\t\t} \n\n\t\tif(o2 != it->first and max_o2 < it->second) {\n\t\t\to2 = it->first;\n\t\t\tmax_o2 = it->second;\n\t\t}\n\t}\n\t\n\tll rsl1 = 0;\n\tll rsl2 = 0;\n\tif(e1 != o1) {\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e1 != tmp_v[i]) rsl1++;\n\t\t\t} else {\n\t\t\t\tif(o1 != tmp_v[i]) rsl1++;\n\t\t\t}\n\t\t}\n\t\tcout << rsl1 << endl;\n\t} else {\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e1 != tmp_v[i]) rsl1++;\n\t\t\t} else {\n\t\t\t\tif(o2 != tmp_v[i]) rsl1++;\n\t\t\t}\n\t\t}\n\t\trep(i, 0, n) {\n\t\t\tif(i % 2 == 0) {\n\t\t\t\tif(e2 != tmp_v[i]) rsl2++;\n\t\t\t} else {\n\t\t\t\tif(o1 != tmp_v[i]) rsl2++;\n\t\t\t}\n\t\t}\n\t\tll rsl = min(rsl1, rsl2);\n\t\tcout << rsl << endl;\n\t}\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2273, "cpu_time_ms": 48, "memory_kb": 7284}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s514237180", "group_id": "codeNet:p03247", "input_text": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N = 1e5+10;\nint n, a[N], b[N], c[2], d[N];\nchar s[N];\nint Abs(int x){return x > 0 ? x : -x;}\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tscanf(\"%d%d\", &a[i], &b[i]);\n\t\t++c[(a[i] + b[i]) & 1];\n }\n if (c[0] != n && c[1] != n)\n {\n \tputs(\"-1\");\n\t\treturn 0;\n }\n printf(\"%d\\n\", 31 + (c[0] != 0));\n\tfor (int i = 0; i <= 30; i++)\n\t\tprintf(\"%d \", 1 << i);\n\tif (c[0])\n\t\tprintf(\"1 \");\n\tputchar(10);\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tint x = a[i], y = b[i];\n\t\tif (c[0])\n\t\t\t--x, s[31] = 'R';\n\t\tint f = 0;\n for (int i = 30; i >= 0; i--)\n {\n if (Abs(x) < Abs(y))\n \tswap(x, y), f ^= 1;\n\t\t\tif (x > 0)\n\t\t\t\tx -= 1 << i, s[i] = \"RU\"[f];\n\t\t\telse\n\t\t\t\tx += 1 << i, s[i] = \"LD\"[f];\n\t\t}\n\t\tputs(s);\n }\n}", "language": "C++", "metadata": {"date": 1580351749, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03247.html", "problem_id": "p03247", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03247/input.txt", "sample_output_relpath": "derived/input_output/data/p03247/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03247/C++/s514237180.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514237180", "user_id": "u089230684"}, "prompt_components": {"gold_output": "2\n1 2\nRL\nUU\nDR\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N = 1e5+10;\nint n, a[N], b[N], c[2], d[N];\nchar s[N];\nint Abs(int x){return x > 0 ? x : -x;}\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tscanf(\"%d%d\", &a[i], &b[i]);\n\t\t++c[(a[i] + b[i]) & 1];\n }\n if (c[0] != n && c[1] != n)\n {\n \tputs(\"-1\");\n\t\treturn 0;\n }\n printf(\"%d\\n\", 31 + (c[0] != 0));\n\tfor (int i = 0; i <= 30; i++)\n\t\tprintf(\"%d \", 1 << i);\n\tif (c[0])\n\t\tprintf(\"1 \");\n\tputchar(10);\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tint x = a[i], y = b[i];\n\t\tif (c[0])\n\t\t\t--x, s[31] = 'R';\n\t\tint f = 0;\n for (int i = 30; i >= 0; i--)\n {\n if (Abs(x) < Abs(y))\n \tswap(x, y), f ^= 1;\n\t\t\tif (x > 0)\n\t\t\t\tx -= 1 << i, s[i] = \"RU\"[f];\n\t\t\telse\n\t\t\t\tx += 1 << i, s[i] = \"LD\"[f];\n\t\t}\n\t\tputs(s);\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "sample_input": "3\n-1 0\n0 3\n2 -1\n"}, "reference_outputs": ["2\n1 2\nRL\nUU\nDR\n"], "source_document_id": "p03247", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 883, "cpu_time_ms": 2, "memory_kb": 384}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s717607392", "group_id": "codeNet:p03252", "input_text": "#include \nusing namespace std;\nchar s[200003],s1[200003];\nint ss[30],ss1[30];\nint main()\n{\n\ncin>>s>>s1;\nint a,b;a=strlen(s);b=strlen(s1);\n for(int i=1;i<=a;i++)\n ss[s[i]-'a']++,ss1[s1[i]-'a']++;\n for(int i=1;i<=a;i++)\n if(s[i]!=s1[i]&&ss[s[i]-'a']!=ss1[s1[i]-'a']){cout<<\"No\";return 0;}\n cout<<\"Yes\";\nreturn 0;\n}\n\n", "language": "C++", "metadata": {"date": 1537834078, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03252.html", "problem_id": "p03252", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03252/input.txt", "sample_output_relpath": "derived/input_output/data/p03252/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03252/C++/s717607392.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Output Limit Exceeded", "submission_id": "s717607392", "user_id": "u114362525"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \nusing namespace std;\nchar s[200003],s1[200003];\nint ss[30],ss1[30];\nint main()\n{\n\ncin>>s>>s1;\nint a,b;a=strlen(s);b=strlen(s1);\n for(int i=1;i<=a;i++)\n ss[s[i]-'a']++,ss1[s1[i]-'a']++;\n for(int i=1;i<=a;i++)\n if(s[i]!=s1[i]&&ss[s[i]-'a']!=ss1[s1[i]-'a']){cout<<\"No\";return 0;}\n cout<<\"Yes\";\nreturn 0;\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "sample_input": "azzel\napple\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03252", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given strings S and T consisting of lowercase English letters.\n\nYou can perform the following operation on S any number of times:\n\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\n\nDetermine if S and T can be made equal by performing the operation zero or more times.\n\nConstraints\n\n1 \\leq |S| \\leq 2 \\times 10^5\n\n|S| = |T|\n\nS and T consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S and T can be made equal, print Yes; otherwise, print No.\n\nSample Input 1\n\nazzel\napple\n\nSample Output 1\n\nYes\n\nazzel can be changed to apple, as follows:\n\nChoose e as c_1 and l as c_2. azzel becomes azzle.\n\nChoose z as c_1 and p as c_2. azzle becomes apple.\n\nSample Input 2\n\nchokudai\nredcoder\n\nSample Output 2\n\nNo\n\nNo sequences of operation can change chokudai to redcoder.\n\nSample Input 3\n\nabcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 341, "cpu_time_ms": 1770, "memory_kb": 131840}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s564704536", "group_id": "codeNet:p03253", "input_text": "#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#define rep(i, n) for (int i = 0; i < (n); i++)\n#define loop(i, x, n) for (int i = (x); i < (n); i++)\n#define all(v) (v).begin(), (v).end()\n#define int long long\nusing namespace std;\nconst int MOD = 1e9 + 7;\nconst int INF = 1e18;\ntemplate void cmax(T &a, T b) { a = max(a, b); }\ntemplate void cmin(T &a, T b) { a = min(a, b); }\n\nint modinv(int a, int m) {\n int b = m, u = 1, v = 0;\n while (b) {\n int 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\nmap prime_fac(int n) {\n map ret;\n for (int 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}\nint fact[200005];\nint inv[200005];\n\nsigned main() {\n int n, m;\n cin >> n >> m;\n map mp = prime_fac(m);\n fact[0] = 1;\n inv[0] = 1;\n loop(i, 1, 200005) {\n fact[i] = fact[i - 1] * i;\n fact[i] %= MOD;\n inv[i] = modinv(fact[i], MOD);\n }\n\n int ans = 1;\n for (auto x : mp) {\n int t = x.second;\n // cout << x.first << ' ' << t << endl;\n ans *= fact[t + n - 1] * inv[t] % MOD * inv[n - 1] % MOD;\n }\n cout << ans % MOD << endl;\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1543456105, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03253.html", "problem_id": "p03253", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03253/input.txt", "sample_output_relpath": "derived/input_output/data/p03253/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03253/C++/s564704536.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s564704536", "user_id": "u093420647"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "#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#define rep(i, n) for (int i = 0; i < (n); i++)\n#define loop(i, x, n) for (int i = (x); i < (n); i++)\n#define all(v) (v).begin(), (v).end()\n#define int long long\nusing namespace std;\nconst int MOD = 1e9 + 7;\nconst int INF = 1e18;\ntemplate void cmax(T &a, T b) { a = max(a, b); }\ntemplate void cmin(T &a, T b) { a = min(a, b); }\n\nint modinv(int a, int m) {\n int b = m, u = 1, v = 0;\n while (b) {\n int 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\nmap prime_fac(int n) {\n map ret;\n for (int 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}\nint fact[200005];\nint inv[200005];\n\nsigned main() {\n int n, m;\n cin >> n >> m;\n map mp = prime_fac(m);\n fact[0] = 1;\n inv[0] = 1;\n loop(i, 1, 200005) {\n fact[i] = fact[i - 1] * i;\n fact[i] %= MOD;\n inv[i] = modinv(fact[i], MOD);\n }\n\n int ans = 1;\n for (auto x : mp) {\n int t = x.second;\n // cout << x.first << ' ' << t << endl;\n ans *= fact[t + n - 1] * inv[t] % MOD * inv[n - 1] % MOD;\n }\n cout << ans % MOD << endl;\n return 0;\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "sample_input": "2 6\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03253", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given positive integers N and M.\n\nHow many sequences a of length N consisting of positive integers satisfy a_1 \\times a_2 \\times ... \\times a_N = M? Find the count modulo 10^9+7.\n\nHere, two sequences a' and a'' are considered different when there exists some i such that a_i' \\neq a_i''.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n2 6\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: \\{a_1, a_2\\} = \\{1, 6\\}, \\{2, 3\\}, \\{3, 2\\} and \\{6, 1\\}.\n\nSample Input 2\n\n3 12\n\nSample Output 2\n\n18\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n957870001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1479, "cpu_time_ms": 62, "memory_kb": 3328}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s710847800", "group_id": "codeNet:p03254", "input_text": "#include \nint main(){\nint N;\nint x;\nint kids[105];\nint order[105];\nint all=0;\nint flag =0;\nstd::cin >> N >> x;\nfor(int i = 0;i > kids[i];\nall+=kids[i];\n\norder[i] = kids[i];\nif(i != 0){\nfor(int j = i;j > 0;j--){\nif(kids[j] > order[j-1]){\norder[j] = order [j-1];\norder[j-1] = kids[j];\n}\n}\n}\n}\nif(all == x){\nstd::cout << N <<'\\n';\nflag =1;\n}else if (all > x){\nstd::cout << N-1<<'\\n';\nflag =1;\n}else{\nfor(int i = 0;i= all - order[i]){\nstd::cout << N - i - 1 << '\\n';\nflag =1;\n}else{\nall -= order[i];\n}\n}\n\n\n\n}\nif(!flag)std::cout << 0 << '\\n';\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1537064654, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/C++/s710847800.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s710847800", "user_id": "u604446158"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include \nint main(){\nint N;\nint x;\nint kids[105];\nint order[105];\nint all=0;\nint flag =0;\nstd::cin >> N >> x;\nfor(int i = 0;i > kids[i];\nall+=kids[i];\n\norder[i] = kids[i];\nif(i != 0){\nfor(int j = i;j > 0;j--){\nif(kids[j] > order[j-1]){\norder[j] = order [j-1];\norder[j-1] = kids[j];\n}\n}\n}\n}\nif(all == x){\nstd::cout << N <<'\\n';\nflag =1;\n}else if (all > x){\nstd::cout << N-1<<'\\n';\nflag =1;\n}else{\nfor(int i = 0;i= all - order[i]){\nstd::cout << N - i - 1 << '\\n';\nflag =1;\n}else{\nall -= order[i];\n}\n}\n\n\n\n}\nif(!flag)std::cout << 0 << '\\n';\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s577064193", "group_id": "codeNet:p03255", "input_text": "#include \n#define rep(i, a, n) for(int i = a; i < n; i++)\n#define repr(i, a, b) for(int i = a; i >= b; i--)\n#define int long long\n#define all(a) a.begin(), a.end()\n#define chmax(x, y) x = max(x, y)\n#define chmin(x, y) x = min(x, y)\nusing namespace std;\ntypedef pair P;\nconst int mod = 1000000007;\nconst int INF = 1e18;\n\nint n, x;\nvector a;\nint cost[2010][2010];\nint dp[2010];\n\nsigned main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tcin >> n >> x;\n\tassert(n <= 2000);\n\ta.resize(n);\n\trep(i, 0, n) cin >> a[i];\n\trep(i, 0, n){\n\t\tint now = x + a[i], cnt = 0;\n\t\tfor(int j = i; j >= 0; j--){\n\t\t\tnow += x;\n\t\t\tcnt++;\n\t\t\tcost[j][i] = now + (cnt + 1) * (cnt + 1) * a[j];\n\t\t\tif(j) now += (cnt + 1) * (cnt + 1) * (a[j] - a[j - 1]);\n\t\t}\n\t}\n\trep(i, 0, n + 1) dp[i] = INF; \n\tdp[0] = 0;\n\trep(i, 0, n){\n\t\trep(j, 0, n){\n\t\t\tdp[j + 1] = min(dp[j + 1], dp[i] + cost[i][j]);\n\t\t}\n\t}\n\tcout << dp[n] << endl;\n}", "language": "C++", "metadata": {"date": 1537071771, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03255.html", "problem_id": "p03255", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03255/input.txt", "sample_output_relpath": "derived/input_output/data/p03255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03255/C++/s577064193.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s577064193", "user_id": "u984730891"}, "prompt_components": {"gold_output": "355\n", "input_to_evaluate": "#include \n#define rep(i, a, n) for(int i = a; i < n; i++)\n#define repr(i, a, b) for(int i = a; i >= b; i--)\n#define int long long\n#define all(a) a.begin(), a.end()\n#define chmax(x, y) x = max(x, y)\n#define chmin(x, y) x = min(x, y)\nusing namespace std;\ntypedef pair P;\nconst int mod = 1000000007;\nconst int INF = 1e18;\n\nint n, x;\nvector a;\nint cost[2010][2010];\nint dp[2010];\n\nsigned main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tcin >> n >> x;\n\tassert(n <= 2000);\n\ta.resize(n);\n\trep(i, 0, n) cin >> a[i];\n\trep(i, 0, n){\n\t\tint now = x + a[i], cnt = 0;\n\t\tfor(int j = i; j >= 0; j--){\n\t\t\tnow += x;\n\t\t\tcnt++;\n\t\t\tcost[j][i] = now + (cnt + 1) * (cnt + 1) * a[j];\n\t\t\tif(j) now += (cnt + 1) * (cnt + 1) * (a[j] - a[j - 1]);\n\t\t}\n\t}\n\trep(i, 0, n + 1) dp[i] = INF; \n\tdp[0] = 0;\n\trep(i, 0, n){\n\t\trep(j, 0, n){\n\t\t\tdp[j + 1] = min(dp[j + 1], dp[i] + cost[i][j]);\n\t\t}\n\t}\n\tcout << dp[n] << endl;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line.\nThe i-th piece from the left is at position x_i.\nWe would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9} holds.\n\nThe robot is initially at position 0.\nIt can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 0. It is not allowed to put pieces of trash anywhere except in the trash bin.\n\nThe robot consumes X points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes X points of energy.)\nAlso, the robot consumes (k+1)^{2} points of energy to travel by a distance of 1 when the robot is carrying k pieces of trash.\n\nFind the minimum amount of energy required to put all the N pieces of trash in the trash bin.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n0 < x_1 < ... < x_N \\leq 10^9\n\n1 \\leq X \\leq 10^9\n\nAll values in input are integers.\n\nPartial Scores\n\n400 points will be awarded for passing the test set satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nx_1 x_2 ... x_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 100\n1 10\n\nSample Output 1\n\n355\n\nTravel to position 10 by consuming 10 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 1 by consuming 36 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 0 by consuming 9 points of energy.\n\nPut the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\nSample Input 2\n\n5 1\n1 999999997 999999998 999999999 1000000000\n\nSample Output 2\n\n19999999983\n\nSample Input 3\n\n10 8851025\n38 87 668 3175 22601 65499 90236 790604 4290609 4894746\n\nSample Output 3\n\n150710136\n\nSample Input 4\n\n16 10\n1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408\n\nSample Output 4\n\n3256017715", "sample_input": "2 100\n1 10\n"}, "reference_outputs": ["355\n"], "source_document_id": "p03255", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line.\nThe i-th piece from the left is at position x_i.\nWe would like to put all of them in a trash bin at position 0.\n\nFor the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \\leq 10^{9} holds.\n\nThe robot is initially at position 0.\nIt can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 0. It is not allowed to put pieces of trash anywhere except in the trash bin.\n\nThe robot consumes X points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes X points of energy.)\nAlso, the robot consumes (k+1)^{2} points of energy to travel by a distance of 1 when the robot is carrying k pieces of trash.\n\nFind the minimum amount of energy required to put all the N pieces of trash in the trash bin.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^{5}\n\n0 < x_1 < ... < x_N \\leq 10^9\n\n1 \\leq X \\leq 10^9\n\nAll values in input are integers.\n\nPartial Scores\n\n400 points will be awarded for passing the test set satisfying N \\leq 2000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nx_1 x_2 ... x_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 100\n1 10\n\nSample Output 1\n\n355\n\nTravel to position 10 by consuming 10 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 1 by consuming 36 points of energy.\n\nPick up the piece of trash by consuming 100 points of energy.\n\nTravel to position 0 by consuming 9 points of energy.\n\nPut the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\nSample Input 2\n\n5 1\n1 999999997 999999998 999999999 1000000000\n\nSample Output 2\n\n19999999983\n\nSample Input 3\n\n10 8851025\n38 87 668 3175 22601 65499 90236 790604 4290609 4894746\n\nSample Output 3\n\n150710136\n\nSample Input 4\n\n16 10\n1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408\n\nSample Output 4\n\n3256017715", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 918, "cpu_time_ms": 97, "memory_kb": 31232}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s603227409", "group_id": "codeNet:p03256", "input_text": "#include\nusing namespace std;\n\nusing Graph=vector>;\nint main(){\n int n;\n cin>>n;\n int m;\n cin>>m;\n string s;\n cin>>s;\n Graph g(n);\n for(int i=0;i>a>>b;\n a--,b--;\n g[a].push_back(b);\n g[b].push_back(a);\n }\n vector acnt(n);\n vector bcnt(n);\n vector ng(n,false);\n stack ngs;\n for(int i=0;i\nusing namespace std;\n\nusing Graph=vector>;\nint main(){\n int n;\n cin>>n;\n int m;\n cin>>m;\n string s;\n cin>>s;\n Graph g(n);\n for(int i=0;i>a>>b;\n a--,b--;\n g[a].push_back(b);\n g[b].push_back(a);\n }\n vector acnt(n);\n vector bcnt(n);\n vector ng(n,false);\n stack ngs;\n for(int i=0;i\n#include\n\nusing namespace std;\n\nint main(){ \n int H,W; cin >> H >> W;\n vector> A(H,vector(W));\n vector Y1; vector X1; vector Y2; vector X2;\n \n for(int i = 0; i < H; i++){\n for(int j = 0; j < W; j++){ cin >> A[i][j];}}\n int cnt = 0;\n for(int i = 0; i < H; i++){ \n if( i % 2 == 0){ //0-indexedで偶数番目の行について調べる\n for(int j = 0; j < W; j++){\n if( j != W - 1){ \n if( A[i][j] % 2 == 0){ continue;}\n else{ A[i][j]--; A[i][j+1]++; cnt++; Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+1); X2.push_back(j+2);\n }}\n else{ // j == W - 1の時\n if( A[i][j] % 2 != 0){ A[i][j]--;A[i+1][j]++; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+2); X2.push_back(j+1);\n }}\n }} //偶数行終了\n else{\n for(int j = W- 1; j >= 0; j--){\n if( j != 0){\n if( A[i][j] % 2 == 0){ continue;}\n else{ A[i][j]--; A[i][j-1]--; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+1); X2.push_back(j);}}\n else{ // j == 0の時\n if( A[i][j] % 2 != 0){ A[i][j]--; A[i+1][j]++; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+2); X2.push_back(j+1);}}\n }}} //奇数行終了\n \n cout << cnt << endl;\n if( cnt != 0){\n \n for(int i = 0; i < cnt; i++){\n cout << Y1[i] << \" \" << X1[i] << \" \" << Y2[i] << \" \" << X2[i] << endl;}}\n \n return 0;}\n \n \n", "language": "C++", "metadata": {"date": 1560399727, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03263.html", "problem_id": "p03263", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03263/input.txt", "sample_output_relpath": "derived/input_output/data/p03263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03263/C++/s329968103.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s329968103", "user_id": "u904123392"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "#include\n#include\n\nusing namespace std;\n\nint main(){ \n int H,W; cin >> H >> W;\n vector> A(H,vector(W));\n vector Y1; vector X1; vector Y2; vector X2;\n \n for(int i = 0; i < H; i++){\n for(int j = 0; j < W; j++){ cin >> A[i][j];}}\n int cnt = 0;\n for(int i = 0; i < H; i++){ \n if( i % 2 == 0){ //0-indexedで偶数番目の行について調べる\n for(int j = 0; j < W; j++){\n if( j != W - 1){ \n if( A[i][j] % 2 == 0){ continue;}\n else{ A[i][j]--; A[i][j+1]++; cnt++; Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+1); X2.push_back(j+2);\n }}\n else{ // j == W - 1の時\n if( A[i][j] % 2 != 0){ A[i][j]--;A[i+1][j]++; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+2); X2.push_back(j+1);\n }}\n }} //偶数行終了\n else{\n for(int j = W- 1; j >= 0; j--){\n if( j != 0){\n if( A[i][j] % 2 == 0){ continue;}\n else{ A[i][j]--; A[i][j-1]--; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+1); X2.push_back(j);}}\n else{ // j == 0の時\n if( A[i][j] % 2 != 0){ A[i][j]--; A[i+1][j]++; cnt++;\n Y1.push_back(i+1); X1.push_back(j+1);\n Y2.push_back(i+2); X2.push_back(j+1);}}\n }}} //奇数行終了\n \n cout << cnt << endl;\n if( cnt != 0){\n \n for(int i = 0; i < cnt; i++){\n cout << Y1[i] << \" \" << X1[i] << \" \" << Y2[i] << \" \" << X2[i] << endl;}}\n \n return 0;}\n \n \n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "sample_input": "2 3\n1 2 3\n0 1 1\n"}, "reference_outputs": ["3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n"], "source_document_id": "p03263", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1786, "cpu_time_ms": 271, "memory_kb": 5224}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s946340221", "group_id": "codeNet:p03268", "input_text": "#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 unsigned long long ull;\ntypedef pair pii;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef vector vpli;\n\ninline ll read(){\n ll Hashimoto=0;\n\tbool Kanna=1;\n char I_Love=getchar();\n while(I_Love<'0'||I_Love>'9'){\n if(I_Love=='-')Kanna=0;\n I_Love=getchar();\n }\n while(I_Love>='0'&&I_Love<='9'){\n Hashimoto=Hashimoto*10+I_Love-'0';\n I_Love=getchar();\n }\n return (Kanna?Hashimoto:-Hashimoto);\n}\ntemplate inline void Umax(T1 &a,T2 b){\n\tif(a inline void Umin(T1 &a,T2 b){\n\tif(a>b)a=b;\n}\n\n#define I_Love_Hashimoto_Kanna main\n#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define filein(s) freopen(s,\"r\",stdin);\n#define fileout(s) freopen(s,\"w\",stdout);\n#define file freopen(\"I_Love_Hashimoto_Kanna.out\",\"w\",stdout);\n#define RE cout<<\"I_Love_Hashimoto_Kanna\"<>n>>k;\n\tll cnt=0;\n\tll cnt2=0;\n\tfor(int i=1;i<=n;i++){\n\t\tif(2*i%k==0){\n\t\t\tif((2*i/k)%2)cnt++;\n\t\t\telse cnt2++;\n\t\t}\n\t}\n\t\n\tTone(cnt*cnt*cnt+cnt2*cnt2*cnt2)\n\t\n\t\n\treturn 0;\n}\n", "language": "C++", "metadata": {"date": 1535850793, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03268.html", "problem_id": "p03268", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03268/input.txt", "sample_output_relpath": "derived/input_output/data/p03268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03268/C++/s946340221.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946340221", "user_id": "u754862537"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "#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 unsigned long long ull;\ntypedef pair pii;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef vector vpli;\n\ninline ll read(){\n ll Hashimoto=0;\n\tbool Kanna=1;\n char I_Love=getchar();\n while(I_Love<'0'||I_Love>'9'){\n if(I_Love=='-')Kanna=0;\n I_Love=getchar();\n }\n while(I_Love>='0'&&I_Love<='9'){\n Hashimoto=Hashimoto*10+I_Love-'0';\n I_Love=getchar();\n }\n return (Kanna?Hashimoto:-Hashimoto);\n}\ntemplate inline void Umax(T1 &a,T2 b){\n\tif(a inline void Umin(T1 &a,T2 b){\n\tif(a>b)a=b;\n}\n\n#define I_Love_Hashimoto_Kanna main\n#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define filein(s) freopen(s,\"r\",stdin);\n#define fileout(s) freopen(s,\"w\",stdout);\n#define file freopen(\"I_Love_Hashimoto_Kanna.out\",\"w\",stdout);\n#define RE cout<<\"I_Love_Hashimoto_Kanna\"<>n>>k;\n\tll cnt=0;\n\tll cnt2=0;\n\tfor(int i=1;i<=n;i++){\n\t\tif(2*i%k==0){\n\t\t\tif((2*i/k)%2)cnt++;\n\t\t\telse cnt2++;\n\t\t}\n\t}\n\t\n\tTone(cnt*cnt*cnt+cnt2*cnt2*cnt2)\n\t\n\t\n\treturn 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "sample_input": "3 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03268", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n1 \\leq N,K \\leq 2\\times 10^5\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n9\n\n(1,1,1),(1,1,3),(1,3,1),(1,3,3),(2,2,2),(3,1,1),(3,1,3),(3,3,1) and (3,3,3) satisfy the condition.\n\nSample Input 2\n\n5 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n27\n\nSample Input 4\n\n35897 932\n\nSample Output 4\n\n114191", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2027, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s480642101", "group_id": "codeNet:p03272", "input_text": "#include \nusing namespace std;\n\n// Loops\n#define _overload3(_1, _2, _3, name, ...) name\n#define _rep(i, n) repi(i, 0, n)\n#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)\n#define _rrep(i, n) rrepi(i, n, 0)\n#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)\n\n#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)\n#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)\n#define each(xi, x) for (auto &&xi : x)\n// Note: we can use rep(i,N) or rep(i,from,to)\n\n// typedef\ntemplate using vec = vector;\nusing ll = long long;\nusing vi = vec;\nusing vvi = vec;\nusing vvvi = vec;\nusing pii = pair;\n\n// Constants\n\n// Shorter repr for frequently used terms\n#define pb push_back\n#define mp make_pair\n\n// Algorithms\n#define all(x) (x).begin(), (x).end()\n#define uniq(v) v.erase(unique(all(v)), v.end())\n#define perm(c) \\\n sort(all(c)); \\\n for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))\n\ntemplate pair max(vector &x) {\n auto it = max_element(all(x));\n return mp(*it, it - x.begin());\n}\ntemplate pair min(vector &x) {\n auto it = min_element(all(x));\n return mp(*it, it - x.begin());\n}\n\ntemplate inline bool chmax(T &maxval, const T &newval) {\n if (maxval < newval) {\n maxval = newval;\n return 1;\n }\n return 0;\n}\ntemplate inline bool chmin(T &minval, const T &newval) {\n if (minval > newval) {\n minval = newval;\n return 1;\n }\n return 0;\n}\n\n// Utilities\n// Grid world utilities\nint dx[4] = {0, 1, 0, -1};\nint dy[4] = {1, 0, -1, 0};\n#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)\n\n// Debug\n#ifdef LOCAL\n#include \"dump.hpp\"\n#define debug(x) cerr << #x << \": \" << x << '\\n'\n#else\n#define dump(...)\n#define debug(x)\n#endif\n\n// Yes or No\nvoid yesno(bool ok, string yes = \"Yes\", string no = \"No\") {\n cout << (ok ? yes : no) << endl;\n}\n\n// Paste snippets here!!\n\n//\n\nvoid solve(long long N, long long i) {\n cout << N - i + 1 << endl;\n}\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false); // Magic for faster cin\n cout.precision(12);\n long long N;\n std::cin >> N;\n long long i;\n std::cin >> i;\n solve(N, i);\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1593572559, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03272/input.txt", "sample_output_relpath": "derived/input_output/data/p03272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03272/C++/s480642101.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s480642101", "user_id": "u292813062"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\n\n// Loops\n#define _overload3(_1, _2, _3, name, ...) name\n#define _rep(i, n) repi(i, 0, n)\n#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)\n#define _rrep(i, n) rrepi(i, n, 0)\n#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)\n\n#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)\n#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)\n#define each(xi, x) for (auto &&xi : x)\n// Note: we can use rep(i,N) or rep(i,from,to)\n\n// typedef\ntemplate using vec = vector;\nusing ll = long long;\nusing vi = vec;\nusing vvi = vec;\nusing vvvi = vec;\nusing pii = pair;\n\n// Constants\n\n// Shorter repr for frequently used terms\n#define pb push_back\n#define mp make_pair\n\n// Algorithms\n#define all(x) (x).begin(), (x).end()\n#define uniq(v) v.erase(unique(all(v)), v.end())\n#define perm(c) \\\n sort(all(c)); \\\n for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))\n\ntemplate pair max(vector &x) {\n auto it = max_element(all(x));\n return mp(*it, it - x.begin());\n}\ntemplate pair min(vector &x) {\n auto it = min_element(all(x));\n return mp(*it, it - x.begin());\n}\n\ntemplate inline bool chmax(T &maxval, const T &newval) {\n if (maxval < newval) {\n maxval = newval;\n return 1;\n }\n return 0;\n}\ntemplate inline bool chmin(T &minval, const T &newval) {\n if (minval > newval) {\n minval = newval;\n return 1;\n }\n return 0;\n}\n\n// Utilities\n// Grid world utilities\nint dx[4] = {0, 1, 0, -1};\nint dy[4] = {1, 0, -1, 0};\n#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)\n\n// Debug\n#ifdef LOCAL\n#include \"dump.hpp\"\n#define debug(x) cerr << #x << \": \" << x << '\\n'\n#else\n#define dump(...)\n#define debug(x)\n#endif\n\n// Yes or No\nvoid yesno(bool ok, string yes = \"Yes\", string no = \"No\") {\n cout << (ok ? yes : no) << endl;\n}\n\n// Paste snippets here!!\n\n//\n\nvoid solve(long long N, long long i) {\n cout << N - i + 1 << endl;\n}\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false); // Magic for faster cin\n cout.precision(12);\n long long N;\n std::cin >> N;\n long long i;\n std::cin >> i;\n solve(N, i);\n return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2370, "cpu_time_ms": 8, "memory_kb": 3576}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s349422277", "group_id": "codeNet:p03272", "input_text": "#include\nusing namespace std;\n#define rep(i, n) for(int i = 0; i < (n); i++)\n#define rep1(i, n) for(int i = 1; i <= (n); i++)\n#define Would\n#define you\n#define please\n\nint main() {\n\tint N,i;\n\tcin >> N >> i;\n\tcout << N + 1 - i << \"\\n\";\n\n\tWould you please return 0;\n}\n", "language": "C++", "metadata": {"date": 1535245301, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03272/input.txt", "sample_output_relpath": "derived/input_output/data/p03272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03272/C++/s349422277.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s349422277", "user_id": "u096883693"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\nusing namespace std;\n#define rep(i, n) for(int i = 0; i < (n); i++)\n#define rep1(i, n) for(int i = 1; i <= (n); i++)\n#define Would\n#define you\n#define please\n\nint main() {\n\tint N,i;\n\tcin >> N >> i;\n\tcout << N + 1 - i << \"\\n\";\n\n\tWould you please return 0;\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s513032179", "group_id": "codeNet:p03273", "input_text": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int INF = 1 << 30;\nconst ll INFll = 1ll << 60;\n\nint main() {\n int h, w;\n cin >> h >> w;\n vector H;\n vector W;\n vector> A(h, vector(w));\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n char a;\n cin >> a;\n A[i][j] = a;\n if (a == '#') {\n H.push_back(i);\n W.push_back(j);\n }\n }\n }\n\n for (int i : H) {\n for (int j : W) {\n cout << A[i][j];\n }\n cout << endl;\n }\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1577168940, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/C++/s513032179.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s513032179", "user_id": "u735008991"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int INF = 1 << 30;\nconst ll INFll = 1ll << 60;\n\nint main() {\n int h, w;\n cin >> h >> w;\n vector H;\n vector W;\n vector> A(h, vector(w));\n for (int i = 0; i < h; i++) {\n for (int j = 0; j < w; j++) {\n char a;\n cin >> a;\n A[i][j] = a;\n if (a == '#') {\n H.push_back(i);\n W.push_back(j);\n }\n }\n }\n\n for (int i : H) {\n for (int j : W) {\n cout << A[i][j];\n }\n cout << endl;\n }\n\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 590, "cpu_time_ms": 2103, "memory_kb": 70656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s408838026", "group_id": "codeNet:p03273", "input_text": "#include\nusing namespace std;\nint n,m;\nchar f[101][101]={0};\nint check(int a,int i)\n{\n\tint j;\n\tif(a==0)\n\t{\n\t\tfor(j=0;j\nusing namespace std;\nint n,m;\nchar f[101][101]={0};\nint check(int a,int i)\n{\n\tint j;\n\tif(a==0)\n\t{\n\t\tfor(j=0;j\n#include \nusing namespace std;\n#define MAX_N 100001\n\nint N;\nint K;\nlong int x[MAX_N];\n\nint main(){\n cin >> N >> K;\n bool flag = true;\n for (int i = 0; i < N; i++){\n long int element;\n cin >> element;\n // if ((element > 0) && (flag)){\n // flag = false;\n // x[i] = 0;\n // i ++;\n // }\n x[i] = element;\n }\n // for (int i = 0; i <= N; i++){\n // cout << x[i] << endl;\n // }\n int left = 0;\n int right = K - 1;\n long int distance = 10000000001;\n if (x[0] >= 0){\n distance = x[K - 1];\n }\n else if (x[N - 1] <= 0){\n distance = - x[N - K];\n }\n else{\n while (right < N){\n if ((x[right] >= 0) && (x[left] <= 0)){\n distance = min(min(2 * x[right] - x[left], x[right] - 2 * x[left]), distance);\n }\n left ++;\n right ++;\n }\n }\n cout << distance << endl;\n\n return 0;\n}", "language": "C++", "metadata": {"date": 1556733542, "filename_ext": "cpp", "original_language": "C++14 (Clang 3.8.0)", "problem_description_relpath": "problem_descriptions/p03274.html", "problem_id": "p03274", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03274/input.txt", "sample_output_relpath": "derived/input_output/data/p03274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03274/C++/s857444803.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857444803", "user_id": "u168139048"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "#include \n#include \nusing namespace std;\n#define MAX_N 100001\n\nint N;\nint K;\nlong int x[MAX_N];\n\nint main(){\n cin >> N >> K;\n bool flag = true;\n for (int i = 0; i < N; i++){\n long int element;\n cin >> element;\n // if ((element > 0) && (flag)){\n // flag = false;\n // x[i] = 0;\n // i ++;\n // }\n x[i] = element;\n }\n // for (int i = 0; i <= N; i++){\n // cout << x[i] << endl;\n // }\n int left = 0;\n int right = K - 1;\n long int distance = 10000000001;\n if (x[0] >= 0){\n distance = x[K - 1];\n }\n else if (x[N - 1] <= 0){\n distance = - x[N - K];\n }\n else{\n while (right < N){\n if ((x[right] >= 0) && (x[left] <= 0)){\n distance = min(min(2 * x[right] - x[left], x[right] - 2 * x[left]), distance);\n }\n left ++;\n right ++;\n }\n }\n cout << distance << endl;\n\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03274", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 994, "cpu_time_ms": 110, "memory_kb": 1024}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s869856828", "group_id": "codeNet:p03275", "input_text": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\ntemplate\nstruct SegmentTree {\n using F = function;\n\n int sz;\n vector seg;\n\n const F f;\n const Monoid M1;\n\n SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {\n sz = 1;\n while(sz < n) sz <<= 1;\n seg.assign(2 * sz, M1);\n }\n\n void set(int k, const Monoid &x) {\n seg[k + sz] = x;\n }\n\n void build() {\n for(int k = sz - 1; k > 0; k--) {\n seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);\n }\n }\n\n void update(int k, const Monoid &x) {\n k += sz;\n seg[k] = x;\n while(k >>= 1) {\n seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);\n }\n }\n\n Monoid query(int a, int b) {\n Monoid L = M1, R = M1;\n for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {\n if(a & 1) L = f(L, seg[a++]);\n if(b & 1) R = f(seg[--b], R);\n }\n return f(L, R);\n }\n\n Monoid operator[](const int &k) const {\n return seg[k + sz];\n }\n};\n\nint main()\n{\n int n;\n cin >> n;\n int a[100002];\n for(int i = 0; i < n; i++) cin >> a[i];\n int now = 1048576 * 512 - 1;\n int mid = 1048576 * 256;\n while(mid){\n int b[100002]{0};\n for(int i = 0; i < n; i++){\n if(a[i] >= now) b[i]++;\n else b[i]--;\n b[i + 1] += b[i];\n }\n ll s[200002]{0};\n for(int i = 0; i < n; i++) s[b[i] + 100000]++;\n SegmentTree seg(200000, [](ll a, ll b){return a + b;}, 0ll);\n for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);\n seg.build();\n int k = 0;\n ll sum = 0;\n for(int i = 0; i < n; i++){\n sum += seg.query(k + 100000, 200001);\n seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);\n if(a[i] < now) k--;\n else k++;\n }\n if(sum >= (n * (n + 1) / 2 + 1) / 2) now += mid;\n else now -= mid;\n mid /= 2;\n }\n int b[100002]{0};\n for(int i = 0; i < n; i++){\n if(a[i] >= now) b[i]++;\n else b[i]--;\n b[i + 1] += b[i];\n }\n ll s[200002]{0};\n for(int i = 0; i < n; i++) s[b[i] + 100000]++;\n SegmentTree seg(200000, [](ll a, ll b){return a + b;}, 0ll);\n for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);\n seg.build();\n int k = 0;\n ll sum = 0;\n for(int i = 0; i < n; i++){\n sum += seg.query(k + 100000, 200001);\n seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);\n if(a[i] < now) k--;\n else k++;\n }\n if(sum < (n * (n + 1) / 2 + 1) / 2) now--;\n cout << now << endl;\n}", "language": "C++", "metadata": {"date": 1578693285, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03275.html", "problem_id": "p03275", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03275/input.txt", "sample_output_relpath": "derived/input_output/data/p03275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03275/C++/s869856828.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s869856828", "user_id": "u681557252"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\ntemplate\nstruct SegmentTree {\n using F = function;\n\n int sz;\n vector seg;\n\n const F f;\n const Monoid M1;\n\n SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {\n sz = 1;\n while(sz < n) sz <<= 1;\n seg.assign(2 * sz, M1);\n }\n\n void set(int k, const Monoid &x) {\n seg[k + sz] = x;\n }\n\n void build() {\n for(int k = sz - 1; k > 0; k--) {\n seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);\n }\n }\n\n void update(int k, const Monoid &x) {\n k += sz;\n seg[k] = x;\n while(k >>= 1) {\n seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);\n }\n }\n\n Monoid query(int a, int b) {\n Monoid L = M1, R = M1;\n for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {\n if(a & 1) L = f(L, seg[a++]);\n if(b & 1) R = f(seg[--b], R);\n }\n return f(L, R);\n }\n\n Monoid operator[](const int &k) const {\n return seg[k + sz];\n }\n};\n\nint main()\n{\n int n;\n cin >> n;\n int a[100002];\n for(int i = 0; i < n; i++) cin >> a[i];\n int now = 1048576 * 512 - 1;\n int mid = 1048576 * 256;\n while(mid){\n int b[100002]{0};\n for(int i = 0; i < n; i++){\n if(a[i] >= now) b[i]++;\n else b[i]--;\n b[i + 1] += b[i];\n }\n ll s[200002]{0};\n for(int i = 0; i < n; i++) s[b[i] + 100000]++;\n SegmentTree seg(200000, [](ll a, ll b){return a + b;}, 0ll);\n for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);\n seg.build();\n int k = 0;\n ll sum = 0;\n for(int i = 0; i < n; i++){\n sum += seg.query(k + 100000, 200001);\n seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);\n if(a[i] < now) k--;\n else k++;\n }\n if(sum >= (n * (n + 1) / 2 + 1) / 2) now += mid;\n else now -= mid;\n mid /= 2;\n }\n int b[100002]{0};\n for(int i = 0; i < n; i++){\n if(a[i] >= now) b[i]++;\n else b[i]--;\n b[i + 1] += b[i];\n }\n ll s[200002]{0};\n for(int i = 0; i < n; i++) s[b[i] + 100000]++;\n SegmentTree seg(200000, [](ll a, ll b){return a + b;}, 0ll);\n for(int i = 0; i <= 200000; i++) seg.set(i, s[i]);\n seg.build();\n int k = 0;\n ll sum = 0;\n for(int i = 0; i < n; i++){\n sum += seg.query(k + 100000, 200001);\n seg.update(b[i] + 100000, seg[b[i] + 100000] - 1);\n if(a[i] < now) k--;\n else k++;\n }\n if(sum < (n * (n + 1) / 2 + 1) / 2) now--;\n cout << now << endl;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "sample_input": "3\n10 30 20\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03275", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2718, "cpu_time_ms": 580, "memory_kb": 6656}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s150970974", "group_id": "codeNet:p03275", "input_text": "#include \n#include \n#include \nusing namespace std;\nconst int maxn=1e6+10;\nint a[maxn],b[maxn];\nstruct node{\n\tint val,loc;\n}sub[maxn];\nlong long tre[maxn],n;\nint cmp(const node &a,const node &b){\n\tif(a.val==b.val) return a.loc0){\n\t\tsum+=tre[pos];\n\t\tpos-=lowbit(pos);\n\t}\n\treturn sum;\n}\nlong long check(int val){\n\tmemset(tre,0,sizeof(tre));\n\tlong long ans=0;\n\tfor(int i=1;i<=n;i++){\n\t\tif(a[i]=0) ans++;\n\t}\n\treturn ans;\n}\nint erf(int l,int r){\n\tint mid;\n\tlong long _std=(n+1)*n/4+1;\n\twhile(l>1;\n\t\tif(check(b[mid])>=_std) l=mid;//Çó³ö±Èb[mid]´óÓÚµÈÓÚµÄ \n\t\telse r=mid-1;\n\t}\n\treturn l;\n}\nint main(){\n\tcin>>n;\n\tfor(int i=1;i<=n;i++) {\n\t\tscanf(\"%d\",&a[i]);b[i]=a[i];\n\t}\n\t\n\tsort(b+1,b+n+1);\n\tcout<\n#include \n#include \nusing namespace std;\nconst int maxn=1e6+10;\nint a[maxn],b[maxn];\nstruct node{\n\tint val,loc;\n}sub[maxn];\nlong long tre[maxn],n;\nint cmp(const node &a,const node &b){\n\tif(a.val==b.val) return a.loc0){\n\t\tsum+=tre[pos];\n\t\tpos-=lowbit(pos);\n\t}\n\treturn sum;\n}\nlong long check(int val){\n\tmemset(tre,0,sizeof(tre));\n\tlong long ans=0;\n\tfor(int i=1;i<=n;i++){\n\t\tif(a[i]=0) ans++;\n\t}\n\treturn ans;\n}\nint erf(int l,int r){\n\tint mid;\n\tlong long _std=(n+1)*n/4+1;\n\twhile(l>1;\n\t\tif(check(b[mid])>=_std) l=mid;//Çó³ö±Èb[mid]´óÓÚµÈÓÚµÄ \n\t\telse r=mid-1;\n\t}\n\treturn l;\n}\nint main(){\n\tcin>>n;\n\tfor(int i=1;i<=n;i++) {\n\t\tscanf(\"%d\",&a[i]);b[i]=a[i];\n\t}\n\t\n\tsort(b+1,b+n+1);\n\tcout<\n#include\n#include\nusing namespace std;\nlong long n,k,s[101010],minv=200000020;\nint main()\n{\n\tcin>>n>>k;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>s[i];\n\t}\n\tfor(int i=1;i<=(n-k+1);i++)minv=min(minv,(s[i]*s[i+k-1]>0)?max(abs(s[i]),abs(s[i+k-1])):min(abs(s[i]),abs(s[i+k-1]))*2+max(abs(s[i]),abs(s[i+k-1])));\n\tcout<\n#include\n#include\nusing namespace std;\nlong long n,k,s[101010],minv=200000020;\nint main()\n{\n\tcin>>n>>k;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>s[i];\n\t}\n\tfor(int i=1;i<=(n-k+1);i++)minv=min(minv,(s[i]*s[i+k-1]>0)?max(abs(s[i]),abs(s[i+k-1])):min(abs(s[i]),abs(s[i+k-1]))*2+max(abs(s[i]),abs(s[i+k-1])));\n\tcout<\n\nusing namespace std;\n\n#define rep(i, a, b) for (int i = (a); i <= (b); i++)\n#define per(i, a, b) for (int i = (a); i >= (b); i--)\n#define trv(p, u) for (edg *p = h[u]; p; p = p->nxt)\n#define push_back pb\ntypedef long long ll;\ntypedef double db;\nconst int N = 2e5 + 100;\nconst int inf = 0x3f3f3f3f;\nconst int mod = 1e9 + 7;\n\ninline int rd() {\n int s = 0, w = 1; char c = getchar();\n while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }\n while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();\n return s * w;\n}\n\nint n, ans, a[N], s[N];\n\nstruct nod {\n int lft, rgt, sum;\n nod *ls, *rs;\n inline void setc() { sum++; }\n inline void upd() { sum = ls->sum + rs->sum; }\n} pol[N << 3], *rot, *cur = pol;\n\ninline void build(nod *r, int lft, int rgt) {\n r->lft = lft, r->rgt = rgt;\n if (lft == rgt) {\n r->sum = 0;\n return ;\n }\n int mid = (lft + rgt) >> 1;\n nod *ls = ++cur, *rs = ++cur;\n r->ls = ls, r->rs = rs;\n build(ls, lft, mid), build(rs, mid + 1, rgt);\n r->upd();\n}\n\ninline void chg(nod *r, int pos) {\n if (r->lft == pos && r->rgt == pos) {\n r->setc(); return ;\n }\n if (r->ls->rgt >= pos) chg(r->ls, pos);\n else chg(r->rs, pos);\n r->upd();\n}\n\ninline int qry(nod *r, int lft, int rgt) {\n if (lft > rgt) return 0;\n if (r->lft == lft && r->rgt == rgt) return r->sum;\n if (r->ls->rgt >= rgt) return qry(r->ls, lft, rgt);\n else if (r->rs->lft <= lft) return qry(r->rs, lft, rgt);\n else return qry(r->ls, lft, r->ls->rgt) +\n qry(r->rs, r->rs->lft, rgt);\n}\n\ninline bool chk(int x) {\n ll res = 0;\n memset(s, 0, sizeof(s));\n cur = pol;\n rep(i, 1, n) {\n if (a[i] <= x) s[i] = s[i - 1] + 1;\n else s[i] = s[i - 1] - 1;\n }\n rep(i, 0, n) s[i] += (n + 1);\n build(rot = pol, 1, N - 100);\n rep(i, 0, n) {\n res += 1ll * qry(rot, 1, s[i] - 1);\n chg(rot, s[i]);\n }\n return (res >= 1ll * n * (n + 1) / 4 + 1);\n}\n\nint main() {\n n = rd();\n rep(i, 1, n) a[i] = rd();\n int l = 1, r = inf;\n while (l <= r) {\n int mid = (l + r) >> 1;\n if (chk(mid)) ans = mid, r = mid - 1;\n else l = mid + 1;\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "language": "C++", "metadata": {"date": 1566447858, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03277.html", "problem_id": "p03277", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03277/input.txt", "sample_output_relpath": "derived/input_output/data/p03277/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03277/C++/s599787790.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s599787790", "user_id": "u353919145"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\n#define rep(i, a, b) for (int i = (a); i <= (b); i++)\n#define per(i, a, b) for (int i = (a); i >= (b); i--)\n#define trv(p, u) for (edg *p = h[u]; p; p = p->nxt)\n#define push_back pb\ntypedef long long ll;\ntypedef double db;\nconst int N = 2e5 + 100;\nconst int inf = 0x3f3f3f3f;\nconst int mod = 1e9 + 7;\n\ninline int rd() {\n int s = 0, w = 1; char c = getchar();\n while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }\n while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();\n return s * w;\n}\n\nint n, ans, a[N], s[N];\n\nstruct nod {\n int lft, rgt, sum;\n nod *ls, *rs;\n inline void setc() { sum++; }\n inline void upd() { sum = ls->sum + rs->sum; }\n} pol[N << 3], *rot, *cur = pol;\n\ninline void build(nod *r, int lft, int rgt) {\n r->lft = lft, r->rgt = rgt;\n if (lft == rgt) {\n r->sum = 0;\n return ;\n }\n int mid = (lft + rgt) >> 1;\n nod *ls = ++cur, *rs = ++cur;\n r->ls = ls, r->rs = rs;\n build(ls, lft, mid), build(rs, mid + 1, rgt);\n r->upd();\n}\n\ninline void chg(nod *r, int pos) {\n if (r->lft == pos && r->rgt == pos) {\n r->setc(); return ;\n }\n if (r->ls->rgt >= pos) chg(r->ls, pos);\n else chg(r->rs, pos);\n r->upd();\n}\n\ninline int qry(nod *r, int lft, int rgt) {\n if (lft > rgt) return 0;\n if (r->lft == lft && r->rgt == rgt) return r->sum;\n if (r->ls->rgt >= rgt) return qry(r->ls, lft, rgt);\n else if (r->rs->lft <= lft) return qry(r->rs, lft, rgt);\n else return qry(r->ls, lft, r->ls->rgt) +\n qry(r->rs, r->rs->lft, rgt);\n}\n\ninline bool chk(int x) {\n ll res = 0;\n memset(s, 0, sizeof(s));\n cur = pol;\n rep(i, 1, n) {\n if (a[i] <= x) s[i] = s[i - 1] + 1;\n else s[i] = s[i - 1] - 1;\n }\n rep(i, 0, n) s[i] += (n + 1);\n build(rot = pol, 1, N - 100);\n rep(i, 0, n) {\n res += 1ll * qry(rot, 1, s[i] - 1);\n chg(rot, s[i]);\n }\n return (res >= 1ll * n * (n + 1) / 4 + 1);\n}\n\nint main() {\n n = rd();\n rep(i, 1, n) a[i] = rd();\n int l = 1, r = inf;\n while (l <= r) {\n int mid = (l + r) >> 1;\n if (chk(mid)) ans = mid, r = mid - 1;\n else l = mid + 1;\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "sample_input": "3\n10 30 20\n"}, "reference_outputs": ["30\n"], "source_document_id": "p03277", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe will define the median of a sequence b of length M, as follows:\n\nLet b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.\n\nFor example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10.\n\nSnuke comes up with the following problem.\n\nYou are given a sequence a of length N.\nFor each pair (l, r) (1 \\leq l \\leq r \\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a.\nWe will list m_{l, r} for all pairs (l, r) to create a new sequence m.\nFind the median of m.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the median of m.\n\nSample Input 1\n\n3\n10 30 20\n\nSample Output 1\n\n30\n\nThe median of each contiguous subsequence of a is as follows:\n\nThe median of (10) is 10.\n\nThe median of (30) is 30.\n\nThe median of (20) is 20.\n\nThe median of (10, 30) is 30.\n\nThe median of (30, 20) is 30.\n\nThe median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\nSample Input 2\n\n1\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n10\n5 9 5 9 8 9 3 5 4 3\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2134, "cpu_time_ms": 400, "memory_kb": 16768}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s768691622", "group_id": "codeNet:p03282", "input_text": "//url:\n//problem name:\n\n#include \n#define REP(i,n) for (int i = 0; i < (n); ++i)\ntemplate inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}\ntemplate inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing Pl = pair;\nusing veci = vector;\nusing vecl = vector;\nusing vecveci = vector>;\nusing vecvecl = vector>;\n\nint main() {\n string S;\n ll K;\n cin >> S >> K;\n if(K == 1) cout << S[0] << endl;\n else if(S[0] == '1') {\n int i = 1;\n while(S[i] == '1') i++;\n cout << S[i] << endl;\n }\n else cout << S[0] << endl;\n}\n\n", "language": "C++", "metadata": {"date": 1590290656, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/C++/s768691622.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s768691622", "user_id": "u446371873"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//url:\n//problem name:\n\n#include \n#define REP(i,n) for (int i = 0; i < (n); ++i)\ntemplate inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}\ntemplate inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}\nusing namespace std;\nusing ll = long long;\nusing P = pair;\nusing Pl = pair;\nusing veci = vector;\nusing vecl = vector;\nusing vecveci = vector>;\nusing vecvecl = vector>;\n\nint main() {\n string S;\n ll K;\n cin >> S >> K;\n if(K == 1) cout << S[0] << endl;\n else if(S[0] == '1') {\n int i = 1;\n while(S[i] == '1') i++;\n cout << S[i] << endl;\n }\n else cout << S[0] << endl;\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 755, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s779337125", "group_id": "codeNet:p03282", "input_text": "#include\nusing namespace std;\n\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\tstring s; long long n;\n\tcin >> s >> n;\n\tlong long temp=0;\n\tfor(int i=0;i 1){\n\t\t\tif(n < temp){\n\t\t\t\tputs(\"1\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcout << s[i] << \"\\n\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\ttemp++;\n\t}\n\treturn 0;\n}", "language": "C++", "metadata": {"date": 1535234028, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/C++/s779337125.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s779337125", "user_id": "u211227348"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\tstring s; long long n;\n\tcin >> s >> n;\n\tlong long temp=0;\n\tfor(int i=0;i 1){\n\t\t\tif(n < temp){\n\t\t\t\tputs(\"1\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcout << s[i] << \"\\n\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\ttemp++;\n\t}\n\treturn 0;\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s771590235", "group_id": "codeNet:p03283", "input_text": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair P;\ntypedef pair l_l;\nconst int INF=1001001000;\nconst int mINF=-1001001000;\nconst ll LINF=10100100100100100;\nint main(){\n int n,m,Q;cin >> n >> m >> Q;\n vector L(m),R(m);\n vector> sum(n+1,vector(n+1,0));\n for(int i=0;i> L[i] >> R[i];\n sum[L[i]][R[i]]++;\n }\n for(int i=1;i<=n;i++){\n for(int j=1;j<=n;j++){\n sum[i][j]+=sum[i][j-1]+sum[i-1][j];\n sum[i][j]-=sum[i-1][j-1];\n }\n }\n vector ans(Q);\n for(int i=0;i> p >> q;\n ans[i]=sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1];\n }\n for(int i=0;i\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair P;\ntypedef pair l_l;\nconst int INF=1001001000;\nconst int mINF=-1001001000;\nconst ll LINF=10100100100100100;\nint main(){\n int n,m,Q;cin >> n >> m >> Q;\n vector L(m),R(m);\n vector> sum(n+1,vector(n+1,0));\n for(int i=0;i> L[i] >> R[i];\n sum[L[i]][R[i]]++;\n }\n for(int i=1;i<=n;i++){\n for(int j=1;j<=n;j++){\n sum[i][j]+=sum[i][j-1]+sum[i-1][j];\n sum[i][j]-=sum[i-1][j-1];\n }\n }\n vector ans(Q);\n for(int i=0;i> p >> q;\n ans[i]=sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1];\n }\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n int N,K;\n cin >> N >> K;\n cout << N%K << endl;\n \nreturn 0;\n}\n\n", "language": "C++", "metadata": {"date": 1556943747, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/C++/s396516431.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s396516431", "user_id": "u451206510"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n int N,K;\n cin >> N >> K;\n cout << N%K << endl;\n \nreturn 0;\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s425313614", "group_id": "codeNet:p03284", "input_text": "#include \n\nusing namespace std;\n\nint main() {\n int N, K;\n cin >> N >> K;\n if(N < K) cout << 1 << \"\\n\";\n else cout << N%K << \"\\n\";\n}", "language": "C++", "metadata": {"date": 1541414799, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/C++/s425313614.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s425313614", "user_id": "u021083776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include \n\nusing namespace std;\n\nint main() {\n int N, K;\n cin >> N >> K;\n if(N < K) cout << 1 << \"\\n\";\n else cout << N%K << \"\\n\";\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 153, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s092270934", "group_id": "codeNet:p03284", "input_text": "#include\n#include\nusing namespace std;\nint main(){\n\tint n,k;\n\tcin>>n>>k;\n\tif(n%k==0)\n\tprintf(\"0\");\n\telse\n\tprintf(\"1\");\n}", "language": "C++", "metadata": {"date": 1534036023, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03284/input.txt", "sample_output_relpath": "derived/input_output/data/p03284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03284/C++/s092270934.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092270934", "user_id": "u935016091"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "#include\n#include\nusing namespace std;\nint main(){\n\tint n,k;\n\tcin>>n>>k;\n\tif(n%k==0)\n\tprintf(\"0\");\n\telse\n\tprintf(\"1\");\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s605834576", "group_id": "codeNet:p03285", "input_text": "\n#include \n#include //! for setprecision(10)\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\n#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } \n#define rep(i,n) for (int i = 0; i < (n); ++i)\n\nconst int MOD = 1000000007;\n\nint main()\n{\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\n int N;\n cin >> N;\n\n int ans = 0;\n for (int i = 0; i*4 <= N; ++i) {\n if ((N-i*4)%7 == 0) {\n ++ans;\n }\n }\n\n cout << (ans ? \"Yes\" : \"No\") << endl;\n\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1574681693, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/C++/s605834576.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s605834576", "user_id": "u851470173"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\n#include \n#include //! for setprecision(10)\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\n#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } \n#define rep(i,n) for (int i = 0; i < (n); ++i)\n\nconst int MOD = 1000000007;\n\nint main()\n{\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\n int N;\n cin >> N;\n\n int ans = 0;\n for (int i = 0; i*4 <= N; ++i) {\n if ((N-i*4)%7 == 0) {\n ++ans;\n }\n }\n\n cout << (ans ? \"Yes\" : \"No\") << endl;\n\n return 0;\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 771, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s420745734", "group_id": "codeNet:p03285", "input_text": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tint x;\n\tcin >> x;\n\n\tint n = 0;\n\tfor (int i = 0; i < 26; i++) {\n\t\tfor (int j = 0; j < 16; j++) {\n\t\t\tif ((4*i + 7*j) == x)n++;\n\t\t}\n\t}\n\t\n\tif (n > 0)cout << \"Yes\";\n\telse cout << \"No\";\n}\n", "language": "C++", "metadata": {"date": 1569545983, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/C++/s420745734.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420745734", "user_id": "u103686642"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tint x;\n\tcin >> x;\n\n\tint n = 0;\n\tfor (int i = 0; i < 26; i++) {\n\t\tfor (int j = 0; j < 16; j++) {\n\t\t\tif ((4*i + 7*j) == x)n++;\n\t\t}\n\t}\n\t\n\tif (n > 0)cout << \"Yes\";\n\telse cout << \"No\";\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s554460579", "group_id": "codeNet:p03286", "input_text": "#include \n\n#define F first \n#define S second\n#define PB push_back\n\nusing namespace std;\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef priority_queue HEAP;\ntypedef priority_queue, greater > RHEAP;\n\nconst int N = 100010, M = 1010;\n\nint n, m = -2;\nstring res;\n\nint main()\n{\n\tcin >> n;\n\tif (!n) puts(\"0\");\n\telse\n\t{\n\t\tfor (int i = n; i; i /= m)\n\t\t{\n\t\t\tif (i % abs(m))\n\t\t\t{\n\t\t\t\tres += \"1\";\n\t\t\t\tif (m < 0) i -- ;\n\t\t\t}\n\t\t\telse res += \"0\";\n\t\t}\n\t\treverse(res.begin(), res.end());\n\t}\n\tcout << res << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1594828501, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/C++/s554460579.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554460579", "user_id": "u866538547"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "#include \n\n#define F first \n#define S second\n#define PB push_back\n\nusing namespace std;\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef priority_queue HEAP;\ntypedef priority_queue, greater > RHEAP;\n\nconst int N = 100010, M = 1010;\n\nint n, m = -2;\nstring res;\n\nint main()\n{\n\tcin >> n;\n\tif (!n) puts(\"0\");\n\telse\n\t{\n\t\tfor (int i = n; i; i /= m)\n\t\t{\n\t\t\tif (i % abs(m))\n\t\t\t{\n\t\t\t\tres += \"1\";\n\t\t\t\tif (m < 0) i -- ;\n\t\t\t}\n\t\t\telse res += \"0\";\n\t\t}\n\t\treverse(res.begin(), res.end());\n\t}\n\tcout << res << endl;\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 565, "cpu_time_ms": 6, "memory_kb": 3608}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s916588996", "group_id": "codeNet:p03286", "input_text": "#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n\nint main() {\n ll n; cin >> n;\n string s;\n while (n) {\n if (n == 0) {\n cout << 0 << endl;\n }\n if (n % 2 == 0){\n s = \"0\" + s;\n n /= -2;\n } else {\n n -= 1;\n s = \"1\" + s;\n n /= -2;\n }\n }\n cout << s << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1534042056, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/C++/s916588996.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s916588996", "user_id": "u073731976"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n\nint main() {\n ll n; cin >> n;\n string s;\n while (n) {\n if (n == 0) {\n cout << 0 << endl;\n }\n if (n % 2 == 0){\n s = \"0\" + s;\n n /= -2;\n } else {\n n -= 1;\n s = \"1\" + s;\n n /= -2;\n }\n }\n cout << s << endl;\n return 0;\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 454, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s100142647", "group_id": "codeNet:p03286", "input_text": "#include\nusing namespace std;\n\nint main(){\nint N;\nint A[1000];\ndouble all=0;\ndouble ten=1;\nint x;\nint i=0;\nint total;\n\ncin >> N;\nwhile(1){\n if(N == 0){\n break;\n }\n\nx = N%(-2);\nif(x==(-1))x=1;\nA[i] = x;\ni++;\nN -= x;\nN = N/(-2);\n}\n\ntotal = i-1;\nfor(int k = total; k>=0; k--)\ncout << A[k] ;\n\ncout << endl;\n\n}", "language": "C++", "metadata": {"date": 1534039216, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03286.html", "problem_id": "p03286", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03286/input.txt", "sample_output_relpath": "derived/input_output/data/p03286/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03286/C++/s100142647.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s100142647", "user_id": "u571764501"}, "prompt_components": {"gold_output": "1011\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\nint N;\nint A[1000];\ndouble all=0;\ndouble ten=1;\nint x;\nint i=0;\nint total;\n\ncin >> N;\nwhile(1){\n if(N == 0){\n break;\n }\n\nx = N%(-2);\nif(x==(-1))x=1;\nA[i] = x;\ni++;\nN -= x;\nN = N/(-2);\n}\n\ntotal = i-1;\nfor(int k = total; k>=0; k--)\ncout << A[k] ;\n\ncout << endl;\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "-9\n"}, "reference_outputs": ["1011\n"], "source_document_id": "p03286", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven an integer N, find the base -2 representation of N.\n\nHere, S is the base -2 representation of N when the following are all satisfied:\n\nS is a string consisting of 0 and 1.\n\nUnless S = 0, the initial character of S is 1.\n\nLet S = S_k S_{k-1} ... S_0, then S_0 \\times (-2)^0 + S_1 \\times (-2)^1 + ... + S_k \\times (-2)^k = N.\n\nIt can be proved that, for any integer M, the base -2 representation of M is uniquely determined.\n\nConstraints\n\nEvery value in input is integer.\n\n-10^9 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the base -2 representation of N.\n\nSample Input 1\n\n-9\n\nSample Output 1\n\n1011\n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.\n\nSample Input 2\n\n123456789\n\nSample Output 2\n\n11000101011001101110100010101\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s793072633", "group_id": "codeNet:p03287", "input_text": "/*\n 友利奈緒ぱわーでACしてくれ!!!!!!!!!!!!\n Charlotteまだ見てない人は見ような!!!!!!!\n\n /  /:/              \:ヽ \\n         /  /                     \  ヽ\n      \__L 彡                    ヽ  ',\n        フ /   /  /  /   ,         ヽ  ',  j\n        レ    /  /  /                ',  ヽ j\n         //     ! /_l_/__ノ   { \}       ',  ',/\n       i ハ     { 从j ハ i    ',  ト-、}  i i  }  jj\n       ( ハ   (  川 ハ ハ  !  ' ハ  ハ j j ,'   八\n     <_,ィ∧   斗芹テミxハ ハ  レ } /__レレ /   ∧ \ ノ\n         ∨ \  ゝ 辷:ソ    ) 芹レ心ヾレ′ / ト-- ´\n    \ー‐' ノ   \ゝ           ゞ:_ソ \"/  /  ヽ\n        フ    i八 \" \"   ,       ム彡    \\n       /  /  j  ト           \" \"イト<      \\\n      /  /   j //ヽ、   ∩     イ { {   ̄ フフへ \\\n     ( /    ,/ /   i >――<ニニニニ┐  〃/: : ヽ ヽヽ\n     /  ィT´/ /┌―  ̄ ̄ /::: , ,)      〃//: : : : : :} ヽヽ)\n    / /  ∧ヾi┌― { { ̄    ノ:::ト゚<      ∥//: : : : : : : : i  ノ ノ\n .   ( 人  {:ヽヾi∨ ∧V    /:::/ 、ヽ    ∥/: : : : : : : : : :} /\n    V ( ∧: :\'∨ ∧V   ノ:::/  ∧ 〉___∥: : : : : :/: : : :レ\n        /∧: : : : ∨ ∧V┬イ:::ノ  〈 TT | |{{: : : : /: : : : : ∧   ノ\n       ( ハ: : : : :∨'T∧Vi i (    V ! ! {{: : / : : : : : : / ー ノ\n      V ハ: : : : :∨ヘ∧V i ゝゝ  i/⌒\{/ : : : : : : : /ー― ´\n       ∨ ヽ: : : : :∨ヘ∧∨i 〉 〉 / /二  ): : : : : : : : :/\n\n (https://seesaawiki.jp/asciiart/d/Charlotte より)\n*/\n#include \nusing namespace std;\nusing ll = long long; using ull = unsigned long long;\n// #define int ll\n// #define DEBUG 42\ninline void nprint(){}\ntemplate \ninline void nprint(Head &&head, Tail &&... tail) {\n cout << head << endl;\n nprint(move(tail)...);\n}\n#ifdef DEBUG\n #define eprint(...) nprint(__VA_ARGS__)\n#else\n #define eprint(...) if(0==1) cout << 1 << endl;\n#endif\n#define Yes(a) cout << (a ? \"Yes\" : \"No\") << endl\n#define YES(a) cout << (a ? \"YES\" : \"NO\") << endl\n#define POSSIBLE(a) cout << (a ? \"POSSIBLE\" : \"IMPOSSIBLE\") << endl\nusing cmp = complex;\nusing vb = vector; using vvb = vector;\nusing vi = vector; using vvi = vector;\nusing vl = vector; using vvl = vector;\ntemplate using V = vector;\ntemplate using VV = vector>;\n#define fi first\n#define se second\n#define maxs(x,y) (x=max(x,y))\n#define mins(x,y) (x=min(x,y))\nusing pii = pair; using pll = pair;\n#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)\n#define REP(i,n) FOR(i,0,n)\n#define FORS(i,a,b) FOR(i,a,b+1)\n#define REPS(i,n) REP(i,n+1)\n#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)\n#define RREP(i,n) RFOR(i,0,n)\n#define RREPS(i,n) RREP(i,n+1)\n#define RFORS(i,a,b) RFOR(i,a,b+1)\n#define ALL(obj) (obj).begin(), (obj).end()\n#define RALL(obj) (obj).rbegin(), (obj).rend()\n#define PERM(c) sort(ALL(c)); for(bool cp = true;cp;cp = next_permutation(ALL(c)))\n#define eb(val) emplace_back(val)\nconst double PI = acos(-1), EPS = 1e-10;\nconstexpr ll MOD = 1E9+7;\nconstexpr int dx[] = {1,0,-1,0}; constexpr int dy[] = {0,1,0,-1};\ntemplate ostream& operator<<(ostream& s, const pair& p){\n return s << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate istream& operator>>(istream &is,vector &st){\n for(size_t i=0;i> st[i];\n return is;\n}\ntemplate istream& operator>>(istream &is,vector> &st){\n for(size_t i=0;i> st[i];\n return is;\n}\ntemplate ostream& operator<<(ostream &os, const vector &st){\n for(size_t i=0;i ostream& operator<<(ostream &os, const vector> &st){\n for(size_t i=0;i> n >> m;\n vi a(n);\n ll sum[n+1];\n cin >> a;\n sum[0] = 0;\n REP(i,n){\n sum[i+1] = sum[i] + a[i];\n }\n ll ans = 0;\n int i=0,j=0;\n ++n;\n for(i=0;i\nusing namespace std;\nusing ll = long long; using ull = unsigned long long;\n// #define int ll\n// #define DEBUG 42\ninline void nprint(){}\ntemplate \ninline void nprint(Head &&head, Tail &&... tail) {\n cout << head << endl;\n nprint(move(tail)...);\n}\n#ifdef DEBUG\n #define eprint(...) nprint(__VA_ARGS__)\n#else\n #define eprint(...) if(0==1) cout << 1 << endl;\n#endif\n#define Yes(a) cout << (a ? \"Yes\" : \"No\") << endl\n#define YES(a) cout << (a ? \"YES\" : \"NO\") << endl\n#define POSSIBLE(a) cout << (a ? \"POSSIBLE\" : \"IMPOSSIBLE\") << endl\nusing cmp = complex;\nusing vb = vector; using vvb = vector;\nusing vi = vector; using vvi = vector;\nusing vl = vector; using vvl = vector;\ntemplate using V = vector;\ntemplate using VV = vector>;\n#define fi first\n#define se second\n#define maxs(x,y) (x=max(x,y))\n#define mins(x,y) (x=min(x,y))\nusing pii = pair; using pll = pair;\n#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)\n#define REP(i,n) FOR(i,0,n)\n#define FORS(i,a,b) FOR(i,a,b+1)\n#define REPS(i,n) REP(i,n+1)\n#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)\n#define RREP(i,n) RFOR(i,0,n)\n#define RREPS(i,n) RREP(i,n+1)\n#define RFORS(i,a,b) RFOR(i,a,b+1)\n#define ALL(obj) (obj).begin(), (obj).end()\n#define RALL(obj) (obj).rbegin(), (obj).rend()\n#define PERM(c) sort(ALL(c)); for(bool cp = true;cp;cp = next_permutation(ALL(c)))\n#define eb(val) emplace_back(val)\nconst double PI = acos(-1), EPS = 1e-10;\nconstexpr ll MOD = 1E9+7;\nconstexpr int dx[] = {1,0,-1,0}; constexpr int dy[] = {0,1,0,-1};\ntemplate ostream& operator<<(ostream& s, const pair& p){\n return s << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate istream& operator>>(istream &is,vector &st){\n for(size_t i=0;i> st[i];\n return is;\n}\ntemplate istream& operator>>(istream &is,vector> &st){\n for(size_t i=0;i> st[i];\n return is;\n}\ntemplate ostream& operator<<(ostream &os, const vector &st){\n for(size_t i=0;i ostream& operator<<(ostream &os, const vector> &st){\n for(size_t i=0;i> n >> m;\n vi a(n);\n ll sum[n+1];\n cin >> a;\n sum[0] = 0;\n REP(i,n){\n sum[i+1] = sum[i] + a[i];\n }\n ll ans = 0;\n int i=0,j=0;\n ++n;\n for(i=0;i\nint main(void){\n int R;\n scanf(\"%d\",&R);\n if(R<1200){\n printf(\"ABC\");\n }\n else if(1200<=R&&R<2800){\n printf(\"ARC\");\n }\n else{\n\tprintf(\"AGC\");\n }\n return 0;\n}", "language": "C++", "metadata": {"date": 1543199401, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/C++/s011044796.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011044796", "user_id": "u521382680"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "#include\nint main(void){\n int R;\n scanf(\"%d\",&R);\n if(R<1200){\n printf(\"ABC\");\n }\n else if(1200<=R&&R<2800){\n printf(\"ARC\");\n }\n else{\n\tprintf(\"AGC\");\n }\n return 0;\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 190, "cpu_time_ms": 2, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s132041551", "group_id": "codeNet:p03290", "input_text": "#include\n\nusing namespace std;\nint d,g;\npair pc[10];\nint ans=100000;\n\nbool dfs(int sum,int cnt,int i){\n if(sum>=g){\n ans=min(ans,cnt);\n return true;\n }else if(i<0)\n return false;\n\n dfs(sum+(i+1)*100*(pc[i].first)+pc[i].second,cnt+(pc[i].first),i-1);\n\n for(int j=0;j> d >> g;\n for(int i=0;i> pc[i].first >> pc[i].second;\n \n solve();\n return 0;\n}\n", "language": "C++", "metadata": {"date": 1597680326, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/C++/s132041551.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s132041551", "user_id": "u725680599"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include\n\nusing namespace std;\nint d,g;\npair pc[10];\nint ans=100000;\n\nbool dfs(int sum,int cnt,int i){\n if(sum>=g){\n ans=min(ans,cnt);\n return true;\n }else if(i<0)\n return false;\n\n dfs(sum+(i+1)*100*(pc[i].first)+pc[i].second,cnt+(pc[i].first),i-1);\n\n for(int j=0;j> d >> g;\n for(int i=0;i> pc[i].first >> pc[i].second;\n \n solve();\n return 0;\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 638, "cpu_time_ms": 2205, "memory_kb": 3684}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s600671389", "group_id": "codeNet:p03290", "input_text": "#include \nusing namespace std;\nusing P = pair;\n\nconst int INF = 1 << 30;\n\nint main(){\n\tint d, g;\n\tscanf(\"%d%d\", &d, &g);\n\tvector > p;\n\tfor(int i = 0; i < d; i++) {\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a, &b);\n\t\tp.push_back(make_pair(a, b));\n\t}\n\tint ans = INF;\n\tfor(int i = 0; i < (1 << d); i++) {\n\t\tint sum = 0, last = -1;\n\t\tint cnt = 0;\n\t\tfor(int j = 0; j < d; j++) {\n\t\t\tif(i & (1 << j)) {\n\t\t\t\tsum += 100 * (j + 1) * p[j].first + p[j].second;\n\t\t\t\tcnt += p[j].first;\n\t\t\t}else{\n\t\t\t\tlast = j;\n\t\t\t}\n\t\t}\n\t\tif(sum < g) {\n\t\t\tint point = 100 * (last + 1);\n\t\t\tint need = (g - sum + point - 1) / point;\n\t\t\tif(need >= p[last].first) continue;\n\t\t\tcnt += need;\n\t\t}\n\t\tans = min(ans, cnt);\n\t}\n\tprintf(\"%d\\n\", ans);\n}\n", "language": "C++", "metadata": {"date": 1588910489, "filename_ext": "cpp", "original_language": "C++14 (GCC 5.4.1)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03290/input.txt", "sample_output_relpath": "derived/input_output/data/p03290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03290/C++/s600671389.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s600671389", "user_id": "u132602393"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "#include \nusing namespace std;\nusing P = pair;\n\nconst int INF = 1 << 30;\n\nint main(){\n\tint d, g;\n\tscanf(\"%d%d\", &d, &g);\n\tvector > p;\n\tfor(int i = 0; i < d; i++) {\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a, &b);\n\t\tp.push_back(make_pair(a, b));\n\t}\n\tint ans = INF;\n\tfor(int i = 0; i < (1 << d); i++) {\n\t\tint sum = 0, last = -1;\n\t\tint cnt = 0;\n\t\tfor(int j = 0; j < d; j++) {\n\t\t\tif(i & (1 << j)) {\n\t\t\t\tsum += 100 * (j + 1) * p[j].first + p[j].second;\n\t\t\t\tcnt += p[j].first;\n\t\t\t}else{\n\t\t\t\tlast = j;\n\t\t\t}\n\t\t}\n\t\tif(sum < g) {\n\t\t\tint point = 100 * (last + 1);\n\t\t\tint need = (g - sum + point - 1) / point;\n\t\t\tif(need >= p[last].first) continue;\n\t\t\tcnt += need;\n\t\t}\n\t\tans = min(ans, cnt);\n\t}\n\tprintf(\"%d\\n\", ans);\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 735, "cpu_time_ms": 1, "memory_kb": 256}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s344549325", "group_id": "codeNet:p03290", "input_text": "#include \ntypedef long long int ll;\ntypedef long double ld;\nusing namespace std;\nconst long long int INF = 1e18;\nconst long long int mod = 1e9+7;\n\ntypedef pair pairs;\ntypedef vector p;\n\nstruct Edge{\n ll to, weight;\n Edge(ll t, ll w) : to(t), weight(w){}\n};\nusing graph = vector>;\nusing Graph = vector>;\n\n\nll gcd(ll a,ll b){\n if(b == 0){\n return a;\n }else{\n return gcd(b, a%b);\n }\n}\n\nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n\nll keta(ll N){\n int tmp{};\n while( N > 0 ){\n tmp += ( N % 10 );\n N /= 10;\n }\n N = tmp;\n return N;\n}\n\n// 回文\nbool kai(string S){\n bool flag = true;\n for(ll i=0;i>d>>g;\n vector p(d), c(d);\n for(ll i=0;i>p[i]>>c[i];\n }\n\n ll ans = INF;\n for(ll b=0;b<(1 << d);++b){\n ll flag = 0;\n ll num = 0;\n ll r = -1;\n for(ll i=0;i> i & 1){\n flag += 100 * (i+1) * p[i] + c[i];\n num += p[i];\n }else{\n r = i;\n }\n }\n if(flag < g){\n ll fl = 100 * (r+1);\n ll sum = (g - flag + fl -1) / fl;\n if(sum >= p[r]){\n continue;\n }\n num += sum;\n }\n ans = min(ans, num);\n }\n cout<\ntypedef long long int ll;\ntypedef long double ld;\nusing namespace std;\nconst long long int INF = 1e18;\nconst long long int mod = 1e9+7;\n\ntypedef pair pairs;\ntypedef vector p;\n\nstruct Edge{\n ll to, weight;\n Edge(ll t, ll w) : to(t), weight(w){}\n};\nusing graph = vector>;\nusing Graph = vector>;\n\n\nll gcd(ll a,ll b){\n if(b == 0){\n return a;\n }else{\n return gcd(b, a%b);\n }\n}\n\nll lcm(ll a, ll b){\n return a / gcd(a, b) * b;\n}\n\nll keta(ll N){\n int tmp{};\n while( N > 0 ){\n tmp += ( N % 10 );\n N /= 10;\n }\n N = tmp;\n return N;\n}\n\n// 回文\nbool kai(string S){\n bool flag = true;\n for(ll i=0;i>d>>g;\n vector p(d), c(d);\n for(ll i=0;i>p[i]>>c[i];\n }\n\n ll ans = INF;\n for(ll b=0;b<(1 << d);++b){\n ll flag = 0;\n ll num = 0;\n ll r = -1;\n for(ll i=0;i> i & 1){\n flag += 100 * (i+1) * p[i] + c[i];\n num += p[i];\n }else{\n r = i;\n }\n }\n if(flag < g){\n ll fl = 100 * (r+1);\n ll sum = (g - flag + fl -1) / fl;\n if(sum >= p[r]){\n continue;\n }\n num += sum;\n }\n ans = min(ans, num);\n }\n cout<\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int d,g;\n cin>>d>>g;\n vector >ar(d+1);\n for(int i=1;i<=d;i++)\n {\n cin>>ar[i+1].first>>ar[i+1].second;\n }\n long long int y=0;long long int ans=0;\n for(int i=d;i;i--)\n { if(g<=0)break;\n y=ar[i].first*100*i;y+=ar[i].second;\n if(y<=g){g-=y;ans+=ar[i].first;continue;}\n y-=ar[i].second;y/=ar[i].first;\n long long int v=g/y;\n if(g%y&&v\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int d,g;\n cin>>d>>g;\n vector >ar(d+1);\n for(int i=1;i<=d;i++)\n {\n cin>>ar[i+1].first>>ar[i+1].second;\n }\n long long int y=0;long long int ans=0;\n for(int i=d;i;i--)\n { if(g<=0)break;\n y=ar[i].first*100*i;y+=ar[i].second;\n if(y<=g){g-=y;ans+=ar[i].first;continue;}\n y-=ar[i].second;y/=ar[i].first;\n long long int v=g/y;\n if(g%y&&v\nusing namespace std;\nusing i64 = long long;\n\nint main(){\n vector a(3);\n for(int i=0;i<3;i++)cin>>a[i];\n sort(a.begin(),a.end());\n cout<<(a[1]-a[0])+(a[2]-a[1])<\nusing namespace std;\nusing i64 = long long;\n\nint main(){\n vector a(3);\n for(int i=0;i<3;i++)cin>>a[i];\n sort(a.begin(),a.end());\n cout<<(a[1]-a[0])+(a[2]-a[1])<\nusing namespace std;\n\nint main(){\n string s,t;\n cin >> s >> t;\n for(int i = 0; i < s.size(); i++){\n s = s.substr(s.size()-1, 1) + s;\n s.pop_back();\n if(s == t){\n cout << \"Yes\" << endl;\n return 0;\n }\n }\n cout << \"No\" << endl;\n return 0;\n}", "language": "C++", "metadata": {"date": 1596331189, "filename_ext": "cpp", "original_language": "C++ (GCC 9.2.1)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "high_resource", "sample_input_relpath": "derived/input_output/data/p03293/input.txt", "sample_output_relpath": "derived/input_output/data/p03293/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03293/C++/s150094340.cpp", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s150094340", "user_id": "u225777148"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "#include\nusing namespace std;\n\nint main(){\n string s,t;\n cin >> s >> t;\n for(int i = 0; i < s.size(); i++){\n s = s.substr(s.size()-1, 1) + s;\n s.pop_back();\n if(s == t){\n cout << \"Yes\" << endl;\n return 0;\n }\n }\n cout << \"No\" << endl;\n return 0;\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "sample_input": "kyoto\ntokyo\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03293", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given string S and T consisting of lowercase English letters.\n\nDetermine if S equals T after rotation.\n\nThat is, determine if S equals T after the following operation is performed some number of times:\n\nOperation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.\n\nHere, |X| denotes the length of the string X.\n\nConstraints\n\n2 \\leq |S| \\leq 100\n\n|S| = |T|\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf S equals T after rotation, print Yes; if it does not, print No.\n\nSample Input 1\n\nkyoto\ntokyo\n\nSample Output 1\n\nYes\n\nIn the first operation, kyoto becomes okyot.\n\nIn the second operation, okyot becomes tokyo.\n\nSample Input 2\n\nabc\narc\n\nSample Output 2\n\nNo\n\nabc does not equal arc after any number of operations.\n\nSample Input 3\n\naaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 8, "memory_kb": 3608}, "variant": "high_resource"} +{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:C++:s476059117", "group_id": "codeNet:p03306", "input_text": "#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 P;\nconst ll INF=4e18;\nconst ll MOD=1e9+7;\nconst double EPS=1e-7;\n\nll N,M;\nstruct Edge{\n ll to,cost;\n};\nvector edges[100010];\nP state[100010];\nll cnt=0;\nmap used;\nvoid Serch(ll n){\n for(auto e:edges[n]){\n if(used[P(min(n,e.to),max(n,e.to))])continue;\n if(state[e.to].first==-1){\n if(state[n].second==0){\n state[e.to] = P(-(e.cost-state[n].first),1);\n }else{\n state[e.to] = P(e.cost+state[n].first,0);\n }\n used[P(min(n,e.to),max(n,e.to))]=true;\n Serch(e.to);\n }else{\n used[P(min(n,e.to),max(n,e.to))]=true;\n cnt++;\n if(cnt>=2){\n return;\n }\n }\n }\n}\nint main(){\n cin>>N>>M;\n for(ll i=0;i>u>>v>>s;\n u--;v--;\n edges[u].push_back(Edge{v,s});\n edges[v].push_back(Edge{u,s});\n }\n for(ll i=0;i\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 P;\nconst ll INF=4e18;\nconst ll MOD=1e9+7;\nconst double EPS=1e-7;\n\nll N,M;\nstruct Edge{\n ll to,cost;\n};\nvector edges[100010];\nP state[100010];\nll cnt=0;\nmap used;\nvoid Serch(ll n){\n for(auto e:edges[n]){\n if(used[P(min(n,e.to),max(n,e.to))])continue;\n if(state[e.to].first==-1){\n if(state[n].second==0){\n state[e.to] = P(-(e.cost-state[n].first),1);\n }else{\n state[e.to] = P(e.cost+state[n].first,0);\n }\n used[P(min(n,e.to),max(n,e.to))]=true;\n Serch(e.to);\n }else{\n used[P(min(n,e.to),max(n,e.to))]=true;\n cnt++;\n if(cnt>=2){\n return;\n }\n }\n }\n}\nint main(){\n cin>>N>>M;\n for(ll i=0;i>u>>v>>s;\n u--;v--;\n edges[u].push_back(Edge{v,s});\n edges[v].push_back(Edge{u,s});\n }\n for(ll i=0;i\nusing namespace std;\nusing ll = long long;\n\n#define REP(i,n) for(long long i = 0; i < (n); i++)\n#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)\n#define ALL(obj) (obj).begin(),(obj).end()\n\ntemplate using V = vector;\ntemplate using P = pair;\n\nconst ll MOD = (ll)1e9 + 7;\nconst ll MOD2 = 998244353;\nconst ll LLINF = (ll)1e18;\nconst ll INTINF = (ll)1e9;\nconst long double PI = 3.1415926535897932384626433;\n\ntemplate void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}\ntemplate ostream &operator<<(ostream &o, const map&obj) {o << \"{\"; for (auto &x : obj) o << \" {\" << x.first << \" : \" << x.second << \"}\" << \",\"; o << \" }\"; return o;}\ntemplate ostream &operator<<(ostream &o, const set&obj) {o << \"{\"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? \", \" : \"\") << *itr; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const vector&obj) {o << \"{\"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? \", \" : \"\") << obj[i]; o << \"}\"; return o;}\ntemplate ostream &operator<<(ostream &o, const pair&obj) {o << \"{\" << obj.first << \", \" << obj.second << \"}\"; return o;}\ntemplate